@xopcai/xopc 0.0.350 → 0.0.351
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-GAs9LrbD.js → agent-avatar-dicebear-Dc0yBlKV.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-q6mFje6y.js → agent-defaults-settings-panel-BXFins6I.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-vR-3YU8w.js → agent-plugin-dialog-B-w6bJuj.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-DZXa_QVc.js → agents-CuFzMN58.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-5GU28Q-V.js → app-management-settings-panel-C7QjGlMZ.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-uxEo59iJ.js → appearance-settings-CgApGxhN.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-06LrJSYf.js → apps-page-DWii4stP.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-B4z8_4sq.js → archive-plugin--oP0UmoE.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Cap0FMSp.js → automations-page-DkV4w6xr.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DEsdkcup.js → automations-workspace-DT95Uk9d.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-PKMXJixJ.js → binary-plugins-DIpBiw_8.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Dv83e7vb.js → block-editor-Di4X446B.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-C1mBYS2x.js → browser-automations-page-pKPvkGW8.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-Co2D8mug.js → browser-settings-page-cJ200PlY.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-nIIqZJuL.js → capabilities-page-CPKbJUDL.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BrXWQIs7.js → capabilities-settings-panel-D5xUFWBJ.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-C6d_GsqD.js → capability-header-actions-9qDm8ioP.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-EUbBfvHY.js → channels-CO_9_oIH.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CZTrJ5Do.js → chat-terminal-dock-DCFwzHu2.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CWBZwtYT.js → computer-settings-page-bwWQ3axN.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-B5pF87fY.js → connector-service-page-BIIP-gX4.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-9ztbuGCI.js → connectors-page-C0b5Xbca.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-xb5w8iAa.js → date-picker-DBio7OE6.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-D7B6s4d4.js → dependency-picker-hyPm_1tB.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bt5JatKm.js → desktop-pet-BDPfot60.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BdgUJk-e.js → desktop-pet-settings-C6IRO2iD.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DQ7LNTKz.js → device-pairing-wizard-CUOh38IK.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-_PcWmfRH.js → directory-picker-path-field-ljXXfuLL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BhXwxHMP.js → extension-debug-page-DHw1dG1g.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CIXPBzGU.js → extension-page-BjLN3E6q.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DE4UUMD-.js → extension-settings-page-BMp6v6zP.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CI2oGZEg.js → gateway-settings-D76thCuX.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DfJvuWC-.js → home-page-D1Tyeuul.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-DRG-aahH.js → imports-page-CabovqRQ.js} +1 -1
- package/dist/gateway/static/root/assets/{index-Z6i4GDcT.js → index-Bb32g7Ll.js} +7 -7
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CSwc_Olv.js → keyboard-shortcuts-settings-DvN-2bcS.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DsSCCThS.js → local-app-workbench-page-CSEzRWxs.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-C4psaPz5.js → local-apps-page-C3Wy2zG2.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-kx7ama7K.js → logs-page-YojQFX9o.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-BqcrFVsF.js → management-settings-CNMk0HRn.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BCMV9heb.js → media-plugins-Ds7HF3EM.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-Bvjc5JNM.js → note-detail-panel-D8vQ_INI.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-Dak5PuTq.js → notes-page-CIFcEPAd.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BYQnvTni.js → page-context-capture-button-YKiYT0q2.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs--d3GEnvY.js → page-tabs-ZUC486EH.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-ByuWaDEv.js → preview-open-alternatives-Ca9tBmOg.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CMvjGjTz.js → product-open-page-BuGb8QPn.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-m8ybJpJ_.js → project-detail-page-C6Awj1Ql.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-i00ns68r.js → projects-page-CmO8Gb9G.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-CY4kQa1Z.js → remote-access-hub-BsqHroXR.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D-gA6BW9.js → runtime-tools-settings-panel-Cva9t35o.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page--sExi9Fz.js → scenes-page-3_61bQHN.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-B8Zns_Se.js → schema-form-DWHFyKEB.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BzW33zp4.js → sessions-page-BaHue2bK.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C4y4c2M7.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-Lpep8yx-.js → settings-form-section-BwdrtX6k.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-Cl_KOVsG.js → settings-page-B6YZFEye.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-mWQaql5h.js → setup-status-panel-nMWHz-ra.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-ZZ6qg3xL.js → share-preview-page-DH0KHlev.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DhQRwYYL.js → shares-settings-KK-VNbMw.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-DC3EXeUS.js → skill-api-BbNk-3Ig.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-C-Dn5hSx.js → skill-reload-api-DUOG2Ig1.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-ThkBmKew.js → skills-page-BQya9ygw.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-C93mkvML.js → system-settings-panel-akm5mc8b.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DWqYIP_j.js → task-detail-page-wLGUc7Nu.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DI4NcRc8.js → tunnel-api-vZ7P_KIQ.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-C--1ibDb.js → usage-page-BV1KJ0EY.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-83u3Kf_7.js → use-autosave-DQdLcZfO.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-DasK0_MY.js → user-model-page-DnLTTyOE.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-D4SxKV47.js → voice-api-key-field-CJ-FjNHr.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-RSWjSoEp.js → work-discovery-overlay-BA1AAqaW.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BINT9Shl.js → workflow-run-setup-panel-BhIOKmjW.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-Bj3K-lxR.js → workflows-page-aYoObmuS.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/auth/credentials.js +1 -1
- package/dist/src/auth/oauth-provider-lock.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/service.js +2 -2
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tui/backends/embedded-backend.js +3 -3
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/realtime/runtime.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-CVnn1f7J.js +0 -1
package/dist/gateway/static/root/assets/{sessions-page-BzW33zp4.js → sessions-page-BaHue2bK.js}
RENAMED
|
@@ -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{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-0p9PIHRy.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./folder-open-CyzJ19I9.js";import{t as l}from"./minimize-2-DtOGrlpo.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./search-DA7gz22f.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./messages-sXePe3LQ.js";import{t as m}from"./cn-JdwAhgNB.js";import{a as h,c as g,n as _,r as v}from"./locale-store-WMaCMm3_.js";import{a as ee,n as y,o as b,r as x,s as S,t as te}from"./dist-BGTk37IG.js";import{a as C,c as w,f as T,n as E,o as D,p as O,r as k,s as A,t as j}from"./session-api-Bv-hCMKS.js";import{i as M}from"./vendor-swr-BIWyz7Rc.js";import{t as N}from"./button-CS04eWY9.js";import{n as P,r as F}from"./gateway-config-swr-CmjHbMj7.js";import{n as I,t as L}from"./registry-api-DEePN1Rc.js";import{t as R}from"./skeleton-BwbyijEw.js";import{i as ne,o as z}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Bc as B,Cu as V,Da as H,Il as U,L as re,La as ie,Ll as ae,Lo as W,Mi as oe,Ms as se,Mu as ce,Ns as G,Oa as K,Pa as le,Qt as ue,Ra as de,Zt as fe,al as pe,bl as me,cd as he,il as ge,ka as _e,ld as ve,vc as ye,vu as be,zl as xe}from"./index-Z6i4GDcT.js";import{t as Se}from"./page-tabs--d3GEnvY.js";import{n as Ce,r as we}from"./settings-page-layout-X1x-2Cp9.js";import{n as Te,t as q}from"./settings-form-section-Lpep8yx-.js";import{n as J,t as Ee}from"./use-autosave-83u3Kf_7.js";import{t as De}from"./settings-advanced-gate-CVnn1f7J.js";var Y=e(t(),1),Oe=n(),X=r();function ke(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function Ae(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function je(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function Me(e){let t=(0,Oe.c)(124),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,f=_(Ie),h;t[3]!==f||t[4]!==n?(h=de(n,p(f).sidebar.sessionFilters),t[3]=f,t[4]=n,t[5]=h):h=t[5];let g=h,v;t[6]===n.name?v=t[7]:(v=n.name?.trim(),t[6]=n.name,t[7]=v);let ee=!!v,y=n.status===`archived`,b=n.status===`pinned`,x=n.usage,S;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==x?(S=x?.calls?x.costCompleteness===`unknown`?i.costUnknown:`${x.costCompleteness===`partial`?`≥ `:`≈ `}${je(x.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=x,t[11]=S):S=t[11];let te=S,C=x?.calls?x.costCompleteness===`partial`?i.costPartial:x.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,w=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,T;t[12]===w?T=t[13]:(T=m(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,w),t[12]=w,t[13]=T);let E;t[14]===c?E=t[15]:(E=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=E);let D=r===`list`&&`sm:py-3`,O;t[16]===D?O=t[17]:(O=m(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,D),t[16]=D,t[17]=O);let k;t[18]===n?k=t[19]:(k=(0,X.jsx)(ie,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=k);let A;t[20]===g?A=t[21]:(A=(0,X.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:g}),t[20]=g,t[21]=A);let j;t[22]!==k||t[23]!==A?(j=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[k,A]}),t[22]=k,t[23]=A,t[24]=j):j=t[24];let M;t[25]===b?M=t[26]:(M=b?(0,X.jsx)(pe,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=b,t[26]=M);let N;t[27]===n.updatedAt?N=t[28]:(N=ke(n.updatedAt),t[27]=n.updatedAt,t[28]=N);let P;t[29]===N?P=t[30]:(P=(0,X.jsx)(`span`,{children:N}),t[29]=N,t[30]=P);let F;t[31]!==M||t[32]!==P?(F=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[M,P]}),t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==j||t[35]!==F||t[36]!==O?(I=(0,X.jsxs)(`div`,{className:O,children:[j,F]}),t[34]=j,t[35]=F,t[36]=O,t[37]=I):I=t[37];let L=r===`list`&&`sm:py-3`,R;t[38]===L?R=t[39]:(R=m(`min-w-0 flex-1 px-3 py-2`,L),t[38]=L,t[39]=R);let ne=r===`list`&&`sm:items-start`,z;t[40]===ne?z=t[41]:(z=m(`flex gap-3`,ne),t[40]=ne,t[41]=z);let B;t[42]!==o||t[43]!==a?(B=(0,X.jsx)(re,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=o,t[43]=a,t[44]=B):B=t[44];let H;t[45]===d?H=t[46]:(H=(0,X.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[45]=d,t[46]=H);let U;t[47]!==n.key||t[48]!==ee?(U=ee?(0,X.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[47]=n.key,t[48]=ee,t[49]=U):U=t[49];let ae;t[50]!==H||t[51]!==U?(ae=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[H,U]}),t[50]=H,t[51]=U,t[52]=ae):ae=t[52];let W;t[53]!==z||t[54]!==B||t[55]!==ae?(W=(0,X.jsxs)(`div`,{className:z,children:[B,ae]}),t[53]=z,t[54]=B,t[55]=ae,t[56]=W):W=t[56];let oe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,X.jsx)(me,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=oe):oe=t[57];let ce;t[58]===n.messageCount?ce=t[59]:(ce=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[oe,n.messageCount]}),t[58]=n.messageCount,t[59]=ce);let G;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,X.jsx)(be,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=G):G=t[60];let K=x?.totalTokens??0,le;t[61]!==f||t[62]!==K?(le=Ae(K,f),t[61]=f,t[62]=K,t[63]=le):le=t[63];let ue;t[64]!==i.tokens||t[65]!==le?(ue=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[G,le,` `,i.tokens]}),t[64]=i.tokens,t[65]=le,t[66]=ue):ue=t[66];let fe;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,X.jsx)(V,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=fe):fe=t[67];let _e;t[68]!==te||t[69]!==C?(_e=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:C,children:[fe,te]}),t[68]=te,t[69]=C,t[70]=_e):_e=t[70];let xe;t[71]!==ce||t[72]!==ue||t[73]!==_e?(xe=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[ce,ue,_e]}),t[71]=ce,t[72]=ue,t[73]=_e,t[74]=xe):xe=t[74];let Se;t[75]===n.tags?Se=t[76]:(Se=n.tags.length>0?(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Fe),n.tags.length>3?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=Se);let Ce;t[77]!==R||t[78]!==W||t[79]!==xe||t[80]!==Se?(Ce=(0,X.jsxs)(`div`,{className:R,children:[W,xe,Se]}),t[77]=R,t[78]=W,t[79]=xe,t[80]=Se,t[81]=Ce):Ce=t[81];let we;t[82]===l?we=t[83]:(we=()=>l(`continue`),t[82]=l,t[83]=we);let Te;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,X.jsx)(me,{className:`size-4`,strokeWidth:1.75}),t[84]=Te):Te=t[84];let q;t[85]!==i.continueChat||t[86]!==we?(q=(0,X.jsx)(`button`,{type:`button`,className:se,title:i.continueChat,"aria-label":i.continueChat,onClick:we,children:Te}),t[85]=i.continueChat,t[86]=we,t[87]=q):q=t[87];let J;t[88]!==y||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==l?(J=y?(0,X.jsx)(`button`,{type:`button`,className:se,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,X.jsx)(ve,{className:`size-4`,strokeWidth:1.75})}):(0,X.jsx)(`button`,{type:`button`,className:se,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,X.jsx)(he,{className:`size-4`,strokeWidth:1.75})}),t[88]=y,t[89]=i.archive,t[90]=i.unarchive,t[91]=l,t[92]=J):J=t[92];let Ee;t[93]!==b||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==l?(Ee=b?(0,X.jsx)(`button`,{type:`button`,className:se,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,X.jsx)(ge,{className:`size-4`,strokeWidth:1.75})}):(0,X.jsx)(`button`,{type:`button`,className:se,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,X.jsx)(pe,{className:`size-4`,strokeWidth:1.75})}),t[93]=b,t[94]=i.pin,t[95]=i.unpin,t[96]=l,t[97]=Ee):Ee=t[97];let De;t[98]===l?De=t[99]:(De=()=>l(`export`),t[98]=l,t[99]=De);let Y;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,X.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[100]=Y):Y=t[100];let Me;t[101]!==i.export||t[102]!==De?(Me=(0,X.jsx)(`button`,{type:`button`,className:se,title:i.export,"aria-label":i.export,onClick:De,children:Y}),t[101]=i.export,t[102]=De,t[103]=Me):Me=t[103];let Le;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Le=m(se,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=Le):Le=t[104];let Re;t[105]===l?Re=t[106]:(Re=()=>l(`delete`),t[105]=l,t[106]=Re);let ze;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,X.jsx)(ye,{className:`size-4`,strokeWidth:1.75}),t[107]=ze):ze=t[107];let Z;t[108]!==i.delete||t[109]!==Re?(Z=(0,X.jsx)(`button`,{type:`button`,className:Le,title:i.delete,"aria-label":i.delete,onClick:Re,children:ze}),t[108]=i.delete,t[109]=Re,t[110]=Z):Z=t[110];let Be;t[111]!==q||t[112]!==J||t[113]!==Ee||t[114]!==Me||t[115]!==Z?(Be=(0,X.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Pe,onKeyDown:Ne,children:[q,J,Ee,Me,Z]}),t[111]=q,t[112]=J,t[113]=Ee,t[114]=Me,t[115]=Z,t[116]=Be):Be=t[116];let Q;return t[117]!==c||t[118]!==I||t[119]!==Ce||t[120]!==Be||t[121]!==T||t[122]!==E?(Q=(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,className:T,onClick:c,onKeyDown:E,children:[I,Ce,Be]}),t[117]=c,t[118]=I,t[119]=Ce,t[120]=Be,t[121]=T,t[122]=E,t[123]=Q):Q=t[123],Q}function Ne(e){return e.stopPropagation()}function Pe(e){return e.stopPropagation()}function Fe(e){return(0,X.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Ie(e){return e.language}function Le(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Re(e,t){return t.find(t=>t.id===e)?.avatar}var ze={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Be(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Ve(e){let t=Z(e)?e:{},n=Z(t.userContext)?t.userContext:{},r=Z(n.contextPlanning)?n.contextPlanning:{},i=Z(r.compaction)?r.compaction:{},a=ze,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Be(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function He(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ue(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function We(e){await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ue(e))}),await P()}var Ge=128e3,Ke={balanced:ze,preserve:{...ze,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...ze,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},qe=H();function Je(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,W,`dark:border-edge`)}function Ye(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function Xe(e){let t=Ye(e);for(let[e,n]of Object.entries(Ke))if(t===Ye(n))return e;return`custom`}function Ze(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Oe.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Je(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,X.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,X.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Qe(e){let t=(0,Oe.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=m(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,X.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,X.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let h;return t[15]!==c||t[16]!==u||t[17]!==p?(h=(0,X.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=h):h=t[18],h}function $e({hasToken:e}){let t=p(_(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=F(e),{data:i=[],isLoading:a}=M(e?L:null,I,{revalidateOnFocus:!1}),o=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:Ve(n.payload.config),[n]),[s,c]=(0,Y.useReducer)(qe,{form:null,baseline:null}),[d,h]=(0,Y.useState)(``),g=(0,Y.useRef)(!1),v=(0,Y.useRef)(s.form);v.current=s.form;let ee=(0,Y.useRef)(null);K({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:ee,dispatch:c,onResetDirty:()=>{g.current=!1}});let y=s.form,b=s.baseline,x=!!(y&&b&&JSON.stringify(y)!==JSON.stringify(b)),S=(0,Y.useCallback)(e=>{g.current=!0,c({type:`patch`,patch:e})},[]),te=(0,Y.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),C=Ee({value:y,dirty:x,onSave:(0,Y.useCallback)(async e=>{try{await We(e),c({type:`saved`,value:e}),g.current=!!(v.current&&JSON.stringify(v.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=He(e);return n?t.invalidValue.replace(`{{field}}`,te(n)):null}});if(!e||!y)return r?(0,X.jsx)(q,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,X.jsx)(R,{className:`h-5 w-48`}),(0,X.jsx)(R,{className:`h-20 w-full rounded-xl`}),(0,X.jsx)(R,{className:`h-36 w-full rounded-xl`})]})}):null;let w=Xe(y),T=Math.max(0,Ge-y.reserveTokens),E=Math.min(Math.floor(Ge*y.triggerThreshold),T),D=Math.min(100,E/Ge*100),O=Math.min(100,T/Ge*100),k=y.model?i.find(e=>e.id===y.model):void 0,A=k?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>k.contextWindow,j=y.keepRecentTokens+y.reserveTokens>E,P=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),ne=e=>{let t=Ke[e];S({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},z={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},B=()=>{let e=d.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(S({postCompactionSections:[...y.postCompactionSections,e]}),h(``))};return(0,X.jsxs)(q,{onBlurCapture:C.onBlurCapture,children:[(0,X.jsx)(Te,{icon:l,title:t.title,subtitle:t.hint,trailing:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(J,{status:C.status,error:C.error}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>S({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),C.error?(0,X.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:C.error}):null,y.enabled?null:(0,X.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,X.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),w===`custom`?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,X.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":w===e,className:m(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,G.transition,G.focusRingPanel,w===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>ne(e),children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:z[e].title}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:z[e].hint})]},e))})]}),(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,X.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,X.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:t.compactionTrigger}),(0,X.jsx)(`span`,{className:`font-mono text-fg`,children:Ze(E)})]}),(0,X.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${D}%`}})})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:t.hardInputLimit}),(0,X.jsx)(`span`,{className:`font-mono text-fg`,children:Ze(T)})]}),(0,X.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${O}%`}})})]})]}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,X.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ze(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ze(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),j?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,X.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,X.jsx)(oe,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),y.model?(0,X.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>S({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,X.jsx)(Qe,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>S({qualityGuard:e})}),(0,X.jsx)(Qe,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>S({gapAudit:e})})]}),y.qualityGuard?null:(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,X.jsx)(De,{children:(0,X.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,X.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(P)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,X.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),A?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,X.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:m(`text-fg-muted hover:text-fg`,G.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,X.jsx)(f,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsx)(`input`,{className:Je(),value:d,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),B())}}),(0,X.jsxs)(N,{type:`button`,variant:`secondary`,disabled:!d.trim()||y.postCompactionSections.length>=12,onClick:B,children:[(0,X.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tt(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function nt(e){let t=et(e)?e:{},n=et(t.session)?t.session:{},r=et(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:tt(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function rt(e){await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),P()}function it(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,W,`dark:border-edge`)}var at=H();function ot({hasToken:e}){let t=p(_(e=>e.language)).sessions.config,{data:n,isLoading:r}=F(e),i=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:nt(n.payload.config),[n]),[s,c]=(0,Y.useReducer)(at,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,Y.useRef)(!1),f=(0,Y.useRef)(l);f.current=l;let m=(0,Y.useRef)(null);K({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:c,onResetDirty:()=>{d.current=!1}});let h=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),g=(0,Y.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=Ee({value:l,dirty:h,onSave:(0,Y.useCallback)(async e=>{try{await rt(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,X.jsx)(q,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,X.jsx)(R,{className:`h-5 w-40`}),(0,X.jsx)(R,{className:`h-24 w-full rounded-xl`})]})}):null:(0,X.jsxs)(q,{onBlurCapture:v.onBlurCapture,children:[(0,X.jsx)(Te,{icon:be,title:t.title,subtitle:t.hint,trailing:(0,X.jsx)(J,{status:v.status,error:v.error})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,X.jsxs)(a,{className:it(),value:l.dmScope,onChange:e=>g({dmScope:e.target.value}),children:[(0,X.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,X.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,X.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,X.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,X.jsx)(`input`,{type:`number`,min:0,className:it(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,X.jsx)(`input`,{type:`number`,min:1,className:it(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function st(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function ct(e){let t=(0,Oe.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:u,onPin:d,onUnpin:p,onExport:h,onDelete:g}=e,_=i?.status===`archived`,v=i?.status===`pinned`,C;t[0]===c?C=t[1]:(C=e=>!e&&c(),t[0]=c,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,X.jsx)(ee,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim`,z)}),t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=m(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,ne,`dark:border-edge`),t[3]=T):T=t[3];let E;t[4]!==i||t[5]!==o||t[6]!==a?(E=i&&a?(0,X.jsx)(re,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=E):E=t[7];let D;t[8]!==s.unnamedSession||t[9]!==i?.name?(D=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=D):D=t[10];let O;t[11]===D?O=t[12]:(O=(0,X.jsx)(S,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:D}),t[11]=D,t[12]=O);let k;t[13]!==E||t[14]!==O?(k=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[E,O]}),t[13]=E,t[14]=O,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,X.jsx)(f,{className:`size-5`,strokeWidth:1.75}),t[16]=A):A=t[16];let j;t[17]===s.close?j=t[18]:(j=(0,X.jsx)(y,{asChild:!0,children:(0,X.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:A})}),t[17]=s.close,t[18]=j);let M;t[19]!==k||t[20]!==j?(M=(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[k,j]}),t[19]=k,t[20]=j,t[21]=M):M=t[21];let P;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(P=r?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,X.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,X.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,X.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(lt)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=P):P=t[26];let F;t[27]===P?F=t[28]:(F=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:P}),t[27]=P,t[28]=F);let I;t[29]!==s.detailExport||t[30]!==h?(I=(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.detailExport}),t[29]=s.detailExport,t[30]=h,t[31]=I):I=t[31];let L;t[32]!==_||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==u?(L=_?(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:s.unarchive}):(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=_,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=u,t[37]=L):L=t[37];let R;t[38]!==v||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==d||t[42]!==p?(R=v?(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.unpin}):(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.pin}),t[38]=v,t[39]=s.pin,t[40]=s.unpin,t[41]=d,t[42]=p,t[43]=R):R=t[43];let B;t[44]!==s.delete||t[45]!==g?(B=(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:g,children:s.delete}),t[44]=s.delete,t[45]=g,t[46]=B):B=t[46];let V;t[47]!==I||t[48]!==L||t[49]!==R||t[50]!==B?(V=(0,X.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,R,B]})}),t[47]=I,t[48]=L,t[49]=R,t[50]=B,t[51]=V):V=t[51];let H;t[52]!==M||t[53]!==F||t[54]!==V?(H=(0,X.jsxs)(b,{children:[w,(0,X.jsxs)(x,{className:T,"aria-describedby":void 0,children:[M,F,V]})]}),t[52]=M,t[53]=F,t[54]=V,t[55]=H):H=t[55];let U;return t[56]!==n||t[57]!==C||t[58]!==H?(U=(0,X.jsx)(te,{open:n,onOpenChange:C,children:H}),t[56]=n,t[57]=C,t[58]=H,t[59]=U):U=t[59],U}function lt(e){return(0,X.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,X.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:st(e.content)})]},`${e.timestamp??``}-${e.role}-${st(e.content).slice(0,24)}`)}var ut=20;function dt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ft=new Set([`all`,`active`,`pinned`,`archived`]),pt=new Set([`grid`,`list`]),mt=[`sessions`,`settings`];function ht(e){return e&&mt.includes(e)?e:`sessions`}function gt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function _t(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function vt(e){let t=(0,Oe.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=mt.map(e=>({id:e,label:gt(n,e),icon:e===`sessions`?xe:B})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,X.jsx)(Se,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function yt(e){let t=(0,Oe.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mb-5`,children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:gt(n,r)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:_t(n,r)})]}),(0,X.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,X.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function bt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ft.has(t)?t:`all`,viewMode:pt.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function xt(){let e=p(_(e=>e.language)),t=e.sessions,n=g(e=>e.conversationId),r=!!n,{data:a,mutate:o}=M(r?[`gateway-chat-agents`,n]:null,le,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,l=a?.items??[],[u,f]=i(),h=ht(u.get(`tab`)),v=(0,Y.useCallback)(e=>{let t=new URLSearchParams(u);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),f(t,{replace:!0})},[u,f]),[y,P]=(0,Y.useReducer)(_e,u,bt),{searchInput:F,debouncedSearch:I,statusFilter:L,viewMode:R,channelFilter:B,sessions:V,loading:H,error:re,hasMore:ie,stats:W,detailOpen:oe,detailLoading:se,detailSession:K,confirmOpen:de,confirmKey:me}=y;(0,Y.useEffect)(()=>{let e=setTimeout(()=>{let e=F.trim();I!==e&&P({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[F,I]);let ge=u.toString(),ve=(0,Y.useRef)(ge);if(ve.current!==ge){ve.current=ge;let e=u.get(`q`)??``,t=u.get(`status`),n=u.get(`view`),r=(u.get(`channel`)??``).trim(),i=ft.has(t)?t:`all`,a=pt.has(n)?n:`grid`,o=e.trim();P({type:`patch`,patch:{...F===e?{}:{searchInput:e},...I===o?{}:{debouncedSearch:o},...L===i?{}:{statusFilter:i},...R===a?{}:{viewMode:a},...B===r?{}:{channelFilter:r}}})}(0,Y.useEffect)(()=>{let e=new URLSearchParams(u),t=I.trim();t?e.set(`q`,t):e.delete(`q`),L===`all`?e.delete(`status`):e.set(`status`,L),R===`grid`?e.delete(`view`):e.set(`view`,R),B?e.set(`channel`,B):e.delete(`channel`),e.toString()!==u.toString()&&f(e,{replace:!0})},[I,u,f,L,R,B]),(0,Y.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=!1;return(async()=>{P({type:`patch`,patch:{loading:!0,error:null}});try{let t=await A({limit:ut,offset:0,...I?{search:I}:{},...L===`all`?{}:{status:L},...B?{channel:B}:{}});if(e)return;P({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||P({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||P({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,h,I,L,B,t.loadError]),(0,Y.useEffect)(()=>{!r||h!==`sessions`||D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,h]),(0,Y.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,h,o]),(0,Y.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||P({type:`patch`,patch:{sessions:V.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:K&&K.key===t.key?{...K,name:t.name}:K}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,h,V,K]);let ye=(0,Y.useCallback)(async()=>{if(!(!r||H||!ie)){P({type:`patch`,patch:{loading:!0,error:null}});try{let e=await A({limit:ut,offset:V.length,...I?{search:I}:{},...L===`all`?{}:{status:L},...B?{channel:B}:{}});P({type:`patch`,patch:{sessions:[...V,...e.items],hasMore:e.hasMore}})}catch(e){P({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{P({type:`patch`,patch:{loading:!1}})}}},[r,H,ie,V.length,I,L,B,t.loadError]),be=(0,Y.useCallback)((e,t)=>{P({type:`patch`,patch:{sessions:V.map(n=>n.key===e?{...n,status:t}:n),detailSession:K&&K.key===e?{...K,status:t}:K}})},[V,K]),Se=(0,Y.useCallback)(async e=>{P({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{P({type:`patch`,patch:{detailSession:await C(e)}})}catch{P({type:`patch`,patch:{detailOpen:!1}})}finally{P({type:`patch`,patch:{detailLoading:!1}})}},[]),Te=e=>{Se(e)},q=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){P({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await j(e),be(e,`archived`);break;case`unarchive`:await T(e),be(e,`active`);break;case`pin`:await w(e),be(e,`pinned`);break;case`unpin`:await O(e),be(e,`active`);break;case`export`:{let t=await k(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},J=async e=>{try{await E(e),P({type:`patch`,patch:{sessions:V.filter(t=>t.key!==e),detailSession:K?.key===e?null:K,...K?.key===e?{detailOpen:!1}:{}}}),D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ee={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},De={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Oe=[{key:`all`,label:t.filterAll,icon:xe},{key:`active`,label:t.filterActive,icon:ce},{key:`pinned`,label:t.filterPinned,icon:pe},{key:`archived`,label:t.filterArchived,icon:he}],ke=(()=>{let e=Object.entries(W?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,X.jsxs)(we,{gap:`gap-6`,children:[(0,X.jsx)(Ce,{title:t.title}),(0,X.jsx)(vt,{s:t,activeTab:h,onChange:v}),(0,X.jsx)(yt,{s:t,id:`settings`,activeTab:h,plain:!0,children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)($e,{hasToken:r}),(0,X.jsx)(ot,{hasToken:r})]})}),(0,X.jsxs)(yt,{s:t,id:`sessions`,activeTab:h,plain:!0,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Oe.map(({key:e,label:t,icon:n})=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":L===e,onClick:()=>P({type:`patch`,patch:{statusFilter:e}}),className:m(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,L===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,X.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,X.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,X.jsx)(d,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:F,onChange:e=>P({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":I||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,X.jsx)(`button`,{type:`button`,"aria-pressed":!B,onClick:()=>P({type:`patch`,patch:{channelFilter:``}}),className:m(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,B?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),ke.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":B===e,onClick:()=>P({type:`patch`,patch:{channelFilter:e}}),className:m(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,B===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,W?.byChannel?.[e]==null?null:(0,X.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:W.byChannel[e]})]},e))]}),W?(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[W.totalSessions,t.totalSessions],[W.activeSessions,t.activeSessions],[W.pinnedSessions,t.pinnedSessions],[W.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,X.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,X.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,re?(0,X.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:re}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:dt(t.sessionCount,{count:V.length})}),(0,X.jsxs)(`div`,{className:ue,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,X.jsx)(N,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":R===`grid`,onClick:()=>P({type:`patch`,patch:{viewMode:`grid`}}),className:m(fe,`size-7 p-0`,R===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`grid`&&`text-accent-fg`),children:(0,X.jsx)(ae,{className:`size-3.5`,strokeWidth:1.5})}),(0,X.jsx)(N,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":R===`list`,onClick:()=>P({type:`patch`,patch:{viewMode:`list`}}),className:m(fe,`size-9 p-0`,R===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`list`&&`text-accent-fg`),children:(0,X.jsx)(U,{className:`size-3.5`,strokeWidth:1.5})})]})]}),H&&V.length===0?(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,X.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):V.length===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,X.jsx)(c,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,X.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,X.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,X.jsx)(N,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:m(`grid min-w-0 gap-3`,R===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":I||void 0,children:V.map(e=>{let t=Le(e,s);return(0,X.jsx)(Me,{session:e,variant:R,labels:Ee,sessionAgentId:t,sessionAgentAvatar:Re(t,l),onOpen:()=>Te(e.key),onAction:t=>void q(e.key,t)},e.key)})}),ie?(0,X.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,X.jsx)(N,{type:`button`,variant:`secondary`,disabled:H,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,X.jsx)(ct,{open:oe,loading:se,session:K,sessionAgentId:K?Le(K,s):void 0,sessionAgentAvatar:K?Re(Le(K,s),l):void 0,labels:De,onClose:()=>{P({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>K&&void q(K.key,`archive`),onUnarchive:()=>K&&void q(K.key,`unarchive`),onPin:()=>K&&void q(K.key,`pin`),onUnpin:()=>K&&void q(K.key,`unpin`),onExport:()=>K&&void q(K.key,`export`),onDelete:()=>K&&P({type:`patch`,patch:{confirmKey:K.key,confirmOpen:!0}})}),(0,X.jsx)(te,{open:de,onOpenChange:e=>P({type:`patch`,patch:{confirmOpen:e}}),children:(0,X.jsxs)(b,{children:[(0,X.jsx)(ee,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim`,z)}),(0,X.jsxs)(x,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,ne),children:[(0,X.jsx)(S,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:me?dt(t.deleteSessionMessage,{name:V.find(e=>e.key===me)?.name?.trim()||e.chat.newSession}):``}),(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>P({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,X.jsx)(N,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{me&&J(me),P({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,X.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{xt as SessionsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-0p9PIHRy.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./folder-open-CyzJ19I9.js";import{t as l}from"./minimize-2-DtOGrlpo.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./search-DA7gz22f.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./messages-sXePe3LQ.js";import{t as m}from"./cn-JdwAhgNB.js";import{a as h,c as g,n as _,r as v}from"./locale-store-WMaCMm3_.js";import{a as ee,n as y,o as b,r as x,s as S,t as te}from"./dist-BGTk37IG.js";import{a as C,c as w,f as T,n as E,o as D,p as O,r as k,s as A,t as j}from"./session-api-Bv-hCMKS.js";import{i as M}from"./vendor-swr-BIWyz7Rc.js";import{t as N}from"./button-CS04eWY9.js";import{n as P,r as F}from"./gateway-config-swr-CmjHbMj7.js";import{n as I,t as L}from"./registry-api-DEePN1Rc.js";import{t as R}from"./skeleton-BwbyijEw.js";import{i as ne,o as z}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Bc as B,Cu as V,Da as H,Il as U,L as re,La as ie,Ll as ae,Lo as W,Mi as oe,Ms as se,Mu as ce,Ns as G,Oa as K,Pa as le,Qt as ue,Ra as de,Zt as fe,al as pe,bl as me,cd as he,il as ge,ka as _e,ld as ve,vc as ye,vu as be,zl as xe}from"./index-Bb32g7Ll.js";import{t as Se}from"./page-tabs-ZUC486EH.js";import{n as Ce,r as we}from"./settings-page-layout-X1x-2Cp9.js";import{n as Te,t as q}from"./settings-form-section-BwdrtX6k.js";import{n as J,t as Ee}from"./use-autosave-DQdLcZfO.js";import{t as De}from"./settings-advanced-gate-C4y4c2M7.js";var Y=e(t(),1),Oe=n(),X=r();function ke(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function Ae(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function je(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function Me(e){let t=(0,Oe.c)(124),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,f=_(Ie),h;t[3]!==f||t[4]!==n?(h=de(n,p(f).sidebar.sessionFilters),t[3]=f,t[4]=n,t[5]=h):h=t[5];let g=h,v;t[6]===n.name?v=t[7]:(v=n.name?.trim(),t[6]=n.name,t[7]=v);let ee=!!v,y=n.status===`archived`,b=n.status===`pinned`,x=n.usage,S;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==x?(S=x?.calls?x.costCompleteness===`unknown`?i.costUnknown:`${x.costCompleteness===`partial`?`≥ `:`≈ `}${je(x.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=x,t[11]=S):S=t[11];let te=S,C=x?.calls?x.costCompleteness===`partial`?i.costPartial:x.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,w=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,T;t[12]===w?T=t[13]:(T=m(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,w),t[12]=w,t[13]=T);let E;t[14]===c?E=t[15]:(E=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=E);let D=r===`list`&&`sm:py-3`,O;t[16]===D?O=t[17]:(O=m(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,D),t[16]=D,t[17]=O);let k;t[18]===n?k=t[19]:(k=(0,X.jsx)(ie,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=k);let A;t[20]===g?A=t[21]:(A=(0,X.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:g}),t[20]=g,t[21]=A);let j;t[22]!==k||t[23]!==A?(j=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[k,A]}),t[22]=k,t[23]=A,t[24]=j):j=t[24];let M;t[25]===b?M=t[26]:(M=b?(0,X.jsx)(pe,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=b,t[26]=M);let N;t[27]===n.updatedAt?N=t[28]:(N=ke(n.updatedAt),t[27]=n.updatedAt,t[28]=N);let P;t[29]===N?P=t[30]:(P=(0,X.jsx)(`span`,{children:N}),t[29]=N,t[30]=P);let F;t[31]!==M||t[32]!==P?(F=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[M,P]}),t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==j||t[35]!==F||t[36]!==O?(I=(0,X.jsxs)(`div`,{className:O,children:[j,F]}),t[34]=j,t[35]=F,t[36]=O,t[37]=I):I=t[37];let L=r===`list`&&`sm:py-3`,R;t[38]===L?R=t[39]:(R=m(`min-w-0 flex-1 px-3 py-2`,L),t[38]=L,t[39]=R);let ne=r===`list`&&`sm:items-start`,z;t[40]===ne?z=t[41]:(z=m(`flex gap-3`,ne),t[40]=ne,t[41]=z);let B;t[42]!==o||t[43]!==a?(B=(0,X.jsx)(re,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=o,t[43]=a,t[44]=B):B=t[44];let H;t[45]===d?H=t[46]:(H=(0,X.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[45]=d,t[46]=H);let U;t[47]!==n.key||t[48]!==ee?(U=ee?(0,X.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[47]=n.key,t[48]=ee,t[49]=U):U=t[49];let ae;t[50]!==H||t[51]!==U?(ae=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[H,U]}),t[50]=H,t[51]=U,t[52]=ae):ae=t[52];let W;t[53]!==z||t[54]!==B||t[55]!==ae?(W=(0,X.jsxs)(`div`,{className:z,children:[B,ae]}),t[53]=z,t[54]=B,t[55]=ae,t[56]=W):W=t[56];let oe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,X.jsx)(me,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=oe):oe=t[57];let ce;t[58]===n.messageCount?ce=t[59]:(ce=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[oe,n.messageCount]}),t[58]=n.messageCount,t[59]=ce);let G;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,X.jsx)(be,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=G):G=t[60];let K=x?.totalTokens??0,le;t[61]!==f||t[62]!==K?(le=Ae(K,f),t[61]=f,t[62]=K,t[63]=le):le=t[63];let ue;t[64]!==i.tokens||t[65]!==le?(ue=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[G,le,` `,i.tokens]}),t[64]=i.tokens,t[65]=le,t[66]=ue):ue=t[66];let fe;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,X.jsx)(V,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=fe):fe=t[67];let _e;t[68]!==te||t[69]!==C?(_e=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:C,children:[fe,te]}),t[68]=te,t[69]=C,t[70]=_e):_e=t[70];let xe;t[71]!==ce||t[72]!==ue||t[73]!==_e?(xe=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[ce,ue,_e]}),t[71]=ce,t[72]=ue,t[73]=_e,t[74]=xe):xe=t[74];let Se;t[75]===n.tags?Se=t[76]:(Se=n.tags.length>0?(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Fe),n.tags.length>3?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=Se);let Ce;t[77]!==R||t[78]!==W||t[79]!==xe||t[80]!==Se?(Ce=(0,X.jsxs)(`div`,{className:R,children:[W,xe,Se]}),t[77]=R,t[78]=W,t[79]=xe,t[80]=Se,t[81]=Ce):Ce=t[81];let we;t[82]===l?we=t[83]:(we=()=>l(`continue`),t[82]=l,t[83]=we);let Te;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,X.jsx)(me,{className:`size-4`,strokeWidth:1.75}),t[84]=Te):Te=t[84];let q;t[85]!==i.continueChat||t[86]!==we?(q=(0,X.jsx)(`button`,{type:`button`,className:se,title:i.continueChat,"aria-label":i.continueChat,onClick:we,children:Te}),t[85]=i.continueChat,t[86]=we,t[87]=q):q=t[87];let J;t[88]!==y||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==l?(J=y?(0,X.jsx)(`button`,{type:`button`,className:se,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,X.jsx)(ve,{className:`size-4`,strokeWidth:1.75})}):(0,X.jsx)(`button`,{type:`button`,className:se,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,X.jsx)(he,{className:`size-4`,strokeWidth:1.75})}),t[88]=y,t[89]=i.archive,t[90]=i.unarchive,t[91]=l,t[92]=J):J=t[92];let Ee;t[93]!==b||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==l?(Ee=b?(0,X.jsx)(`button`,{type:`button`,className:se,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,X.jsx)(ge,{className:`size-4`,strokeWidth:1.75})}):(0,X.jsx)(`button`,{type:`button`,className:se,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,X.jsx)(pe,{className:`size-4`,strokeWidth:1.75})}),t[93]=b,t[94]=i.pin,t[95]=i.unpin,t[96]=l,t[97]=Ee):Ee=t[97];let De;t[98]===l?De=t[99]:(De=()=>l(`export`),t[98]=l,t[99]=De);let Y;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,X.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[100]=Y):Y=t[100];let Me;t[101]!==i.export||t[102]!==De?(Me=(0,X.jsx)(`button`,{type:`button`,className:se,title:i.export,"aria-label":i.export,onClick:De,children:Y}),t[101]=i.export,t[102]=De,t[103]=Me):Me=t[103];let Le;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Le=m(se,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=Le):Le=t[104];let Re;t[105]===l?Re=t[106]:(Re=()=>l(`delete`),t[105]=l,t[106]=Re);let ze;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,X.jsx)(ye,{className:`size-4`,strokeWidth:1.75}),t[107]=ze):ze=t[107];let Z;t[108]!==i.delete||t[109]!==Re?(Z=(0,X.jsx)(`button`,{type:`button`,className:Le,title:i.delete,"aria-label":i.delete,onClick:Re,children:ze}),t[108]=i.delete,t[109]=Re,t[110]=Z):Z=t[110];let Be;t[111]!==q||t[112]!==J||t[113]!==Ee||t[114]!==Me||t[115]!==Z?(Be=(0,X.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Pe,onKeyDown:Ne,children:[q,J,Ee,Me,Z]}),t[111]=q,t[112]=J,t[113]=Ee,t[114]=Me,t[115]=Z,t[116]=Be):Be=t[116];let Q;return t[117]!==c||t[118]!==I||t[119]!==Ce||t[120]!==Be||t[121]!==T||t[122]!==E?(Q=(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,className:T,onClick:c,onKeyDown:E,children:[I,Ce,Be]}),t[117]=c,t[118]=I,t[119]=Ce,t[120]=Be,t[121]=T,t[122]=E,t[123]=Q):Q=t[123],Q}function Ne(e){return e.stopPropagation()}function Pe(e){return e.stopPropagation()}function Fe(e){return(0,X.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Ie(e){return e.language}function Le(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Re(e,t){return t.find(t=>t.id===e)?.avatar}var ze={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Be(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Ve(e){let t=Z(e)?e:{},n=Z(t.userContext)?t.userContext:{},r=Z(n.contextPlanning)?n.contextPlanning:{},i=Z(r.compaction)?r.compaction:{},a=ze,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Be(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function He(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ue(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function We(e){await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ue(e))}),await P()}var Ge=128e3,Ke={balanced:ze,preserve:{...ze,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...ze,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},qe=H();function Je(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,W,`dark:border-edge`)}function Ye(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function Xe(e){let t=Ye(e);for(let[e,n]of Object.entries(Ke))if(t===Ye(n))return e;return`custom`}function Ze(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Oe.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Je(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,X.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,X.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Qe(e){let t=(0,Oe.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=m(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,X.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,X.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let h;return t[15]!==c||t[16]!==u||t[17]!==p?(h=(0,X.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=h):h=t[18],h}function $e({hasToken:e}){let t=p(_(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=F(e),{data:i=[],isLoading:a}=M(e?L:null,I,{revalidateOnFocus:!1}),o=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:Ve(n.payload.config),[n]),[s,c]=(0,Y.useReducer)(qe,{form:null,baseline:null}),[d,h]=(0,Y.useState)(``),g=(0,Y.useRef)(!1),v=(0,Y.useRef)(s.form);v.current=s.form;let ee=(0,Y.useRef)(null);K({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:ee,dispatch:c,onResetDirty:()=>{g.current=!1}});let y=s.form,b=s.baseline,x=!!(y&&b&&JSON.stringify(y)!==JSON.stringify(b)),S=(0,Y.useCallback)(e=>{g.current=!0,c({type:`patch`,patch:e})},[]),te=(0,Y.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),C=Ee({value:y,dirty:x,onSave:(0,Y.useCallback)(async e=>{try{await We(e),c({type:`saved`,value:e}),g.current=!!(v.current&&JSON.stringify(v.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=He(e);return n?t.invalidValue.replace(`{{field}}`,te(n)):null}});if(!e||!y)return r?(0,X.jsx)(q,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,X.jsx)(R,{className:`h-5 w-48`}),(0,X.jsx)(R,{className:`h-20 w-full rounded-xl`}),(0,X.jsx)(R,{className:`h-36 w-full rounded-xl`})]})}):null;let w=Xe(y),T=Math.max(0,Ge-y.reserveTokens),E=Math.min(Math.floor(Ge*y.triggerThreshold),T),D=Math.min(100,E/Ge*100),O=Math.min(100,T/Ge*100),k=y.model?i.find(e=>e.id===y.model):void 0,A=k?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>k.contextWindow,j=y.keepRecentTokens+y.reserveTokens>E,P=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),ne=e=>{let t=Ke[e];S({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},z={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},B=()=>{let e=d.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(S({postCompactionSections:[...y.postCompactionSections,e]}),h(``))};return(0,X.jsxs)(q,{onBlurCapture:C.onBlurCapture,children:[(0,X.jsx)(Te,{icon:l,title:t.title,subtitle:t.hint,trailing:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(J,{status:C.status,error:C.error}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>S({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),C.error?(0,X.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:C.error}):null,y.enabled?null:(0,X.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,X.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),w===`custom`?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,X.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":w===e,className:m(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,G.transition,G.focusRingPanel,w===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>ne(e),children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:z[e].title}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:z[e].hint})]},e))})]}),(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,X.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,X.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:t.compactionTrigger}),(0,X.jsx)(`span`,{className:`font-mono text-fg`,children:Ze(E)})]}),(0,X.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${D}%`}})})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:t.hardInputLimit}),(0,X.jsx)(`span`,{className:`font-mono text-fg`,children:Ze(T)})]}),(0,X.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${O}%`}})})]})]}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,X.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ze(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ze(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),j?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,X.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,X.jsx)(oe,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),y.model?(0,X.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>S({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,X.jsx)(Qe,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>S({qualityGuard:e})}),(0,X.jsx)(Qe,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>S({gapAudit:e})})]}),y.qualityGuard?null:(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,X.jsx)(De,{children:(0,X.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,X.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(P)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,X.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),A?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,X.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:m(`text-fg-muted hover:text-fg`,G.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,X.jsx)(f,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsx)(`input`,{className:Je(),value:d,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),B())}}),(0,X.jsxs)(N,{type:`button`,variant:`secondary`,disabled:!d.trim()||y.postCompactionSections.length>=12,onClick:B,children:[(0,X.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tt(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function nt(e){let t=et(e)?e:{},n=et(t.session)?t.session:{},r=et(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:tt(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function rt(e){await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),P()}function it(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,W,`dark:border-edge`)}var at=H();function ot({hasToken:e}){let t=p(_(e=>e.language)).sessions.config,{data:n,isLoading:r}=F(e),i=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:nt(n.payload.config),[n]),[s,c]=(0,Y.useReducer)(at,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,Y.useRef)(!1),f=(0,Y.useRef)(l);f.current=l;let m=(0,Y.useRef)(null);K({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:c,onResetDirty:()=>{d.current=!1}});let h=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),g=(0,Y.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=Ee({value:l,dirty:h,onSave:(0,Y.useCallback)(async e=>{try{await rt(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,X.jsx)(q,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,X.jsx)(R,{className:`h-5 w-40`}),(0,X.jsx)(R,{className:`h-24 w-full rounded-xl`})]})}):null:(0,X.jsxs)(q,{onBlurCapture:v.onBlurCapture,children:[(0,X.jsx)(Te,{icon:be,title:t.title,subtitle:t.hint,trailing:(0,X.jsx)(J,{status:v.status,error:v.error})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,X.jsxs)(a,{className:it(),value:l.dmScope,onChange:e=>g({dmScope:e.target.value}),children:[(0,X.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,X.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,X.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,X.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,X.jsx)(`input`,{type:`number`,min:0,className:it(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,X.jsx)(`input`,{type:`number`,min:1,className:it(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function st(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function ct(e){let t=(0,Oe.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:u,onPin:d,onUnpin:p,onExport:h,onDelete:g}=e,_=i?.status===`archived`,v=i?.status===`pinned`,C;t[0]===c?C=t[1]:(C=e=>!e&&c(),t[0]=c,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,X.jsx)(ee,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim`,z)}),t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=m(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,ne,`dark:border-edge`),t[3]=T):T=t[3];let E;t[4]!==i||t[5]!==o||t[6]!==a?(E=i&&a?(0,X.jsx)(re,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=E):E=t[7];let D;t[8]!==s.unnamedSession||t[9]!==i?.name?(D=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=D):D=t[10];let O;t[11]===D?O=t[12]:(O=(0,X.jsx)(S,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:D}),t[11]=D,t[12]=O);let k;t[13]!==E||t[14]!==O?(k=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[E,O]}),t[13]=E,t[14]=O,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,X.jsx)(f,{className:`size-5`,strokeWidth:1.75}),t[16]=A):A=t[16];let j;t[17]===s.close?j=t[18]:(j=(0,X.jsx)(y,{asChild:!0,children:(0,X.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:A})}),t[17]=s.close,t[18]=j);let M;t[19]!==k||t[20]!==j?(M=(0,X.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[k,j]}),t[19]=k,t[20]=j,t[21]=M):M=t[21];let P;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(P=r?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,X.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,X.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,X.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(lt)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=P):P=t[26];let F;t[27]===P?F=t[28]:(F=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:P}),t[27]=P,t[28]=F);let I;t[29]!==s.detailExport||t[30]!==h?(I=(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.detailExport}),t[29]=s.detailExport,t[30]=h,t[31]=I):I=t[31];let L;t[32]!==_||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==u?(L=_?(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:s.unarchive}):(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=_,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=u,t[37]=L):L=t[37];let R;t[38]!==v||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==d||t[42]!==p?(R=v?(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.unpin}):(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.pin}),t[38]=v,t[39]=s.pin,t[40]=s.unpin,t[41]=d,t[42]=p,t[43]=R):R=t[43];let B;t[44]!==s.delete||t[45]!==g?(B=(0,X.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:g,children:s.delete}),t[44]=s.delete,t[45]=g,t[46]=B):B=t[46];let V;t[47]!==I||t[48]!==L||t[49]!==R||t[50]!==B?(V=(0,X.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,R,B]})}),t[47]=I,t[48]=L,t[49]=R,t[50]=B,t[51]=V):V=t[51];let H;t[52]!==M||t[53]!==F||t[54]!==V?(H=(0,X.jsxs)(b,{children:[w,(0,X.jsxs)(x,{className:T,"aria-describedby":void 0,children:[M,F,V]})]}),t[52]=M,t[53]=F,t[54]=V,t[55]=H):H=t[55];let U;return t[56]!==n||t[57]!==C||t[58]!==H?(U=(0,X.jsx)(te,{open:n,onOpenChange:C,children:H}),t[56]=n,t[57]=C,t[58]=H,t[59]=U):U=t[59],U}function lt(e){return(0,X.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,X.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:st(e.content)})]},`${e.timestamp??``}-${e.role}-${st(e.content).slice(0,24)}`)}var ut=20;function dt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ft=new Set([`all`,`active`,`pinned`,`archived`]),pt=new Set([`grid`,`list`]),mt=[`sessions`,`settings`];function ht(e){return e&&mt.includes(e)?e:`sessions`}function gt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function _t(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function vt(e){let t=(0,Oe.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=mt.map(e=>({id:e,label:gt(n,e),icon:e===`sessions`?xe:B})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,X.jsx)(Se,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function yt(e){let t=(0,Oe.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mb-5`,children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:gt(n,r)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:_t(n,r)})]}),(0,X.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,X.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function bt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ft.has(t)?t:`all`,viewMode:pt.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function xt(){let e=p(_(e=>e.language)),t=e.sessions,n=g(e=>e.conversationId),r=!!n,{data:a,mutate:o}=M(r?[`gateway-chat-agents`,n]:null,le,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,l=a?.items??[],[u,f]=i(),h=ht(u.get(`tab`)),v=(0,Y.useCallback)(e=>{let t=new URLSearchParams(u);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),f(t,{replace:!0})},[u,f]),[y,P]=(0,Y.useReducer)(_e,u,bt),{searchInput:F,debouncedSearch:I,statusFilter:L,viewMode:R,channelFilter:B,sessions:V,loading:H,error:re,hasMore:ie,stats:W,detailOpen:oe,detailLoading:se,detailSession:K,confirmOpen:de,confirmKey:me}=y;(0,Y.useEffect)(()=>{let e=setTimeout(()=>{let e=F.trim();I!==e&&P({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[F,I]);let ge=u.toString(),ve=(0,Y.useRef)(ge);if(ve.current!==ge){ve.current=ge;let e=u.get(`q`)??``,t=u.get(`status`),n=u.get(`view`),r=(u.get(`channel`)??``).trim(),i=ft.has(t)?t:`all`,a=pt.has(n)?n:`grid`,o=e.trim();P({type:`patch`,patch:{...F===e?{}:{searchInput:e},...I===o?{}:{debouncedSearch:o},...L===i?{}:{statusFilter:i},...R===a?{}:{viewMode:a},...B===r?{}:{channelFilter:r}}})}(0,Y.useEffect)(()=>{let e=new URLSearchParams(u),t=I.trim();t?e.set(`q`,t):e.delete(`q`),L===`all`?e.delete(`status`):e.set(`status`,L),R===`grid`?e.delete(`view`):e.set(`view`,R),B?e.set(`channel`,B):e.delete(`channel`),e.toString()!==u.toString()&&f(e,{replace:!0})},[I,u,f,L,R,B]),(0,Y.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=!1;return(async()=>{P({type:`patch`,patch:{loading:!0,error:null}});try{let t=await A({limit:ut,offset:0,...I?{search:I}:{},...L===`all`?{}:{status:L},...B?{channel:B}:{}});if(e)return;P({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||P({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||P({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,h,I,L,B,t.loadError]),(0,Y.useEffect)(()=>{!r||h!==`sessions`||D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,h]),(0,Y.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,h,o]),(0,Y.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||P({type:`patch`,patch:{sessions:V.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:K&&K.key===t.key?{...K,name:t.name}:K}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,h,V,K]);let ye=(0,Y.useCallback)(async()=>{if(!(!r||H||!ie)){P({type:`patch`,patch:{loading:!0,error:null}});try{let e=await A({limit:ut,offset:V.length,...I?{search:I}:{},...L===`all`?{}:{status:L},...B?{channel:B}:{}});P({type:`patch`,patch:{sessions:[...V,...e.items],hasMore:e.hasMore}})}catch(e){P({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{P({type:`patch`,patch:{loading:!1}})}}},[r,H,ie,V.length,I,L,B,t.loadError]),be=(0,Y.useCallback)((e,t)=>{P({type:`patch`,patch:{sessions:V.map(n=>n.key===e?{...n,status:t}:n),detailSession:K&&K.key===e?{...K,status:t}:K}})},[V,K]),Se=(0,Y.useCallback)(async e=>{P({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{P({type:`patch`,patch:{detailSession:await C(e)}})}catch{P({type:`patch`,patch:{detailOpen:!1}})}finally{P({type:`patch`,patch:{detailLoading:!1}})}},[]),Te=e=>{Se(e)},q=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){P({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await j(e),be(e,`archived`);break;case`unarchive`:await T(e),be(e,`active`);break;case`pin`:await w(e),be(e,`pinned`);break;case`unpin`:await O(e),be(e,`active`);break;case`export`:{let t=await k(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},J=async e=>{try{await E(e),P({type:`patch`,patch:{sessions:V.filter(t=>t.key!==e),detailSession:K?.key===e?null:K,...K?.key===e?{detailOpen:!1}:{}}}),D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ee={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},De={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Oe=[{key:`all`,label:t.filterAll,icon:xe},{key:`active`,label:t.filterActive,icon:ce},{key:`pinned`,label:t.filterPinned,icon:pe},{key:`archived`,label:t.filterArchived,icon:he}],ke=(()=>{let e=Object.entries(W?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,X.jsxs)(we,{gap:`gap-6`,children:[(0,X.jsx)(Ce,{title:t.title}),(0,X.jsx)(vt,{s:t,activeTab:h,onChange:v}),(0,X.jsx)(yt,{s:t,id:`settings`,activeTab:h,plain:!0,children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)($e,{hasToken:r}),(0,X.jsx)(ot,{hasToken:r})]})}),(0,X.jsxs)(yt,{s:t,id:`sessions`,activeTab:h,plain:!0,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Oe.map(({key:e,label:t,icon:n})=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":L===e,onClick:()=>P({type:`patch`,patch:{statusFilter:e}}),className:m(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,L===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,X.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,X.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,X.jsx)(d,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:F,onChange:e=>P({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":I||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,X.jsx)(`button`,{type:`button`,"aria-pressed":!B,onClick:()=>P({type:`patch`,patch:{channelFilter:``}}),className:m(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,B?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),ke.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":B===e,onClick:()=>P({type:`patch`,patch:{channelFilter:e}}),className:m(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,B===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,W?.byChannel?.[e]==null?null:(0,X.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:W.byChannel[e]})]},e))]}),W?(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[W.totalSessions,t.totalSessions],[W.activeSessions,t.activeSessions],[W.pinnedSessions,t.pinnedSessions],[W.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,X.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,X.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,re?(0,X.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:re}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:dt(t.sessionCount,{count:V.length})}),(0,X.jsxs)(`div`,{className:ue,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,X.jsx)(N,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":R===`grid`,onClick:()=>P({type:`patch`,patch:{viewMode:`grid`}}),className:m(fe,`size-7 p-0`,R===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`grid`&&`text-accent-fg`),children:(0,X.jsx)(ae,{className:`size-3.5`,strokeWidth:1.5})}),(0,X.jsx)(N,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":R===`list`,onClick:()=>P({type:`patch`,patch:{viewMode:`list`}}),className:m(fe,`size-9 p-0`,R===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`list`&&`text-accent-fg`),children:(0,X.jsx)(U,{className:`size-3.5`,strokeWidth:1.5})})]})]}),H&&V.length===0?(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,X.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):V.length===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,X.jsx)(c,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,X.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,X.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,X.jsx)(N,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:m(`grid min-w-0 gap-3`,R===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":I||void 0,children:V.map(e=>{let t=Le(e,s);return(0,X.jsx)(Me,{session:e,variant:R,labels:Ee,sessionAgentId:t,sessionAgentAvatar:Re(t,l),onOpen:()=>Te(e.key),onAction:t=>void q(e.key,t)},e.key)})}),ie?(0,X.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,X.jsx)(N,{type:`button`,variant:`secondary`,disabled:H,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,X.jsx)(ct,{open:oe,loading:se,session:K,sessionAgentId:K?Le(K,s):void 0,sessionAgentAvatar:K?Re(Le(K,s),l):void 0,labels:De,onClose:()=>{P({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>K&&void q(K.key,`archive`),onUnarchive:()=>K&&void q(K.key,`unarchive`),onPin:()=>K&&void q(K.key,`pin`),onUnpin:()=>K&&void q(K.key,`unpin`),onExport:()=>K&&void q(K.key,`export`),onDelete:()=>K&&P({type:`patch`,patch:{confirmKey:K.key,confirmOpen:!0}})}),(0,X.jsx)(te,{open:de,onOpenChange:e=>P({type:`patch`,patch:{confirmOpen:e}}),children:(0,X.jsxs)(b,{children:[(0,X.jsx)(ee,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim`,z)}),(0,X.jsxs)(x,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,ne),children:[(0,X.jsx)(S,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:me?dt(t.deleteSessionMessage,{name:V.find(e=>e.key===me)?.name?.trim()||e.chat.newSession}):``}),(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>P({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,X.jsx)(N,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{me&&J(me),P({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,X.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{xt as SessionsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Dn as e}from"./index-Bb32g7Ll.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./pencil-DmIY3Oa-.js";import{t as r}from"./cn-JdwAhgNB.js";import{Ns as i}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./pencil-DmIY3Oa-.js";import{t as r}from"./cn-JdwAhgNB.js";import{Ns as i}from"./index-Bb32g7Ll.js";var a=e();function o(){return`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(7),{children:n,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=r(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==n||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:n}),t[2]=n,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}var l=`mt-0.5 flex size-7 shrink-0 items-center justify-center text-fg-muted transition-colors`;function u(e){let t=(0,a.c)(27),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v,y;if(t[2]!==p||t[3]!==m||t[4]!==h||t[5]!==_){let e=h?r(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press):r(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press),a=!!(m&&h);t[8]===p?v=t[9]:(v=r(`mb-4 flex items-start gap-2.5`,p),t[8]=p,t[9]=v),y=m?a?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:r(`touch-target`,e),children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(n,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:r(`touch-target`,e),children:_}):(0,s.jsx)(`div`,{className:r(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[2]=p,t[3]=m,t[4]=h,t[5]=_,t[6]=v,t[7]=y}else v=t[6],y=t[7];let b;t[10]===c?b=t[11]:(b=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[10]=c,t[11]=b);let x;t[12]!==b||t[13]!==f?(x=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[b,f]}),t[12]=b,t[13]=f,t[14]=x):x=t[14];let S;t[15]===u?S=t[16]:(S=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[15]=u,t[16]=S);let C;t[17]!==x||t[18]!==S?(C=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S]}),t[17]=x,t[18]=S,t[19]=C):C=t[19];let w;t[20]===d?w=t[21]:(w=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[20]=d,t[21]=w);let T;return t[22]!==v||t[23]!==y||t[24]!==C||t[25]!==w?(T=(0,s.jsxs)(`div`,{className:v,children:[y,C,w]}),t[22]=v,t[23]=y,t[24]=C,t[25]=w,t[26]=T):T=t[26],T}export{u as n,o as r,c as t};
|
package/dist/gateway/static/root/assets/{settings-page-Cl_KOVsG.js → settings-page-B6YZFEye.js}
RENAMED
|
@@ -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{m as i,r as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./messages-sXePe3LQ.js";import{n as s}from"./locale-store-WMaCMm3_.js";import{ao as c,co as l,do as u,fo as d,io as f,lo as p,mo as m,oo as h,po as g,ro as _,so as v,uo as y}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{m as i,r as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./messages-sXePe3LQ.js";import{n as s}from"./locale-store-WMaCMm3_.js";import{ao as c,co as l,do as u,fo as d,io as f,lo as p,mo as m,oo as h,po as g,ro as _,so as v,uo as y}from"./index-Bb32g7Ll.js";var b=n(),x=e(t(),1),S=r(),C=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`agent-defaults`,`gateway`,`runtimes`,`devices`,`heartbeat`,`remote-access`,`shares`],w=(0,x.lazy)(()=>d().then(e=>({default:e.SetupStatusPanel}))),T=(0,x.lazy)(()=>c().then(e=>({default:e.AppearanceSettingsPanel}))),E=(0,x.lazy)(()=>p().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),D=(0,x.lazy)(()=>m().then(e=>({default:e.SystemSettingsPanel}))),O=(0,x.lazy)(()=>h().then(e=>({default:e.DesktopPetSettings}))),k=(0,x.lazy)(()=>f().then(e=>({default:e.AppManagementSettingsPanel}))),A=(0,x.lazy)(()=>l().then(e=>({default:e.GatewaySettingsPanel}))),j=(0,x.lazy)(()=>u().then(e=>({default:e.RuntimeToolsSettingsPanel}))),M=(0,x.lazy)(()=>y().then(e=>({default:e.RemoteAccessHub}))),N=(0,x.lazy)(()=>g().then(e=>({default:e.SharesSettingsPanel}))),P=(0,x.lazy)(()=>_().then(e=>({default:e.AgentDefaultsSettingsPanel}))),F=(0,x.lazy)(()=>v().then(e=>({default:e.EndpointToolsManagementSettings})));function I(){let e=(0,b.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,S.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function L(e){return(0,S.jsx)(x.Suspense,{fallback:(0,S.jsx)(I,{}),children:(0,S.jsx)(e,{})})}function R(){let e=(0,b.c)(27),{section:t}=i(),n=s(z),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=o(n);if(!t||!C.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(w),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(T),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(E),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(D),e[11]=t):t=e[11],d=t;break bb0}if(s===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(O),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(k),e[13]=t):t=e[13],d=t;break bb0}if(s===`agent-defaults`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(P),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(A),e[15]=t):t=e[15],d=t;break bb0}if(s===`runtimes`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(j),e[16]=t):t=e[16],d=t;break bb0}if(s===`devices`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(F),e[17]=t):t=e[17],d=t;break bb0}if(s===`remote-access`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(M),e[18]=t):t=e[18],d=t;break bb0}if(s===`shares`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(N),e[19]=t):t=e[19],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,S.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[20]!==r||e[21]!==c?(f=(0,S.jsx)(`p`,{className:r,children:c}),e[20]=r,e[21]=c,e[22]=f):f=e[22];let p;return e[23]!==l||e[24]!==u||e[25]!==f?(p=(0,S.jsxs)(`div`,{className:l,children:[u,f]}),e[23]=l,e[24]=u,e[25]=f,e[26]=p):p=e[26],p}function z(e){return e.language}export{R as SettingsPage};
|
|
@@ -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-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-sXePe3LQ.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,n as d,r as f}from"./locale-store-WMaCMm3_.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-CmjHbMj7.js";import{n as h}from"./gateway-realtime-store-KyhksZSM.js";import{n as g,t as _}from"./registry-api-DEePN1Rc.js";import{n as v}from"./electron-env-Dit0bHgy.js";import{Dc as y,Jc as b,Mu as x,No as S,Ns as C,Nu as w,Ri as T,Ut as E,Vu as D,Wl as O,_c as k,ud as A}from"./index-Z6i4GDcT.js";import{n as j,r as M}from"./settings-page-layout-X1x-2Cp9.js";import{n as N,t as P}from"./settings-form-section-Lpep8yx-.js";import{n as F}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as I}from"./settings-advanced-gate-CVnn1f7J.js";var L=e(t(),1),R=n();function z(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&S(e)).length}function B(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function V(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function ee(e){if(!e||typeof e!=`object`)return{enabled:!1,driverKind:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,driverKind:`extension`};let n=t,r=n.driver&&typeof n.driver==`object`&&!Array.isArray(n.driver)?n.driver:void 0;return{enabled:n.enabled===!0,driverKind:typeof r?.kind==`string`&&r.kind.trim()?r.kind.trim():`extension`}}function H(e){return e?`pass`:`fail`}function U(e){if(e===`tool-runtimes`)return`/settings/runtimes`;if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/capabilities/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/capabilities/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function W(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(e,t){let n=e.match(/^Run(?::|\s)(.*)$/i);if(n?.[1])return t.runCommand(n[1].trim());let r=e.match(/^Install(?::|\s)(.*)$/i);if(r?.[1])return t.installCommand(r[1].trim());let i=e.match(/^Start(?::|\s)(.*)$/i);return i?.[1]?t.startCommand(i[1].trim()):e}function G(e,t){if(!t)return e;let n=e.message;if(e.id===`tool-runtimes`){let r=e.message.match(/^(.*) runtime is not installed\.$/),i=e.message.match(/^(.*) runtime installation is invalid\.$/);r?.[1]?n=t.runtimeMissing(r[1]):i?.[1]&&(n=t.runtimeInvalid(i[1]))}else if(e.id===`gateway-service`)if(e.message===`Gateway is not installed as a system service.`)n=t.gatewayNotInstalled;else{let r=e.message.match(/^Service backend unavailable: (.*)$/),i=e.message.match(/^Gateway service is installed but not running \(status: (.*)\)\.$/);r?.[1]?n=t.gatewayUnavailable(r[1]):i?.[1]&&(n=t.gatewayNotRunning(i[1]))}else e.id===`provider-auth`&&e.message===`No API keys detected for configured providers.`&&(n=t.providerAuthMissing);return{...e,label:t.labels[e.id]??e.label,message:n,hints:e.hints.map(e=>te(e,t))}}function K(e,t){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>{let n=G(e,t);return{id:n.id,label:n.label,status:n.status,message:n.message,hints:n.hints,path:U(n.id),source:`doctor`}}).toSorted((e,t)=>W(t.status)-W(e.status)||e.label.localeCompare(t.label))}function ne(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let r of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let i=t.get(r);if(i){let t=G(i,e.copy);n.push({id:t.id,label:t.label,status:t.status,message:t.message,path:U(t.id)})}}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:e.copy?.labels[`logs-health`]??`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.copy?e.logsHealth.shuttingDown?e.copy.logsShuttingDown:t>0?e.copy.logsErrors(t):e.copy.logsHealthy:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[]){let r=t.message;if(e.copy){r={"Local Chromium is installed.":e.copy.chromiumInstalled,"Local Chromium is not installed.":e.copy.chromiumNotInstalled,"Chrome extension bridge is connected.":e.copy.extensionConnected,"Chrome extension needs refresh.":e.copy.extensionNeedsRefresh,"Chrome extension is installed but not connected.":e.copy.extensionNotConnected,"Chrome extension is not installed.":e.copy.extensionNotInstalled}[t.message]??t.message;let n=t.message.match(/^Browser driver "(.*)" is configured\.$/);n?.[1]&&(r=e.copy.browserDriverConfigured(n[1]))}n.push({...t,label:e.copy?.labels[t.id]??t.label,message:r})}return n}function re(e){let t=z(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=B(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=V(e.config),l=e.skillCount>0,u=(e.doctorChecks??[]).filter(t=>!e.isElectron||t.id!==`gateway-service`),d=K(u,e.labels.diagnostics),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:H(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:H(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:H(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=ne({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics,copy:e.labels.diagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function ie(e){return ee(e)}function ae(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function oe(){return f(`/api/doctor`)}async function se(){return((await l(oe())).checks??[]).map(ae).filter(e=>e!==null)}function ce(){return f(`/api/logs/health`)}async function le(){return l(ce())}function q(e){return e?`pass`:`warn`}function ue(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function J(e){if(!e.enabled)return[];if(e.driverKind===`playwright`){let e=await l(f(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:q(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser`}]}if(e.driverKind===`extension`){let e=await l(f(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser driver "${e.driverKind}" is configured.`,path:`/settings/agent-browser`}]}function Y(){let e=(0,R.c)(95),t=u(ge),n=d(he),r;e[0]===n?r=e[1]:(r=s(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=i.setupStatus.diagnostics,c=h(me),{data:l,error:f,isLoading:y,mutate:b}=m(!!t),x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!1},e[2]=x):x=e[2];let{data:S,error:C,isLoading:w,mutate:T}=p(t?`setup-checklist-skills`:null,pe,x),D;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(D={revalidateOnFocus:!1},e[3]=D):D=e[3];let{data:O,error:k,isLoading:A,mutate:j}=p(t?`setup-checklist-provider-meta`:null,E,D),M;e[4]===t?M=e[5]:(M=t?oe():null,e[4]=t,e[5]=M);let N;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(N={revalidateOnFocus:!1},e[6]=N):N=e[6];let{data:P,error:F,isLoading:I,mutate:L}=p(M,se,N),z;e[7]===t?z=e[8]:(z=t?ce():null,e[7]=t,e[8]=z);let B;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(B={revalidateOnFocus:!1},e[9]=B):B=e[9];let{data:V,isLoading:ee,mutate:H}=p(z,le,B);l?.payload?.config;let U=l?.payload?.config,W;e[10]===U?W=e[11]:(W=ie(U),e[10]=U,e[11]=W);let te=t?W:null,G;e[12]===te?G=e[13]:(G=ue(te),e[12]=te,e[13]=G);let K;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(K={revalidateOnFocus:!1},e[14]=K):K=e[14];let{data:ne,isLoading:ae,mutate:q}=p(G,fe,K),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?_:null,g,J);let Y=!t||!y&&!w&&!A&&!I&&!ee&&!ae,X=!!(f||C||k||F),_e;bb0:{if(!t||!Y){_e=null;break bb0}let n=S?.catalog?.length??0,r;if(e[16]!==ne||e[17]!==l?.payload?.config||e[18]!==o.browserDriverConfigured||e[19]!==o.chromiumInstalled||e[20]!==o.chromiumNotInstalled||e[21]!==o.extensionConnected||e[22]!==o.extensionNeedsRefresh||e[23]!==o.extensionNotConnected||e[24]!==o.extensionNotInstalled||e[25]!==o.gatewayNotInstalled||e[26]!==o.gatewayNotRunning||e[27]!==o.gatewayUnavailable||e[28]!==o.installCommand||e[29]!==o.labels||e[30]!==o.logsErrors||e[31]!==o.logsHealthy||e[32]!==o.logsShuttingDown||e[33]!==o.providerAuthMissing||e[34]!==o.runCommand||e[35]!==o.runtimeInvalid||e[36]!==o.runtimeMissing||e[37]!==o.startCommand||e[38]!==P||e[39]!==a.channelConfigured||e[40]!==a.channelMissing||e[41]!==a.gatewayOffline||e[42]!==a.gatewayOnline||e[43]!==a.modelConfigured||e[44]!==a.modelMissing||e[45]!==a.providersConfigured||e[46]!==a.providersMetaReady||e[47]!==a.providersMissing||e[48]!==a.skillsConfigured||e[49]!==a.skillsMissing||e[50]!==V||e[51]!==i.setupStatus.requiredCompleteMessage||e[52]!==O||e[53]!==c||e[54]!==n||e[55]!==t){let s=O?.filter(de).length??0,u=O?.length??0,d;e[57]===a.providersConfigured?d=e[58]:(d=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[57]=a.providersConfigured,e[58]=d);let f;e[59]===a.providersMetaReady?f=e[60]:(f=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[59]=a.providersMetaReady,e[60]=f);let p;e[61]===a.modelConfigured?p=e[62]:(p=e=>a.modelConfigured.replace(`{{model}}`,e),e[61]=a.modelConfigured,e[62]=p);let m;e[63]===a.skillsConfigured?m=e[64]:(m=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[63]=a.skillsConfigured,e[64]=m);let h;e[65]===o.runtimeMissing?h=e[66]:(h=e=>o.runtimeMissing.replace(`{{runtimes}}`,e),e[65]=o.runtimeMissing,e[66]=h);let g;e[67]===o.runtimeInvalid?g=e[68]:(g=e=>o.runtimeInvalid.replace(`{{runtimes}}`,e),e[67]=o.runtimeInvalid,e[68]=g);let _;e[69]===o.gatewayUnavailable?_=e[70]:(_=e=>o.gatewayUnavailable.replace(`{{detail}}`,e),e[69]=o.gatewayUnavailable,e[70]=_);let y;e[71]===o.gatewayNotRunning?y=e[72]:(y=e=>o.gatewayNotRunning.replace(`{{status}}`,e),e[71]=o.gatewayNotRunning,e[72]=y);let b;e[73]===o.runCommand?b=e[74]:(b=e=>o.runCommand.replace(`{{command}}`,e),e[73]=o.runCommand,e[74]=b);let x;e[75]===o.installCommand?x=e[76]:(x=e=>o.installCommand.replace(`{{command}}`,e),e[75]=o.installCommand,e[76]=x);let S;e[77]===o.startCommand?S=e[78]:(S=e=>o.startCommand.replace(`{{command}}`,e),e[77]=o.startCommand,e[78]=S);let C;e[79]===o.logsErrors?C=e[80]:(C=e=>o.logsErrors.replace(`{{count}}`,String(e)),e[79]=o.logsErrors,e[80]=C);let w;e[81]===o.browserDriverConfigured?w=e[82]:(w=e=>o.browserDriverConfigured.replace(`{{driver}}`,e),e[81]=o.browserDriverConfigured,e[82]=w),r=re({isElectron:v(),hasToken:!!t,realtimeConnected:c,config:l?.payload?.config,skillCount:n,providerMeta:u>0?{configured:s,total:u}:null,doctorChecks:P,logsHealth:V,browserDiagnostics:ne,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:d,providersMetaReady:f,providersMissing:a.providersMissing,modelConfigured:p,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:m,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage,diagnostics:{labels:o.labels,runtimeMissing:h,runtimeInvalid:g,gatewayNotInstalled:o.gatewayNotInstalled,gatewayUnavailable:_,gatewayNotRunning:y,providerAuthMissing:o.providerAuthMissing,runCommand:b,installCommand:x,startCommand:S,logsHealthy:o.logsHealthy,logsShuttingDown:o.logsShuttingDown,logsErrors:C,chromiumInstalled:o.chromiumInstalled,chromiumNotInstalled:o.chromiumNotInstalled,extensionConnected:o.extensionConnected,extensionNeedsRefresh:o.extensionNeedsRefresh,extensionNotConnected:o.extensionNotConnected,extensionNotInstalled:o.extensionNotInstalled,browserDriverConfigured:w}}}),e[16]=ne,e[17]=l?.payload?.config,e[18]=o.browserDriverConfigured,e[19]=o.chromiumInstalled,e[20]=o.chromiumNotInstalled,e[21]=o.extensionConnected,e[22]=o.extensionNeedsRefresh,e[23]=o.extensionNotConnected,e[24]=o.extensionNotInstalled,e[25]=o.gatewayNotInstalled,e[26]=o.gatewayNotRunning,e[27]=o.gatewayUnavailable,e[28]=o.installCommand,e[29]=o.labels,e[30]=o.logsErrors,e[31]=o.logsHealthy,e[32]=o.logsShuttingDown,e[33]=o.providerAuthMissing,e[34]=o.runCommand,e[35]=o.runtimeInvalid,e[36]=o.runtimeMissing,e[37]=o.startCommand,e[38]=P,e[39]=a.channelConfigured,e[40]=a.channelMissing,e[41]=a.gatewayOffline,e[42]=a.gatewayOnline,e[43]=a.modelConfigured,e[44]=a.modelMissing,e[45]=a.providersConfigured,e[46]=a.providersMetaReady,e[47]=a.providersMissing,e[48]=a.skillsConfigured,e[49]=a.skillsMissing,e[50]=V,e[51]=i.setupStatus.requiredCompleteMessage,e[52]=O,e[53]=c,e[54]=n,e[55]=t,e[56]=r}else r=e[56];_e=r}let Z=_e,Q;e[83]!==q||e[84]!==b||e[85]!==L||e[86]!==H||e[87]!==j||e[88]!==T?(Q=async()=>{await Promise.all([b(),T(),j(),L(),H(),q()])},e[83]=q,e[84]=b,e[85]=L,e[86]=H,e[87]=j,e[88]=T,e[89]=Q):Q=e[89];let ve=Q,$;return e[90]!==X||e[91]!==Y||e[92]!==ve||e[93]!==Z?($={ready:Y,error:X,snapshot:Z,refresh:ve},e[90]=X,e[91]=Y,e[92]=ve,e[93]=Z,e[94]=$):$=e[94],$}function de(e){return e.configured}function fe(e){let[,t]=e;return J(t)}function pe(){return T()}function me(e){return e.connectionState===`connected`}function he(e){return e.language}function ge(e){return e.conversationId}var X=r();function _e(e){return e===`pass`?`bg-success-soft text-success`:e===`warn`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`bg-red-500/10 text-red-700 dark:text-red-300`:`bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?a:e===`warn`?k:e===`fail`?w:O}function Q(e,t){return e===`blocked`?{icon:w,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:k,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:x,className:`bg-surface-hover/50 text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function ve(e){let t=(0,R.c)(46),{tier:n,issueCount:r,onRunDoctor:a,ready:l,doctorRunning:u,doctorRunState:f}=e,p=d($),m,h,g,_,v,y,x,S,w;if(t[0]!==r||t[1]!==p||t[2]!==n){h=s(p).setupStatus;let e=Q(n,h),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=o?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.scrollIntoView({block:`start`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):(0,X.jsxs)(i,{to:l,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}),w=c(`rounded-xl p-4`,e.className),S=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,y=`flex min-w-0 gap-3`,x=(0,X.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),g=`min-w-0`,_=(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),v=r>0?(0,X.jsx)(`p`,{className:`mt-1 text-sm opacity-80`,children:h.health.issueCount.replace(`{{count}}`,String(r))}):null,t[0]=r,t[1]=p,t[2]=n,t[3]=m,t[4]=h,t[5]=g,t[6]=_,t[7]=v,t[8]=y,t[9]=x,t[10]=S,t[11]=w}else m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],x=t[9],S=t[10],w=t[11];let T;t[12]!==g||t[13]!==_||t[14]!==v?(T=(0,X.jsxs)(`div`,{className:g,children:[_,v]}),t[12]=g,t[13]=_,t[14]=v,t[15]=T):T=t[15];let E;t[16]!==y||t[17]!==x||t[18]!==T?(E=(0,X.jsxs)(`div`,{className:y,children:[x,T]}),t[16]=y,t[17]=x,t[18]=T,t[19]=E):E=t[19];let O;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=c(`inline-flex items-center gap-2 rounded-lg bg-surface-base/70 px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,C.press),t[20]=O):O=t[20];let k=!l||u,A;t[21]===u?A=t[22]:(A=u?(0,X.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0}),t[21]=u,t[22]=A);let j=u?h.health.runDoctorRunning:h.health.runDoctor,M;t[23]!==u||t[24]!==a||t[25]!==k||t[26]!==A||t[27]!==j?(M=(0,X.jsxs)(`button`,{type:`button`,className:O,onClick:a,disabled:k,"aria-busy":u,children:[A,j]}),t[23]=u,t[24]=a,t[25]=k,t[26]=A,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==m||t[30]!==M?(N=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,M]}),t[29]=m,t[30]=M,t[31]=N):N=t[31];let P;t[32]!==N||t[33]!==S||t[34]!==E?(P=(0,X.jsxs)(`div`,{className:S,children:[E,N]}),t[32]=N,t[33]=S,t[34]=E,t[35]=P):P=t[35];let F;t[36]!==f||t[37]!==u||t[38]!==h.health.doctorCompleteMessage||t[39]!==h.health.doctorFailedMessage||t[40]!==h.health.doctorRunningMessage?(F=u||f!==`idle`?(0,X.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:u?h.health.doctorRunningMessage:f===`success`?h.health.doctorCompleteMessage:h.health.doctorFailedMessage}):null,t[36]=f,t[37]=u,t[38]=h.health.doctorCompleteMessage,t[39]=h.health.doctorFailedMessage,t[40]=h.health.doctorRunningMessage,t[41]=F):F=t[41];let I;return t[42]!==P||t[43]!==F||t[44]!==w?(I=(0,X.jsxs)(`section`,{className:w,children:[P,F]}),t[42]=P,t[43]=F,t[44]=w,t[45]=I):I=t[45],I}function $(e){return e.language}function ye(e){let t=(0,R.c)(26),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]===n.hints[0]?u=t[9]:(u=n.hints[0]?(0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[8]=n.hints[0],t[9]=u);let d;t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l,u]}),t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==r||t[15]!==n.path?(f=n.path?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):null,t[14]=r,t[15]=n.path,t[16]=f):f=t[16];let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,X.jsxs)(X.Fragment,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m=p;if(n.path){let e;return t[21]!==m||t[22]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-start gap-3 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m}),t[21]=m,t[22]=n.path,t[23]=e):e=t[23],e}let h;return t[24]===m?h=t[25]:(h=(0,X.jsx)(`div`,{className:`flex items-start gap-3 px-1 py-3`,children:m}),t[24]=m,t[25]=h),h}function be(e){let t=(0,R.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=c(`flex size-7 shrink-0 items-center justify-center rounded-full`,_e(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===o?u=t[5]:(u=(0,X.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,X.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===s?f=t[10]:(f=(0,X.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,X.jsx)(D,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,X.jsxs)(X.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,X.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function xe(e){let t=(0,R.c)(23),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==r||t[12]!==n.path?(d=n.path?(0,X.jsx)(`span`,{className:`sr-only`,children:r}):null,t[11]=r,t[12]=n.path,t[13]=d):d=t[13];let f;t[14]!==s||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(X.Fragment,{children:[s,u,d]}),t[14]=s,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p=f;if(n.path){let e;return t[18]!==p||t[19]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:p}),t[18]=p,t[19]=n.path,t[20]=e):e=t[20],e}let m;return t[21]===p?m=t[22]:(m=(0,X.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 px-1 py-3`,children:p}),t[21]=p,t[22]=m),m}function Se(){let e=s(d(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=Y(),[a,o]=(0,L.useState)(!1),[c,l]=(0,L.useState)(`idle`),u=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],f=async()=>{if(!(a||!t)){o(!0),l(`idle`);try{await i(),l(`success`)}catch{l(`error`)}finally{o(!1)}}};return(0,X.jsxs)(M,{gap:`gap-6`,children:[(0,X.jsx)(j,{title:e.title}),n?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,X.jsx)(F,{sections:2}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ve,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void f(),doctorRunning:a,doctorRunState:c}),(0,X.jsxs)(P,{id:`next-steps`,children:[(0,X.jsx)(N,{icon:r.issues.length?k:A,title:e.nextStepsTitle}),r.issues.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:r.issues.slice(0,8).map(t=>(0,X.jsx)(ye,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:bg-surface-base/45`,children:r.readiness.map(t=>(0,X.jsx)(be,{item:t,labels:e.readinessLabels},t.id))})]}),(0,X.jsx)(I,{children:(0,X.jsxs)(P,{children:[(0,X.jsx)(N,{icon:y,title:e.diagnosticsTitle}),u.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:u.map(t=>(0,X.jsx)(xe,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,X.jsx)(`p`,{className:`mt-3 py-2 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})})]})]})}export{Se as SetupStatusPanel};
|
|
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-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-sXePe3LQ.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,n as d,r as f}from"./locale-store-WMaCMm3_.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-CmjHbMj7.js";import{n as h}from"./gateway-realtime-store-KyhksZSM.js";import{n as g,t as _}from"./registry-api-DEePN1Rc.js";import{n as v}from"./electron-env-Dit0bHgy.js";import{Dc as y,Jc as b,Mu as x,No as S,Ns as C,Nu as w,Ri as T,Ut as E,Vu as D,Wl as O,_c as k,ud as A}from"./index-Bb32g7Ll.js";import{n as j,r as M}from"./settings-page-layout-X1x-2Cp9.js";import{n as N,t as P}from"./settings-form-section-BwdrtX6k.js";import{n as F}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as I}from"./settings-advanced-gate-C4y4c2M7.js";var L=e(t(),1),R=n();function z(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&S(e)).length}function B(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function V(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function ee(e){if(!e||typeof e!=`object`)return{enabled:!1,driverKind:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,driverKind:`extension`};let n=t,r=n.driver&&typeof n.driver==`object`&&!Array.isArray(n.driver)?n.driver:void 0;return{enabled:n.enabled===!0,driverKind:typeof r?.kind==`string`&&r.kind.trim()?r.kind.trim():`extension`}}function H(e){return e?`pass`:`fail`}function U(e){if(e===`tool-runtimes`)return`/settings/runtimes`;if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/capabilities/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/capabilities/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function W(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(e,t){let n=e.match(/^Run(?::|\s)(.*)$/i);if(n?.[1])return t.runCommand(n[1].trim());let r=e.match(/^Install(?::|\s)(.*)$/i);if(r?.[1])return t.installCommand(r[1].trim());let i=e.match(/^Start(?::|\s)(.*)$/i);return i?.[1]?t.startCommand(i[1].trim()):e}function G(e,t){if(!t)return e;let n=e.message;if(e.id===`tool-runtimes`){let r=e.message.match(/^(.*) runtime is not installed\.$/),i=e.message.match(/^(.*) runtime installation is invalid\.$/);r?.[1]?n=t.runtimeMissing(r[1]):i?.[1]&&(n=t.runtimeInvalid(i[1]))}else if(e.id===`gateway-service`)if(e.message===`Gateway is not installed as a system service.`)n=t.gatewayNotInstalled;else{let r=e.message.match(/^Service backend unavailable: (.*)$/),i=e.message.match(/^Gateway service is installed but not running \(status: (.*)\)\.$/);r?.[1]?n=t.gatewayUnavailable(r[1]):i?.[1]&&(n=t.gatewayNotRunning(i[1]))}else e.id===`provider-auth`&&e.message===`No API keys detected for configured providers.`&&(n=t.providerAuthMissing);return{...e,label:t.labels[e.id]??e.label,message:n,hints:e.hints.map(e=>te(e,t))}}function K(e,t){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>{let n=G(e,t);return{id:n.id,label:n.label,status:n.status,message:n.message,hints:n.hints,path:U(n.id),source:`doctor`}}).toSorted((e,t)=>W(t.status)-W(e.status)||e.label.localeCompare(t.label))}function ne(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let r of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let i=t.get(r);if(i){let t=G(i,e.copy);n.push({id:t.id,label:t.label,status:t.status,message:t.message,path:U(t.id)})}}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:e.copy?.labels[`logs-health`]??`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.copy?e.logsHealth.shuttingDown?e.copy.logsShuttingDown:t>0?e.copy.logsErrors(t):e.copy.logsHealthy:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[]){let r=t.message;if(e.copy){r={"Local Chromium is installed.":e.copy.chromiumInstalled,"Local Chromium is not installed.":e.copy.chromiumNotInstalled,"Chrome extension bridge is connected.":e.copy.extensionConnected,"Chrome extension needs refresh.":e.copy.extensionNeedsRefresh,"Chrome extension is installed but not connected.":e.copy.extensionNotConnected,"Chrome extension is not installed.":e.copy.extensionNotInstalled}[t.message]??t.message;let n=t.message.match(/^Browser driver "(.*)" is configured\.$/);n?.[1]&&(r=e.copy.browserDriverConfigured(n[1]))}n.push({...t,label:e.copy?.labels[t.id]??t.label,message:r})}return n}function re(e){let t=z(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=B(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=V(e.config),l=e.skillCount>0,u=(e.doctorChecks??[]).filter(t=>!e.isElectron||t.id!==`gateway-service`),d=K(u,e.labels.diagnostics),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:H(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:H(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:H(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=ne({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics,copy:e.labels.diagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function ie(e){return ee(e)}function ae(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function oe(){return f(`/api/doctor`)}async function se(){return((await l(oe())).checks??[]).map(ae).filter(e=>e!==null)}function ce(){return f(`/api/logs/health`)}async function le(){return l(ce())}function q(e){return e?`pass`:`warn`}function ue(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function J(e){if(!e.enabled)return[];if(e.driverKind===`playwright`){let e=await l(f(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:q(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser`}]}if(e.driverKind===`extension`){let e=await l(f(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser driver "${e.driverKind}" is configured.`,path:`/settings/agent-browser`}]}function Y(){let e=(0,R.c)(95),t=u(ge),n=d(he),r;e[0]===n?r=e[1]:(r=s(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=i.setupStatus.diagnostics,c=h(me),{data:l,error:f,isLoading:y,mutate:b}=m(!!t),x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!1},e[2]=x):x=e[2];let{data:S,error:C,isLoading:w,mutate:T}=p(t?`setup-checklist-skills`:null,pe,x),D;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(D={revalidateOnFocus:!1},e[3]=D):D=e[3];let{data:O,error:k,isLoading:A,mutate:j}=p(t?`setup-checklist-provider-meta`:null,E,D),M;e[4]===t?M=e[5]:(M=t?oe():null,e[4]=t,e[5]=M);let N;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(N={revalidateOnFocus:!1},e[6]=N):N=e[6];let{data:P,error:F,isLoading:I,mutate:L}=p(M,se,N),z;e[7]===t?z=e[8]:(z=t?ce():null,e[7]=t,e[8]=z);let B;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(B={revalidateOnFocus:!1},e[9]=B):B=e[9];let{data:V,isLoading:ee,mutate:H}=p(z,le,B);l?.payload?.config;let U=l?.payload?.config,W;e[10]===U?W=e[11]:(W=ie(U),e[10]=U,e[11]=W);let te=t?W:null,G;e[12]===te?G=e[13]:(G=ue(te),e[12]=te,e[13]=G);let K;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(K={revalidateOnFocus:!1},e[14]=K):K=e[14];let{data:ne,isLoading:ae,mutate:q}=p(G,fe,K),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?_:null,g,J);let Y=!t||!y&&!w&&!A&&!I&&!ee&&!ae,X=!!(f||C||k||F),_e;bb0:{if(!t||!Y){_e=null;break bb0}let n=S?.catalog?.length??0,r;if(e[16]!==ne||e[17]!==l?.payload?.config||e[18]!==o.browserDriverConfigured||e[19]!==o.chromiumInstalled||e[20]!==o.chromiumNotInstalled||e[21]!==o.extensionConnected||e[22]!==o.extensionNeedsRefresh||e[23]!==o.extensionNotConnected||e[24]!==o.extensionNotInstalled||e[25]!==o.gatewayNotInstalled||e[26]!==o.gatewayNotRunning||e[27]!==o.gatewayUnavailable||e[28]!==o.installCommand||e[29]!==o.labels||e[30]!==o.logsErrors||e[31]!==o.logsHealthy||e[32]!==o.logsShuttingDown||e[33]!==o.providerAuthMissing||e[34]!==o.runCommand||e[35]!==o.runtimeInvalid||e[36]!==o.runtimeMissing||e[37]!==o.startCommand||e[38]!==P||e[39]!==a.channelConfigured||e[40]!==a.channelMissing||e[41]!==a.gatewayOffline||e[42]!==a.gatewayOnline||e[43]!==a.modelConfigured||e[44]!==a.modelMissing||e[45]!==a.providersConfigured||e[46]!==a.providersMetaReady||e[47]!==a.providersMissing||e[48]!==a.skillsConfigured||e[49]!==a.skillsMissing||e[50]!==V||e[51]!==i.setupStatus.requiredCompleteMessage||e[52]!==O||e[53]!==c||e[54]!==n||e[55]!==t){let s=O?.filter(de).length??0,u=O?.length??0,d;e[57]===a.providersConfigured?d=e[58]:(d=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[57]=a.providersConfigured,e[58]=d);let f;e[59]===a.providersMetaReady?f=e[60]:(f=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[59]=a.providersMetaReady,e[60]=f);let p;e[61]===a.modelConfigured?p=e[62]:(p=e=>a.modelConfigured.replace(`{{model}}`,e),e[61]=a.modelConfigured,e[62]=p);let m;e[63]===a.skillsConfigured?m=e[64]:(m=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[63]=a.skillsConfigured,e[64]=m);let h;e[65]===o.runtimeMissing?h=e[66]:(h=e=>o.runtimeMissing.replace(`{{runtimes}}`,e),e[65]=o.runtimeMissing,e[66]=h);let g;e[67]===o.runtimeInvalid?g=e[68]:(g=e=>o.runtimeInvalid.replace(`{{runtimes}}`,e),e[67]=o.runtimeInvalid,e[68]=g);let _;e[69]===o.gatewayUnavailable?_=e[70]:(_=e=>o.gatewayUnavailable.replace(`{{detail}}`,e),e[69]=o.gatewayUnavailable,e[70]=_);let y;e[71]===o.gatewayNotRunning?y=e[72]:(y=e=>o.gatewayNotRunning.replace(`{{status}}`,e),e[71]=o.gatewayNotRunning,e[72]=y);let b;e[73]===o.runCommand?b=e[74]:(b=e=>o.runCommand.replace(`{{command}}`,e),e[73]=o.runCommand,e[74]=b);let x;e[75]===o.installCommand?x=e[76]:(x=e=>o.installCommand.replace(`{{command}}`,e),e[75]=o.installCommand,e[76]=x);let S;e[77]===o.startCommand?S=e[78]:(S=e=>o.startCommand.replace(`{{command}}`,e),e[77]=o.startCommand,e[78]=S);let C;e[79]===o.logsErrors?C=e[80]:(C=e=>o.logsErrors.replace(`{{count}}`,String(e)),e[79]=o.logsErrors,e[80]=C);let w;e[81]===o.browserDriverConfigured?w=e[82]:(w=e=>o.browserDriverConfigured.replace(`{{driver}}`,e),e[81]=o.browserDriverConfigured,e[82]=w),r=re({isElectron:v(),hasToken:!!t,realtimeConnected:c,config:l?.payload?.config,skillCount:n,providerMeta:u>0?{configured:s,total:u}:null,doctorChecks:P,logsHealth:V,browserDiagnostics:ne,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:d,providersMetaReady:f,providersMissing:a.providersMissing,modelConfigured:p,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:m,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage,diagnostics:{labels:o.labels,runtimeMissing:h,runtimeInvalid:g,gatewayNotInstalled:o.gatewayNotInstalled,gatewayUnavailable:_,gatewayNotRunning:y,providerAuthMissing:o.providerAuthMissing,runCommand:b,installCommand:x,startCommand:S,logsHealthy:o.logsHealthy,logsShuttingDown:o.logsShuttingDown,logsErrors:C,chromiumInstalled:o.chromiumInstalled,chromiumNotInstalled:o.chromiumNotInstalled,extensionConnected:o.extensionConnected,extensionNeedsRefresh:o.extensionNeedsRefresh,extensionNotConnected:o.extensionNotConnected,extensionNotInstalled:o.extensionNotInstalled,browserDriverConfigured:w}}}),e[16]=ne,e[17]=l?.payload?.config,e[18]=o.browserDriverConfigured,e[19]=o.chromiumInstalled,e[20]=o.chromiumNotInstalled,e[21]=o.extensionConnected,e[22]=o.extensionNeedsRefresh,e[23]=o.extensionNotConnected,e[24]=o.extensionNotInstalled,e[25]=o.gatewayNotInstalled,e[26]=o.gatewayNotRunning,e[27]=o.gatewayUnavailable,e[28]=o.installCommand,e[29]=o.labels,e[30]=o.logsErrors,e[31]=o.logsHealthy,e[32]=o.logsShuttingDown,e[33]=o.providerAuthMissing,e[34]=o.runCommand,e[35]=o.runtimeInvalid,e[36]=o.runtimeMissing,e[37]=o.startCommand,e[38]=P,e[39]=a.channelConfigured,e[40]=a.channelMissing,e[41]=a.gatewayOffline,e[42]=a.gatewayOnline,e[43]=a.modelConfigured,e[44]=a.modelMissing,e[45]=a.providersConfigured,e[46]=a.providersMetaReady,e[47]=a.providersMissing,e[48]=a.skillsConfigured,e[49]=a.skillsMissing,e[50]=V,e[51]=i.setupStatus.requiredCompleteMessage,e[52]=O,e[53]=c,e[54]=n,e[55]=t,e[56]=r}else r=e[56];_e=r}let Z=_e,Q;e[83]!==q||e[84]!==b||e[85]!==L||e[86]!==H||e[87]!==j||e[88]!==T?(Q=async()=>{await Promise.all([b(),T(),j(),L(),H(),q()])},e[83]=q,e[84]=b,e[85]=L,e[86]=H,e[87]=j,e[88]=T,e[89]=Q):Q=e[89];let ve=Q,$;return e[90]!==X||e[91]!==Y||e[92]!==ve||e[93]!==Z?($={ready:Y,error:X,snapshot:Z,refresh:ve},e[90]=X,e[91]=Y,e[92]=ve,e[93]=Z,e[94]=$):$=e[94],$}function de(e){return e.configured}function fe(e){let[,t]=e;return J(t)}function pe(){return T()}function me(e){return e.connectionState===`connected`}function he(e){return e.language}function ge(e){return e.conversationId}var X=r();function _e(e){return e===`pass`?`bg-success-soft text-success`:e===`warn`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`bg-red-500/10 text-red-700 dark:text-red-300`:`bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?a:e===`warn`?k:e===`fail`?w:O}function Q(e,t){return e===`blocked`?{icon:w,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:k,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:x,className:`bg-surface-hover/50 text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function ve(e){let t=(0,R.c)(46),{tier:n,issueCount:r,onRunDoctor:a,ready:l,doctorRunning:u,doctorRunState:f}=e,p=d($),m,h,g,_,v,y,x,S,w;if(t[0]!==r||t[1]!==p||t[2]!==n){h=s(p).setupStatus;let e=Q(n,h),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=o?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.scrollIntoView({block:`start`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):(0,X.jsxs)(i,{to:l,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}),w=c(`rounded-xl p-4`,e.className),S=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,y=`flex min-w-0 gap-3`,x=(0,X.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),g=`min-w-0`,_=(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),v=r>0?(0,X.jsx)(`p`,{className:`mt-1 text-sm opacity-80`,children:h.health.issueCount.replace(`{{count}}`,String(r))}):null,t[0]=r,t[1]=p,t[2]=n,t[3]=m,t[4]=h,t[5]=g,t[6]=_,t[7]=v,t[8]=y,t[9]=x,t[10]=S,t[11]=w}else m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],x=t[9],S=t[10],w=t[11];let T;t[12]!==g||t[13]!==_||t[14]!==v?(T=(0,X.jsxs)(`div`,{className:g,children:[_,v]}),t[12]=g,t[13]=_,t[14]=v,t[15]=T):T=t[15];let E;t[16]!==y||t[17]!==x||t[18]!==T?(E=(0,X.jsxs)(`div`,{className:y,children:[x,T]}),t[16]=y,t[17]=x,t[18]=T,t[19]=E):E=t[19];let O;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=c(`inline-flex items-center gap-2 rounded-lg bg-surface-base/70 px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,C.press),t[20]=O):O=t[20];let k=!l||u,A;t[21]===u?A=t[22]:(A=u?(0,X.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(b,{className:`size-4`,"aria-hidden":!0}),t[21]=u,t[22]=A);let j=u?h.health.runDoctorRunning:h.health.runDoctor,M;t[23]!==u||t[24]!==a||t[25]!==k||t[26]!==A||t[27]!==j?(M=(0,X.jsxs)(`button`,{type:`button`,className:O,onClick:a,disabled:k,"aria-busy":u,children:[A,j]}),t[23]=u,t[24]=a,t[25]=k,t[26]=A,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==m||t[30]!==M?(N=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,M]}),t[29]=m,t[30]=M,t[31]=N):N=t[31];let P;t[32]!==N||t[33]!==S||t[34]!==E?(P=(0,X.jsxs)(`div`,{className:S,children:[E,N]}),t[32]=N,t[33]=S,t[34]=E,t[35]=P):P=t[35];let F;t[36]!==f||t[37]!==u||t[38]!==h.health.doctorCompleteMessage||t[39]!==h.health.doctorFailedMessage||t[40]!==h.health.doctorRunningMessage?(F=u||f!==`idle`?(0,X.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:u?h.health.doctorRunningMessage:f===`success`?h.health.doctorCompleteMessage:h.health.doctorFailedMessage}):null,t[36]=f,t[37]=u,t[38]=h.health.doctorCompleteMessage,t[39]=h.health.doctorFailedMessage,t[40]=h.health.doctorRunningMessage,t[41]=F):F=t[41];let I;return t[42]!==P||t[43]!==F||t[44]!==w?(I=(0,X.jsxs)(`section`,{className:w,children:[P,F]}),t[42]=P,t[43]=F,t[44]=w,t[45]=I):I=t[45],I}function $(e){return e.language}function ye(e){let t=(0,R.c)(26),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]===n.hints[0]?u=t[9]:(u=n.hints[0]?(0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[8]=n.hints[0],t[9]=u);let d;t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l,u]}),t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==r||t[15]!==n.path?(f=n.path?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,X.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):null,t[14]=r,t[15]=n.path,t[16]=f):f=t[16];let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,X.jsxs)(X.Fragment,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m=p;if(n.path){let e;return t[21]!==m||t[22]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-start gap-3 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m}),t[21]=m,t[22]=n.path,t[23]=e):e=t[23],e}let h;return t[24]===m?h=t[25]:(h=(0,X.jsx)(`div`,{className:`flex items-start gap-3 px-1 py-3`,children:m}),t[24]=m,t[25]=h),h}function be(e){let t=(0,R.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=c(`flex size-7 shrink-0 items-center justify-center rounded-full`,_e(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===o?u=t[5]:(u=(0,X.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,X.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===s?f=t[10]:(f=(0,X.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,X.jsx)(D,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,X.jsxs)(X.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,X.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function xe(e){let t=(0,R.c)(23),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==r||t[12]!==n.path?(d=n.path?(0,X.jsx)(`span`,{className:`sr-only`,children:r}):null,t[11]=r,t[12]=n.path,t[13]=d):d=t[13];let f;t[14]!==s||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(X.Fragment,{children:[s,u,d]}),t[14]=s,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p=f;if(n.path){let e;return t[18]!==p||t[19]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:p}),t[18]=p,t[19]=n.path,t[20]=e):e=t[20],e}let m;return t[21]===p?m=t[22]:(m=(0,X.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 px-1 py-3`,children:p}),t[21]=p,t[22]=m),m}function Se(){let e=s(d(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=Y(),[a,o]=(0,L.useState)(!1),[c,l]=(0,L.useState)(`idle`),u=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],f=async()=>{if(!(a||!t)){o(!0),l(`idle`);try{await i(),l(`success`)}catch{l(`error`)}finally{o(!1)}}};return(0,X.jsxs)(M,{gap:`gap-6`,children:[(0,X.jsx)(j,{title:e.title}),n?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,X.jsx)(F,{sections:2}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ve,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void f(),doctorRunning:a,doctorRunState:c}),(0,X.jsxs)(P,{id:`next-steps`,children:[(0,X.jsx)(N,{icon:r.issues.length?k:A,title:e.nextStepsTitle}),r.issues.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:r.issues.slice(0,8).map(t=>(0,X.jsx)(ye,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:bg-surface-base/45`,children:r.readiness.map(t=>(0,X.jsx)(be,{item:t,labels:e.readinessLabels},t.id))})]}),(0,X.jsx)(I,{children:(0,X.jsxs)(P,{children:[(0,X.jsx)(N,{icon:y,title:e.diagnosticsTitle}),u.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:u.map(t=>(0,X.jsx)(xe,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,X.jsx)(`p`,{className:`mt-3 py-2 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})})]})]})}export{Se as SetupStatusPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-Db4nTY5N.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/pdf-runtime-DU_sMPjG.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{m as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./markdown-view-Oe4rXk1N.js";import{t as s}from"./messages-sXePe3LQ.js";import{t as c}from"./cn-JdwAhgNB.js";import{n as l,r as u}from"./locale-store-WMaCMm3_.js";import{t as d}from"./copy-to-clipboard-HOJ79TWv.js";import{t as f}from"./attachment-utils-core-BIOUBrpT.js";import{t as p}from"./skeleton-BwbyijEw.js";import{Fi as m,Ii as h,ga as g,ha as _,pa as v,qo as y}from"./index-Z6i4GDcT.js";var b=e(t(),1),x=n(),S=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,C=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,w=/!\[([^\]]*)\]\[([^\]]+)\]/g;function T(e,t){let n=new Map;for(let t of e.matchAll(S))n.set(E(t[1]??``),t[2]??``);return e.replace(C,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(w,(e,r,i)=>{let a=n.get(E(i));return a?`[${r.trim()||t}](${a})`:e})}function E(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var D=r();function O(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function k(e){let t=(0,x.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:o,setExpanded:l}=m(),u=s(a.language),f;t[0]===u?f=t[1]:(f=async()=>{let e=await d(window.location.href);y(e?`success`:`warning`,e?u.sharesSettings.copied:u.clipboard.copyFailed)},t[0]=u,t[1]=f);let p=f,g=o&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,_;t[2]===g?_=t[3]:(_=c(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,g),t[2]=g,t[3]=_);let v;t[4]!==l||t[5]!==a.loadError||t[6]!==a.loading?(v=!a.loading&&!a.loadError?()=>l(A):void 0,t[4]=l,t[5]=a.loadError,t[6]=a.loading,t[7]=v):v=t[7];let b;t[8]===i?b=t[9]:(b=()=>window.location.assign(i),t[8]=i,t[9]=b);let S;t[10]===p?S=t[11]:(S=()=>void p(),t[10]=p,t[11]=S);let C=a.loading||!!a.loadError,w;t[12]!==S||t[13]!==C?(w={onClick:S,disabled:C},t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==o||t[18]!==n||t[19]!==v||t[20]!==b||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:o,onToggleExpanded:v,onClose:b,share:w,openInBrowser:T},t[17]=o,t[18]=n,t[19]=v,t[20]=b,t[21]=w,t[22]=T,t[23]=E):E=t[23];let O;t[24]!==a||t[25]!==E?(O=(0,D.jsx)(h,{...a,header:E}),t[24]=a,t[25]=E,t[26]=O):O=t[26];let k;return t[27]!==O||t[28]!==_?(k=(0,D.jsx)(`div`,{className:_,children:O}),t[27]=O,t[28]=_,t[29]=k):k=t[29],k}function A(e){return!e}function j(){let{token:e}=a(),t=l(e=>e.language),n=t===`zh`?P:F,[r,s]=(0,b.useState)(null),[c,d]=(0,b.useState)(O),[m,h]=(0,b.useState)(!0),[y,x]=(0,b.useState)(null),[S,C]=(0,b.useState)(null),[w,E]=(0,b.useState)(null),A=(0,b.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=_(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:v(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,b.useEffect)(()=>{if(!e){x(n.invalidLink),h(!1);return}let t=!1;return(async()=>{try{h(!0),x(null),d(O()),C(null),E(null);let r=await fetch(u(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||x(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(s(a),!a.valid){x(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(u(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){x(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&C(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let o=_(a.fileName,a.mimeType),c=v(a.fileName,o),l=g(c),p=u(`/s/${encodeURIComponent(e)}?inline=1`);if(l===`text`){if(a.fileSize>5242880){x(n.tooLarge);return}let e=await fetch(p);if(!e.ok){x(n.expired);return}let r=await e.text();t||d({...O(),textContent:r});return}if(l===`binary`){if(a.fileSize>33554432){x(n.tooLarge);return}let e=await fetch(p);if(!e.ok){x(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-Db4nTY5N.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>f;d({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,f):t,extractedTextTruncated:n});return}d({...O(),binaryBuffer:r})}}catch(e){t||x(e instanceof Error?e.message:String(e))}finally{t||h(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let j=e?u(`/s/${encodeURIComponent(e)}?dl=1`):`#`,I=e?u(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return A&&r&&e?(0,D.jsx)(k,{language:t,descriptor:A,loading:m,loadError:y,textContent:c.textContent,binaryBuffer:c.binaryBuffer,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,subtitle:(0,D.jsxs)(`span`,{className:`truncate`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:I,landingUrl:u(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=j},canDownload:!m&&!y}}):(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,D.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,D.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):m?(0,D.jsx)(p,{className:`h-4 w-48 max-w-full`}):(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,D.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,D.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:m?(0,D.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,D.jsx)(p,{className:`h-5 w-56 max-w-full`}),(0,D.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,D.jsx)(p,{className:`h-4 w-full`}),(0,D.jsx)(p,{className:`h-4 w-11/12`}),(0,D.jsx)(p,{className:`h-4 w-10/12`}),(0,D.jsx)(p,{className:`h-4 w-3/4`})]}),(0,D.jsx)(p,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):y?(0,D.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,D.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,D.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:y})]}):r?.kind===`directory`?(0,D.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&S?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,D.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:S.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(S.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(S.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),S.description?(0,D.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-inset px-4 py-3 text-sm leading-6 text-fg-muted`,children:S.description}):null,(0,D.jsx)(o,{content:T(S.markdown,n.remoteImageBlocked),className:`mt-8`}),(0,D.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&w?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,D.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:w.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(w.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(w.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),w.description?(0,D.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:w.description}):null]}),(0,D.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[w.messages.map(e=>(0,D.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,D.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,D.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-inset px-4 py-3`:`px-1 py-1`,children:[(0,D.jsx)(o,{content:T(e.markdown,n.remoteImageBlocked)}),w.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,D.jsx)(M,{attachment:e},e.id)),w.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,D.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e.toolName}),(0,D.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,D.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),w.toolActivities.filter(e=>!e.messageId).map(e=>(0,D.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,D.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})}function M(e){let t=(0,x.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,D.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,D.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=N(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,D.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,D.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function N(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var P={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},F={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{j as SharePreviewPage};
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{m as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./markdown-view-Oe4rXk1N.js";import{t as s}from"./messages-sXePe3LQ.js";import{t as c}from"./cn-JdwAhgNB.js";import{n as l,r as u}from"./locale-store-WMaCMm3_.js";import{t as d}from"./copy-to-clipboard-HOJ79TWv.js";import{t as f}from"./attachment-utils-core-BIOUBrpT.js";import{t as p}from"./skeleton-BwbyijEw.js";import{Fi as m,Ii as h,ga as g,ha as _,pa as v,qo as y}from"./index-Bb32g7Ll.js";var b=e(t(),1),x=n(),S=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,C=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,w=/!\[([^\]]*)\]\[([^\]]+)\]/g;function T(e,t){let n=new Map;for(let t of e.matchAll(S))n.set(E(t[1]??``),t[2]??``);return e.replace(C,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(w,(e,r,i)=>{let a=n.get(E(i));return a?`[${r.trim()||t}](${a})`:e})}function E(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var D=r();function O(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function k(e){let t=(0,x.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:o,setExpanded:l}=m(),u=s(a.language),f;t[0]===u?f=t[1]:(f=async()=>{let e=await d(window.location.href);y(e?`success`:`warning`,e?u.sharesSettings.copied:u.clipboard.copyFailed)},t[0]=u,t[1]=f);let p=f,g=o&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,_;t[2]===g?_=t[3]:(_=c(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,g),t[2]=g,t[3]=_);let v;t[4]!==l||t[5]!==a.loadError||t[6]!==a.loading?(v=!a.loading&&!a.loadError?()=>l(A):void 0,t[4]=l,t[5]=a.loadError,t[6]=a.loading,t[7]=v):v=t[7];let b;t[8]===i?b=t[9]:(b=()=>window.location.assign(i),t[8]=i,t[9]=b);let S;t[10]===p?S=t[11]:(S=()=>void p(),t[10]=p,t[11]=S);let C=a.loading||!!a.loadError,w;t[12]!==S||t[13]!==C?(w={onClick:S,disabled:C},t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==o||t[18]!==n||t[19]!==v||t[20]!==b||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:o,onToggleExpanded:v,onClose:b,share:w,openInBrowser:T},t[17]=o,t[18]=n,t[19]=v,t[20]=b,t[21]=w,t[22]=T,t[23]=E):E=t[23];let O;t[24]!==a||t[25]!==E?(O=(0,D.jsx)(h,{...a,header:E}),t[24]=a,t[25]=E,t[26]=O):O=t[26];let k;return t[27]!==O||t[28]!==_?(k=(0,D.jsx)(`div`,{className:_,children:O}),t[27]=O,t[28]=_,t[29]=k):k=t[29],k}function A(e){return!e}function j(){let{token:e}=a(),t=l(e=>e.language),n=t===`zh`?P:F,[r,s]=(0,b.useState)(null),[c,d]=(0,b.useState)(O),[m,h]=(0,b.useState)(!0),[y,x]=(0,b.useState)(null),[S,C]=(0,b.useState)(null),[w,E]=(0,b.useState)(null),A=(0,b.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=_(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:v(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,b.useEffect)(()=>{if(!e){x(n.invalidLink),h(!1);return}let t=!1;return(async()=>{try{h(!0),x(null),d(O()),C(null),E(null);let r=await fetch(u(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||x(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(s(a),!a.valid){x(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(u(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){x(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&C(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let o=_(a.fileName,a.mimeType),c=v(a.fileName,o),l=g(c),p=u(`/s/${encodeURIComponent(e)}?inline=1`);if(l===`text`){if(a.fileSize>5242880){x(n.tooLarge);return}let e=await fetch(p);if(!e.ok){x(n.expired);return}let r=await e.text();t||d({...O(),textContent:r});return}if(l===`binary`){if(a.fileSize>33554432){x(n.tooLarge);return}let e=await fetch(p);if(!e.ok){x(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-Db4nTY5N.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>f;d({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,f):t,extractedTextTruncated:n});return}d({...O(),binaryBuffer:r})}}catch(e){t||x(e instanceof Error?e.message:String(e))}finally{t||h(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let j=e?u(`/s/${encodeURIComponent(e)}?dl=1`):`#`,I=e?u(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return A&&r&&e?(0,D.jsx)(k,{language:t,descriptor:A,loading:m,loadError:y,textContent:c.textContent,binaryBuffer:c.binaryBuffer,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,subtitle:(0,D.jsxs)(`span`,{className:`truncate`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:I,landingUrl:u(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=j},canDownload:!m&&!y}}):(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,D.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,D.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):m?(0,D.jsx)(p,{className:`h-4 w-48 max-w-full`}):(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,D.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,D.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:m?(0,D.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,D.jsx)(p,{className:`h-5 w-56 max-w-full`}),(0,D.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,D.jsx)(p,{className:`h-4 w-full`}),(0,D.jsx)(p,{className:`h-4 w-11/12`}),(0,D.jsx)(p,{className:`h-4 w-10/12`}),(0,D.jsx)(p,{className:`h-4 w-3/4`})]}),(0,D.jsx)(p,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):y?(0,D.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,D.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,D.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:y})]}):r?.kind===`directory`?(0,D.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&S?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,D.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:S.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(S.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(S.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),S.description?(0,D.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-inset px-4 py-3 text-sm leading-6 text-fg-muted`,children:S.description}):null,(0,D.jsx)(o,{content:T(S.markdown,n.remoteImageBlocked),className:`mt-8`}),(0,D.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&w?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,D.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:w.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(w.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(w.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),w.description?(0,D.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:w.description}):null]}),(0,D.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[w.messages.map(e=>(0,D.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,D.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,D.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-inset px-4 py-3`:`px-1 py-1`,children:[(0,D.jsx)(o,{content:T(e.markdown,n.remoteImageBlocked)}),w.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,D.jsx)(M,{attachment:e},e.id)),w.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,D.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e.toolName}),(0,D.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,D.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),w.toolActivities.filter(e=>!e.messageId).map(e=>(0,D.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,D.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})}function M(e){let t=(0,x.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,D.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,D.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=N(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,D.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,D.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function N(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var P={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},F={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{j as SharePreviewPage};
|