@xopcai/xopc 0.0.151 → 0.0.152
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/{agent-avatar-dicebear-BuO-OVfD.js → agent-avatar-dicebear-CXe2KDZj.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-Bpv3h31T.js → agents-BjLxhsVX.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B6OU3Eol.js → app-management-settings-panel-DekP2_hC.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BaP4GFvN.js → appearance-settings-Cfd5YavF.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DZKNIMRg.js → apps-page-PS-uUoSk.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CJX3zIh_.js → archive-plugin-DWglUgbp.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CI1ejk_l.js → attachment-load-BJdxo2Vn.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CjmhICbv.js → automation-suggestion-card-B-TfxjJF.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BtZl3B8m.js → automations-page-CtNevo3y.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-CZ8nOXqK.js → binary-plugins-DwrYsL8l.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BoSfyS_j.js → block-editor-CIxjL5Kp.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-CL1UiPcb.js → browser-settings-page-QncZ-2vS.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-XzDKxPZ8.js → capability-presets-api-ChR2rMfo.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Dc_uHYgl.js → capability-presets-settings-panel-_JBmJl5A.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-mALvXpJj.js → channels-settings-Bz3tyWpH.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-logo-BSjlInHT.js → connector-logo-KsRvub5G.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-Cm_E3mmI.js → connectors-page-_pT0aE0S.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DcJc91-C.js → desktop-pet-CRCERvWy.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CdeqTa3Q.js → desktop-pet-settings-vGrxshsU.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Cp3fpm0k.js → directory-picker-path-field-BGPYrtx6.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-Bwj1O3zr.js → dreaming-settings-B5pzvNgs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-D_1xpKbZ.js → extension-debug-page-BaCko1XU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CqZNCj96.js → extension-page-TTXKCMtb.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-5MWbtQaQ.js → extension-settings-page-CEMb3uXY.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Co_IaS34.js → gateway-config-api-Bf37OGhQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-kmeWm2Pt.js → gateway-settings-cu-vyeNk.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-FoO-R4_U.js → goal-create-dialog-C-bL8rj8.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-CkJq7N5g.js → goal-detail-page-p5zPrlTq.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-DrtsYjXz.js → goals-config-api-D2pEoiiO.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-DRAN-R64.js → goals-page-D-H2u2-J.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-wq9TKhIZ.js → goals-settings-BVZaBqPa.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-B5zDoHbo.js → heartbeat-settings-B-AC_uwa.js} +1 -1
- package/dist/gateway/static/root/assets/{index-apLU0Hun.js → index-DSydVlxZ.js} +6 -6
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-3tC9iD21.js → keyboard-shortcuts-settings-w0yIP0UB.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CT-vDTLK.js → local-app-workbench-page-CTq0TIH4.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-B9ruF9GV.js → local-apps-page-srIyxJuy.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Ca1X8X2P.js → logs-page-MQB6-NKt.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CzuhSQAB.js → markdown-split-Du5yPuDb.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-a3R4y-EL.js → media-plugins-Cd1Rmw15.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-panel-CbTlz9Of.js → models-hub-panel-BMg_Xqd9.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BCxDy2dV.js → notes-page-DhfrFd89.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-z6sBX9B2.js → notes-workbench-CwJk-D7Y.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-CJfk6M78.js → page-tabs-HACawonJ.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-MFopTSgF.js → preview-open-alternatives-CjEZt_F5.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-DU29deIr.js → project-detail-page-Dut_micj.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-Ck3DLTlZ.js → projects-page-sTRlCEZ5.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-gLsLyAyi.js → remote-access-hub-Fx81YH7S.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-D0uhU3Z8.js → save-bar-controls-CbktHUqt.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-NGOH-7wV.js → schedule-field-BGx_Nb45.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BJz5LoqG.js → schema-form-Cg-LJVvG.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-TmNoWpa_.js → sessions-page-DFnmyBpj.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BlWxQ6Ea.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-oDnUHnX_.js → settings-collapsible-section-yYK4O-5E.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DND90dDt.js → settings-form-section-DPSA8tG8.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CEJtaoQp.js → settings-loading-skeleton-ClHNJwRL.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B1LJlRi9.js → settings-page-lPM7md10.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CsrLuDsW.js → settings-page-layout-B_-VepeK.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BPCJPHHY.js → setup-status-panel-hORJvGAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-C1PwLh-p.js → share-preview-page-DyzplAEL.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DCuqr7js.js → shares-settings-DO3IIgcC.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-kn1Vypcy.js → skill-reload-api-C9BqzDjZ.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-k6VIqTkK.js → skills-page-CvOIrcCJ.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BEsrEkSx.js → system-settings-panel-eIyklo0K.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-dOypdlMf.js → typed-models-lib-BgOpEx3h.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-B9Y_Ciav.js → user-context-page-BG_1IrIJ.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-fields-editor-DGC38Lx7.js → user-profile-fields-editor-CfLUK6MT.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-DFkZ-tan.js → user-profile-settings-panel-BmzPREhJ.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-CEIYZihF.js → utils-DbFnvDPi.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DK6gaQsA.js → voice-api-key-field-1xyza74n.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-DSJb9Kq7.js → work-discovery-page-Dhyk4LHJ.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-DVavwV3D.js → work-item-detail-page-CxBRnWeQ.js} +1 -1
- package/dist/gateway/static/root/assets/{work-page-foJDp0nz.js → work-page-Btq3YeCH.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BYqZpFCC.js → workflow-run-setup-panel-8HLqUALq.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DgO0WAzs.js → workflows-page-D48bPgLI.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/product-delivery.js +63 -0
- package/dist/src/agent/code-intelligence/tool-gating.d.ts +5 -0
- package/dist/src/agent/code-intelligence/tool-gating.js +6 -0
- package/dist/src/agent/tools/automation-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +2 -1
- package/dist/src/agent/tools/goal-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/routes/status.d.ts +8 -0
- package/dist/src/gateway/hono/routes/status.js +71 -1
- package/package.json +9 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CtPhh2m9.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-B0B40tpO.js";import{n as l}from"./locale-store-GfSwnwIZ.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$s as d,$t as f,Bo as p,Cs as m,Fl as h,Fo as g,Fs as _,Ho as v,Il as y,Io as b,Lo as x,Ms as S,No as C,Po as w,Qc as T,Ro as E,Tc as D,Xl as O,Yo as k,Ys as A,Zo as j,_n as M,an as N,ar as P,cn as F,dl as I,dn as L,en as ee,et as R,fn as te,gn as ne,hn as z,in as re,js as ie,ln as ae,lo as B,lu as oe,mn as se,mu as ce,nc as le,nn as ue,on as de,pl as fe,pn as pe,rn as me,ru as he,sn as ge,tn as _e,un as ve,vn as ye,wn as be,yc as xe,yn as Se,ys as V,zo as Ce,zs as we}from"./index-apLU0Hun.js";import{t as Te}from"./page-tabs-CJfk6M78.js";import{t as Ee}from"./user-profile-fields-editor-DGC38Lx7.js";import{t as De}from"./connector-logo-BSjlInHT.js";var H=e(t(),1),U=n(),Oe={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function ke(e){if(e.branding?.logoUrl)return e.branding;let t=Oe[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}var W=r();function Ae(e){let t=(0,U.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:s}=e,l=c(r).you,[u,d]=(0,H.useState)(!1),f,p;t[0]===n?(f=t[1],p=t[2]):(f=()=>{n&&d(!1)},p=[n],t[0]=n,t[1]=f,t[2]=p),(0,H.useEffect)(f,p);let h;t[3]!==i||t[4]!==a?(h=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=h):h=t[5];let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,W.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=v):v=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,W.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t[7]=T):T=t[7];let D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>d(!1),t[8]=D):D=t[8];let O=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,k;t[9]===O?k=t[10]:(k=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,O),t[9]=O,t[10]=k);let A;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,W.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=A):A=t[11];let j;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>d(!0),t[12]=j):j=t[12];let M=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,N;t[13]===M?N=t[14]:(N=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,M),t[13]=M,t[14]=N);let P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,W.jsx)(_,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=P):P=t[15];let F=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),I;t[16]===F?I=t[17]:(I=(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:F}),t[16]=F,t[17]=I);let L;t[18]!==i||t[19]!==l.cancel?(L=(0,W.jsx)(w,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=L):L=t[20];let ee=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,R;t[21]!==u||t[22]!==s?(R=()=>s(u),t[21]=u,t[22]=s,t[23]=R):R=t[23];let te;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,W.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t[24]=te):te=t[24];let ne=i?l.disconnecting:l.disconnectAction,z;t[25]!==i||t[26]!==ee||t[27]!==R||t[28]!==ne?(z=(0,W.jsxs)(V,{type:`button`,variant:`secondary`,className:ee,disabled:i,onClick:R,children:[te,ne]}),t[25]=i,t[26]=ee,t[27]=R,t[28]=ne,t[29]=z):z=t[29];let re;return t[30]!==L||t[31]!==z?(re=(0,W.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[L,z]}),t[30]=L,t[31]=z,t[32]=re):re=t[32],(0,W.jsx)(C,{open:n!==null,onOpenChange:h,children:(0,W.jsxs)(E,{children:[v,(0,W.jsxs)(g,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ce,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,W.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,W.jsx)(w,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:T})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[n?.accountLabel?(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,n.accountLabel)}):null,(0,W.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:D,className:k,children:[A,(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:j,disabled:!n?.derivedUnderstandingCount,className:N,children:[P,(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),I]})]})]}),re]})]})})}var je=new Set([`overview`,`understanding`,`sources`,`controls`]),Me=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],G=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function K(e,t){return e.replace(`{{count}}`,String(t))}function q(e,t){let n=Date.parse(e);return Number.isFinite(n)?R(n,t):e}function Ne(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&je.has(e)?e:`overview`}function Pe(){let e=(0,U.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(B,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(B,{className:`h-64 rounded-2xl`}),(0,W.jsx)(B,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Fe(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function Ie(e){let t=(0,U.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,H.useState)(!1),[h,g]=(0,H.useState)(n.statement),[v,y]=(0,H.useState)(null),[b,x]=(0,H.useState)(!1),S=n.status!==`active`,C=S?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,w;t[0]===C?w=t[1]:(w=o(`rounded-xl border p-3.5`,C),t[0]=C,t[1]=w);let T;t[2]!==a||t[3]!==h||t[4]!==f||t[5]!==v||t[6]!==b||t[7]!==n||t[8]!==r||t[9]!==S||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(T=f?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-20 resize-y`),value:h,onChange:e=>g(e.target.value),placeholder:i.updatePlaceholder}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{g(n.statement),p(!1)},children:i.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!h.trim(),onClick:()=>{u(h.trim()),p(!1)},children:i.save})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(A,{className:`size-3 text-accent`,"aria-hidden":!0}),Fe(n,i)]}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,W.jsx)(`span`,{children:K(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,W.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,q(n.latestEvidenceAt,r))}):null]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[S?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,W.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,W.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,W.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:b,onClick:()=>{if(v){y(null);return}x(!0),de(n.id).then(e=>y(e.history)).finally(()=>x(!1))},children:[(0,W.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,W.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,W.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,W.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,W.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,W.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,W.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:q(n.updatedAt,r)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,W.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:K(i.evidenceCount,n.evidenceCount)})]})]})]}),v?(0,W.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),v.map(e=>(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,W.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,W.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:q(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=h,t[4]=f,t[5]=v,t[6]=b,t[7]=n,t[8]=r,t[9]=S,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=T):T=t[15];let E;return t[16]!==w||t[17]!==T?(E=(0,W.jsx)(`article`,{className:w,children:T}),t[16]=w,t[17]=T,t[18]=E):E=t[18],E}function Le(e){let t=(0,U.c)(79),{source:n,language:r,t:i,onConfigure:a,onDisconnect:s}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.lastHealthStatus||t[1]!==i.healthIssue||t[2]!==i.healthOk||t[3]!==i.sourceHealth?(l=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[0]=n.lastHealthStatus,t[1]=i.healthIssue,t[2]=i.healthOk,t[3]=i.sourceHealth,t[4]=l):l=t[4];let u=l,d=`${i.manageSources}: ${n.displayName}`,f;t[5]===a?f=t[6]:(f=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[5]=a,t[6]=f);let p=n.displayName,m;t[7]===n?m=t[8]:(m=ke(n),t[7]=n,t[8]=m);let h;t[9]!==n.displayName||t[10]!==m?(h=(0,W.jsx)(De,{connector:{displayName:p,branding:m},size:`sm`}),t[9]=n.displayName,t[10]=m,t[11]=h):h=t[11];let g;t[12]===n.displayName?g=t[13]:(g=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[12]=n.displayName,t[13]=g);let _;t[14]===n.accountLabel?_=t[15]:(_=n.accountLabel?(0,W.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:n.accountLabel}):null,t[14]=n.accountLabel,t[15]=_);let v;t[16]===n.description?v=t[17]:(v=(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[16]=n.description,t[17]=v);let y;t[18]!==g||t[19]!==_||t[20]!==v?(y=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,_,v]}),t[18]=g,t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==y||t[23]!==h?(b=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,y]}),t[22]=y,t[23]=h,t[24]=b):b=t[24];let x=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,S;t[25]===x?S=t[26]:(S=o(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,x),t[25]=x,t[26]=S);let C;t[27]!==c||t[28]!==S?(C=(0,W.jsx)(`span`,{className:S,children:c}),t[27]=c,t[28]=S,t[29]=C):C=t[29];let w;t[30]!==b||t[31]!==C?(w=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,C]}),t[30]=b,t[31]=C,t[32]=w):w=t[32];let T;t[33]!==n.access.context||t[34]!==i.sourceContext?(T=n.access.context?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[33]=n.access.context,t[34]=i.sourceContext,t[35]=T):T=t[35];let E;t[36]!==n.access.memory||t[37]!==i.sourceMemory?(E=n.access.memory?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[36]=n.access.memory,t[37]=i.sourceMemory,t[38]=E):E=t[38];let D;t[39]!==n.access.read||t[40]!==i.sourceRead?(D=n.access.read?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[39]=n.access.read,t[40]=i.sourceRead,t[41]=D):D=t[41];let O;t[42]!==n.access.write||t[43]!==i.sourceWrite?(O=n.access.write?(0,W.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[42]=n.access.write,t[43]=i.sourceWrite,t[44]=O):O=t[44];let k;t[45]!==T||t[46]!==E||t[47]!==D||t[48]!==O?(k=(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[T,E,D,O]}),t[45]=T,t[46]=E,t[47]=D,t[48]=O,t[49]=k):k=t[49];let A;t[50]!==u||t[51]!==r||t[52]!==n.derivedUnderstandingCount||t[53]!==n.installed||t[54]!==n.knowledgeItemCount||t[55]!==n.lastActivityAt||t[56]!==n.lastSyncAt||t[57]!==n.lastSyncError||t[58]!==n.lastSyncStatus||t[59]!==i.sourceDerivedCount||t[60]!==i.sourceKnowledgeCount||t[61]!==i.sourceLastSync||t[62]!==i.sourceLastUsed||t[63]!==i.sourceNeverUsed||t[64]!==i.sourceSyncFailed?(A=n.installed?(0,W.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[u?(0,W.jsx)(`p`,{children:u}):null,(0,W.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,q(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,W.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,q(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,W.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,W.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,W.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[50]=u,t[51]=r,t[52]=n.derivedUnderstandingCount,t[53]=n.installed,t[54]=n.knowledgeItemCount,t[55]=n.lastActivityAt,t[56]=n.lastSyncAt,t[57]=n.lastSyncError,t[58]=n.lastSyncStatus,t[59]=i.sourceDerivedCount,t[60]=i.sourceKnowledgeCount,t[61]=i.sourceLastSync,t[62]=i.sourceLastUsed,t[63]=i.sourceNeverUsed,t[64]=i.sourceSyncFailed,t[65]=A):A=t[65];let j;t[66]!==s||t[67]!==n.installed||t[68]!==n.instanceId||t[69]!==i.disconnect?(j=n.installed&&n.instanceId?(0,W.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),s()},children:i.disconnect})}):null,t[66]=s,t[67]=n.installed,t[68]=n.instanceId,t[69]=i.disconnect,t[70]=j):j=t[70];let M;return t[71]!==a||t[72]!==w||t[73]!==d||t[74]!==k||t[75]!==A||t[76]!==j||t[77]!==f?(M=(0,W.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":d,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:f,children:[w,k,A,j]}),t[71]=a,t[72]=w,t[73]=d,t[74]=k,t[75]=A,t[76]=j,t[77]=f,t[78]=M):M=t[78],M}function Re(e){let t=(0,U.c)(58),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:s,onUpdate:c,onDelete:l}=e,[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(``),g=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,v;t[0]===g?v=t[1]:(v=o(`rounded-xl border p-4`,g),t[0]=g,t[1]=v);let y=i.playbookNames[n.id],b;t[2]===y?b=t[3]:(b=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:y}),t[2]=y,t[3]=b);let x;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(x=K(i.playbookRuleCount,n.rules.filter(ze).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=x):x=t[6];let S;t[7]===x?S=t[8]:(S=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[7]=x,t[8]=S);let C;t[9]!==b||t[10]!==S?(C=(0,W.jsxs)(`div`,{children:[b,S]}),t[9]=b,t[10]=S,t[11]=C):C=t[11];let w=n.enabled?i.pausePlaybook:i.resumePlaybook,T;t[12]!==r||t[13]!==a||t[14]!==w?(T=(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:w}),t[12]=r,t[13]=a,t[14]=w,t[15]=T):T=t[15];let E;t[16]!==C||t[17]!==T?(E=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,T]}),t[16]=C,t[17]=T,t[18]=E):E=t[18];let O;t[19]!==r||t[20]!==f||t[21]!==m||t[22]!==l||t[23]!==c||t[24]!==n.rules||t[25]!==i.cancel||t[26]!==i.deleteRule||t[27]!==i.disableRule||t[28]!==i.edit||t[29]!==i.enableRule||t[30]!==i.moveDown||t[31]!==i.moveUp||t[32]!==i.save?(O=n.rules.map((e,t)=>(0,W.jsx)(`li`,{className:o(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:f===e.id?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-16 resize-y`),value:m,onChange:e=>h(e.target.value)}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>p(null),children:i.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!m.trim(),onClick:()=>{c(e.id,{statement:m.trim()}),p(null)},children:i.save})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{p(e.id),h(e.statement)},children:[(0,W.jsx)(D,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,W.jsx)(_,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]})]})},e.id)),t[19]=r,t[20]=f,t[21]=m,t[22]=l,t[23]=c,t[24]=n.rules,t[25]=i.cancel,t[26]=i.deleteRule,t[27]=i.disableRule,t[28]=i.edit,t[29]=i.enableRule,t[30]=i.moveDown,t[31]=i.moveUp,t[32]=i.save,t[33]=O):O=t[33];let k;t[34]===O?k=t[35]:(k=(0,W.jsx)(`ul`,{className:`mt-3 space-y-2`,children:O}),t[34]=O,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>d(e.target.value),t[36]=A):A=t[36];let j;t[37]!==u||t[38]!==i.newRulePlaceholder?(j=(0,W.jsx)(`input`,{className:G,value:u,onChange:A,placeholder:i.newRulePlaceholder}),t[37]=u,t[38]=i.newRulePlaceholder,t[39]=j):j=t[39];let M;t[40]!==r||t[41]!==u?(M=r||!u.trim(),t[40]=r,t[41]=u,t[42]=M):M=t[42];let N;t[43]!==u||t[44]!==s?(N=()=>{s(u.trim()),d(``)},t[43]=u,t[44]=s,t[45]=N):N=t[45];let P;t[46]!==i.addRule||t[47]!==M||t[48]!==N?(P=(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:M,onClick:N,children:i.addRule}),t[46]=i.addRule,t[47]=M,t[48]=N,t[49]=P):P=t[49];let F;t[50]!==j||t[51]!==P?(F=(0,W.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[j,P]}),t[50]=j,t[51]=P,t[52]=F):F=t[52];let I;return t[53]!==E||t[54]!==k||t[55]!==F||t[56]!==v?(I=(0,W.jsxs)(`article`,{className:v,children:[E,k,F]}),t[53]=E,t[54]=k,t[55]=F,t[56]=v,t[57]=I):I=t[57],I}function ze(e){return e.enabled}function Be(e){let t=(0,U.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:s,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let f;t[4]===u?f=t[5]:(f=(0,W.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=f);let p=n?l.meetSuggestedBody:l.meetBody,m;t[6]===p?m=t[7]:(m=(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:p}),t[6]=p,t[7]=m);let h;t[8]===l.callName?h=t[9]:(h=(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=h);let g;t[10]===a?g=t[11]:(g=e=>a(e.target.value),t[10]=a,t[11]=g);let _;t[12]!==i||t[13]!==r||t[14]!==s?(_=e=>{e.key===`Enter`&&r.trim()&&!i&&s()},t[12]=i,t[13]=r,t[14]=s,t[15]=_):_=t[15];let v=l.meetPlaceholder,y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=o(G,`h-10 flex-1 bg-surface-base/90`),t[16]=y):y=t[16];let b;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==g||t[20]!==_?(b=(0,W.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,onChange:g,onKeyDown:_,placeholder:v,className:y}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=g,t[20]=_,t[21]=b):b=t[21];let x;t[22]!==i||t[23]!==r?(x=i||!r.trim(),t[22]=i,t[23]=r,t[24]=x):x=t[24];let S=i?l.meetSaving:l.meetSave,C;t[25]!==s||t[26]!==x||t[27]!==S?(C=(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:x,onClick:s,children:S}),t[25]=s,t[26]=x,t[27]=S,t[28]=C):C=t[28];let w;t[29]!==b||t[30]!==C||t[31]!==h?(w=(0,W.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[h,b,C]}),t[29]=b,t[30]=C,t[31]=h,t[32]=w):w=t[32];let T;t[33]!==n||t[34]!==l.meetSource?(T=n?(0,W.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,W.jsx)(d,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=T):T=t[35];let E;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(E=(0,W.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=E):E=t[39];let D;return t[40]!==w||t[41]!==T||t[42]!==E||t[43]!==f||t[44]!==m?(D=(0,W.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,W.jsxs)(`div`,{className:`relative max-w-2xl`,children:[f,m,w,T,E]})}),t[40]=w,t[41]=T,t[42]=E,t[43]=f,t[44]=m,t[45]=D):D=t[45],D}function Ve(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,m]=i(),g=Ne(r.get(`tab`)),_=p(e=>e.setPageHeader),b=p(e=>e.clearPageHeader),{data:x,error:S,isLoading:C,mutate:w}=u(`/api/you`,ge),[E,A]=(0,H.useState)(null),[I,R]=(0,H.useState)(!1),[B,de]=(0,H.useState)(``),[Ce,De]=(0,H.useState)(`preference`),[U,Oe]=(0,H.useState)(null),[ke,je]=(0,H.useState)(!1),[ze,Ve]=(0,H.useState)(null),[He,Ue]=(0,H.useState)(!1),[We,Ge]=(0,H.useState)(``),[Ke,qe]=(0,H.useState)(!1),[Je,Ye]=(0,H.useState)(null),[Xe,Ze]=(0,H.useState)(!1),[Qe,$e]=(0,H.useState)(!1),[et,tt]=(0,H.useState)(null),[nt,rt]=(0,H.useState)(null),[it,at]=(0,H.useState)(!1),[J,ot]=(0,H.useState)(null),st=(0,H.useRef)(null),ct=(0,H.useRef)(null),Y=x?.profile??{callName:``,pronouns:``,timezone:``,notes:``},X=(0,H.useMemo)(()=>x?.understanding.filter(e=>e.status===`active`)??[],[x]),Z=(0,H.useMemo)(()=>x?.understanding.filter(e=>e.status!==`active`)??[],[x]),lt=(0,H.useMemo)(()=>new Map(Me.map(e=>[e,X.filter(t=>t.facet===e)])),[X]),Q=Je??x?.controls??null,ut=x?.sources.filter(e=>e.installed&&e.enabled)??[],dt=ut.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)),$=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),m(n,{replace:!0})},ft=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,H.useLayoutEffect)(()=>(_({startExtra:null,main:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:null}),()=>b()),[b,_,t.subtitle,t.title]),(0,H.useEffect)(()=>{!x||x.profile.callName||Ge(x.profileSetup.callNameSuggestion?.value??``)},[x,x?.profile.callName,x?.profileSetup.callNameSuggestion?.id]);async function pt(e,n,r){A(e.id);try{let t=await z(e.id,{action:n,content:r});await w(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),w()}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{A(null)}}async function mt(e,n){A(`consent:${e}`);try{await ue(e,n),await w(),v({type:`success`,title:t.title,message:t.saved})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{A(null)}}async function ht(){let e=B.trim();if(e){A(`understanding:new`);try{await _e({content:e,kind:Ce}),de(``),R(!1),await w(),v({type:`success`,title:t.understandingTitle,message:t.saved})}catch{v({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{A(null)}}}async function gt(){if(Z.length){A(`understanding:batch`);try{await f(Z.map(e=>e.id),`confirm`),await w()}catch{v({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{A(null)}}}async function _t(e,n){A(`conflict:${e}`);try{await ve(e,n),await w()}catch{v({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{A(null)}}async function vt(e){A(`grant:${e}`);try{await L(e),await w()}catch{v({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{A(null)}}async function yt(r,i){A(`insight:${r.id}`);try{let t=await pe(r.id,{action:i,uiLocale:e});await w(),i===`apply`&&t.href&&n(t.href)}catch{v({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{A(null)}}async function bt(e){A(`playbook:${e.id}`);try{await te(e.id,!e.enabled),await w()}catch{v({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{A(null)}}async function xt(e,n){A(`playbook:${e}`);try{await n(),await w()}catch{v({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{A(null)}}async function St(){if(U){A(U.id);try{await F(U.id);let e=U.id;Oe(null),await w(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),w()}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{A(null)}}}async function Ct(){if(ze){Ue(!0);try{let e=await M(ze);je(!1),Ve(null),await w(t=>t&&{...t,...e},{revalidate:!1})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{Ue(!1)}}}async function wt(){let e=We.trim();if(!(!e||Ke)){qe(!0);try{let t=await M({callName:e,timezone:Y.timezone||be()});await w(e=>e&&{...e,...t},{revalidate:!1})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}async function Tt(){if(!Ke){qe(!0);try{let e=await ye(`snooze`);await w(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}function Et(){Ve(Y),je(!0),requestAnimationFrame(()=>st.current?.scrollIntoView({behavior:`smooth`,block:`center`}))}async function Dt(){if(Q){Ze(!0);try{Ye(await ne(Q)),await w(),v({type:`success`,title:t.title,message:t.saved})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{Ze(!1)}}}async function Ot(e){if(!(Qe||e===x?.trust.defaultActionLevel)){$e(!0);try{let t=await Se(e);await w(e=>e&&{...e,trust:t},{revalidate:!1})}catch{v({type:`error`,title:t.trustTitle,message:t.saveError})}finally{$e(!1),tt(null)}}}async function kt(e){if(!(!nt?.instanceId||it)){at(!0);try{let n=await re(nt.instanceId,e);rt(null),await w(),v({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{v({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{at(!1)}}}async function At(){if(!J){ot(`export`);try{let e=await N(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{v({type:`error`,title:t.transferTitle,message:t.saveError})}finally{ot(null)}}}async function jt(e){if(!(!e||J)){ot(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await ae(JSON.parse(await e.text()));await w(),$(`understanding`,`review`),v({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{v({type:`error`,title:t.transferTitle,message:t.importError})}finally{ct.current&&(ct.current.value=``),ot(null)}}}return(0,W.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,W.jsx)(Te,{items:[{id:`overview`,label:t.tabs.overview,icon:fe},{id:`understanding`,label:t.tabs.understanding,icon:oe,count:Z.length||void 0},{id:`sources`,label:t.tabs.sources,icon:y},{id:`controls`,label:t.tabs.controls,icon:le}],activeTab:g,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`}),C?(0,W.jsx)(Pe,{}):S||!x?(0,W.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,x&&g===`overview`?(0,W.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Y.callName&&x.profileSetup.shouldPrompt?(0,W.jsx)(Be,{suggestion:x.profileSetup.callNameSuggestion,draft:We,busy:Ke,onDraftChange:Ge,onSave:()=>void wt(),onLater:()=>void Tt(),t}):null,Z.length>0||dt.length>0||!Y.callName?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[Z.length>0?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[K(t.reviewCount,Z.length),(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})]}):null,dt.length>0?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[K(t.sourceIssues,dt.length),(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})]}):null,Y.callName?null:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:Et,children:[t.completeProfile,(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/55 via-surface-panel to-surface-panel p-5`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.heroTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.heroBody}),(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`),children:[(0,W.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:X.length}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`sources`),children:[(0,W.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:ut.length}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`controls`),children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.trustLevels[x.trust.defaultActionLevel]}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.currentTrust})]})]})]}),x.insights.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(T,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.insightsHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:x.insights.map(e=>(0,W.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?K(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:E===`insight:${e.id}`,onClick:()=>void yt(e,`dismiss`),children:t.notNow}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:E===`insight:${e.id}`,onClick:()=>void yt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,W.jsxs)(`section`,{ref:st,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),ke?null:(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:Et,children:[(0,W.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),ke&&ze?(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(Ee,{value:ze,onChange:Ve,language:e,inputClassName:G,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{je(!1),Ve(null)},children:t.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:He,onClick:()=>void Ct(),children:He?t.saving:t.save})]})]}):(0,W.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.callName||`—`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.timezone||`—`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.pronouns||`—`})]}),Y.notes?(0,W.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,W.jsx)(`dd`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg`,children:Y.notes})]}):null]})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})})]}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[X.slice(0,4).map(e=>(0,W.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),X.length===0?(0,W.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]}),x.playbooks.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(ce,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.playbooksHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:x.playbooks.map(e=>(0,W.jsx)(Re,{playbook:e,busy:E===`playbook:${e.id}`,t,onToggleGroup:()=>void bt(e),onCreate:t=>void xt(e.id,()=>ee(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void xt(e.id,()=>se(e.id,t,n)),onDelete:t=>void xt(e.id,()=>me(e.id,t))},e.id))})]}):null]}):null,x&&g===`understanding`?(0,W.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs text-fg-muted`,children:t.memoryScope}),(0,W.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),I?null:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>R(!0),children:[(0,W.jsx)(xe,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),I?(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-24 resize-y`),value:B,onChange:e=>de(e.target.value),placeholder:t.understandingPlaceholder}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,W.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,W.jsx)(k,{value:Ce,onChange:e=>De(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,W.jsx)(j,{value:e,children:t},e))})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{R(!1),de(``)},children:t.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:!B.trim()||E===`understanding:new`,onClick:()=>void ht(),children:t.add})]})]})]}):null]}),x.conflictGroups.some(e=>e.unresolved)?(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,W.jsx)(`div`,{className:`mt-3 space-y-3`,children:x.conflictGroups.filter(e=>e.unresolved).map(n=>(0,W.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Fe(r,t),` · `,q(r.updatedAt,e)]})]}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:E===`conflict:${n.id}`,onClick:()=>void _t(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,x.consentRequests.length>0?(0,W.jsxs)(`section`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),x.consentRequests.map(e=>(0,W.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,disabled:E===`consent:${e.id}`,onClick:()=>void mt(e.id,`deny`),children:t.consentDeny}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:E===`consent:${e.id}`,onClick:()=>void mt(e.id,`once`),children:t.consentOnce}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:E===`consent:${e.id}`,onClick:()=>void mt(e.id,`session`),children:t.consentSession}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:E===`consent:${e.id}`,onClick:()=>void mt(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,Z.length>0?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:E===`understanding:batch`,onClick:()=>void gt(),children:t.reviewAll})]}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:Z.map(n=>(0,W.jsx)(Ie,{item:n,language:e,t,busy:E===n.id,onConfirm:()=>void pt(n,`confirm`),onReject:()=>void pt(n,`reject`),onUpdate:e=>void pt(n,`update`,e),onForget:()=>Oe(n)},n.id))})]}):X.length>0?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,W.jsx)(s,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,Me.map(n=>{let r=lt.get(n)??[];return r.length===0?null:(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,W.jsx)(Ie,{item:n,language:e,t,busy:E===n.id,onConfirm:()=>void pt(n,`confirm`),onReject:()=>void pt(n,`reject`),onUpdate:e=>void pt(n,`update`,e),onForget:()=>Oe(n)},n.id))})]},n)}),x.understanding.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,x&&g===`sources`?(0,W.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.sourcesHint})]}),(0,W.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})]})]}),x.sourceRecommendations.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(we,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.recommendationsHint}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:x.sourceRecommendations.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>ft({id:e.sourceId}),children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:x.sources.map(n=>(0,W.jsx)(Le,{source:n,language:e,t,onConfigure:()=>ft(n),onDisconnect:()=>rt(n)},`${n.id}:${n.instanceId??`catalog`}`))}),x.sources.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,x&&g===`controls`&&Q?(0,W.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-2`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.controlHint}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,W.jsx)(k,{value:Q.mode,onChange:e=>Ye({...Q,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,W.jsx)(j,{value:e,children:t},e))})]}),(0,W.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,W.jsx)(k,{value:Q.sensitiveWritePolicy,onChange:e=>Ye({...Q,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,W.jsx)(j,{value:e,children:t},e))})]}),(0,W.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-accent-soft/40 p-3 text-xs leading-5 text-fg-muted`,children:[(0,W.jsx)(d,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:t.transientPromise})]}),(0,W.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:Xe,onClick:()=>void Dt(),children:Xe?t.saving:t.save})})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.trustTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.trustHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:x.trust.levels.map(e=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e===x.trust.defaultActionLevel,disabled:Qe,onClick:()=>e===`auto`?tt(e):void Ot(e),className:o(`rounded-xl border p-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-70`,e===x.trust.defaultActionLevel?`border-accent/35 bg-accent-soft/35`:`border-edge-subtle bg-surface-panel hover:border-accent/25 hover:bg-surface-hover`),children:[(0,W.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:t.trustLevels[e]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustLevelHints[e]}),e===x.trust.defaultActionLevel?(0,W.jsx)(`span`,{className:`mt-2 inline-block rounded-full bg-accent-soft px-2 py-0.5 text-[11px] text-accent-fg`,children:t.defaultTrust}):null]},e))}),(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.autoOptInPromise})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),x.referenceGrants.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:x.referenceGrants.map(n=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${q(n.expiresAt,e)}`:``]})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:E===`grant:${n.id}`,onClick:()=>void vt(n.id),children:t.revoke})]},n.id))}):(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.transferHint}),(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:J!==null,onClick:()=>void At(),children:[(0,W.jsx)(h,{className:`size-4`,"aria-hidden":!0}),J===`export`?t.exporting:t.exportAction]}),(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:J!==null,onClick:()=>ct.current?.click(),children:[(0,W.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),J===`import`?t.importing:t.importAction]}),(0,W.jsx)(`input`,{ref:ct,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>void jt(e.target.files?.[0])})]}),(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.importPromise})]})]}):null,(0,W.jsx)(P,{open:U!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void St(),onCancel:()=>Oe(null)}),(0,W.jsx)(P,{open:et===`auto`,title:t.autoConfirmTitle,description:t.autoConfirmBody,confirmLabel:t.autoConfirmAction,cancelLabel:t.cancel,onConfirm:()=>void Ot(`auto`),onCancel:()=>tt(null)}),(0,W.jsx)(Ae,{source:nt,language:e,busy:it,onOpenChange:e=>{e||rt(null)},onConfirm:e=>void kt(e)})]})}export{Ve as UserContextPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-B0B40tpO.js";import{n as l}from"./locale-store-GfSwnwIZ.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$s as d,$t as f,Bo as p,Cs as m,Fl as h,Fo as g,Fs as _,Ho as v,Il as y,Io as b,Lo as x,Ms as S,No as C,Po as w,Qc as T,Ro as E,Tc as D,Xl as O,Yo as k,Ys as A,Zo as j,_n as M,an as N,ar as P,cn as F,dl as I,dn as L,en as ee,et as R,fn as te,gn as ne,hn as z,in as re,js as ie,ln as ae,lo as B,lu as oe,mn as se,mu as ce,nc as le,nn as ue,on as de,pl as fe,pn as pe,rn as me,ru as he,sn as ge,tn as _e,un as ve,vn as ye,wn as be,yc as xe,yn as Se,ys as V,zo as Ce,zs as we}from"./index-DSydVlxZ.js";import{t as Te}from"./page-tabs-HACawonJ.js";import{t as Ee}from"./user-profile-fields-editor-CfLUK6MT.js";import{t as De}from"./connector-logo-KsRvub5G.js";var H=e(t(),1),U=n(),Oe={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function ke(e){if(e.branding?.logoUrl)return e.branding;let t=Oe[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}var W=r();function Ae(e){let t=(0,U.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:s}=e,l=c(r).you,[u,d]=(0,H.useState)(!1),f,p;t[0]===n?(f=t[1],p=t[2]):(f=()=>{n&&d(!1)},p=[n],t[0]=n,t[1]=f,t[2]=p),(0,H.useEffect)(f,p);let h;t[3]!==i||t[4]!==a?(h=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=h):h=t[5];let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,W.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=v):v=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,W.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t[7]=T):T=t[7];let D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>d(!1),t[8]=D):D=t[8];let O=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,k;t[9]===O?k=t[10]:(k=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,O),t[9]=O,t[10]=k);let A;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,W.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=A):A=t[11];let j;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>d(!0),t[12]=j):j=t[12];let M=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,N;t[13]===M?N=t[14]:(N=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,M),t[13]=M,t[14]=N);let P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,W.jsx)(_,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=P):P=t[15];let F=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),I;t[16]===F?I=t[17]:(I=(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:F}),t[16]=F,t[17]=I);let L;t[18]!==i||t[19]!==l.cancel?(L=(0,W.jsx)(w,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=L):L=t[20];let ee=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,R;t[21]!==u||t[22]!==s?(R=()=>s(u),t[21]=u,t[22]=s,t[23]=R):R=t[23];let te;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,W.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t[24]=te):te=t[24];let ne=i?l.disconnecting:l.disconnectAction,z;t[25]!==i||t[26]!==ee||t[27]!==R||t[28]!==ne?(z=(0,W.jsxs)(V,{type:`button`,variant:`secondary`,className:ee,disabled:i,onClick:R,children:[te,ne]}),t[25]=i,t[26]=ee,t[27]=R,t[28]=ne,t[29]=z):z=t[29];let re;return t[30]!==L||t[31]!==z?(re=(0,W.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[L,z]}),t[30]=L,t[31]=z,t[32]=re):re=t[32],(0,W.jsx)(C,{open:n!==null,onOpenChange:h,children:(0,W.jsxs)(E,{children:[v,(0,W.jsxs)(g,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ce,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,W.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,W.jsx)(w,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:T})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[n?.accountLabel?(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,n.accountLabel)}):null,(0,W.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:D,className:k,children:[A,(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:j,disabled:!n?.derivedUnderstandingCount,className:N,children:[P,(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),I]})]})]}),re]})]})})}var je=new Set([`overview`,`understanding`,`sources`,`controls`]),Me=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],G=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function K(e,t){return e.replace(`{{count}}`,String(t))}function q(e,t){let n=Date.parse(e);return Number.isFinite(n)?R(n,t):e}function Ne(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&je.has(e)?e:`overview`}function Pe(){let e=(0,U.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(B,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(B,{className:`h-64 rounded-2xl`}),(0,W.jsx)(B,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Fe(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function Ie(e){let t=(0,U.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,H.useState)(!1),[h,g]=(0,H.useState)(n.statement),[v,y]=(0,H.useState)(null),[b,x]=(0,H.useState)(!1),S=n.status!==`active`,C=S?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,w;t[0]===C?w=t[1]:(w=o(`rounded-xl border p-3.5`,C),t[0]=C,t[1]=w);let T;t[2]!==a||t[3]!==h||t[4]!==f||t[5]!==v||t[6]!==b||t[7]!==n||t[8]!==r||t[9]!==S||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(T=f?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-20 resize-y`),value:h,onChange:e=>g(e.target.value),placeholder:i.updatePlaceholder}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{g(n.statement),p(!1)},children:i.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!h.trim(),onClick:()=>{u(h.trim()),p(!1)},children:i.save})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(A,{className:`size-3 text-accent`,"aria-hidden":!0}),Fe(n,i)]}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,W.jsx)(`span`,{children:K(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,W.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,q(n.latestEvidenceAt,r))}):null]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[S?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,W.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,W.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,W.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:b,onClick:()=>{if(v){y(null);return}x(!0),de(n.id).then(e=>y(e.history)).finally(()=>x(!1))},children:[(0,W.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,W.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,W.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,W.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,W.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,W.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,W.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:q(n.updatedAt,r)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,W.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:K(i.evidenceCount,n.evidenceCount)})]})]})]}),v?(0,W.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),v.map(e=>(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,W.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,W.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:q(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=h,t[4]=f,t[5]=v,t[6]=b,t[7]=n,t[8]=r,t[9]=S,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=T):T=t[15];let E;return t[16]!==w||t[17]!==T?(E=(0,W.jsx)(`article`,{className:w,children:T}),t[16]=w,t[17]=T,t[18]=E):E=t[18],E}function Le(e){let t=(0,U.c)(79),{source:n,language:r,t:i,onConfigure:a,onDisconnect:s}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.lastHealthStatus||t[1]!==i.healthIssue||t[2]!==i.healthOk||t[3]!==i.sourceHealth?(l=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[0]=n.lastHealthStatus,t[1]=i.healthIssue,t[2]=i.healthOk,t[3]=i.sourceHealth,t[4]=l):l=t[4];let u=l,d=`${i.manageSources}: ${n.displayName}`,f;t[5]===a?f=t[6]:(f=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[5]=a,t[6]=f);let p=n.displayName,m;t[7]===n?m=t[8]:(m=ke(n),t[7]=n,t[8]=m);let h;t[9]!==n.displayName||t[10]!==m?(h=(0,W.jsx)(De,{connector:{displayName:p,branding:m},size:`sm`}),t[9]=n.displayName,t[10]=m,t[11]=h):h=t[11];let g;t[12]===n.displayName?g=t[13]:(g=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[12]=n.displayName,t[13]=g);let _;t[14]===n.accountLabel?_=t[15]:(_=n.accountLabel?(0,W.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:n.accountLabel}):null,t[14]=n.accountLabel,t[15]=_);let v;t[16]===n.description?v=t[17]:(v=(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[16]=n.description,t[17]=v);let y;t[18]!==g||t[19]!==_||t[20]!==v?(y=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,_,v]}),t[18]=g,t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==y||t[23]!==h?(b=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,y]}),t[22]=y,t[23]=h,t[24]=b):b=t[24];let x=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,S;t[25]===x?S=t[26]:(S=o(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,x),t[25]=x,t[26]=S);let C;t[27]!==c||t[28]!==S?(C=(0,W.jsx)(`span`,{className:S,children:c}),t[27]=c,t[28]=S,t[29]=C):C=t[29];let w;t[30]!==b||t[31]!==C?(w=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,C]}),t[30]=b,t[31]=C,t[32]=w):w=t[32];let T;t[33]!==n.access.context||t[34]!==i.sourceContext?(T=n.access.context?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[33]=n.access.context,t[34]=i.sourceContext,t[35]=T):T=t[35];let E;t[36]!==n.access.memory||t[37]!==i.sourceMemory?(E=n.access.memory?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[36]=n.access.memory,t[37]=i.sourceMemory,t[38]=E):E=t[38];let D;t[39]!==n.access.read||t[40]!==i.sourceRead?(D=n.access.read?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[39]=n.access.read,t[40]=i.sourceRead,t[41]=D):D=t[41];let O;t[42]!==n.access.write||t[43]!==i.sourceWrite?(O=n.access.write?(0,W.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[42]=n.access.write,t[43]=i.sourceWrite,t[44]=O):O=t[44];let k;t[45]!==T||t[46]!==E||t[47]!==D||t[48]!==O?(k=(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[T,E,D,O]}),t[45]=T,t[46]=E,t[47]=D,t[48]=O,t[49]=k):k=t[49];let A;t[50]!==u||t[51]!==r||t[52]!==n.derivedUnderstandingCount||t[53]!==n.installed||t[54]!==n.knowledgeItemCount||t[55]!==n.lastActivityAt||t[56]!==n.lastSyncAt||t[57]!==n.lastSyncError||t[58]!==n.lastSyncStatus||t[59]!==i.sourceDerivedCount||t[60]!==i.sourceKnowledgeCount||t[61]!==i.sourceLastSync||t[62]!==i.sourceLastUsed||t[63]!==i.sourceNeverUsed||t[64]!==i.sourceSyncFailed?(A=n.installed?(0,W.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[u?(0,W.jsx)(`p`,{children:u}):null,(0,W.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,q(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,W.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,q(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,W.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,W.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,W.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[50]=u,t[51]=r,t[52]=n.derivedUnderstandingCount,t[53]=n.installed,t[54]=n.knowledgeItemCount,t[55]=n.lastActivityAt,t[56]=n.lastSyncAt,t[57]=n.lastSyncError,t[58]=n.lastSyncStatus,t[59]=i.sourceDerivedCount,t[60]=i.sourceKnowledgeCount,t[61]=i.sourceLastSync,t[62]=i.sourceLastUsed,t[63]=i.sourceNeverUsed,t[64]=i.sourceSyncFailed,t[65]=A):A=t[65];let j;t[66]!==s||t[67]!==n.installed||t[68]!==n.instanceId||t[69]!==i.disconnect?(j=n.installed&&n.instanceId?(0,W.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),s()},children:i.disconnect})}):null,t[66]=s,t[67]=n.installed,t[68]=n.instanceId,t[69]=i.disconnect,t[70]=j):j=t[70];let M;return t[71]!==a||t[72]!==w||t[73]!==d||t[74]!==k||t[75]!==A||t[76]!==j||t[77]!==f?(M=(0,W.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":d,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:f,children:[w,k,A,j]}),t[71]=a,t[72]=w,t[73]=d,t[74]=k,t[75]=A,t[76]=j,t[77]=f,t[78]=M):M=t[78],M}function Re(e){let t=(0,U.c)(58),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:s,onUpdate:c,onDelete:l}=e,[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(``),g=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,v;t[0]===g?v=t[1]:(v=o(`rounded-xl border p-4`,g),t[0]=g,t[1]=v);let y=i.playbookNames[n.id],b;t[2]===y?b=t[3]:(b=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:y}),t[2]=y,t[3]=b);let x;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(x=K(i.playbookRuleCount,n.rules.filter(ze).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=x):x=t[6];let S;t[7]===x?S=t[8]:(S=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[7]=x,t[8]=S);let C;t[9]!==b||t[10]!==S?(C=(0,W.jsxs)(`div`,{children:[b,S]}),t[9]=b,t[10]=S,t[11]=C):C=t[11];let w=n.enabled?i.pausePlaybook:i.resumePlaybook,T;t[12]!==r||t[13]!==a||t[14]!==w?(T=(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:w}),t[12]=r,t[13]=a,t[14]=w,t[15]=T):T=t[15];let E;t[16]!==C||t[17]!==T?(E=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,T]}),t[16]=C,t[17]=T,t[18]=E):E=t[18];let O;t[19]!==r||t[20]!==f||t[21]!==m||t[22]!==l||t[23]!==c||t[24]!==n.rules||t[25]!==i.cancel||t[26]!==i.deleteRule||t[27]!==i.disableRule||t[28]!==i.edit||t[29]!==i.enableRule||t[30]!==i.moveDown||t[31]!==i.moveUp||t[32]!==i.save?(O=n.rules.map((e,t)=>(0,W.jsx)(`li`,{className:o(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:f===e.id?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-16 resize-y`),value:m,onChange:e=>h(e.target.value)}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>p(null),children:i.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!m.trim(),onClick:()=>{c(e.id,{statement:m.trim()}),p(null)},children:i.save})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{p(e.id),h(e.statement)},children:[(0,W.jsx)(D,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,W.jsx)(_,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]})]})},e.id)),t[19]=r,t[20]=f,t[21]=m,t[22]=l,t[23]=c,t[24]=n.rules,t[25]=i.cancel,t[26]=i.deleteRule,t[27]=i.disableRule,t[28]=i.edit,t[29]=i.enableRule,t[30]=i.moveDown,t[31]=i.moveUp,t[32]=i.save,t[33]=O):O=t[33];let k;t[34]===O?k=t[35]:(k=(0,W.jsx)(`ul`,{className:`mt-3 space-y-2`,children:O}),t[34]=O,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>d(e.target.value),t[36]=A):A=t[36];let j;t[37]!==u||t[38]!==i.newRulePlaceholder?(j=(0,W.jsx)(`input`,{className:G,value:u,onChange:A,placeholder:i.newRulePlaceholder}),t[37]=u,t[38]=i.newRulePlaceholder,t[39]=j):j=t[39];let M;t[40]!==r||t[41]!==u?(M=r||!u.trim(),t[40]=r,t[41]=u,t[42]=M):M=t[42];let N;t[43]!==u||t[44]!==s?(N=()=>{s(u.trim()),d(``)},t[43]=u,t[44]=s,t[45]=N):N=t[45];let P;t[46]!==i.addRule||t[47]!==M||t[48]!==N?(P=(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:M,onClick:N,children:i.addRule}),t[46]=i.addRule,t[47]=M,t[48]=N,t[49]=P):P=t[49];let F;t[50]!==j||t[51]!==P?(F=(0,W.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[j,P]}),t[50]=j,t[51]=P,t[52]=F):F=t[52];let I;return t[53]!==E||t[54]!==k||t[55]!==F||t[56]!==v?(I=(0,W.jsxs)(`article`,{className:v,children:[E,k,F]}),t[53]=E,t[54]=k,t[55]=F,t[56]=v,t[57]=I):I=t[57],I}function ze(e){return e.enabled}function Be(e){let t=(0,U.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:s,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let f;t[4]===u?f=t[5]:(f=(0,W.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=f);let p=n?l.meetSuggestedBody:l.meetBody,m;t[6]===p?m=t[7]:(m=(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:p}),t[6]=p,t[7]=m);let h;t[8]===l.callName?h=t[9]:(h=(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=h);let g;t[10]===a?g=t[11]:(g=e=>a(e.target.value),t[10]=a,t[11]=g);let _;t[12]!==i||t[13]!==r||t[14]!==s?(_=e=>{e.key===`Enter`&&r.trim()&&!i&&s()},t[12]=i,t[13]=r,t[14]=s,t[15]=_):_=t[15];let v=l.meetPlaceholder,y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=o(G,`h-10 flex-1 bg-surface-base/90`),t[16]=y):y=t[16];let b;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==g||t[20]!==_?(b=(0,W.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,onChange:g,onKeyDown:_,placeholder:v,className:y}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=g,t[20]=_,t[21]=b):b=t[21];let x;t[22]!==i||t[23]!==r?(x=i||!r.trim(),t[22]=i,t[23]=r,t[24]=x):x=t[24];let S=i?l.meetSaving:l.meetSave,C;t[25]!==s||t[26]!==x||t[27]!==S?(C=(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:x,onClick:s,children:S}),t[25]=s,t[26]=x,t[27]=S,t[28]=C):C=t[28];let w;t[29]!==b||t[30]!==C||t[31]!==h?(w=(0,W.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[h,b,C]}),t[29]=b,t[30]=C,t[31]=h,t[32]=w):w=t[32];let T;t[33]!==n||t[34]!==l.meetSource?(T=n?(0,W.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,W.jsx)(d,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=T):T=t[35];let E;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(E=(0,W.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=E):E=t[39];let D;return t[40]!==w||t[41]!==T||t[42]!==E||t[43]!==f||t[44]!==m?(D=(0,W.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,W.jsxs)(`div`,{className:`relative max-w-2xl`,children:[f,m,w,T,E]})}),t[40]=w,t[41]=T,t[42]=E,t[43]=f,t[44]=m,t[45]=D):D=t[45],D}function Ve(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,m]=i(),g=Ne(r.get(`tab`)),_=p(e=>e.setPageHeader),b=p(e=>e.clearPageHeader),{data:x,error:S,isLoading:C,mutate:w}=u(`/api/you`,ge),[E,A]=(0,H.useState)(null),[I,R]=(0,H.useState)(!1),[B,de]=(0,H.useState)(``),[Ce,De]=(0,H.useState)(`preference`),[U,Oe]=(0,H.useState)(null),[ke,je]=(0,H.useState)(!1),[ze,Ve]=(0,H.useState)(null),[He,Ue]=(0,H.useState)(!1),[We,Ge]=(0,H.useState)(``),[Ke,qe]=(0,H.useState)(!1),[Je,Ye]=(0,H.useState)(null),[Xe,Ze]=(0,H.useState)(!1),[Qe,$e]=(0,H.useState)(!1),[et,tt]=(0,H.useState)(null),[nt,rt]=(0,H.useState)(null),[it,at]=(0,H.useState)(!1),[J,ot]=(0,H.useState)(null),st=(0,H.useRef)(null),ct=(0,H.useRef)(null),Y=x?.profile??{callName:``,pronouns:``,timezone:``,notes:``},X=(0,H.useMemo)(()=>x?.understanding.filter(e=>e.status===`active`)??[],[x]),Z=(0,H.useMemo)(()=>x?.understanding.filter(e=>e.status!==`active`)??[],[x]),lt=(0,H.useMemo)(()=>new Map(Me.map(e=>[e,X.filter(t=>t.facet===e)])),[X]),Q=Je??x?.controls??null,ut=x?.sources.filter(e=>e.installed&&e.enabled)??[],dt=ut.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)),$=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),m(n,{replace:!0})},ft=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,H.useLayoutEffect)(()=>(_({startExtra:null,main:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:null}),()=>b()),[b,_,t.subtitle,t.title]),(0,H.useEffect)(()=>{!x||x.profile.callName||Ge(x.profileSetup.callNameSuggestion?.value??``)},[x,x?.profile.callName,x?.profileSetup.callNameSuggestion?.id]);async function pt(e,n,r){A(e.id);try{let t=await z(e.id,{action:n,content:r});await w(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),w()}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{A(null)}}async function mt(e,n){A(`consent:${e}`);try{await ue(e,n),await w(),v({type:`success`,title:t.title,message:t.saved})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{A(null)}}async function ht(){let e=B.trim();if(e){A(`understanding:new`);try{await _e({content:e,kind:Ce}),de(``),R(!1),await w(),v({type:`success`,title:t.understandingTitle,message:t.saved})}catch{v({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{A(null)}}}async function gt(){if(Z.length){A(`understanding:batch`);try{await f(Z.map(e=>e.id),`confirm`),await w()}catch{v({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{A(null)}}}async function _t(e,n){A(`conflict:${e}`);try{await ve(e,n),await w()}catch{v({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{A(null)}}async function vt(e){A(`grant:${e}`);try{await L(e),await w()}catch{v({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{A(null)}}async function yt(r,i){A(`insight:${r.id}`);try{let t=await pe(r.id,{action:i,uiLocale:e});await w(),i===`apply`&&t.href&&n(t.href)}catch{v({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{A(null)}}async function bt(e){A(`playbook:${e.id}`);try{await te(e.id,!e.enabled),await w()}catch{v({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{A(null)}}async function xt(e,n){A(`playbook:${e}`);try{await n(),await w()}catch{v({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{A(null)}}async function St(){if(U){A(U.id);try{await F(U.id);let e=U.id;Oe(null),await w(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),w()}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{A(null)}}}async function Ct(){if(ze){Ue(!0);try{let e=await M(ze);je(!1),Ve(null),await w(t=>t&&{...t,...e},{revalidate:!1})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{Ue(!1)}}}async function wt(){let e=We.trim();if(!(!e||Ke)){qe(!0);try{let t=await M({callName:e,timezone:Y.timezone||be()});await w(e=>e&&{...e,...t},{revalidate:!1})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}async function Tt(){if(!Ke){qe(!0);try{let e=await ye(`snooze`);await w(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}function Et(){Ve(Y),je(!0),requestAnimationFrame(()=>st.current?.scrollIntoView({behavior:`smooth`,block:`center`}))}async function Dt(){if(Q){Ze(!0);try{Ye(await ne(Q)),await w(),v({type:`success`,title:t.title,message:t.saved})}catch{v({type:`error`,title:t.title,message:t.saveError})}finally{Ze(!1)}}}async function Ot(e){if(!(Qe||e===x?.trust.defaultActionLevel)){$e(!0);try{let t=await Se(e);await w(e=>e&&{...e,trust:t},{revalidate:!1})}catch{v({type:`error`,title:t.trustTitle,message:t.saveError})}finally{$e(!1),tt(null)}}}async function kt(e){if(!(!nt?.instanceId||it)){at(!0);try{let n=await re(nt.instanceId,e);rt(null),await w(),v({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{v({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{at(!1)}}}async function At(){if(!J){ot(`export`);try{let e=await N(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{v({type:`error`,title:t.transferTitle,message:t.saveError})}finally{ot(null)}}}async function jt(e){if(!(!e||J)){ot(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await ae(JSON.parse(await e.text()));await w(),$(`understanding`,`review`),v({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{v({type:`error`,title:t.transferTitle,message:t.importError})}finally{ct.current&&(ct.current.value=``),ot(null)}}}return(0,W.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,W.jsx)(Te,{items:[{id:`overview`,label:t.tabs.overview,icon:fe},{id:`understanding`,label:t.tabs.understanding,icon:oe,count:Z.length||void 0},{id:`sources`,label:t.tabs.sources,icon:y},{id:`controls`,label:t.tabs.controls,icon:le}],activeTab:g,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`}),C?(0,W.jsx)(Pe,{}):S||!x?(0,W.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,x&&g===`overview`?(0,W.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Y.callName&&x.profileSetup.shouldPrompt?(0,W.jsx)(Be,{suggestion:x.profileSetup.callNameSuggestion,draft:We,busy:Ke,onDraftChange:Ge,onSave:()=>void wt(),onLater:()=>void Tt(),t}):null,Z.length>0||dt.length>0||!Y.callName?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[Z.length>0?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[K(t.reviewCount,Z.length),(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})]}):null,dt.length>0?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[K(t.sourceIssues,dt.length),(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})]}):null,Y.callName?null:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:Et,children:[t.completeProfile,(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/55 via-surface-panel to-surface-panel p-5`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.heroTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.heroBody}),(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`),children:[(0,W.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:X.length}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`sources`),children:[(0,W.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:ut.length}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`controls`),children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.trustLevels[x.trust.defaultActionLevel]}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.currentTrust})]})]})]}),x.insights.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(T,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.insightsHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:x.insights.map(e=>(0,W.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?K(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:E===`insight:${e.id}`,onClick:()=>void yt(e,`dismiss`),children:t.notNow}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:E===`insight:${e.id}`,onClick:()=>void yt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,W.jsxs)(`section`,{ref:st,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),ke?null:(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:Et,children:[(0,W.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),ke&&ze?(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(Ee,{value:ze,onChange:Ve,language:e,inputClassName:G,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{je(!1),Ve(null)},children:t.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:He,onClick:()=>void Ct(),children:He?t.saving:t.save})]})]}):(0,W.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.callName||`—`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.timezone||`—`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.pronouns||`—`})]}),Y.notes?(0,W.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,W.jsx)(`dd`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg`,children:Y.notes})]}):null]})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})})]}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[X.slice(0,4).map(e=>(0,W.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),X.length===0?(0,W.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]}),x.playbooks.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(ce,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.playbooksHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:x.playbooks.map(e=>(0,W.jsx)(Re,{playbook:e,busy:E===`playbook:${e.id}`,t,onToggleGroup:()=>void bt(e),onCreate:t=>void xt(e.id,()=>ee(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void xt(e.id,()=>se(e.id,t,n)),onDelete:t=>void xt(e.id,()=>me(e.id,t))},e.id))})]}):null]}):null,x&&g===`understanding`?(0,W.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs text-fg-muted`,children:t.memoryScope}),(0,W.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),I?null:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>R(!0),children:[(0,W.jsx)(xe,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),I?(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-24 resize-y`),value:B,onChange:e=>de(e.target.value),placeholder:t.understandingPlaceholder}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,W.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,W.jsx)(k,{value:Ce,onChange:e=>De(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,W.jsx)(j,{value:e,children:t},e))})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{R(!1),de(``)},children:t.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:!B.trim()||E===`understanding:new`,onClick:()=>void ht(),children:t.add})]})]})]}):null]}),x.conflictGroups.some(e=>e.unresolved)?(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,W.jsx)(`div`,{className:`mt-3 space-y-3`,children:x.conflictGroups.filter(e=>e.unresolved).map(n=>(0,W.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Fe(r,t),` · `,q(r.updatedAt,e)]})]}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:E===`conflict:${n.id}`,onClick:()=>void _t(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,x.consentRequests.length>0?(0,W.jsxs)(`section`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),x.consentRequests.map(e=>(0,W.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,disabled:E===`consent:${e.id}`,onClick:()=>void mt(e.id,`deny`),children:t.consentDeny}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:E===`consent:${e.id}`,onClick:()=>void mt(e.id,`once`),children:t.consentOnce}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:E===`consent:${e.id}`,onClick:()=>void mt(e.id,`session`),children:t.consentSession}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:E===`consent:${e.id}`,onClick:()=>void mt(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,Z.length>0?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:E===`understanding:batch`,onClick:()=>void gt(),children:t.reviewAll})]}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:Z.map(n=>(0,W.jsx)(Ie,{item:n,language:e,t,busy:E===n.id,onConfirm:()=>void pt(n,`confirm`),onReject:()=>void pt(n,`reject`),onUpdate:e=>void pt(n,`update`,e),onForget:()=>Oe(n)},n.id))})]}):X.length>0?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,W.jsx)(s,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,Me.map(n=>{let r=lt.get(n)??[];return r.length===0?null:(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,W.jsx)(Ie,{item:n,language:e,t,busy:E===n.id,onConfirm:()=>void pt(n,`confirm`),onReject:()=>void pt(n,`reject`),onUpdate:e=>void pt(n,`update`,e),onForget:()=>Oe(n)},n.id))})]},n)}),x.understanding.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,x&&g===`sources`?(0,W.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.sourcesHint})]}),(0,W.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,W.jsx)(he,{className:`size-4`,"aria-hidden":!0})]})]}),x.sourceRecommendations.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(we,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.recommendationsHint}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:x.sourceRecommendations.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>ft({id:e.sourceId}),children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:x.sources.map(n=>(0,W.jsx)(Le,{source:n,language:e,t,onConfigure:()=>ft(n),onDisconnect:()=>rt(n)},`${n.id}:${n.instanceId??`catalog`}`))}),x.sources.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,x&&g===`controls`&&Q?(0,W.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-2`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.controlHint}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,W.jsx)(k,{value:Q.mode,onChange:e=>Ye({...Q,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,W.jsx)(j,{value:e,children:t},e))})]}),(0,W.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,W.jsx)(k,{value:Q.sensitiveWritePolicy,onChange:e=>Ye({...Q,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,W.jsx)(j,{value:e,children:t},e))})]}),(0,W.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-accent-soft/40 p-3 text-xs leading-5 text-fg-muted`,children:[(0,W.jsx)(d,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:t.transientPromise})]}),(0,W.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:Xe,onClick:()=>void Dt(),children:Xe?t.saving:t.save})})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.trustTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.trustHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:x.trust.levels.map(e=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e===x.trust.defaultActionLevel,disabled:Qe,onClick:()=>e===`auto`?tt(e):void Ot(e),className:o(`rounded-xl border p-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-70`,e===x.trust.defaultActionLevel?`border-accent/35 bg-accent-soft/35`:`border-edge-subtle bg-surface-panel hover:border-accent/25 hover:bg-surface-hover`),children:[(0,W.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:t.trustLevels[e]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustLevelHints[e]}),e===x.trust.defaultActionLevel?(0,W.jsx)(`span`,{className:`mt-2 inline-block rounded-full bg-accent-soft px-2 py-0.5 text-[11px] text-accent-fg`,children:t.defaultTrust}):null]},e))}),(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.autoOptInPromise})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),x.referenceGrants.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:x.referenceGrants.map(n=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${q(n.expiresAt,e)}`:``]})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:E===`grant:${n.id}`,onClick:()=>void vt(n.id),children:t.revoke})]},n.id))}):(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.transferHint}),(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:J!==null,onClick:()=>void At(),children:[(0,W.jsx)(h,{className:`size-4`,"aria-hidden":!0}),J===`export`?t.exporting:t.exportAction]}),(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:J!==null,onClick:()=>ct.current?.click(),children:[(0,W.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),J===`import`?t.importing:t.importAction]}),(0,W.jsx)(`input`,{ref:ct,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>void jt(e.target.files?.[0])})]}),(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.importPromise})]})]}):null,(0,W.jsx)(P,{open:U!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void St(),onCancel:()=>Oe(null)}),(0,W.jsx)(P,{open:et===`auto`,title:t.autoConfirmTitle,description:t.autoConfirmBody,confirmLabel:t.autoConfirmAction,cancelLabel:t.cancel,onConfirm:()=>void Ot(`auto`),onCancel:()=>tt(null)}),(0,W.jsx)(Ae,{source:nt,language:e,busy:it,onOpenChange:e=>{e||rt(null)},onConfirm:e=>void kt(e)})]})}export{Ve as UserContextPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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"./cn-BQ_8x0bT.js";import{Cn as a,Yo as ee,Zo as o,ps as te,wn as ne,xn as re}from"./index-
|
|
1
|
+
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"./cn-BQ_8x0bT.js";import{Cn as a,Yo as ee,Zo as o,ps as te,wn as ne,xn as re}from"./index-DSydVlxZ.js";var ie=n(),ae=e(t(),1),s=r();function c(e){let t=(0,ie.c)(104),{value:n,onChange:r,labels:c,language:l,inputClassName:u}=e,d;t[0]===n.timezone?d=t[1]:(d=()=>a.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=d);let[f,p]=(0,ae.useState)(d),m;t[2]===n.timezone?m=t[3]:(m=()=>!!n.timezone&&!a.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=m);let[h,g]=(0,ae.useState)(m),_;t[4]===n.pronouns?_=t[5]:(_=()=>!!n.pronouns&&!re.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=_);let[v,oe]=(0,ae.useState)(_),se;bb0:{if(h){se=`__custom__`;break bb0}se=a.some(e=>e.value===n.timezone)?n.timezone:`__custom__`}let ce=se,y;t[6]!==r||t[7]!==n?(y=e=>r({...n,...e}),t[6]=r,t[7]=n,t[8]=y):y=t[8];let b=y,x;t[9]===l?x=t[10]:(x=(e,t)=>l===`zh`?t:e,t[9]=l,t[10]=x);let S=x,C;t[11]===c.callName?C=t[12]:(C=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.callName}),t[11]=c.callName,t[12]=C);let w;t[13]===b?w=t[14]:(w=e=>b({callName:e.target.value}),t[13]=b,t[14]=w);let T;t[15]!==u||t[16]!==c.callNamePlaceholder||t[17]!==w||t[18]!==n.callName?(T=(0,s.jsx)(`input`,{className:u,value:n.callName,onChange:w,placeholder:c.callNamePlaceholder,autoComplete:`off`}),t[15]=u,t[16]=c.callNamePlaceholder,t[17]=w,t[18]=n.callName,t[19]=T):T=t[19];let E;t[20]!==C||t[21]!==T?(E=(0,s.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[C,T]}),t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]===c.pronouns?D=t[24]:(D=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.pronouns}),t[23]=c.pronouns,t[24]=D);let O=v?`__custom__`:n.pronouns,k;t[25]!==b||t[26]!==n.pronouns?(k=e=>{if(e.target.value===`__custom__`){oe(!0),re.some(e=>e.value===n.pronouns)&&b({pronouns:``});return}oe(!1),b({pronouns:e.target.value})},t[25]=b,t[26]=n.pronouns,t[27]=k):k=t[27];let A;t[28]===c.pronounsPlaceholder?A=t[29]:(A=(0,s.jsx)(o,{value:``,children:c.pronounsPlaceholder}),t[28]=c.pronounsPlaceholder,t[29]=A);let j;t[30]===S?j=t[31]:(j=re.map(e=>(0,s.jsx)(o,{value:e.value,children:S(e.labelEn,e.labelZh)},e.value)),t[30]=S,t[31]=j);let M;t[32]===c.custom?M=t[33]:(M=(0,s.jsx)(o,{value:`__custom__`,children:c.custom}),t[32]=c.custom,t[33]=M);let N;t[34]!==u||t[35]!==O||t[36]!==k||t[37]!==A||t[38]!==j||t[39]!==M?(N=(0,s.jsxs)(ee,{className:u,value:O,onChange:k,children:[A,j,M]}),t[34]=u,t[35]=O,t[36]=k,t[37]=A,t[38]=j,t[39]=M,t[40]=N):N=t[40];let P;t[41]!==u||t[42]!==c.pronounsPlaceholder||t[43]!==v||t[44]!==b||t[45]!==n.pronouns?(P=v?(0,s.jsx)(`input`,{className:i(u,`mt-1 text-xs`),value:n.pronouns,onChange:e=>b({pronouns:e.target.value}),placeholder:c.pronounsPlaceholder,autoComplete:`off`}):null,t[41]=u,t[42]=c.pronounsPlaceholder,t[43]=v,t[44]=b,t[45]=n.pronouns,t[46]=P):P=t[46];let F;t[47]!==D||t[48]!==N||t[49]!==P?(F=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[D,N,P]}),t[47]=D,t[48]=N,t[49]=P,t[50]=F):F=t[50];let I;t[51]===c.timezone?I=t[52]:(I=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.timezone}),t[51]=c.timezone,t[52]=I);let L;t[53]===u?L=t[54]:(L=i(u,`min-w-0 flex-1`),t[53]=u,t[54]=L);let R;t[55]===b?R=t[56]:(R=e=>{if(e.target.value===`__custom__`){g(!0);return}g(!1),p(``),b({timezone:e.target.value})},t[55]=b,t[56]=R);let z;t[57]===S?z=t[58]:(z=a.map(e=>(0,s.jsx)(o,{value:e.value,children:S(e.labelEn,e.labelZh)},e.value)),t[57]=S,t[58]=z);let B;t[59]===c.timezoneCustom?B=t[60]:(B=(0,s.jsx)(o,{value:`__custom__`,children:c.timezoneCustom}),t[59]=c.timezoneCustom,t[60]=B);let V;t[61]!==L||t[62]!==R||t[63]!==z||t[64]!==B||t[65]!==ce?(V=(0,s.jsxs)(ee,{className:L,value:ce,onChange:R,children:[z,B]}),t[61]=L,t[62]=R,t[63]=z,t[64]=B,t[65]=ce,t[66]=V):V=t[66];let H;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(H=i(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,te.press),t[67]=H):H=t[67];let U;t[68]===b?U=t[69]:(U=()=>{let e=ne();if(!e)return;let t=a.some(t=>t.value===e);g(!t),p(t?``:e),b({timezone:e})},t[68]=b,t[69]=U);let W;t[70]!==c.timezoneDetect||t[71]!==U?(W=(0,s.jsx)(`button`,{type:`button`,className:H,onClick:U,children:c.timezoneDetect}),t[70]=c.timezoneDetect,t[71]=U,t[72]=W):W=t[72];let G;t[73]!==V||t[74]!==W?(G=(0,s.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[V,W]}),t[73]=V,t[74]=W,t[75]=G):G=t[75];let K;t[76]!==f||t[77]!==u||t[78]!==h||t[79]!==b?(K=h?(0,s.jsx)(`input`,{className:i(u,`mt-1 font-mono text-xs`),value:f,onChange:e=>{p(e.target.value),b({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null,t[76]=f,t[77]=u,t[78]=h,t[79]=b,t[80]=K):K=t[80];let q;t[81]!==I||t[82]!==G||t[83]!==K?(q=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[I,G,K]}),t[81]=I,t[82]=G,t[83]=K,t[84]=q):q=t[84];let J;t[85]===c.notes?J=t[86]:(J=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.notes}),t[85]=c.notes,t[86]=J);let Y;t[87]===u?Y=t[88]:(Y=i(u,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=u,t[88]=Y);let X;t[89]===b?X=t[90]:(X=e=>b({notes:e.target.value}),t[89]=b,t[90]=X);let Z;t[91]!==c.notesPlaceholder||t[92]!==Y||t[93]!==X||t[94]!==n.notes?(Z=(0,s.jsx)(`textarea`,{className:Y,value:n.notes,onChange:X,placeholder:c.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=c.notesPlaceholder,t[92]=Y,t[93]=X,t[94]=n.notes,t[95]=Z):Z=t[95];let Q;t[96]!==J||t[97]!==Z?(Q=(0,s.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[J,Z]}),t[96]=J,t[97]=Z,t[98]=Q):Q=t[98];let $;return t[99]!==E||t[100]!==F||t[101]!==q||t[102]!==Q?($=(0,s.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[E,F,q,Q]}),t[99]=E,t[100]=F,t[101]=q,t[102]=Q,t[103]=$):$=t[103],$}export{c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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"./messages-B0B40tpO.js";import{n as a}from"./locale-store-GfSwnwIZ.js";import{Dn as o,Xr as s,Yl as c,cc as l,kn as u,lo as d,ol as f,ti as p,wn as m,ys as h}from"./index-
|
|
1
|
+
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"./messages-B0B40tpO.js";import{n as a}from"./locale-store-GfSwnwIZ.js";import{Dn as o,Xr as s,Yl as c,cc as l,kn as u,lo as d,ol as f,ti as p,wn as m,ys as h}from"./index-DSydVlxZ.js";import{n as g,r as _}from"./settings-page-layout-B_-VepeK.js";import{n as v,t as y}from"./settings-form-section-DPSA8tG8.js";import{t as b}from"./utils-DbFnvDPi.js";import{t as x}from"./user-profile-fields-editor-CfLUK6MT.js";var S=n(),C=e(t(),1),w=r(),T={callName:``,pronouns:``,timezone:``,notes:``};function E(e){if(e.timezone)return e;let t=m();return t?{...e,timezone:t}:e}function D(){let e=(0,S.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,w.jsxs)(`div`,{className:`grid gap-2`,children:[(0,w.jsx)(d,{className:`h-4 w-24`}),(0,w.jsx)(d,{className:`h-10 rounded-lg`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,w.jsxs)(`div`,{className:`grid gap-2`,children:[(0,w.jsx)(d,{className:`h-4 w-24`}),(0,w.jsx)(d,{className:`h-10 rounded-lg`})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,w.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"aria-hidden":`true`,children:[t,n,(0,w.jsxs)(`div`,{className:`grid gap-2 sm:col-span-2`,children:[(0,w.jsx)(d,{className:`h-4 w-28`}),(0,w.jsx)(d,{className:`h-28 rounded-lg`})]})]}),e[2]=r):r=e[2],r}function O(){let e=a(e=>e.language),t=i(e).userProfileSettings,n=b(),[r,d]=(0,C.useState)(T),[m,S]=(0,C.useState)(JSON.stringify(T)),[O,k]=(0,C.useState)(!0),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)(!1),[P,F]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return k(!0),F(null),s().then(t=>{if(e)return;let n=E(o(t));d(n),S(JSON.stringify(n))}).catch(n=>{e||F(n instanceof Error?n.message:t.loadError)}).finally(()=>{e||k(!1)}),()=>{e=!0}},[t.loadError]);let I=JSON.stringify(r)!==m;async function L(){j(!0),F(null);try{await p(u(r)),S(JSON.stringify(r)),N(!0)}catch(e){F(e instanceof Error?e.message:t.saveError)}finally{j(!1)}}return(0,w.jsxs)(_,{gap:`gap-6`,children:[(0,w.jsx)(g,{title:t.title,subtitle:t.subtitle,actions:(0,w.jsxs)(h,{type:`button`,variant:`primary`,disabled:O||A||!I,onClick:()=>void L(),children:[(0,w.jsx)(l,{className:`size-4`,"aria-hidden":!0}),A?t.saving:M?t.saved:t.save]})}),(0,w.jsxs)(y,{children:[(0,w.jsx)(v,{icon:c,title:t.sectionTitle,subtitle:t.sectionSubtitle}),O?(0,w.jsx)(D,{}):(0,w.jsx)(x,{value:r,onChange:e=>{d(e),N(!1)},labels:t,language:e,inputClassName:n}),(0,w.jsxs)(`div`,{className:`mt-4 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,w.jsx)(f,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,w.jsx)(`span`,{children:t.note})]}),P?(0,w.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:P}):null]})]})}export{O as UserProfileSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cn-BQ_8x0bT.js";import{vs as t}from"./index-
|
|
1
|
+
import{t as e}from"./cn-BQ_8x0bT.js";import{vs as t}from"./index-DSydVlxZ.js";function n(){return e(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,t,`dark:border-edge`)}function r(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function i(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}export{i as n,r,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{l as o,r as s,s as c}from"./locale-store-GfSwnwIZ.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{Ml as u,Uc as d,Xt as f,Yo as p,Yt as m,Zo as h,au as g,cc as _,co as v,qn as y,so as b,us as x,vs as S,ys as ee}from"./index-apLU0Hun.js";var C=`/api/image/providers`;async function te(){return(await c(s(`/api/image/providers`)))?.payload?.providers??[]}var w=e(t(),1),ne=n();function T(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function re(e){return e?.apiKey?`••••••••••••`:``}function E(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:re(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function D(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function O(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(y(n)&&y(r)))return n||(r?null:void 0)}function ie(e,t,n){let r={};for(let i of e){let e=t[i]??T(),a=n[i]??T();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=O(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=D(e,a,`region`);c!==void 0&&(o.region=c);let l=D(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=D(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function k(e){let t=await c(s(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function ae(e){Object.keys(e).length!==0&&(await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await b())}var A=r();function oe(e){let t=(0,ne.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>k(n).then(j),t[0]=n,t[1]=c);let l=c,d=`img-cred-key-${n}`,p;t[2]!==a.apiKeyLabel||t[3]!==d?(p=(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:d,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=d,t[4]=p):p=t[4];let m;t[5]!==s||t[6]!==o?(m=o.length>0?(0,A.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,A.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[f(e.kind,s),(0,A.jsx)(u,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=m):m=t[7];let h=`img-cred-key-${n}`,g;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==h||t[12]!==r?(g=(0,A.jsx)(x,{id:h,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=h,t[12]=r,t[13]=g):g=t[13];let _;return t[14]!==p||t[15]!==m||t[16]!==g?(_=(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[p,m,g]}),t[14]=p,t[15]=m,t[16]=g,t[17]=_):_=t[17],_}function j(e){return e.apiKey??null}function M(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,S)}function se(){return a(M(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var N=`__custom__`;function ce(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:N}function le(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:N}function ue(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function de(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function fe(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function pe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function me(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function P(e){let t=(0,ne.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:f,credNoopFlash:v,updateCredRow:y,onDiscardCredentials:b,onSaveCredentials:x,extensionIds:S,showExtensionLinks:C,showImageModelsLink:te,hideActions:re,language:E,apiKeyLinkLabels:D,messages:O}=e,ie=re===void 0?!1:re,k;t[0]===n?k=t[1]:(k=n.some(ye),t[0]=n,t[1]=k);let ae=k,j;t[2]===n?j=t[3]:(j=n.some(ve),t[2]=n,t[3]=j);let P=j,[F,be]=(0,w.useState)(_e),[I,L]=(0,w.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)pe(r[e.id]??T(),o[e.id]??T())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===O.credentialsIntro?W=t[15]:(W=(0,A.jsx)(`p`,{children:O.credentialsIntro}),t[14]=O.credentialsIntro,t[15]=W);let G;t[16]!==ae||t[17]!==O.regionHint?(G=ae?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.regionHint}):null,t[16]=ae,t[17]=O.regionHint,t[18]=G):G=t[18];let K;t[19]!==P||t[20]!==O.endpointPresetsHint?(K=P?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.endpointPresetsHint}):null,t[19]=P,t[20]=O.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==te||t[23]!==O.imageModelsLinkTitle||t[24]!==O.openImageModelsPage?(q=te?(0,A.jsx)(`p`,{children:(0,A.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:O.imageModelsLinkTitle,children:O.openImageModelsPage})}):null,t[22]=te,t[23]=O.imageModelsLinkTitle,t[24]=O.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,A.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===l?Y=t[32]:(Y=l?(0,A.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==v||t[35]!==f||t[36]!==c||t[37]!==ie||t[38]!==b||t[39]!==x||t[40]!==O.credentialsNothingToSave||t[41]!==O.credentialsSaved||t[42]!==O.discardCredentials||t[43]!==O.saveCredentials||t[44]!==O.savingCredentials?(X=ie?null:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[f?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsSaved}):null,v?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsNothingToSave}):null,(0,A.jsx)(ee,{type:`button`,variant:`secondary`,onClick:b,disabled:!s||c,children:O.discardCredentials}),(0,A.jsx)(ee,{type:`button`,variant:`primary`,onClick:x,disabled:!s||c,children:c?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{className:`size-3.5 animate-spin`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.savingCredentials})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{className:`size-3.5`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.saveCredentials})]})})]}),t[33]=s,t[34]=v,t[35]=f,t[36]=c,t[37]=ie,t[38]=b,t[39]=x,t[40]=O.credentialsNothingToSave,t[41]=O.credentialsSaved,t[42]=O.discardCredentials,t[43]=O.saveCredentials,t[44]=O.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==D||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==E||t[52]!==C||t[53]!==n||t[54]!==O||t[55]!==U||t[56]!==y){let e;t[58]!==D||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==E||t[64]!==C||t[65]!==O||t[66]!==U||t[67]!==y?(e=e=>{let t=r[e.id]??T(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=pe(t,o[e.id]??T()),l=V(e.id),d=e.label??e.id,f=me(O,e.models.length);return(0,A.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,A.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:d}),(0,A.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.unsavedChanges}):null,e.configured?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.configured}):(0,A.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:O.missingKey})]}),(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,A.jsx)(`span`,{children:f}),e.defaultModel?(0,A.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,A.jsx)(g,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`sr-only`,children:l?O.collapseProvider:O.expandProvider})]}),l?(0,A.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 p-4`,children:[s?(0,A.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:O.extensionSettingsLinkTitle,children:[(0,A.jsx)(u,{className:`size-3`}),O.openExtensionSettings]}):null,e.models.length>0?(0,A.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,A.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,A.jsx)(oe,{providerId:e.id,value:t.apiKey,onChange:t=>y(e.id,{apiKey:t}),apiKeyLinks:m(e.id,E),apiKeyLinkLabels:D,labels:{apiKeyLabel:O.apiKeyLabel,optionalPlaceholder:O.optionalPlaceholder,maskedHelp:O.apiKeyMaskedHelp,copy:O.apiKeyCopy,copied:O.apiKeyCopied,show:O.apiKeyShow,hide:O.apiKeyHide,notInConfigFile:O.apiKeyNotInConfigFile,loadFailed:O.apiKeyRevealFailed}}),n?.regions?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:O.regionLabel}),(0,A.jsxs)(p,{id:`img-cred-region-preset-${e.id}`,className:se(),value:ce(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){y(e.id,{region:``,imageBaseUrl:``});return}if(r===N){y(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&y(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,A.jsx)(h,{value:``,children:O.regionPresetDefault}),n.regions.map(e=>(0,A.jsx)(h,{value:e.value,children:ue(O,e.value,e.label)},e.value)),(0,A.jsx)(h,{value:N,children:O.regionPresetCustom})]}),ce(t,n.regions)===N?(0,A.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,A.jsx)(`input`,{type:`text`,className:M(),value:t.region,placeholder:`region`,onChange:t=>y(e.id,{region:t.target.value})}),(0,A.jsx)(`input`,{type:`url`,className:M(),value:t.imageBaseUrl,placeholder:O.imageBaseUrlLabel,onChange:t=>y(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:de(O,n.baseUrlPresetKind)}),fe(O,n.baseUrlPresetKind)?(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:fe(O,n.baseUrlPresetKind)}):null,(0,A.jsxs)(p,{id:`img-cred-base-preset-${e.id}`,className:se(),value:le(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){y(e.id,{baseUrl:``});return}if(n===N){y(e.id,{baseUrl:``});return}y(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,A.jsx)(h,{value:``,children:O.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,A.jsx)(h,{value:N,children:O.baseUrlPresetCustom})]}),le(t,n.baseUrlPresets)===N?(0,A.jsx)(`input`,{type:`url`,className:a(M(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>y(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&ce(t,n.regions)!==N?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:O.imageBaseUrlLabel}),(0,A.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(M(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:O.imageBaseUrlPresetHint}),(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:O.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=D,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=E,t[64]=C,t[65]=O,t[66]=U,t[67]=y,t[68]=e):e=t[68],Z=n.map(e),t[46]=D,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=E,t[52]=C,t[53]=n,t[54]=O,t[55]=U,t[56]=y,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,A.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,A.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function he(e){return(0,A.jsx)(h,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=v(o(e=>!!e.token)),n=t.data,r=(0,w.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,w.useRef)(!1),[a,c]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(!1),[g,_]=(0,w.useState)(!1),y=(0,w.useMemo)(()=>E(n?.payload?.config,r),[n?.payload?.config,r]),b=a??y,x=y;return{gwSwr:t,credDraft:b,credBaseline:x,credDirty:(0,w.useMemo)(()=>JSON.stringify(b)!==JSON.stringify(x),[b,x]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,w.useCallback)((e,t)=>{i.current=!0,c(n=>{let r=n??y,i=r[e]??T();return{...r,[e]:{...i,...t}}})},[y]),onDiscardCredentials:(0,w.useCallback)(()=>{i.current=!1,c(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,w.useCallback)(async e=>{let n=ie(r,b,x);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ae(n),await t.mutate?.(),l(s(C)),i.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,b,x,t])}}function be(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function I(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=be();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=I();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function K(){return G((await c(s(`/api/config`))).payload?.config??{})}async function q(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await c(s(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),b()}async function J(){let e=await c(s(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await c(s(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await c(s(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(){let e=await c(s(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(e){let t=await c(s(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Se(e){let t=await c(s(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function Ce(e){let t=(0,ne.c)(15),{kind:n,providerId:r,fieldId:i,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let h;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(h=(0,A.jsx)(x,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,A.jsx)(`div`,{className:m,children:h}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,te as m,Z as n,X as o,P as p,J as r,Q as s,Ce as t,$ as u};
|
|
1
|
+
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"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{l as o,r as s,s as c}from"./locale-store-GfSwnwIZ.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{Ml as u,Uc as d,Xt as f,Yo as p,Yt as m,Zo as h,au as g,cc as _,co as v,qn as y,so as b,us as x,vs as S,ys as ee}from"./index-DSydVlxZ.js";var C=`/api/image/providers`;async function te(){return(await c(s(`/api/image/providers`)))?.payload?.providers??[]}var w=e(t(),1),ne=n();function T(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function re(e){return e?.apiKey?`••••••••••••`:``}function E(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:re(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function D(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function O(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(y(n)&&y(r)))return n||(r?null:void 0)}function ie(e,t,n){let r={};for(let i of e){let e=t[i]??T(),a=n[i]??T();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=O(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=D(e,a,`region`);c!==void 0&&(o.region=c);let l=D(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=D(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function k(e){let t=await c(s(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function ae(e){Object.keys(e).length!==0&&(await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await b())}var A=r();function oe(e){let t=(0,ne.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>k(n).then(j),t[0]=n,t[1]=c);let l=c,d=`img-cred-key-${n}`,p;t[2]!==a.apiKeyLabel||t[3]!==d?(p=(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:d,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=d,t[4]=p):p=t[4];let m;t[5]!==s||t[6]!==o?(m=o.length>0?(0,A.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,A.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[f(e.kind,s),(0,A.jsx)(u,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=m):m=t[7];let h=`img-cred-key-${n}`,g;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==h||t[12]!==r?(g=(0,A.jsx)(x,{id:h,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=h,t[12]=r,t[13]=g):g=t[13];let _;return t[14]!==p||t[15]!==m||t[16]!==g?(_=(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[p,m,g]}),t[14]=p,t[15]=m,t[16]=g,t[17]=_):_=t[17],_}function j(e){return e.apiKey??null}function M(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,S)}function se(){return a(M(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var N=`__custom__`;function ce(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:N}function le(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:N}function ue(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function de(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function fe(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function pe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function me(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function P(e){let t=(0,ne.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:f,credNoopFlash:v,updateCredRow:y,onDiscardCredentials:b,onSaveCredentials:x,extensionIds:S,showExtensionLinks:C,showImageModelsLink:te,hideActions:re,language:E,apiKeyLinkLabels:D,messages:O}=e,ie=re===void 0?!1:re,k;t[0]===n?k=t[1]:(k=n.some(ye),t[0]=n,t[1]=k);let ae=k,j;t[2]===n?j=t[3]:(j=n.some(ve),t[2]=n,t[3]=j);let P=j,[F,be]=(0,w.useState)(_e),[I,L]=(0,w.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)pe(r[e.id]??T(),o[e.id]??T())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===O.credentialsIntro?W=t[15]:(W=(0,A.jsx)(`p`,{children:O.credentialsIntro}),t[14]=O.credentialsIntro,t[15]=W);let G;t[16]!==ae||t[17]!==O.regionHint?(G=ae?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.regionHint}):null,t[16]=ae,t[17]=O.regionHint,t[18]=G):G=t[18];let K;t[19]!==P||t[20]!==O.endpointPresetsHint?(K=P?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.endpointPresetsHint}):null,t[19]=P,t[20]=O.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==te||t[23]!==O.imageModelsLinkTitle||t[24]!==O.openImageModelsPage?(q=te?(0,A.jsx)(`p`,{children:(0,A.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:O.imageModelsLinkTitle,children:O.openImageModelsPage})}):null,t[22]=te,t[23]=O.imageModelsLinkTitle,t[24]=O.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,A.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===l?Y=t[32]:(Y=l?(0,A.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==v||t[35]!==f||t[36]!==c||t[37]!==ie||t[38]!==b||t[39]!==x||t[40]!==O.credentialsNothingToSave||t[41]!==O.credentialsSaved||t[42]!==O.discardCredentials||t[43]!==O.saveCredentials||t[44]!==O.savingCredentials?(X=ie?null:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[f?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsSaved}):null,v?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsNothingToSave}):null,(0,A.jsx)(ee,{type:`button`,variant:`secondary`,onClick:b,disabled:!s||c,children:O.discardCredentials}),(0,A.jsx)(ee,{type:`button`,variant:`primary`,onClick:x,disabled:!s||c,children:c?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{className:`size-3.5 animate-spin`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.savingCredentials})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{className:`size-3.5`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.saveCredentials})]})})]}),t[33]=s,t[34]=v,t[35]=f,t[36]=c,t[37]=ie,t[38]=b,t[39]=x,t[40]=O.credentialsNothingToSave,t[41]=O.credentialsSaved,t[42]=O.discardCredentials,t[43]=O.saveCredentials,t[44]=O.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==D||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==E||t[52]!==C||t[53]!==n||t[54]!==O||t[55]!==U||t[56]!==y){let e;t[58]!==D||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==E||t[64]!==C||t[65]!==O||t[66]!==U||t[67]!==y?(e=e=>{let t=r[e.id]??T(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=pe(t,o[e.id]??T()),l=V(e.id),d=e.label??e.id,f=me(O,e.models.length);return(0,A.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,A.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:d}),(0,A.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.unsavedChanges}):null,e.configured?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.configured}):(0,A.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:O.missingKey})]}),(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,A.jsx)(`span`,{children:f}),e.defaultModel?(0,A.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,A.jsx)(g,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`sr-only`,children:l?O.collapseProvider:O.expandProvider})]}),l?(0,A.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 p-4`,children:[s?(0,A.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:O.extensionSettingsLinkTitle,children:[(0,A.jsx)(u,{className:`size-3`}),O.openExtensionSettings]}):null,e.models.length>0?(0,A.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,A.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,A.jsx)(oe,{providerId:e.id,value:t.apiKey,onChange:t=>y(e.id,{apiKey:t}),apiKeyLinks:m(e.id,E),apiKeyLinkLabels:D,labels:{apiKeyLabel:O.apiKeyLabel,optionalPlaceholder:O.optionalPlaceholder,maskedHelp:O.apiKeyMaskedHelp,copy:O.apiKeyCopy,copied:O.apiKeyCopied,show:O.apiKeyShow,hide:O.apiKeyHide,notInConfigFile:O.apiKeyNotInConfigFile,loadFailed:O.apiKeyRevealFailed}}),n?.regions?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:O.regionLabel}),(0,A.jsxs)(p,{id:`img-cred-region-preset-${e.id}`,className:se(),value:ce(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){y(e.id,{region:``,imageBaseUrl:``});return}if(r===N){y(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&y(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,A.jsx)(h,{value:``,children:O.regionPresetDefault}),n.regions.map(e=>(0,A.jsx)(h,{value:e.value,children:ue(O,e.value,e.label)},e.value)),(0,A.jsx)(h,{value:N,children:O.regionPresetCustom})]}),ce(t,n.regions)===N?(0,A.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,A.jsx)(`input`,{type:`text`,className:M(),value:t.region,placeholder:`region`,onChange:t=>y(e.id,{region:t.target.value})}),(0,A.jsx)(`input`,{type:`url`,className:M(),value:t.imageBaseUrl,placeholder:O.imageBaseUrlLabel,onChange:t=>y(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:de(O,n.baseUrlPresetKind)}),fe(O,n.baseUrlPresetKind)?(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:fe(O,n.baseUrlPresetKind)}):null,(0,A.jsxs)(p,{id:`img-cred-base-preset-${e.id}`,className:se(),value:le(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){y(e.id,{baseUrl:``});return}if(n===N){y(e.id,{baseUrl:``});return}y(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,A.jsx)(h,{value:``,children:O.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,A.jsx)(h,{value:N,children:O.baseUrlPresetCustom})]}),le(t,n.baseUrlPresets)===N?(0,A.jsx)(`input`,{type:`url`,className:a(M(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>y(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&ce(t,n.regions)!==N?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:O.imageBaseUrlLabel}),(0,A.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(M(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:O.imageBaseUrlPresetHint}),(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:O.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=D,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=E,t[64]=C,t[65]=O,t[66]=U,t[67]=y,t[68]=e):e=t[68],Z=n.map(e),t[46]=D,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=E,t[52]=C,t[53]=n,t[54]=O,t[55]=U,t[56]=y,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,A.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,A.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function he(e){return(0,A.jsx)(h,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=v(o(e=>!!e.token)),n=t.data,r=(0,w.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,w.useRef)(!1),[a,c]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(!1),[g,_]=(0,w.useState)(!1),y=(0,w.useMemo)(()=>E(n?.payload?.config,r),[n?.payload?.config,r]),b=a??y,x=y;return{gwSwr:t,credDraft:b,credBaseline:x,credDirty:(0,w.useMemo)(()=>JSON.stringify(b)!==JSON.stringify(x),[b,x]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,w.useCallback)((e,t)=>{i.current=!0,c(n=>{let r=n??y,i=r[e]??T();return{...r,[e]:{...i,...t}}})},[y]),onDiscardCredentials:(0,w.useCallback)(()=>{i.current=!1,c(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,w.useCallback)(async e=>{let n=ie(r,b,x);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ae(n),await t.mutate?.(),l(s(C)),i.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,b,x,t])}}function be(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function I(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=be();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=I();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function K(){return G((await c(s(`/api/config`))).payload?.config??{})}async function q(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await c(s(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),b()}async function J(){let e=await c(s(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await c(s(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await c(s(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(){let e=await c(s(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(e){let t=await c(s(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Se(e){let t=await c(s(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function Ce(e){let t=(0,ne.c)(15),{kind:n,providerId:r,fieldId:i,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let h;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(h=(0,A.jsx)(x,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,A.jsx)(`div`,{className:m,children:h}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,te as m,Z as n,X as o,P as p,J as r,Q as s,Ce as t,$ as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./check-BODqo66o.js";import{t as o}from"./messages-B0B40tpO.js";import{n as s}from"./locale-store-GfSwnwIZ.js";import{$s as c,At as ee,Bt as te,Cs as l,El as u,Gt as d,Ht as f,Kt as p,Pt as m,Sl as h,Uc as g,Ut as _,Vt as ne,Wl as re,Wt as ie,au as ae,bs as oe,lo as v,qt as y,ru as b,vl as x,ys as S,zt as se}from"./index-apLU0Hun.js";var C=e(t(),1),w=n(),T=[`folder_structure`,`recent_progress`,`next_steps`];function E(e){return e instanceof Error?e.message:String(e)}function D(){let e=s(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,D=i(),[O]=r(),k=O.get(`new`)===`1`,[A,j]=(0,C.useState)(`loading`),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),[B,V]=(0,C.useState)(!1),[H,U]=(0,C.useState)(``),[W,G]=(0,C.useState)(!1),K=(0,C.useCallback)(e=>{F(e),e.status===`completed`?j(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?j(`error`):j(`running`)},[]),q=m({onPicked:(0,C.useCallback)(async e=>{L(!0),z(null);try{N(await _(e)),j(`consent`)}catch(e){z(E(e)),j(`intro`)}finally{L(!1)}},[])});(0,C.useEffect)(()=>{let e=!1;return ne().then(async({enabled:t,state:n})=>{if(!e){if(!t){D(`/chat`,{replace:!0});return}if(!k&&n.activeRunId)try{let t=await f(n.activeRunId);e||K(t);return}catch{}e||j(`intro`)}}).catch(t=>{e||(z(E(t)),j(`intro`))}),()=>{e=!0}},[K,D,k]),(0,C.useEffect)(()=>{if(!P||A!==`running`)return;let e=!1,t=async()=>{try{let t=await f(P.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===P.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[K,A,P]);let J=async()=>{L(!0);try{await te()}finally{D(`/chat`,{replace:!0})}},ce=async()=>{if(M){L(!0),z(null);try{K(await p(M.canonicalRootPath))}catch(e){z(E(e)),j(`consent`)}finally{L(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;D(`/chat/${encodeURIComponent(e)}${n}`)},X=async(t,n)=>{if(!P)return;await d(P.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(P.sessionKey,r)},le=async()=>{if(P){L(!0),z(null);try{F(await y(P.id,`confirmed`)),j(`recommendation`)}catch(e){z(E(e))}finally{L(!1)}}},Z=async e=>{if(!(!P||!H.trim())){L(!0),z(null);try{let t=await y(P.id,e,H.trim());F(t),Y(t.sessionKey,H.trim())}catch(e){z(E(e)),L(!1)}}},ue=async()=>{if(P){L(!0);try{Y((await y(P.id,`dismissed`)).sessionKey)}catch(e){z(E(e)),L(!1)}}},Q=P?.result?.suggestions.find(e=>e.id===P.result?.primarySuggestionId)??P?.result?.suggestions[0],$=P?.result?.suggestions.filter(e=>e.id!==Q?.id)??[];return(0,w.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,w.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,w.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,w.jsx)(oe,{className:`size-11`})}),A===`loading`?(0,w.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,w.jsx)(v,{className:`mx-auto h-8 w-64`}),(0,w.jsx)(v,{className:`mx-auto h-4 w-full max-w-lg`}),(0,w.jsx)(v,{className:`mx-auto size-4/5 max-w-md`}),(0,w.jsx)(v,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,A===`intro`?(0,w.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,w.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,w.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,w.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,w.jsxs)(S,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:q.pick,disabled:I||q.picking,children:[I||q.picking?(0,w.jsx)(g,{className:`size-4 animate-spin`}):(0,w.jsx)(h,{className:`size-4`}),t.chooseFolder]}),(0,w.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,w.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,w.jsx)(`span`,{children:t.readOnlyNote})]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null]}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:I,children:t.skip})]}):null,A===`consent`&&M?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,w.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,w.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,w.jsx)(h,{className:`size-5 shrink-0 text-accent-fg`}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:M.displayName}),(0,w.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:M.canonicalRootPath})]}),(0,w.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:M.projectKind===`coding`?t.codingProject:M.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,w.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:M.fingerprint.branch?t.branchValue.replace(`{{branch}}`,M.fingerprint.branch):t.noGitBranch})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(M.fingerprint.changedFileCount))})]}),M.fingerprint.recentAreas.length>0?(0,w.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,w.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:M.fingerprint.recentAreas.map(e=>(0,w.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,w.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(u,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,w.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:M.remoteModel?t.providerDisclosure.replace(`{{provider}}`,M.provider):t.localDisclosure})]})]})]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,w.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsxs)(S,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void ce(),children:[I?(0,w.jsx)(g,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,w.jsx)(S,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:q.pick,children:t.changeFolder})]}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:t.skip})]}):null,A===`running`&&P?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,w.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle})]}),(0,w.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:T.map((e,n)=>{let r=Math.max(0,T.indexOf(P.stage??`folder_structure`)),i=n<r,o=n===r;return(0,w.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,w.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,w.jsx)(a,{className:`size-4`}):o?(0,w.jsx)(g,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,w.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,w.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,w.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:P.rootPath}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-7 block text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void se(P.id).then(K),children:t.cancelAnalysis})]}):null,A===`recognition`&&P?.result?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,w.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:P.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),(0,w.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,w.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:P.result.projectSummary}),(0,w.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:P.result.currentState}),!P.result.lowConfidence&&Q?.evidence.length?(0,w.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:Q.evidence.slice(0,3).map((e,t)=>(0,w.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,w.jsx)(x,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,w.jsxs)(`span`,{children:[e.path?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),P.result.lowConfidence?(0,w.jsxs)(`div`,{className:`mt-5`,children:[(0,w.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:P.result.contextQuestion}),(0,w.jsx)(`textarea`,{value:H,onChange:e=>U(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,w.jsx)(S,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsxs)(S,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void le(),children:[I?(0,w.jsx)(g,{className:`size-4 animate-spin`}):(0,w.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,w.jsx)(S,{variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:()=>V(e=>!e),children:t.notQuiteRight})]}),B?(0,w.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,w.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,w.jsx)(`textarea`,{id:`work-discovery-correction`,value:H,onChange:e=>U(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,w.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,w.jsx)(S,{variant:`ghost`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,w.jsx)(S,{variant:`primary`,disabled:I||!H.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,w.jsx)(`button`,{type:`button`,disabled:I,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void ue(),children:t.openConversation})]}):null,A===`recommendation`&&P?.result&&Q?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,w.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),(0,w.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,w.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,w.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,w.jsx)(b,{className:`size-5`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,w.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,w.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,w.jsx)(re,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,w.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:(e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis)(Q.risk)})]}),(0,w.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,w.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,w.jsx)(S,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,w.jsx)(S,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),$.length>0?(0,w.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>G(e=>!e),children:[t.otherDirections,(0,w.jsx)(ae,{className:`size-4 transition-transform ${W?`rotate-180`:``}`})]}),W?(0,w.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:$.map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,w.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,w.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,w.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.doSomethingElse}),(0,w.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{V(!0),j(`recognition`)},children:t.correctUnderstanding})]})]}):null,A===`error`&&P?(0,w.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,w.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,w.jsx)(l,{className:`size-5`})}),(0,w.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,w.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:P.errorMessage}),(0,w.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsx)(S,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void ie(P.id).then(K),children:t.retry}),(0,w.jsx)(S,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{F(null),N(null),j(`intro`)},children:t.chooseDifferent})]}),(0,w.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,w.jsx)(ee,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:M?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{D as WorkDiscoveryPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./check-BODqo66o.js";import{t as o}from"./messages-B0B40tpO.js";import{n as s}from"./locale-store-GfSwnwIZ.js";import{$s as c,At as ee,Bt as te,Cs as l,El as u,Gt as d,Ht as f,Kt as p,Pt as m,Sl as h,Uc as g,Ut as _,Vt as ne,Wl as re,Wt as ie,au as ae,bs as oe,lo as v,qt as y,ru as b,vl as x,ys as S,zt as se}from"./index-DSydVlxZ.js";var C=e(t(),1),w=n(),T=[`folder_structure`,`recent_progress`,`next_steps`];function E(e){return e instanceof Error?e.message:String(e)}function D(){let e=s(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,D=i(),[O]=r(),k=O.get(`new`)===`1`,[A,j]=(0,C.useState)(`loading`),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),[B,V]=(0,C.useState)(!1),[H,U]=(0,C.useState)(``),[W,G]=(0,C.useState)(!1),K=(0,C.useCallback)(e=>{F(e),e.status===`completed`?j(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?j(`error`):j(`running`)},[]),q=m({onPicked:(0,C.useCallback)(async e=>{L(!0),z(null);try{N(await _(e)),j(`consent`)}catch(e){z(E(e)),j(`intro`)}finally{L(!1)}},[])});(0,C.useEffect)(()=>{let e=!1;return ne().then(async({enabled:t,state:n})=>{if(!e){if(!t){D(`/chat`,{replace:!0});return}if(!k&&n.activeRunId)try{let t=await f(n.activeRunId);e||K(t);return}catch{}e||j(`intro`)}}).catch(t=>{e||(z(E(t)),j(`intro`))}),()=>{e=!0}},[K,D,k]),(0,C.useEffect)(()=>{if(!P||A!==`running`)return;let e=!1,t=async()=>{try{let t=await f(P.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===P.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[K,A,P]);let J=async()=>{L(!0);try{await te()}finally{D(`/chat`,{replace:!0})}},ce=async()=>{if(M){L(!0),z(null);try{K(await p(M.canonicalRootPath))}catch(e){z(E(e)),j(`consent`)}finally{L(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;D(`/chat/${encodeURIComponent(e)}${n}`)},X=async(t,n)=>{if(!P)return;await d(P.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(P.sessionKey,r)},le=async()=>{if(P){L(!0),z(null);try{F(await y(P.id,`confirmed`)),j(`recommendation`)}catch(e){z(E(e))}finally{L(!1)}}},Z=async e=>{if(!(!P||!H.trim())){L(!0),z(null);try{let t=await y(P.id,e,H.trim());F(t),Y(t.sessionKey,H.trim())}catch(e){z(E(e)),L(!1)}}},ue=async()=>{if(P){L(!0);try{Y((await y(P.id,`dismissed`)).sessionKey)}catch(e){z(E(e)),L(!1)}}},Q=P?.result?.suggestions.find(e=>e.id===P.result?.primarySuggestionId)??P?.result?.suggestions[0],$=P?.result?.suggestions.filter(e=>e.id!==Q?.id)??[];return(0,w.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,w.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,w.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,w.jsx)(oe,{className:`size-11`})}),A===`loading`?(0,w.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,w.jsx)(v,{className:`mx-auto h-8 w-64`}),(0,w.jsx)(v,{className:`mx-auto h-4 w-full max-w-lg`}),(0,w.jsx)(v,{className:`mx-auto size-4/5 max-w-md`}),(0,w.jsx)(v,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,A===`intro`?(0,w.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,w.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,w.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,w.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,w.jsxs)(S,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:q.pick,disabled:I||q.picking,children:[I||q.picking?(0,w.jsx)(g,{className:`size-4 animate-spin`}):(0,w.jsx)(h,{className:`size-4`}),t.chooseFolder]}),(0,w.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,w.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,w.jsx)(`span`,{children:t.readOnlyNote})]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null]}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:I,children:t.skip})]}):null,A===`consent`&&M?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,w.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,w.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,w.jsx)(h,{className:`size-5 shrink-0 text-accent-fg`}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:M.displayName}),(0,w.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:M.canonicalRootPath})]}),(0,w.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:M.projectKind===`coding`?t.codingProject:M.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,w.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:M.fingerprint.branch?t.branchValue.replace(`{{branch}}`,M.fingerprint.branch):t.noGitBranch})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(M.fingerprint.changedFileCount))})]}),M.fingerprint.recentAreas.length>0?(0,w.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,w.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:M.fingerprint.recentAreas.map(e=>(0,w.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,w.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(u,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,w.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:M.remoteModel?t.providerDisclosure.replace(`{{provider}}`,M.provider):t.localDisclosure})]})]})]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,w.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsxs)(S,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void ce(),children:[I?(0,w.jsx)(g,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,w.jsx)(S,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:q.pick,children:t.changeFolder})]}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:t.skip})]}):null,A===`running`&&P?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,w.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle})]}),(0,w.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:T.map((e,n)=>{let r=Math.max(0,T.indexOf(P.stage??`folder_structure`)),i=n<r,o=n===r;return(0,w.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,w.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,w.jsx)(a,{className:`size-4`}):o?(0,w.jsx)(g,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,w.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,w.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,w.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:P.rootPath}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-7 block text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void se(P.id).then(K),children:t.cancelAnalysis})]}):null,A===`recognition`&&P?.result?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,w.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:P.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),(0,w.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,w.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:P.result.projectSummary}),(0,w.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:P.result.currentState}),!P.result.lowConfidence&&Q?.evidence.length?(0,w.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:Q.evidence.slice(0,3).map((e,t)=>(0,w.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,w.jsx)(x,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,w.jsxs)(`span`,{children:[e.path?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),P.result.lowConfidence?(0,w.jsxs)(`div`,{className:`mt-5`,children:[(0,w.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:P.result.contextQuestion}),(0,w.jsx)(`textarea`,{value:H,onChange:e=>U(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,w.jsx)(S,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsxs)(S,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void le(),children:[I?(0,w.jsx)(g,{className:`size-4 animate-spin`}):(0,w.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,w.jsx)(S,{variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:()=>V(e=>!e),children:t.notQuiteRight})]}),B?(0,w.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,w.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,w.jsx)(`textarea`,{id:`work-discovery-correction`,value:H,onChange:e=>U(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,w.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,w.jsx)(S,{variant:`ghost`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,w.jsx)(S,{variant:`primary`,disabled:I||!H.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,w.jsx)(`button`,{type:`button`,disabled:I,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void ue(),children:t.openConversation})]}):null,A===`recommendation`&&P?.result&&Q?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,w.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),(0,w.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,w.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,w.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,w.jsx)(b,{className:`size-5`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,w.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,w.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,w.jsx)(re,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,w.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:(e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis)(Q.risk)})]}),(0,w.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,w.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,w.jsx)(S,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,w.jsx)(S,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),$.length>0?(0,w.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>G(e=>!e),children:[t.otherDirections,(0,w.jsx)(ae,{className:`size-4 transition-transform ${W?`rotate-180`:``}`})]}),W?(0,w.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:$.map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,w.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,w.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,w.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.doSomethingElse}),(0,w.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{V(!0),j(`recognition`)},children:t.correctUnderstanding})]})]}):null,A===`error`&&P?(0,w.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,w.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,w.jsx)(l,{className:`size-5`})}),(0,w.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,w.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:P.errorMessage}),(0,w.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsx)(S,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void ie(P.id).then(K),children:t.retry}),(0,w.jsx)(S,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{F(null),N(null),j(`intro`)},children:t.chooseDifferent})]}),(0,w.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,w.jsx)(ee,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:M?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{D as WorkDiscoveryPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as s}from"./cn-BQ_8x0bT.js";import{t as c}from"./messages-B0B40tpO.js";import{n as l}from"./locale-store-GfSwnwIZ.js";import{Bo as u,El as d,Fl as ee,Fs as te,Ml as ne,Oc as re,Rc as f,Va as ie,Yo as ae,Zo as p,a as oe,bu as m,cu as h,dc as g,et as _,f as se,fc as ce,l as le,m as ue,o as de,p as fe,s as pe,tu as me,u as v,vl as y,yc as b,ys as x,yt as he,zs as S}from"./index-apLU0Hun.js";var C=n(),w=e(t(),1),T=r();function ge(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function E(e){return e?_(new Date(e)):``}function _e(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function ve(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,T.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ye(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,T.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(e.createdAt)})]})},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,T.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=O(i),s=0;for(let e of O(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function A(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(e,t,n)||n.title.localeCompare(r.title))}function j(){let{workItemId:e=``}=o(),t=i(),n=c(l(e=>e.language)).projectDetailPage.workItems,[r,_]=(0,w.useState)(null),[C,O]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=u(e=>e.setPageHeader),K=u(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([le(e),v(e).catch(()=>({events:[]}))]);_(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([ie(t.item.projectId).catch(()=>null),he().catch(()=>[])]),a=A(t.item,r,i);O(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await se(r.id);_(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await oe(r.id);_(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,w.useCallback)(async e=>{M((await v(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await fe(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});_(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await ue(r.id,e);_(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await de(r.id,e.id);_(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await pe(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,C,e)>0).slice(0,3):[],[r,C,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,w.useLayoutEffect)(()=>(G({startExtra:(0,T.jsx)(a,{to:q,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C?.name?n.detail.backToProject.replace(`{{name}}`,C.name):n.detail.backToProjects,children:(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,C?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,C?.name,q,G,n,C]),R?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:H||n.detail.notFound})]}):(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,ge(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(d,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(ye,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(y,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(ae,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,T.jsx)(p,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(p,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.jsx)(`button`,{type:`button`,className:s(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base p-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,T.jsxs)(x,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base p-2 text-sm`,children:[(0,T.jsx)(d,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,_e(e.size)]})]}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:n.attachments.download,"aria-label":n.attachments.download,disabled:B,onClick:()=>void we(e),children:(0,T.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:n.attachments.remove,"aria-label":n.attachments.remove,disabled:B,onClick:()=>void Ce(e),children:(0,T.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(a,{to:ve(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.jsxs)(a,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(me,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:C?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as s}from"./cn-BQ_8x0bT.js";import{t as c}from"./messages-B0B40tpO.js";import{n as l}from"./locale-store-GfSwnwIZ.js";import{Bo as u,El as d,Fl as ee,Fs as te,Ml as ne,Oc as re,Rc as f,Va as ie,Yo as ae,Zo as p,a as oe,bu as m,cu as h,dc as g,et as _,f as se,fc as ce,l as le,m as ue,o as de,p as fe,s as pe,tu as me,u as v,vl as y,yc as b,ys as x,yt as he,zs as S}from"./index-DSydVlxZ.js";var C=n(),w=e(t(),1),T=r();function ge(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function E(e){return e?_(new Date(e)):``}function _e(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function ve(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,T.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ye(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,T.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(e.createdAt)})]})},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,T.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=O(i),s=0;for(let e of O(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function A(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(e,t,n)||n.title.localeCompare(r.title))}function j(){let{workItemId:e=``}=o(),t=i(),n=c(l(e=>e.language)).projectDetailPage.workItems,[r,_]=(0,w.useState)(null),[C,O]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=u(e=>e.setPageHeader),K=u(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([le(e),v(e).catch(()=>({events:[]}))]);_(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([ie(t.item.projectId).catch(()=>null),he().catch(()=>[])]),a=A(t.item,r,i);O(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await se(r.id);_(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await oe(r.id);_(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,w.useCallback)(async e=>{M((await v(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await fe(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});_(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await ue(r.id,e);_(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await de(r.id,e.id);_(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await pe(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,C,e)>0).slice(0,3):[],[r,C,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,w.useLayoutEffect)(()=>(G({startExtra:(0,T.jsx)(a,{to:q,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C?.name?n.detail.backToProject.replace(`{{name}}`,C.name):n.detail.backToProjects,children:(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,C?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,C?.name,q,G,n,C]),R?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:H||n.detail.notFound})]}):(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,ge(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(d,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(ye,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(y,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(ae,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,T.jsx)(p,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(p,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.jsx)(`button`,{type:`button`,className:s(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base p-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,T.jsxs)(x,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base p-2 text-sm`,children:[(0,T.jsx)(d,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,_e(e.size)]})]}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:n.attachments.download,"aria-label":n.attachments.download,disabled:B,onClick:()=>void we(e),children:(0,T.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:n.attachments.remove,"aria-label":n.attachments.remove,disabled:B,onClick:()=>void Ce(e),children:(0,T.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(a,{to:ve(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.jsxs)(a,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(me,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:C?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};
|