@xopcai/xopc 0.0.177 → 0.0.178

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-Wu2ikfbM.js → activity-store-BzGX__8I.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B0_biISn.js → agent-avatar-dicebear-BzxntcaZ.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-TpIpJk59.js → agents-DC9F12Kw.js} +1 -1
  6. package/dist/gateway/static/root/assets/{api-DljBt-N5.js → api-hi6f2Xtp.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CKoZRi7Y.js → app-management-settings-panel-fTY1F7ac.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-DOdXhNDo.js → appearance-settings-BZ-IxQfB.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-Cxbn5hy8.js → apps-page-5bKr05Fa.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-D18gyP76.js → archive-plugin-ZSLLG8wB.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-CZh9fc8u.js → attachment-load-D4YktqIF.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-DKrVoiiK.js → automation-suggestion-card-B7mxFRtf.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-DYv16QMU.js → automations-page-Dg6dmt5g.js} +1 -1
  14. package/dist/gateway/static/root/assets/{binary-plugins-DdSyGL6M.js → binary-plugins-BIkPxfxj.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-BOpNApiX.js → block-editor-Q3v_YQom.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-settings-page-DlcqaGu1.js → browser-settings-page-BHoo6Rpq.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-C0SnSj_R.js → browser-workflow-inputs-M5lTEW1I.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-CzlzH7HA.js → browser-workflows-page-B3T1KYk4.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capabilities-settings-panel-QPX4wsGZ.js → capabilities-settings-panel-BlsqN8Fu.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-api-RM6S7ES5.js → capability-presets-api-DE09c0VB.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DmCeusO8.js → capability-presets-settings-panel-DJeT8_B4.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-B4sha-30.js → channel-recipient-api-CFR5FBfS.js} +1 -1
  23. package/dist/gateway/static/root/assets/{channels-settings-HcKoP1wm.js → channels-settings-C4VVjYEm.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-status-swr-vdf8kB16.js +1 -0
  25. package/dist/gateway/static/root/assets/{connector-logo-BPsKIyoM.js → connector-logo-B1mD-3pM.js} +1 -1
  26. package/dist/gateway/static/root/assets/{connectors-page-DwbThFvd.js → connectors-page-DNcrDThX.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-DjL1GWON.js → desktop-pet-B1urphOZ.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-u_abAXh7.js → desktop-pet-settings-DTL6J3EP.js} +1 -1
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-BoZGualI.js → directory-picker-path-field-BYQJ2XUS.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dreaming-settings-s3gn3f9h.js → dreaming-settings-BXcb8fwx.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-debug-page-DIbMngCF.js → extension-debug-page-O1Xu1r4Q.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-D94f2bWQ.js → extension-page-C2Jraq8l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-B7TI13ex.js → extension-settings-page-DcXQDTpG.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-Do77rV8R.js → gateway-config-api-DmPIZrvg.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-Dt1PNJmb.js → gateway-settings-DmObBx9b.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-WaXTw3fi.js → gateway-startup-retry-BZEkOdPm.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goal-create-dialog-DEiOOLGU.js → goal-create-dialog-BRhmmBe9.js} +1 -1
  38. package/dist/gateway/static/root/assets/{goal-detail-page-C1Qj4o1K.js → goal-detail-page-C1k7_s_O.js} +1 -1
  39. package/dist/gateway/static/root/assets/{goals-config-api-BL0fAEns.js → goals-config-api-Fwu1wjEP.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goals-page-qJDcEDzc.js → goals-page-hOu9uA3q.js} +1 -1
  41. package/dist/gateway/static/root/assets/{goals-settings-DV3ZlrdI.js → goals-settings-DY-JjvHz.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-C3kzg6ai.js → heartbeat-settings-BtKu2NWT.js} +1 -1
  43. package/dist/gateway/static/root/assets/{image-generation-api-BgISY8i-.js → image-generation-api-05Gg8wsU.js} +1 -1
  44. package/dist/gateway/static/root/assets/{index-C1h0zkNo.js → index-C0CGebQ1.js} +7 -7
  45. package/dist/gateway/static/root/assets/index-eqq25gvV.css +1 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-0KSmaPu0.js → keyboard-shortcuts-settings-CfmDR9Sc.js} +1 -1
  47. package/dist/gateway/static/root/assets/{local-app-workbench-page-DcD4mVId.js → local-app-workbench-page-EjsNT7nJ.js} +1 -1
  48. package/dist/gateway/static/root/assets/{local-apps-page-BMrU8u7w.js → local-apps-page-Df8BW1A_.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-DVGhFXRz.js → locale-store-CTwSy7yW.js} +1 -1
  50. package/dist/gateway/static/root/assets/{logs-page-CW5m9Cov.js → logs-page-Dswjlraa.js} +1 -1
  51. package/dist/gateway/static/root/assets/{markdown-split-BVqbtN9o.js → markdown-split-B3FvKbaP.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-Dr_wtkNJ.js → media-plugins-DsjrvvB6.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-DP6tPKk-.js +3 -0
  54. package/dist/gateway/static/root/assets/{notes-page-BWZRXsq6.js → notes-page-tuzIwy3c.js} +1 -1
  55. package/dist/gateway/static/root/assets/{notes-workbench-DdnwNz9x.js → notes-workbench-DSh3-hMY.js} +2 -2
  56. package/dist/gateway/static/root/assets/{page-tabs-DWWgy0bF.js → page-tabs-ke9s4nYi.js} +1 -1
  57. package/dist/gateway/static/root/assets/{preview-open-alternatives-Bnfs93ZP.js → preview-open-alternatives-Cp1eI4S9.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-open-page-BR7QFmT-.js → product-open-page-dXQCMAtH.js} +1 -1
  59. package/dist/gateway/static/root/assets/{project-detail-page-B8GeS4dl.js → project-detail-page-D0QPRHR_.js} +1 -1
  60. package/dist/gateway/static/root/assets/{projects-page-DOeu1Hk_.js → projects-page-CI5Vz62F.js} +1 -1
  61. package/dist/gateway/static/root/assets/{remote-access-hub-De94rxnE.js → remote-access-hub-S1jpzBS5.js} +1 -1
  62. package/dist/gateway/static/root/assets/{save-bar-controls-BzS-rRTP.js → save-bar-controls-Bl30zjHc.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schedule-field-Cl2IIDAN.js → schedule-field-DqhmXQKo.js} +1 -1
  64. package/dist/gateway/static/root/assets/{schema-form-BjKjp5eZ.js → schema-form-DkUCy6vf.js} +1 -1
  65. package/dist/gateway/static/root/assets/{sessions-page-A7p8G0OJ.js → sessions-page-CTm66k7h.js} +1 -1
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-CU52AUVD.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-BSDNBfHn.js → settings-form-section-C6ZbNpdy.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BD4peoAv.js → settings-loading-skeleton-Bk58_cr7.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-S-P3U7at.js → settings-page-k8iE_NdX.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-layout-BQTLh-86.js → settings-page-layout-DgFSya2e.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-W3p6kNyA.js → setup-status-panel-B_KDlyZA.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-DQjMxyvw.js → share-preview-page-CV7nL_J9.js} +1 -1
  73. package/dist/gateway/static/root/assets/{shares-settings-Xo3N99PO.js → shares-settings-DK6XK95e.js} +1 -1
  74. package/dist/gateway/static/root/assets/skill-reload-api-Bvv_u4ii.js +1 -0
  75. package/dist/gateway/static/root/assets/{skills-page-C019Ml5q.js → skills-page-BGHvVbay.js} +1 -1
  76. package/dist/gateway/static/root/assets/{skills-page.utils-CXnpudm6.js → skills-page.utils-kahBIHg0.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-BhFwdYJP.js → system-settings-panel-JV3-MG5F.js} +1 -1
  78. package/dist/gateway/static/root/assets/{theme-store-DQI-HPL-.js → theme-store-DFLyzoLO.js} +1 -1
  79. package/dist/gateway/static/root/assets/{time-picker-C0DCya4U.js → time-picker-XwpxdZFr.js} +1 -1
  80. package/dist/gateway/static/root/assets/{typed-models-lib-C-M3Fv2N.js → typed-models-lib-60Aqo-UJ.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-channel-catalog-Bndq4y4I.js → use-channel-catalog-CnTkHDnw.js} +1 -1
  82. package/dist/gateway/static/root/assets/{user-context-page-fYBzpus-.js → user-context-page-DBCMk-Vn.js} +1 -1
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-p_g4UI1-.js → voice-api-key-field-CNa8qUgS.js} +1 -1
  84. package/dist/gateway/static/root/assets/{work-discovery-page-DI0gCZRw.js → work-discovery-page-C1UIdsCl.js} +1 -1
  85. package/dist/gateway/static/root/assets/work-item-detail-page-DEAQepB8.js +1 -0
  86. package/dist/gateway/static/root/assets/{work-page-Z-nUaS_n.js → work-page-D5qYmCTq.js} +1 -1
  87. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CHEXVvhH.js → workflow-run-setup-panel-yV_x595t.js} +1 -1
  88. package/dist/gateway/static/root/assets/{workflows-page-BDfwnM-Y.js → workflows-page-yrK17ZZ5.js} +1 -1
  89. package/dist/gateway/static/root/index.html +7 -7
  90. package/dist/package.js +1 -1
  91. package/dist/src/agent/embedded/model-runtime.js +3 -0
  92. package/dist/src/agent/embedded/run-for-session.js +18 -5
  93. package/dist/src/agent/embedded/run-turn.js +6 -3
  94. package/dist/src/agent/embedded/types.d.ts +2 -0
  95. package/dist/src/config/agent-profile.js +1 -1
  96. package/dist/src/connectors/composio-sessions.js +1 -1
  97. package/dist/src/gateway/agents-admin.js +1 -1
  98. package/dist/src/gateway/heartbeat/service.js +1 -1
  99. package/dist/src/gateway/hono/routes/browser-install.js +1 -1
  100. package/dist/src/heartbeat/index.js +1 -1
  101. package/dist/src/providers/provider-auth-service.js +3 -0
  102. package/dist/src/providers/register-bundled-oauth-flows.d.ts +2 -0
  103. package/dist/src/providers/register-bundled-oauth-flows.js +16 -0
  104. package/dist/src/session/store.d.ts +2 -0
  105. package/dist/src/session/store.js +30 -0
  106. package/package.json +3 -11
  107. package/dist/gateway/static/root/assets/channels-status-swr-D3xr2enH.js +0 -1
  108. package/dist/gateway/static/root/assets/index-Da36E3WH.css +0 -1
  109. package/dist/gateway/static/root/assets/messages-r8L6Ur3A.js +0 -3
  110. package/dist/gateway/static/root/assets/settings-advanced-gate-BsGzjmqx.js +0 -1
  111. package/dist/gateway/static/root/assets/skill-reload-api-ByPEG5t1.js +0 -1
  112. package/dist/gateway/static/root/assets/work-item-detail-page-DnBRP2wI.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-r8L6Ur3A.js";import{l as s,n as c,r as l,s as u}from"./locale-store-DVGhFXRz.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$a as f,Ac as p,As as m,Bo as h,Cs as g,Fc as _,Go as v,It as y,Iu as b,Jl as x,Ks as S,Lu as ee,Ms as C,Mt as w,Ns as T,Nt as E,Pc as D,Pl as O,Qn as k,Uo as A,Vo as j,Wo as M,Yc as N,Yl as P,Zn as F,_a as I,ba as te,ca as L,da as R,fa as z,fc as B,fl as V,ga as H,gc as U,hl as ne,is as W,jt as re,ks as G,la as ie,ls as ae,ma as oe,no as K,ns as se,ou as ce,pa as le,pl as ue,qc as q,ro as J,to as de,ua as fe,us as pe,va as me,ws as Y,ya as he,zo as ge}from"./index-C1h0zkNo.js";import{t as _e}from"./settings-advanced-gate-BsGzjmqx.js";import{n as ve,t as ye}from"./settings-form-section-BSDNBfHn.js";import{t as be}from"./page-tabs-DWWgy0bF.js";import{n as xe,t as Se}from"./save-bar-controls-BzS-rRTP.js";import{n as Ce,r as we}from"./segmented-styles-BL8oLBEp.js";var X=e(t(),1),Te=n(),Z=r();function Ee(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 De(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Oe(e){let t=(0,Te.c)(105),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,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;t[3]===n.name?f=t[4]:(f=n.name?.trim(),t[3]=n.name,t[4]=f);let p=!!f,m=n.status===`archived`,h=n.status===`pinned`,v=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,y;t[5]===v?y=t[6]:(y=a(`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`,v),t[5]=v,t[6]=y);let w;t[7]===c?w=t[8]:(w=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=w);let T=r===`list`&&`sm:py-3`,E;t[9]===T?E=t[10]:(E=a(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,T),t[9]=T,t[10]=E);let O;t[11]===n.sourceChannel?O=t[12]:(O=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=O);let k;t[13]===h?k=t[14]:(k=h?(0,Z.jsx)(_,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=k);let A;t[15]===n.updatedAt?A=t[16]:(A=Ee(n.updatedAt),t[15]=n.updatedAt,t[16]=A);let j;t[17]===A?j=t[18]:(j=(0,Z.jsx)(`span`,{children:A}),t[17]=A,t[18]=j);let M;t[19]!==j||t[20]!==k?(M=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[k,j]}),t[19]=j,t[20]=k,t[21]=M):M=t[21];let P;t[22]!==M||t[23]!==E||t[24]!==O?(P=(0,Z.jsxs)(`div`,{className:E,children:[O,M]}),t[22]=M,t[23]=E,t[24]=O,t[25]=P):P=t[25];let F=r===`list`&&`sm:py-3`,I;t[26]===F?I=t[27]:(I=a(`min-w-0 flex-1 px-3 py-2`,F),t[26]=F,t[27]=I);let L=r===`list`&&`sm:items-start`,R;t[28]===L?R=t[29]:(R=a(`flex gap-3`,L),t[28]=L,t[29]=R);let z;t[30]!==s||t[31]!==o?(z=(0,Z.jsx)(te,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=s,t[31]=o,t[32]=z):z=t[32];let B;t[33]===d?B=t[34]:(B=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[33]=d,t[34]=B);let V;t[35]!==n.key||t[36]!==p?(V=p?(0,Z.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[35]=n.key,t[36]=p,t[37]=V):V=t[37];let H;t[38]!==B||t[39]!==V?(H=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[B,V]}),t[38]=B,t[39]=V,t[40]=H):H=t[40];let U;t[41]!==R||t[42]!==z||t[43]!==H?(U=(0,Z.jsxs)(`div`,{className:R,children:[z,H]}),t[41]=R,t[42]=z,t[43]=H,t[44]=U):U=t[44];let ne;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(N,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=ne):ne=t[45];let W;t[46]===n.messageCount?W=t[47]:(W=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ne,n.messageCount]}),t[46]=n.messageCount,t[47]=W);let re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(C,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=re):re=t[48];let G;t[49]===n.estimatedTokens?G=t[50]:(G=De(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=G);let ie;t[51]===G?ie=t[52]:(ie=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[re,G]}),t[51]=G,t[52]=ie);let ae;t[53]!==W||t[54]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[W,ie]}),t[53]=W,t[54]=ie,t[55]=ae):ae=t[55];let oe;t[56]===n.tags?oe=t[57]:(oe=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(je),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=oe);let K;t[58]!==I||t[59]!==U||t[60]!==ae||t[61]!==oe?(K=(0,Z.jsxs)(`div`,{className:I,children:[U,ae,oe]}),t[58]=I,t[59]=U,t[60]=ae,t[61]=oe,t[62]=K):K=t[62];let se;t[63]===l?se=t[64]:(se=()=>l(`continue`),t[63]=l,t[64]=se);let ce;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(N,{className:`size-4`,strokeWidth:1.75}),t[65]=ce):ce=t[65];let le;t[66]!==i.continueChat||t[67]!==se?(le=(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.continueChat,"aria-label":i.continueChat,onClick:se,children:ce}),t[66]=i.continueChat,t[67]=se,t[68]=le):le=t[68];let ue;t[69]!==m||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(ue=m?(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(b,{className:`size-4`,strokeWidth:1.75})}),t[69]=m,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=ue):ue=t[73];let q;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(q=h?(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(D,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(_,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=q):q=t[78];let J;t[79]===l?J=t[80]:(J=()=>l(`export`),t[79]=l,t[80]=J);let de;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)(x,{className:`size-4`,strokeWidth:1.75}),t[81]=de):de=t[81];let fe;t[82]!==i.export||t[83]!==J?(fe=(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.export,"aria-label":i.export,onClick:J,children:de}),t[82]=i.export,t[83]=J,t[84]=fe):fe=t[84];let pe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(pe=a(g,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=pe):pe=t[85];let me;t[86]===l?me=t[87]:(me=()=>l(`delete`),t[86]=l,t[87]=me);let Y;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Z.jsx)(S,{className:`size-4`,strokeWidth:1.75}),t[88]=Y):Y=t[88];let he;t[89]!==i.delete||t[90]!==me?(he=(0,Z.jsx)(`button`,{type:`button`,className:pe,title:i.delete,"aria-label":i.delete,onClick:me,children:Y}),t[89]=i.delete,t[90]=me,t[91]=he):he=t[91];let ge;t[92]!==le||t[93]!==ue||t[94]!==q||t[95]!==fe||t[96]!==he?(ge=(0,Z.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:Ae,onKeyDown:ke,children:[le,ue,q,fe,he]}),t[92]=le,t[93]=ue,t[94]=q,t[95]=fe,t[96]=he,t[97]=ge):ge=t[97];let _e;return t[98]!==c||t[99]!==P||t[100]!==K||t[101]!==y||t[102]!==ge||t[103]!==w?(_e=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:y,onClick:c,onKeyDown:w,children:[P,K,ge]}),t[98]=c,t[99]=P,t[100]=K,t[101]=y,t[102]=ge,t[103]=w,t[104]=_e):_e=t[104],_e}function ke(e){return e.stopPropagation()}function Ae(e){return e.stopPropagation()}function je(e){return(0,Z.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)}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(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 Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.memory)?n.memory:{},i=Ne(r.retention)?r.retention:{},a=Ne(i.compaction)?i.compaction:{},o=Me,s=typeof a.model==`string`&&a.model.trim()?a.model.trim():void 0,c=Array.isArray(a.postCompactionSections)&&a.postCompactionSections.length<=12&&a.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(a.postCompactionSections.map(e=>e.trim()))]:[...o.postCompactionSections];return{enabled:typeof a.enabled==`boolean`?a.enabled:o.enabled,triggerThreshold:Pe(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Q(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Q(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Q(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Q(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Q(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Q(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Q(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,...s?{model:s}:{},minToolResultKeepChars:Q(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(a.maxActiveTranscriptBytes,o.maxActiveTranscriptBytes,64e3),postCompactionSections:c}}function Ie(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 Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{memory:{retention:{compaction:t}}}}}async function Re(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await de()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=re();function He(){return a(`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`,G,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(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,Te.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,Z.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=He(),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,Z.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,Z.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,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Te.c)(19),{label:n,hint:r,checked:i,disabled:o,onChange:s}=e,c=o?`cursor-not-allowed opacity-55`:`cursor-pointer`,l;t[0]===c?l=t[1]:(l=a(`flex items-start gap-2 text-sm text-fg`,c),t[0]=c,t[1]=l);let u;t[2]===s?u=t[3]:(u=e=>s(e.target.checked),t[2]=s,t[3]=u);let d;t[4]!==i||t[5]!==o||t[6]!==u?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:o,onChange:u}),t[4]=i,t[5]=o,t[6]=u,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==l||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:l,children:[d,m]}),t[15]=l,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=o(c(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=K(e),{data:i=[],isLoading:s}=d(e?F:null,k,{revalidateOnFocus:!1}),l=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[u,f]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),[b,x]=(0,X.useState)(``),S=(0,X.useRef)(!1),ee=(0,X.useRef)(null);w({enabled:e,parsed:l,dirty:S.current,trackedParsedRef:ee,dispatch:f,onResetDirty:()=>{S.current=!1}});let C=u.form,E=u.baseline,D=!!(C&&E&&JSON.stringify(C)!==JSON.stringify(E)),O=(0,X.useCallback)(e=>{S.current=!0,v(null),f({type:`patch`,patch:e})},[]),A=(0,X.useCallback)(()=>{S.current=!1,v(null),x(``),f({type:`discard`})},[]),j=(0,X.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,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),M=(0,X.useCallback)(async()=>{if(!C)return;let e=Ie(C);if(e){let n=t.invalidValue.replace(`{{field}}`,j(e));throw v(n),Error(n)}g(!0),v(null);try{await Re(C),S.current=!1,f({type:`saved`,value:C})}catch(e){let n=e instanceof Error?e.message:t.saveError;throw v(n),Error(n)}finally{g(!1)}},[j,C,t.invalidValue,t.saveError]);if(xe({id:`context-compaction`,dirty:D,saving:h,save:M,discard:A}),!e||!C)return r?(0,Z.jsx)(ye,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(J,{className:`h-5 w-48`}),(0,Z.jsx)(J,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(J,{className:`h-36 w-full rounded-xl`})]})}):null;let N=We(C),P=Math.max(0,ze-C.reserveTokens),I=Math.min(Math.floor(ze*C.triggerThreshold),P),te=Math.min(100,I/ze*100),L=Math.min(100,P/ze*100),R=C.model?i.find(e=>e.id===C.model):void 0,z=R?.contextWindow&&C.summaryChunkTokens+C.summaryMaxTokens+4096>R.contextWindow,B=C.keepRecentTokens+C.reserveTokens>I,V=Math.round(C.summaryTimeoutMs*(C.summaryRetries+1)/1e3),H=e=>{let t=Be[e];O({...t,...C.model?{model:C.model}:{model:void 0},postCompactionSections:C.postCompactionSections})},U={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},ne=()=>{let e=b.trim();!e||C.postCompactionSections.includes(e)||C.postCompactionSections.length>=12||(O({postCompactionSections:[...C.postCompactionSections,e]}),x(``))};return(0,Z.jsxs)(ye,{children:[(0,Z.jsx)(ve,{icon:q,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:C.enabled,onChange:e=>O({enabled:e.target.checked})}),C.enabled?t.enabled:t.disabled]})}),_?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:_}):null,C.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!C.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),N===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":N===e,className:a(`rounded-xl border px-3 py-3 text-left`,Y.transition,Y.focusRingPanel,N===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>H(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:U[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:U[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(I)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${te}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(P)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${L}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((C.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>O({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(C.reserveTokens)),value:C.reserveTokens,min:1024,step:1024,onChange:e=>O({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:C.recentTurnsPreserve,min:1,max:12,onChange:e=>O({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(C.keepRecentTokens)),value:C.keepRecentTokens,min:1e3,step:1e3,onChange:e=>O({keepRecentTokens:Math.floor(e)})})]}),B?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(y,{value:C.model??``,disabled:!C.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:s,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>O({model:e})}),C.model?(0,Z.jsx)(m,{type:`button`,variant:`secondary`,onClick:()=>O({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:C.qualityGuard,onChange:e=>O({qualityGuard:e})})]}),C.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(_e,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:C.minMessagesBeforeCompact,min:2,onChange:e=>O({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((C.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>O({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:C.summaryMaxTokens,min:256,step:256,onChange:e=>O({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:C.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>O({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(V)),value:C.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>O({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:C.summaryRetries,min:0,max:5,onChange:e=>O({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:C.minToolResultKeepChars,min:200,step:100,onChange:e=>O({minToolResultKeepChars:Math.floor(e)})})]}),z?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),C.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:C.postCompactionSections.map(e=>(0,Z.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,Z.jsx)(`button`,{type:`button`,className:a(`text-fg-muted hover:text-fg`,Y.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>O({postCompactionSections:C.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(T,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:He(),value:b,maxLength:120,disabled:C.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ne())}}),(0,Z.jsxs)(m,{type:`button`,variant:`secondary`,disabled:!b.trim()||C.postCompactionSections.length>=12,onClick:ne,children:[(0,Z.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]}),(0,Z.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Z.jsx)(m,{type:`button`,variant:`secondary`,disabled:!D||h,onClick:A,children:t.discard}),(0,Z.jsx)(m,{type:`button`,variant:`primary`,disabled:!D||h,onClick:()=>void M().catch(()=>{}),children:h?t.saving:t.save})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(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:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),de()}function Qe(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,G,`dark:border-edge`)}var $e=re();function et({hasToken:e}){let t=o(c(e=>e.language)).sessions.config,{data:n,isLoading:r}=K(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[a,s]=(0,X.useReducer)($e,{form:null,baseline:null}),l=a.form,u=a.baseline,[d,f]=(0,X.useState)(!1),[p,h]=(0,X.useState)(null),g=(0,X.useRef)(!1),_=(0,X.useRef)(null);w({enabled:e,parsed:i,dirty:g.current,trackedParsedRef:_,dispatch:s,onResetDirty:()=>{g.current=!1}});let v=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),y=(0,X.useCallback)(e=>{g.current=!0,s({type:`patch`,patch:e})},[]),b=(0,X.useCallback)(()=>{g.current=!1,h(null),s({type:`discard`})},[]),x=(0,X.useCallback)(async()=>{if(l){f(!0),h(null);try{await Ze(l),g.current=!1,s({type:`saved`,value:l})}catch(e){let n=e instanceof Error?e.message:t.saveError;throw h(n),Error(n)}finally{f(!1)}}},[l,t.saveError]);return xe({id:`session-storage`,dirty:v,saving:d,save:x,discard:b}),!e||!l?r?(0,Z.jsx)(ye,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(J,{className:`h-5 w-40`}),(0,Z.jsx)(J,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(ye,{children:[(0,Z.jsx)(ve,{icon:P,title:t.title,subtitle:t.hint}),(0,Z.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Z.jsx)(m,{type:`button`,variant:`secondary`,disabled:!v||d,onClick:b,children:t.discard}),(0,Z.jsx)(m,{type:`button`,variant:`primary`,disabled:!v||d,onClick:()=>void x().catch(()=>{}),children:d?t.saving:t.save})]}),p?(0,Z.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(se,{className:Qe(),value:l.dmScope,onChange:e=>y({dmScope:e.target.value}),children:[(0,Z.jsx)(W,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(W,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(W,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(W,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();y({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();y({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(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 nt(e){let t=(0,Te.c)(60),{open:n,loading:r,session:i,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:d,onPin:f,onUnpin:p,onExport:g,onDelete:_}=e,y=i?.status===`archived`,b=i?.status===`pinned`,x;t[0]===l?x=t[1]:(x=e=>!e&&l(),t[0]=l,t[1]=x);let S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(A,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,pe)}),t[2]=S):S=t[2];let ee;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(ee=a(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,ae,`dark:border-edge`),t[3]=ee):ee=t[3];let C;t[4]!==i||t[5]!==s||t[6]!==o?(C=i&&o?(0,Z.jsx)(te,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=s,t[6]=o,t[7]=C):C=t[7];let w;t[8]!==c.unnamedSession||t[9]!==i?.name?(w=i?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=i?.name,t[10]=w):w=t[10];let E;t[11]===w?E=t[12]:(E=(0,Z.jsx)(v,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:w}),t[11]=w,t[12]=E);let D;t[13]!==C||t[14]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[C,E]}),t[13]=C,t[14]=E,t[15]=D):D=t[15];let O;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(T,{className:`size-5`,strokeWidth:1.75}),t[16]=O):O=t[16];let k;t[17]===c.close?k=t[18]:(k=(0,Z.jsx)(h,{asChild:!0,children:(0,Z.jsx)(m,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:O})}),t[17]=c.close,t[18]=k);let N;t[19]!==D||t[20]!==k?(N=(0,Z.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:[D,k]}),t[19]=D,t[20]=k,t[21]=N):N=t[21];let P;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==i?(P=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:c.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=i,t[26]=P):P=t[26];let F;t[27]===P?F=t[28]:(F=(0,Z.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]!==c.detailExport||t[30]!==g?(I=(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:c.detailExport}),t[29]=c.detailExport,t[30]=g,t[31]=I):I=t[31];let L;t[32]!==y||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(L=y?(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=y,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=L):L=t[37];let R;t[38]!==b||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==f||t[42]!==p?(R=b?(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.unpin}):(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:c.pin}),t[38]=b,t[39]=c.pin,t[40]=c.unpin,t[41]=f,t[42]=p,t[43]=R):R=t[43];let z;t[44]!==c.delete||t[45]!==_?(z=(0,Z.jsx)(m,{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:_,children:c.delete}),t[44]=c.delete,t[45]=_,t[46]=z):z=t[46];let B;t[47]!==I||t[48]!==L||t[49]!==R||t[50]!==z?(B=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,R,z]})}),t[47]=I,t[48]=L,t[49]=R,t[50]=z,t[51]=B):B=t[51];let V;t[52]!==N||t[53]!==F||t[54]!==B?(V=(0,Z.jsxs)(M,{children:[S,(0,Z.jsxs)(j,{className:ee,"aria-describedby":void 0,children:[N,F,B]})]}),t[52]=N,t[53]=F,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==n||t[57]!==x||t[58]!==V?(H=(0,Z.jsx)(ge,{open:n,onOpenChange:x,children:V}),t[56]=n,t[57]=x,t[58]=V,t[59]=H):H=t[59],H}function rt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Te.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?ne: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,Z.jsx)(be,{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 pt(e){let t=(0,Te.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-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Z.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,Z.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 mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.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 ht(){let e=o(c(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:l,mutate:u}=d(r?[`gateway-chat-agents`,n]:null,f,{revalidateOnFocus:!1}),p=l?.defaultId??`main`,h=l?.items??[],[g,y]=i(),x=lt(g.get(`tab`)),S=(0,X.useCallback)(e=>{let t=new URLSearchParams(g);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),y(t,{replace:!0})},[g,y]),[ee,C]=(0,X.useReducer)(E,g,mt),{searchInput:w,debouncedSearch:T,statusFilter:D,viewMode:k,channelFilter:N,sessions:P,loading:F,error:te,hasMore:B,stats:W,detailOpen:re,detailLoading:G,detailSession:K,confirmOpen:se,confirmKey:q}=ee;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=w.trim();T!==e&&C({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[w,T]);let J=g.toString(),de=(0,X.useRef)(J);if(de.current!==J){de.current=J;let e=g.get(`q`)??``,t=g.get(`status`),n=g.get(`view`),r=(g.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();C({type:`patch`,patch:{...w===e?{}:{searchInput:e},...T===o?{}:{debouncedSearch:o},...D===i?{}:{statusFilter:i},...k===a?{}:{viewMode:a},...N===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(g),t=T.trim();t?e.set(`q`,t):e.delete(`q`),D===`all`?e.delete(`status`):e.set(`status`,D),k===`grid`?e.delete(`view`):e.set(`view`,k),N?e.set(`channel`,N):e.delete(`channel`),e.toString()!==g.toString()&&y(e,{replace:!0})},[T,g,y,D,k,N]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=!1;return(async()=>{C({type:`patch`,patch:{loading:!0,error:null}});try{let t=await le({limit:it,offset:0,...T?{search:T}:{},...D===`all`?{}:{status:D},...N?{channel:N}:{}});if(e)return;C({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||C({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||C({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,x,T,D,N,t.loadError]),(0,X.useEffect)(()=>{!r||x!==`sessions`||z().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,x]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=()=>void u();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,x,u]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||C({type:`patch`,patch:{sessions:P.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,x,P,K]);let _e=(0,X.useCallback)(async()=>{if(!(!r||F||!B)){C({type:`patch`,patch:{loading:!0,error:null}});try{let e=await le({limit:it,offset:P.length,...T?{search:T}:{},...D===`all`?{}:{status:D},...N?{channel:N}:{}});C({type:`patch`,patch:{sessions:[...P,...e.items],hasMore:e.hasMore}})}catch(e){C({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{C({type:`patch`,patch:{loading:!1}})}}},[r,F,B,P.length,T,D,N,t.loadError]),ve=(0,X.useCallback)((e,t)=>{C({type:`patch`,patch:{sessions:P.map(n=>n.key===e?{...n,status:t}:n),detailSession:K&&K.key===e?{...K,status:t}:K}})},[P,K]),ye=(0,X.useCallback)(async e=>{C({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{C({type:`patch`,patch:{detailSession:await R(e)}})}catch{C({type:`patch`,patch:{detailOpen:!1}})}finally{C({type:`patch`,patch:{detailLoading:!1}})}},[]),be=e=>{ye(e)},xe=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){C({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await L(e),ve(e,`archived`);break;case`unarchive`:await H(e),ve(e,`active`);break;case`pin`:await oe(e),ve(e,`pinned`);break;case`unpin`:await I(e),ve(e,`active`);break;case`export`:{let t=await fe(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}z().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te=async e=>{try{await ie(e),C({type:`patch`,patch:{sessions:P.filter(t=>t.key!==e),detailSession:K?.key===e?null:K,...K?.key===e?{detailOpen:!1}:{}}}),z().then(e=>C({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,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},ke=[{key:`all`,label:t.filterAll,icon:ne},{key:`active`,label:t.filterActive,icon:ce},{key:`pinned`,label:t.filterPinned,icon:_},{key:`archived`,label:t.filterArchived,icon:b}],Ae=(()=>{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,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:x,onChange:S}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:x,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Se,{}),(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:x,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ke.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":D===e,onClick:()=>C({type:`patch`,patch:{statusFilter:e}}),className:a(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,Y.transition,Y.focusRingPanel,D===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,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(U,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:w,onChange:e=>C({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":T||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!N,onClick:()=>C({type:`patch`,patch:{channelFilter:``}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,Y.transition,Y.focusRingPanel,N?`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}),Ae.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":N===e,onClick:()=>C({type:`patch`,patch:{channelFilter:e}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,Y.transition,Y.focusRingPanel,N===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,Z.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,Z.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,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,te?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:te}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:P.length})}),(0,Z.jsxs)(`div`,{className:we,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(m,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":k===`grid`,onClick:()=>C({type:`patch`,patch:{viewMode:`grid`}}),className:a(Ce,`size-7 p-0`,k===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,k===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(ue,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(m,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":k===`list`,onClick:()=>C({type:`patch`,patch:{viewMode:`list`}}),className:a(Ce,`size-9 p-0`,k===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,k===`list`&&`text-accent-fg`),children:(0,Z.jsx)(V,{className:`size-3.5`,strokeWidth:1.5})})]})]}),F&&P.length===0?(0,Z.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,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):P.length===0?(0,Z.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,Z.jsx)(O,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(m,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:a(`grid min-w-0 gap-3`,k===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":T||void 0,children:P.map(e=>{let t=he(e,p);return(0,Z.jsx)(Oe,{session:e,variant:k,labels:Ee,sessionAgentId:t,sessionAgentAvatar:me(t,h),onOpen:()=>be(e.key),onAction:t=>void xe(e.key,t)},e.key)})}),B?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(m,{type:`button`,variant:`secondary`,disabled:F,onClick:()=>void _e(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:re,loading:G,session:K,sessionAgentId:K?he(K,p):void 0,sessionAgentAvatar:K?me(he(K,p),h):void 0,labels:De,onClose:()=>{C({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>K&&void xe(K.key,`archive`),onUnarchive:()=>K&&void xe(K.key,`unarchive`),onPin:()=>K&&void xe(K.key,`pin`),onUnpin:()=>K&&void xe(K.key,`unpin`),onExport:()=>K&&void xe(K.key,`export`),onDelete:()=>K&&C({type:`patch`,patch:{confirmKey:K.key,confirmOpen:!0}})}),(0,Z.jsx)(ge,{open:se,onOpenChange:e=>C({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(M,{children:[(0,Z.jsx)(A,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,pe)}),(0,Z.jsxs)(j,{className:a(`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-panel p-4 shadow-popover dark:border-edge`,ae),children:[(0,Z.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:q?at(t.deleteSessionMessage,{name:P.find(e=>e.key===q)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(m,{type:`button`,variant:`secondary`,onClick:()=>C({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(m,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{q&&Te(q),C({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.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{ht 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{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DP6tPKk-.js";import{l as s,n as c,r as l,s as u}from"./locale-store-CTwSy7yW.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$a as f,Ac as p,As as m,Bo as h,Cs as g,Fc as _,Go as v,It as y,Iu as b,Jl as x,Ks as S,Lu as ee,Ms as C,Mt as w,Ns as T,Nt as E,Pc as D,Pl as O,Qn as k,Uo as A,Vo as j,Wo as M,Yc as N,Yl as P,Zn as F,_a as I,ba as te,ca as L,da as R,fa as z,fc as B,fl as V,ga as H,gc as U,hl as ne,is as W,jt as re,ks as G,la as ie,ls as ae,ma as oe,no as K,ns as se,ou as ce,pa as le,pl as ue,qc as q,ro as J,to as de,ua as fe,us as pe,va as me,ws as Y,ya as he,zo as ge}from"./index-C0CGebQ1.js";import{t as _e}from"./settings-advanced-gate-CU52AUVD.js";import{n as ve,t as ye}from"./settings-form-section-C6ZbNpdy.js";import{t as be}from"./page-tabs-ke9s4nYi.js";import{n as xe,t as Se}from"./save-bar-controls-Bl30zjHc.js";import{n as Ce,r as we}from"./segmented-styles-BL8oLBEp.js";var X=e(t(),1),Te=n(),Z=r();function Ee(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 De(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Oe(e){let t=(0,Te.c)(105),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,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;t[3]===n.name?f=t[4]:(f=n.name?.trim(),t[3]=n.name,t[4]=f);let p=!!f,m=n.status===`archived`,h=n.status===`pinned`,v=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,y;t[5]===v?y=t[6]:(y=a(`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`,v),t[5]=v,t[6]=y);let w;t[7]===c?w=t[8]:(w=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=w);let T=r===`list`&&`sm:py-3`,E;t[9]===T?E=t[10]:(E=a(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,T),t[9]=T,t[10]=E);let O;t[11]===n.sourceChannel?O=t[12]:(O=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=O);let k;t[13]===h?k=t[14]:(k=h?(0,Z.jsx)(_,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=k);let A;t[15]===n.updatedAt?A=t[16]:(A=Ee(n.updatedAt),t[15]=n.updatedAt,t[16]=A);let j;t[17]===A?j=t[18]:(j=(0,Z.jsx)(`span`,{children:A}),t[17]=A,t[18]=j);let M;t[19]!==j||t[20]!==k?(M=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[k,j]}),t[19]=j,t[20]=k,t[21]=M):M=t[21];let P;t[22]!==M||t[23]!==E||t[24]!==O?(P=(0,Z.jsxs)(`div`,{className:E,children:[O,M]}),t[22]=M,t[23]=E,t[24]=O,t[25]=P):P=t[25];let F=r===`list`&&`sm:py-3`,I;t[26]===F?I=t[27]:(I=a(`min-w-0 flex-1 px-3 py-2`,F),t[26]=F,t[27]=I);let L=r===`list`&&`sm:items-start`,R;t[28]===L?R=t[29]:(R=a(`flex gap-3`,L),t[28]=L,t[29]=R);let z;t[30]!==s||t[31]!==o?(z=(0,Z.jsx)(te,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=s,t[31]=o,t[32]=z):z=t[32];let B;t[33]===d?B=t[34]:(B=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[33]=d,t[34]=B);let V;t[35]!==n.key||t[36]!==p?(V=p?(0,Z.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[35]=n.key,t[36]=p,t[37]=V):V=t[37];let H;t[38]!==B||t[39]!==V?(H=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[B,V]}),t[38]=B,t[39]=V,t[40]=H):H=t[40];let U;t[41]!==R||t[42]!==z||t[43]!==H?(U=(0,Z.jsxs)(`div`,{className:R,children:[z,H]}),t[41]=R,t[42]=z,t[43]=H,t[44]=U):U=t[44];let ne;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(N,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=ne):ne=t[45];let W;t[46]===n.messageCount?W=t[47]:(W=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ne,n.messageCount]}),t[46]=n.messageCount,t[47]=W);let re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(C,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=re):re=t[48];let G;t[49]===n.estimatedTokens?G=t[50]:(G=De(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=G);let ie;t[51]===G?ie=t[52]:(ie=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[re,G]}),t[51]=G,t[52]=ie);let ae;t[53]!==W||t[54]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[W,ie]}),t[53]=W,t[54]=ie,t[55]=ae):ae=t[55];let oe;t[56]===n.tags?oe=t[57]:(oe=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(je),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=oe);let K;t[58]!==I||t[59]!==U||t[60]!==ae||t[61]!==oe?(K=(0,Z.jsxs)(`div`,{className:I,children:[U,ae,oe]}),t[58]=I,t[59]=U,t[60]=ae,t[61]=oe,t[62]=K):K=t[62];let se;t[63]===l?se=t[64]:(se=()=>l(`continue`),t[63]=l,t[64]=se);let ce;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(N,{className:`size-4`,strokeWidth:1.75}),t[65]=ce):ce=t[65];let le;t[66]!==i.continueChat||t[67]!==se?(le=(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.continueChat,"aria-label":i.continueChat,onClick:se,children:ce}),t[66]=i.continueChat,t[67]=se,t[68]=le):le=t[68];let ue;t[69]!==m||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(ue=m?(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(b,{className:`size-4`,strokeWidth:1.75})}),t[69]=m,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=ue):ue=t[73];let q;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(q=h?(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(D,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(_,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=q):q=t[78];let J;t[79]===l?J=t[80]:(J=()=>l(`export`),t[79]=l,t[80]=J);let de;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)(x,{className:`size-4`,strokeWidth:1.75}),t[81]=de):de=t[81];let fe;t[82]!==i.export||t[83]!==J?(fe=(0,Z.jsx)(`button`,{type:`button`,className:g,title:i.export,"aria-label":i.export,onClick:J,children:de}),t[82]=i.export,t[83]=J,t[84]=fe):fe=t[84];let pe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(pe=a(g,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=pe):pe=t[85];let me;t[86]===l?me=t[87]:(me=()=>l(`delete`),t[86]=l,t[87]=me);let Y;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Z.jsx)(S,{className:`size-4`,strokeWidth:1.75}),t[88]=Y):Y=t[88];let he;t[89]!==i.delete||t[90]!==me?(he=(0,Z.jsx)(`button`,{type:`button`,className:pe,title:i.delete,"aria-label":i.delete,onClick:me,children:Y}),t[89]=i.delete,t[90]=me,t[91]=he):he=t[91];let ge;t[92]!==le||t[93]!==ue||t[94]!==q||t[95]!==fe||t[96]!==he?(ge=(0,Z.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:Ae,onKeyDown:ke,children:[le,ue,q,fe,he]}),t[92]=le,t[93]=ue,t[94]=q,t[95]=fe,t[96]=he,t[97]=ge):ge=t[97];let _e;return t[98]!==c||t[99]!==P||t[100]!==K||t[101]!==y||t[102]!==ge||t[103]!==w?(_e=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:y,onClick:c,onKeyDown:w,children:[P,K,ge]}),t[98]=c,t[99]=P,t[100]=K,t[101]=y,t[102]=ge,t[103]=w,t[104]=_e):_e=t[104],_e}function ke(e){return e.stopPropagation()}function Ae(e){return e.stopPropagation()}function je(e){return(0,Z.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)}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(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 Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.memory)?n.memory:{},i=Ne(r.retention)?r.retention:{},a=Ne(i.compaction)?i.compaction:{},o=Me,s=typeof a.model==`string`&&a.model.trim()?a.model.trim():void 0,c=Array.isArray(a.postCompactionSections)&&a.postCompactionSections.length<=12&&a.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(a.postCompactionSections.map(e=>e.trim()))]:[...o.postCompactionSections];return{enabled:typeof a.enabled==`boolean`?a.enabled:o.enabled,triggerThreshold:Pe(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Q(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Q(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Q(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Q(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Q(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Q(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Q(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,...s?{model:s}:{},minToolResultKeepChars:Q(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(a.maxActiveTranscriptBytes,o.maxActiveTranscriptBytes,64e3),postCompactionSections:c}}function Ie(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 Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{memory:{retention:{compaction:t}}}}}async function Re(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await de()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=re();function He(){return a(`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`,G,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(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,Te.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,Z.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=He(),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,Z.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,Z.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,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Te.c)(19),{label:n,hint:r,checked:i,disabled:o,onChange:s}=e,c=o?`cursor-not-allowed opacity-55`:`cursor-pointer`,l;t[0]===c?l=t[1]:(l=a(`flex items-start gap-2 text-sm text-fg`,c),t[0]=c,t[1]=l);let u;t[2]===s?u=t[3]:(u=e=>s(e.target.checked),t[2]=s,t[3]=u);let d;t[4]!==i||t[5]!==o||t[6]!==u?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:o,onChange:u}),t[4]=i,t[5]=o,t[6]=u,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==l||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:l,children:[d,m]}),t[15]=l,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=o(c(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=K(e),{data:i=[],isLoading:s}=d(e?F:null,k,{revalidateOnFocus:!1}),l=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[u,f]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),[b,x]=(0,X.useState)(``),S=(0,X.useRef)(!1),ee=(0,X.useRef)(null);w({enabled:e,parsed:l,dirty:S.current,trackedParsedRef:ee,dispatch:f,onResetDirty:()=>{S.current=!1}});let C=u.form,E=u.baseline,D=!!(C&&E&&JSON.stringify(C)!==JSON.stringify(E)),O=(0,X.useCallback)(e=>{S.current=!0,v(null),f({type:`patch`,patch:e})},[]),A=(0,X.useCallback)(()=>{S.current=!1,v(null),x(``),f({type:`discard`})},[]),j=(0,X.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,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),M=(0,X.useCallback)(async()=>{if(!C)return;let e=Ie(C);if(e){let n=t.invalidValue.replace(`{{field}}`,j(e));throw v(n),Error(n)}g(!0),v(null);try{await Re(C),S.current=!1,f({type:`saved`,value:C})}catch(e){let n=e instanceof Error?e.message:t.saveError;throw v(n),Error(n)}finally{g(!1)}},[j,C,t.invalidValue,t.saveError]);if(xe({id:`context-compaction`,dirty:D,saving:h,save:M,discard:A}),!e||!C)return r?(0,Z.jsx)(ye,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(J,{className:`h-5 w-48`}),(0,Z.jsx)(J,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(J,{className:`h-36 w-full rounded-xl`})]})}):null;let N=We(C),P=Math.max(0,ze-C.reserveTokens),I=Math.min(Math.floor(ze*C.triggerThreshold),P),te=Math.min(100,I/ze*100),L=Math.min(100,P/ze*100),R=C.model?i.find(e=>e.id===C.model):void 0,z=R?.contextWindow&&C.summaryChunkTokens+C.summaryMaxTokens+4096>R.contextWindow,B=C.keepRecentTokens+C.reserveTokens>I,V=Math.round(C.summaryTimeoutMs*(C.summaryRetries+1)/1e3),H=e=>{let t=Be[e];O({...t,...C.model?{model:C.model}:{model:void 0},postCompactionSections:C.postCompactionSections})},U={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},ne=()=>{let e=b.trim();!e||C.postCompactionSections.includes(e)||C.postCompactionSections.length>=12||(O({postCompactionSections:[...C.postCompactionSections,e]}),x(``))};return(0,Z.jsxs)(ye,{children:[(0,Z.jsx)(ve,{icon:q,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:C.enabled,onChange:e=>O({enabled:e.target.checked})}),C.enabled?t.enabled:t.disabled]})}),_?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:_}):null,C.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!C.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),N===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":N===e,className:a(`rounded-xl border px-3 py-3 text-left`,Y.transition,Y.focusRingPanel,N===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>H(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:U[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:U[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(I)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${te}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(P)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${L}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((C.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>O({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(C.reserveTokens)),value:C.reserveTokens,min:1024,step:1024,onChange:e=>O({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:C.recentTurnsPreserve,min:1,max:12,onChange:e=>O({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(C.keepRecentTokens)),value:C.keepRecentTokens,min:1e3,step:1e3,onChange:e=>O({keepRecentTokens:Math.floor(e)})})]}),B?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(y,{value:C.model??``,disabled:!C.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:s,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>O({model:e})}),C.model?(0,Z.jsx)(m,{type:`button`,variant:`secondary`,onClick:()=>O({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:C.qualityGuard,onChange:e=>O({qualityGuard:e})})]}),C.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(_e,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:C.minMessagesBeforeCompact,min:2,onChange:e=>O({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((C.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>O({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:C.summaryMaxTokens,min:256,step:256,onChange:e=>O({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:C.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>O({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(V)),value:C.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>O({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:C.summaryRetries,min:0,max:5,onChange:e=>O({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:C.minToolResultKeepChars,min:200,step:100,onChange:e=>O({minToolResultKeepChars:Math.floor(e)})})]}),z?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),C.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:C.postCompactionSections.map(e=>(0,Z.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,Z.jsx)(`button`,{type:`button`,className:a(`text-fg-muted hover:text-fg`,Y.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>O({postCompactionSections:C.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(T,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:He(),value:b,maxLength:120,disabled:C.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ne())}}),(0,Z.jsxs)(m,{type:`button`,variant:`secondary`,disabled:!b.trim()||C.postCompactionSections.length>=12,onClick:ne,children:[(0,Z.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]}),(0,Z.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Z.jsx)(m,{type:`button`,variant:`secondary`,disabled:!D||h,onClick:A,children:t.discard}),(0,Z.jsx)(m,{type:`button`,variant:`primary`,disabled:!D||h,onClick:()=>void M().catch(()=>{}),children:h?t.saving:t.save})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(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:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),de()}function Qe(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,G,`dark:border-edge`)}var $e=re();function et({hasToken:e}){let t=o(c(e=>e.language)).sessions.config,{data:n,isLoading:r}=K(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[a,s]=(0,X.useReducer)($e,{form:null,baseline:null}),l=a.form,u=a.baseline,[d,f]=(0,X.useState)(!1),[p,h]=(0,X.useState)(null),g=(0,X.useRef)(!1),_=(0,X.useRef)(null);w({enabled:e,parsed:i,dirty:g.current,trackedParsedRef:_,dispatch:s,onResetDirty:()=>{g.current=!1}});let v=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),y=(0,X.useCallback)(e=>{g.current=!0,s({type:`patch`,patch:e})},[]),b=(0,X.useCallback)(()=>{g.current=!1,h(null),s({type:`discard`})},[]),x=(0,X.useCallback)(async()=>{if(l){f(!0),h(null);try{await Ze(l),g.current=!1,s({type:`saved`,value:l})}catch(e){let n=e instanceof Error?e.message:t.saveError;throw h(n),Error(n)}finally{f(!1)}}},[l,t.saveError]);return xe({id:`session-storage`,dirty:v,saving:d,save:x,discard:b}),!e||!l?r?(0,Z.jsx)(ye,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(J,{className:`h-5 w-40`}),(0,Z.jsx)(J,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(ye,{children:[(0,Z.jsx)(ve,{icon:P,title:t.title,subtitle:t.hint}),(0,Z.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Z.jsx)(m,{type:`button`,variant:`secondary`,disabled:!v||d,onClick:b,children:t.discard}),(0,Z.jsx)(m,{type:`button`,variant:`primary`,disabled:!v||d,onClick:()=>void x().catch(()=>{}),children:d?t.saving:t.save})]}),p?(0,Z.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(se,{className:Qe(),value:l.dmScope,onChange:e=>y({dmScope:e.target.value}),children:[(0,Z.jsx)(W,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(W,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(W,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(W,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();y({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();y({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(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 nt(e){let t=(0,Te.c)(60),{open:n,loading:r,session:i,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:d,onPin:f,onUnpin:p,onExport:g,onDelete:_}=e,y=i?.status===`archived`,b=i?.status===`pinned`,x;t[0]===l?x=t[1]:(x=e=>!e&&l(),t[0]=l,t[1]=x);let S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(A,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,pe)}),t[2]=S):S=t[2];let ee;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(ee=a(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,ae,`dark:border-edge`),t[3]=ee):ee=t[3];let C;t[4]!==i||t[5]!==s||t[6]!==o?(C=i&&o?(0,Z.jsx)(te,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=s,t[6]=o,t[7]=C):C=t[7];let w;t[8]!==c.unnamedSession||t[9]!==i?.name?(w=i?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=i?.name,t[10]=w):w=t[10];let E;t[11]===w?E=t[12]:(E=(0,Z.jsx)(v,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:w}),t[11]=w,t[12]=E);let D;t[13]!==C||t[14]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[C,E]}),t[13]=C,t[14]=E,t[15]=D):D=t[15];let O;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(T,{className:`size-5`,strokeWidth:1.75}),t[16]=O):O=t[16];let k;t[17]===c.close?k=t[18]:(k=(0,Z.jsx)(h,{asChild:!0,children:(0,Z.jsx)(m,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:O})}),t[17]=c.close,t[18]=k);let N;t[19]!==D||t[20]!==k?(N=(0,Z.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:[D,k]}),t[19]=D,t[20]=k,t[21]=N):N=t[21];let P;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==i?(P=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:c.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=i,t[26]=P):P=t[26];let F;t[27]===P?F=t[28]:(F=(0,Z.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]!==c.detailExport||t[30]!==g?(I=(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:c.detailExport}),t[29]=c.detailExport,t[30]=g,t[31]=I):I=t[31];let L;t[32]!==y||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(L=y?(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=y,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=L):L=t[37];let R;t[38]!==b||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==f||t[42]!==p?(R=b?(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.unpin}):(0,Z.jsx)(m,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:c.pin}),t[38]=b,t[39]=c.pin,t[40]=c.unpin,t[41]=f,t[42]=p,t[43]=R):R=t[43];let z;t[44]!==c.delete||t[45]!==_?(z=(0,Z.jsx)(m,{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:_,children:c.delete}),t[44]=c.delete,t[45]=_,t[46]=z):z=t[46];let B;t[47]!==I||t[48]!==L||t[49]!==R||t[50]!==z?(B=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,R,z]})}),t[47]=I,t[48]=L,t[49]=R,t[50]=z,t[51]=B):B=t[51];let V;t[52]!==N||t[53]!==F||t[54]!==B?(V=(0,Z.jsxs)(M,{children:[S,(0,Z.jsxs)(j,{className:ee,"aria-describedby":void 0,children:[N,F,B]})]}),t[52]=N,t[53]=F,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==n||t[57]!==x||t[58]!==V?(H=(0,Z.jsx)(ge,{open:n,onOpenChange:x,children:V}),t[56]=n,t[57]=x,t[58]=V,t[59]=H):H=t[59],H}function rt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Te.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?ne: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,Z.jsx)(be,{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 pt(e){let t=(0,Te.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-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Z.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,Z.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 mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.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 ht(){let e=o(c(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:l,mutate:u}=d(r?[`gateway-chat-agents`,n]:null,f,{revalidateOnFocus:!1}),p=l?.defaultId??`main`,h=l?.items??[],[g,y]=i(),x=lt(g.get(`tab`)),S=(0,X.useCallback)(e=>{let t=new URLSearchParams(g);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),y(t,{replace:!0})},[g,y]),[ee,C]=(0,X.useReducer)(E,g,mt),{searchInput:w,debouncedSearch:T,statusFilter:D,viewMode:k,channelFilter:N,sessions:P,loading:F,error:te,hasMore:B,stats:W,detailOpen:re,detailLoading:G,detailSession:K,confirmOpen:se,confirmKey:q}=ee;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=w.trim();T!==e&&C({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[w,T]);let J=g.toString(),de=(0,X.useRef)(J);if(de.current!==J){de.current=J;let e=g.get(`q`)??``,t=g.get(`status`),n=g.get(`view`),r=(g.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();C({type:`patch`,patch:{...w===e?{}:{searchInput:e},...T===o?{}:{debouncedSearch:o},...D===i?{}:{statusFilter:i},...k===a?{}:{viewMode:a},...N===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(g),t=T.trim();t?e.set(`q`,t):e.delete(`q`),D===`all`?e.delete(`status`):e.set(`status`,D),k===`grid`?e.delete(`view`):e.set(`view`,k),N?e.set(`channel`,N):e.delete(`channel`),e.toString()!==g.toString()&&y(e,{replace:!0})},[T,g,y,D,k,N]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=!1;return(async()=>{C({type:`patch`,patch:{loading:!0,error:null}});try{let t=await le({limit:it,offset:0,...T?{search:T}:{},...D===`all`?{}:{status:D},...N?{channel:N}:{}});if(e)return;C({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||C({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||C({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,x,T,D,N,t.loadError]),(0,X.useEffect)(()=>{!r||x!==`sessions`||z().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,x]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=()=>void u();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,x,u]),(0,X.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||C({type:`patch`,patch:{sessions:P.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,x,P,K]);let _e=(0,X.useCallback)(async()=>{if(!(!r||F||!B)){C({type:`patch`,patch:{loading:!0,error:null}});try{let e=await le({limit:it,offset:P.length,...T?{search:T}:{},...D===`all`?{}:{status:D},...N?{channel:N}:{}});C({type:`patch`,patch:{sessions:[...P,...e.items],hasMore:e.hasMore}})}catch(e){C({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{C({type:`patch`,patch:{loading:!1}})}}},[r,F,B,P.length,T,D,N,t.loadError]),ve=(0,X.useCallback)((e,t)=>{C({type:`patch`,patch:{sessions:P.map(n=>n.key===e?{...n,status:t}:n),detailSession:K&&K.key===e?{...K,status:t}:K}})},[P,K]),ye=(0,X.useCallback)(async e=>{C({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{C({type:`patch`,patch:{detailSession:await R(e)}})}catch{C({type:`patch`,patch:{detailOpen:!1}})}finally{C({type:`patch`,patch:{detailLoading:!1}})}},[]),be=e=>{ye(e)},xe=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){C({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await L(e),ve(e,`archived`);break;case`unarchive`:await H(e),ve(e,`active`);break;case`pin`:await oe(e),ve(e,`pinned`);break;case`unpin`:await I(e),ve(e,`active`);break;case`export`:{let t=await fe(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}z().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te=async e=>{try{await ie(e),C({type:`patch`,patch:{sessions:P.filter(t=>t.key!==e),detailSession:K?.key===e?null:K,...K?.key===e?{detailOpen:!1}:{}}}),z().then(e=>C({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,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},ke=[{key:`all`,label:t.filterAll,icon:ne},{key:`active`,label:t.filterActive,icon:ce},{key:`pinned`,label:t.filterPinned,icon:_},{key:`archived`,label:t.filterArchived,icon:b}],Ae=(()=>{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,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:x,onChange:S}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:x,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Se,{}),(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:x,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ke.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":D===e,onClick:()=>C({type:`patch`,patch:{statusFilter:e}}),className:a(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,Y.transition,Y.focusRingPanel,D===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,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(U,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:w,onChange:e=>C({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":T||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!N,onClick:()=>C({type:`patch`,patch:{channelFilter:``}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,Y.transition,Y.focusRingPanel,N?`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}),Ae.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":N===e,onClick:()=>C({type:`patch`,patch:{channelFilter:e}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,Y.transition,Y.focusRingPanel,N===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,Z.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,Z.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,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,te?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:te}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:P.length})}),(0,Z.jsxs)(`div`,{className:we,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(m,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":k===`grid`,onClick:()=>C({type:`patch`,patch:{viewMode:`grid`}}),className:a(Ce,`size-7 p-0`,k===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,k===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(ue,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(m,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":k===`list`,onClick:()=>C({type:`patch`,patch:{viewMode:`list`}}),className:a(Ce,`size-9 p-0`,k===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,k===`list`&&`text-accent-fg`),children:(0,Z.jsx)(V,{className:`size-3.5`,strokeWidth:1.5})})]})]}),F&&P.length===0?(0,Z.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,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):P.length===0?(0,Z.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,Z.jsx)(O,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(m,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:a(`grid min-w-0 gap-3`,k===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":T||void 0,children:P.map(e=>{let t=he(e,p);return(0,Z.jsx)(Oe,{session:e,variant:k,labels:Ee,sessionAgentId:t,sessionAgentAvatar:me(t,h),onOpen:()=>be(e.key),onAction:t=>void xe(e.key,t)},e.key)})}),B?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(m,{type:`button`,variant:`secondary`,disabled:F,onClick:()=>void _e(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:re,loading:G,session:K,sessionAgentId:K?he(K,p):void 0,sessionAgentAvatar:K?me(he(K,p),h):void 0,labels:De,onClose:()=>{C({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>K&&void xe(K.key,`archive`),onUnarchive:()=>K&&void xe(K.key,`unarchive`),onPin:()=>K&&void xe(K.key,`pin`),onUnpin:()=>K&&void xe(K.key,`unpin`),onExport:()=>K&&void xe(K.key,`export`),onDelete:()=>K&&C({type:`patch`,patch:{confirmKey:K.key,confirmOpen:!0}})}),(0,Z.jsx)(ge,{open:se,onOpenChange:e=>C({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(M,{children:[(0,Z.jsx)(A,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,pe)}),(0,Z.jsxs)(j,{className:a(`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-panel p-4 shadow-popover dark:border-edge`,ae),children:[(0,Z.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:q?at(t.deleteSessionMessage,{name:P.find(e=>e.key===q)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(m,{type:`button`,variant:`secondary`,onClick:()=>C({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(m,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{q&&Te(q),C({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.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{ht as SessionsPage};
@@ -0,0 +1 @@
1
+ import{ni as e}from"./index-C0CGebQ1.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"./cn-JdwAhgNB.js";import{Ic as r,ws as i}from"./index-C1h0zkNo.js";var a=e();function o(){return`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(6),{children:r,className:i,id:c}=e,l;t[0]===i?l=t[1]:(l=n(o(),i),t[0]=i,t[1]=l);let u;return t[2]!==r||t[3]!==c||t[4]!==l?(u=(0,s.jsx)(`section`,{id:c,className:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u):u=t[5],u}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(29),{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;t[2]===h?v=t[3]:(v=h?n(`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):n(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),t[2]=h,t[3]=v);let y=v,b=!!(m&&h),x;t[4]===p?x=t[5]:(x=n(`mb-5 flex items-start gap-3`,p),t[4]=p,t[5]=x);let S;t[6]!==m||t[7]!==h||t[8]!==_||t[9]!==y||t[10]!==b?(S=m?b?(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:y,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)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}):(0,s.jsx)(`div`,{className:n(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[6]=m,t[7]=h,t[8]=_,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]===c?C=t[13]:(C=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=C);let w;t[14]!==C||t[15]!==f?(w=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[C,f]}),t[14]=C,t[15]=f,t[16]=w):w=t[16];let T;t[17]===u?T=t[18]:(T=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[17]=u,t[18]=T);let E;t[19]!==w||t[20]!==T?(E=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,T]}),t[19]=w,t[20]=T,t[21]=E):E=t[21];let D;t[22]===d?D=t[23]:(D=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[22]=d,t[23]=D);let O;return t[24]!==x||t[25]!==S||t[26]!==E||t[27]!==D?(O=(0,s.jsxs)(`div`,{className:x,children:[S,E,D]}),t[24]=x,t[25]=S,t[26]=E,t[27]=D,t[28]=O):O=t[28],O}export{u as n,o as r,c as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Ic as r,ws as i}from"./index-C0CGebQ1.js";var a=e();function o(){return`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(6),{children:r,className:i,id:c}=e,l;t[0]===i?l=t[1]:(l=n(o(),i),t[0]=i,t[1]=l);let u;return t[2]!==r||t[3]!==c||t[4]!==l?(u=(0,s.jsx)(`section`,{id:c,className:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u):u=t[5],u}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(29),{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;t[2]===h?v=t[3]:(v=h?n(`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):n(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),t[2]=h,t[3]=v);let y=v,b=!!(m&&h),x;t[4]===p?x=t[5]:(x=n(`mb-5 flex items-start gap-3`,p),t[4]=p,t[5]=x);let S;t[6]!==m||t[7]!==h||t[8]!==_||t[9]!==y||t[10]!==b?(S=m?b?(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:y,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)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}):(0,s.jsx)(`div`,{className:n(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[6]=m,t[7]=h,t[8]=_,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]===c?C=t[13]:(C=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=C);let w;t[14]!==C||t[15]!==f?(w=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[C,f]}),t[14]=C,t[15]=f,t[16]=w):w=t[16];let T;t[17]===u?T=t[18]:(T=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[17]=u,t[18]=T);let E;t[19]!==w||t[20]!==T?(E=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,T]}),t[19]=w,t[20]=T,t[21]=E):E=t[21];let D;t[22]===d?D=t[23]:(D=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[22]=d,t[23]=D);let O;return t[24]!==x||t[25]!==S||t[26]!==E||t[27]!==D?(O=(0,s.jsxs)(`div`,{className:x,children:[S,E,D]}),t[24]=x,t[25]=S,t[26]=E,t[27]=D,t[28]=O):O=t[28],O}export{u as n,o as r,c as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{ro as n}from"./index-C1h0zkNo.js";var r=e(),i=t();function a(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,s;return t[0]===a?s=t[1]:(s=(0,i.jsx)(`div`,{className:`flex flex-col gap-2.5`,"aria-busy":`true`,children:Array.from({length:a}).map(o)}),t[0]=a,t[1]=s),s}function o(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-48 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-72 max-w-full`})]},t)}function s(e){let t=(0,r.c)(3),{sections:a}=e,o=a===void 0?2:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-6 w-48 max-w-full`}),(0,i.jsx)(n,{className:`h-4 w-80 max-w-full`})]}),t[0]=s):s=t[0];let l;return t[1]===o?l=t[2]:(l=(0,i.jsxs)(`div`,{className:`flex flex-col gap-6`,"aria-busy":`true`,children:[s,Array.from({length:o}).map(c)]}),t[1]=o,t[2]=l),l}function c(e,t){return(0,i.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-5 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-4 w-72 max-w-full`}),(0,i.jsx)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:Array.from({length:4}).map(l)})]},t)}function l(e,t){return(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-3 w-24`}),(0,i.jsx)(n,{className:`h-10 w-full rounded-lg`})]},t)}function u(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,o;return t[0]===a?o=t[1]:(o=(0,i.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:Array.from({length:a}).map(d)}),t[0]=a,t[1]=o),o}function d(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-64 max-w-full`})]},t)}export{s as n,a as r,u as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{ro as n}from"./index-C0CGebQ1.js";var r=e(),i=t();function a(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,s;return t[0]===a?s=t[1]:(s=(0,i.jsx)(`div`,{className:`flex flex-col gap-2.5`,"aria-busy":`true`,children:Array.from({length:a}).map(o)}),t[0]=a,t[1]=s),s}function o(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-48 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-72 max-w-full`})]},t)}function s(e){let t=(0,r.c)(3),{sections:a}=e,o=a===void 0?2:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-6 w-48 max-w-full`}),(0,i.jsx)(n,{className:`h-4 w-80 max-w-full`})]}),t[0]=s):s=t[0];let l;return t[1]===o?l=t[2]:(l=(0,i.jsxs)(`div`,{className:`flex flex-col gap-6`,"aria-busy":`true`,children:[s,Array.from({length:o}).map(c)]}),t[1]=o,t[2]=l),l}function c(e,t){return(0,i.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-5 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-4 w-72 max-w-full`}),(0,i.jsx)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:Array.from({length:4}).map(l)})]},t)}function l(e,t){return(0,i.jsxs)(`div`,{className:`space-y-2`,children:[(0,i.jsx)(n,{className:`h-3 w-24`}),(0,i.jsx)(n,{className:`h-10 w-full rounded-lg`})]},t)}function u(e){let t=(0,r.c)(2),{rows:n}=e,a=n===void 0?3:n,o;return t[0]===a?o=t[1]:(o=(0,i.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:Array.from({length:a}).map(d)}),t[0]=a,t[1]=o),o}function d(e,t){return(0,i.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,i.jsx)(n,{className:`h-4 w-40 max-w-full`}),(0,i.jsx)(n,{className:`mt-2 h-3 w-64 max-w-full`})]},t)}export{s as n,a as r,u as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,r as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./messages-r8L6Ur3A.js";import{n as s}from"./locale-store-DVGhFXRz.js";import{So as c,_o as l,bo as u,do as d,fo as f,go as p,ho as m,mo as h,po as g,uo as _,vo as v,xo as y,yo as b}from"./index-C1h0zkNo.js";var x=n(),S=e(t(),1),C=r(),w=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`capability-presets`,`gateway`,`heartbeat`,`remote-access`,`shares`,`goals`,`dreams`],T=(0,S.lazy)(()=>u().then(e=>({default:e.SetupStatusPanel}))),E=(0,S.lazy)(()=>d().then(e=>({default:e.AppearanceSettingsPanel}))),D=(0,S.lazy)(()=>v().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),O=(0,S.lazy)(()=>c().then(e=>({default:e.SystemSettingsPanel}))),k=(0,S.lazy)(()=>g().then(e=>({default:e.DesktopPetSettings}))),A=(0,S.lazy)(()=>_().then(e=>({default:e.AppManagementSettingsPanel}))),j=(0,S.lazy)(()=>m().then(e=>({default:e.GatewaySettingsPanel}))),M=(0,S.lazy)(()=>l().then(e=>({default:e.HeartbeatSettingsPanel}))),N=(0,S.lazy)(()=>b().then(e=>({default:e.RemoteAccessHub}))),P=(0,S.lazy)(()=>y().then(e=>({default:e.SharesSettingsPanel}))),F=(0,S.lazy)(()=>h().then(e=>({default:e.DreamingSettingsPanel}))),I=(0,S.lazy)(()=>p().then(e=>({default:e.GoalsSettingsPanel}))),L=(0,S.lazy)(()=>f().then(e=>({default:e.CapabilityPresetsSettingsPanel})));function R(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,C.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function z(e){return(0,C.jsx)(S.Suspense,{fallback:(0,C.jsx)(R,{}),children:(0,C.jsx)(e,{})})}function B(){let e=(0,x.c)(28),{section:t}=i(),n=s(V),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||!w.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.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=z(T),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=z(E),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=z(D),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(O),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=z(k),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=z(A),e[13]=t):t=e[13],d=t;break bb0}if(s===`capability-presets`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(L),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(j),e[15]=t):t=e[15],d=t;break bb0}if(s===`heartbeat`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(M),e[16]=t):t=e[16],d=t;break bb0}if(s===`remote-access`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(N),e[17]=t):t=e[17],d=t;break bb0}if(s===`shares`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(P),e[18]=t):t=e[18],d=t;break bb0}if(s===`dreams`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(F),e[19]=t):t=e[19],d=t;break bb0}if(s===`goals`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(I),e[20]=t):t=e[20],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,C.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[21]!==r||e[22]!==c?(f=(0,C.jsx)(`p`,{className:r,children:c}),e[21]=r,e[22]=c,e[23]=f):f=e[23];let p;return e[24]!==l||e[25]!==u||e[26]!==f?(p=(0,C.jsxs)(`div`,{className:l,children:[u,f]}),e[24]=l,e[25]=u,e[26]=f,e[27]=p):p=e[27],p}function V(e){return e.language}export{B as SettingsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,r as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./messages-DP6tPKk-.js";import{n as s}from"./locale-store-CTwSy7yW.js";import{So as c,_o as l,bo as u,do as d,fo as f,go as p,ho as m,mo as h,po as g,uo as _,vo as v,xo as y,yo as b}from"./index-C0CGebQ1.js";var x=n(),S=e(t(),1),C=r(),w=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`capability-presets`,`gateway`,`heartbeat`,`remote-access`,`shares`,`goals`,`dreams`],T=(0,S.lazy)(()=>u().then(e=>({default:e.SetupStatusPanel}))),E=(0,S.lazy)(()=>d().then(e=>({default:e.AppearanceSettingsPanel}))),D=(0,S.lazy)(()=>v().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),O=(0,S.lazy)(()=>c().then(e=>({default:e.SystemSettingsPanel}))),k=(0,S.lazy)(()=>g().then(e=>({default:e.DesktopPetSettings}))),A=(0,S.lazy)(()=>_().then(e=>({default:e.AppManagementSettingsPanel}))),j=(0,S.lazy)(()=>m().then(e=>({default:e.GatewaySettingsPanel}))),M=(0,S.lazy)(()=>l().then(e=>({default:e.HeartbeatSettingsPanel}))),N=(0,S.lazy)(()=>b().then(e=>({default:e.RemoteAccessHub}))),P=(0,S.lazy)(()=>y().then(e=>({default:e.SharesSettingsPanel}))),F=(0,S.lazy)(()=>h().then(e=>({default:e.DreamingSettingsPanel}))),I=(0,S.lazy)(()=>p().then(e=>({default:e.GoalsSettingsPanel}))),L=(0,S.lazy)(()=>f().then(e=>({default:e.CapabilityPresetsSettingsPanel})));function R(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,C.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function z(e){return(0,C.jsx)(S.Suspense,{fallback:(0,C.jsx)(R,{}),children:(0,C.jsx)(e,{})})}function B(){let e=(0,x.c)(28),{section:t}=i(),n=s(V),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||!w.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.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=z(T),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=z(E),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=z(D),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(O),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=z(k),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=z(A),e[13]=t):t=e[13],d=t;break bb0}if(s===`capability-presets`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(L),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(j),e[15]=t):t=e[15],d=t;break bb0}if(s===`heartbeat`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(M),e[16]=t):t=e[16],d=t;break bb0}if(s===`remote-access`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(N),e[17]=t):t=e[17],d=t;break bb0}if(s===`shares`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(P),e[18]=t):t=e[18],d=t;break bb0}if(s===`dreams`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(F),e[19]=t):t=e[19],d=t;break bb0}if(s===`goals`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(I),e[20]=t):t=e[20],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,C.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[21]!==r||e[22]!==c?(f=(0,C.jsx)(`p`,{className:r,children:c}),e[21]=r,e[22]=c,e[23]=f):f=e[23];let p;return e[24]!==l||e[25]!==u||e[26]!==f?(p=(0,C.jsxs)(`div`,{className:l,children:[u,f]}),e[24]=l,e[25]=u,e[26]=f,e[27]=p):p=e[27],p}function V(e){return e.language}export{B as SettingsPage};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Wl as r}from"./index-C1h0zkNo.js";var i=e(),a=t();function o(e){let t=(0,i.c)(14),r,o,s,c,l;t[0]===e?(r=t[1],o=t[2],s=t[3],c=t[4],l=t[5]):({children:r,className:o,gap:c,padding:l,...s}=e,t[0]=e,t[1]=r,t[2]=o,t[3]=s,t[4]=c,t[5]=l);let u=c===void 0?`gap-4`:c,d=l===void 0?`px-3 py-6 sm:px-5 xl:px-6`:l,f;t[6]!==o||t[7]!==u||t[8]!==d?(f=n(`flex min-h-full w-full flex-col bg-surface-panel`,u,d,o),t[6]=o,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p;return t[10]!==r||t[11]!==s||t[12]!==f?(p=(0,a.jsx)(`div`,{className:f,...s,children:r}),t[10]=r,t[11]=s,t[12]=f,t[13]=p):p=t[13],p}function s(e){let t=(0,i.c)(20),{title:o,subtitle:s,docsLink:c,docsLabel:l,meta:u,actions:d,className:f}=e,p;t[0]===f?p=t[1]:(p=n(`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,f),t[0]=f,t[1]=p);let m;t[2]===o?m=t[3]:(m=(0,a.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:o}),t[2]=o,t[3]=m);let h;t[4]===s?h=t[5]:(h=s?(0,a.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null,t[4]=s,t[5]=h);let g;t[6]!==l||t[7]!==c?(g=c&&l?(0,a.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[l,(0,a.jsx)(r,{className:`size-3.5`,"aria-hidden":!0})]}):null,t[6]=l,t[7]=c,t[8]=g):g=t[8];let _;t[9]!==u||t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,a.jsxs)(`div`,{className:`min-w-0`,children:[m,h,g,u]}),t[9]=u,t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d?(0,a.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:d}):null,t[14]=d,t[15]=v);let y;return t[16]!==p||t[17]!==_||t[18]!==v?(y=(0,a.jsxs)(`header`,{className:p,children:[_,v]}),t[16]=p,t[17]=_,t[18]=v,t[19]=y):y=t[19],y}function c(e){let t=(0,i.c)(13),{id:r,activeTab:o,tabIdPrefix:s,panelIdPrefix:c,title:l,hint:u,showHeading:d,framed:f,children:p,className:m}=e,h=d===void 0?!0:d,g=f===void 0?!0:f;if(o!==r)return null;let _=`${c}-${r}`,v=`${s}-${r}`,y=g&&`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`,b;t[0]!==m||t[1]!==y?(b=n(`min-w-0`,y,m),t[0]=m,t[1]=y,t[2]=b):b=t[2];let x;t[3]!==u||t[4]!==h||t[5]!==l?(x=h&&(l||u)?(0,a.jsxs)(`div`,{className:`mb-5`,children:[l?(0,a.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:l}):null,u?(0,a.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}):null]}):null,t[3]=u,t[4]=h,t[5]=l,t[6]=x):x=t[6];let S;return t[7]!==p||t[8]!==_||t[9]!==v||t[10]!==b||t[11]!==x?(S=(0,a.jsxs)(`section`,{id:_,role:`tabpanel`,"aria-labelledby":v,className:b,children:[x,p]}),t[7]=p,t[8]=_,t[9]=v,t[10]=b,t[11]=x,t[12]=S):S=t[12],S}export{s as n,o as r,c as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Wl as r}from"./index-C0CGebQ1.js";var i=e(),a=t();function o(e){let t=(0,i.c)(14),r,o,s,c,l;t[0]===e?(r=t[1],o=t[2],s=t[3],c=t[4],l=t[5]):({children:r,className:o,gap:c,padding:l,...s}=e,t[0]=e,t[1]=r,t[2]=o,t[3]=s,t[4]=c,t[5]=l);let u=c===void 0?`gap-4`:c,d=l===void 0?`px-3 py-6 sm:px-5 xl:px-6`:l,f;t[6]!==o||t[7]!==u||t[8]!==d?(f=n(`flex min-h-full w-full flex-col bg-surface-panel`,u,d,o),t[6]=o,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p;return t[10]!==r||t[11]!==s||t[12]!==f?(p=(0,a.jsx)(`div`,{className:f,...s,children:r}),t[10]=r,t[11]=s,t[12]=f,t[13]=p):p=t[13],p}function s(e){let t=(0,i.c)(20),{title:o,subtitle:s,docsLink:c,docsLabel:l,meta:u,actions:d,className:f}=e,p;t[0]===f?p=t[1]:(p=n(`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,f),t[0]=f,t[1]=p);let m;t[2]===o?m=t[3]:(m=(0,a.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:o}),t[2]=o,t[3]=m);let h;t[4]===s?h=t[5]:(h=s?(0,a.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null,t[4]=s,t[5]=h);let g;t[6]!==l||t[7]!==c?(g=c&&l?(0,a.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[l,(0,a.jsx)(r,{className:`size-3.5`,"aria-hidden":!0})]}):null,t[6]=l,t[7]=c,t[8]=g):g=t[8];let _;t[9]!==u||t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,a.jsxs)(`div`,{className:`min-w-0`,children:[m,h,g,u]}),t[9]=u,t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d?(0,a.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:d}):null,t[14]=d,t[15]=v);let y;return t[16]!==p||t[17]!==_||t[18]!==v?(y=(0,a.jsxs)(`header`,{className:p,children:[_,v]}),t[16]=p,t[17]=_,t[18]=v,t[19]=y):y=t[19],y}function c(e){let t=(0,i.c)(13),{id:r,activeTab:o,tabIdPrefix:s,panelIdPrefix:c,title:l,hint:u,showHeading:d,framed:f,children:p,className:m}=e,h=d===void 0?!0:d,g=f===void 0?!0:f;if(o!==r)return null;let _=`${c}-${r}`,v=`${s}-${r}`,y=g&&`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`,b;t[0]!==m||t[1]!==y?(b=n(`min-w-0`,y,m),t[0]=m,t[1]=y,t[2]=b):b=t[2];let x;t[3]!==u||t[4]!==h||t[5]!==l?(x=h&&(l||u)?(0,a.jsxs)(`div`,{className:`mb-5`,children:[l?(0,a.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:l}):null,u?(0,a.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}):null]}):null,t[3]=u,t[4]=h,t[5]=l,t[6]=x):x=t[6];let S;return t[7]!==p||t[8]!==_||t[9]!==v||t[10]!==b||t[11]!==x?(S=(0,a.jsxs)(`section`,{id:_,role:`tabpanel`,"aria-labelledby":v,className:b,children:[x,p]}),t[7]=p,t[8]=_,t[9]=v,t[10]=b,t[11]=x,t[12]=S):S=t[12],S}export{s as n,o as r,c as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-r8L6Ur3A.js";import{l as s,n as c,r as l,s as u}from"./locale-store-DVGhFXRz.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$r as f,Cc as p,Gs as m,Hn as h,Qn as g,Ru as _,Ss as v,Zn as y,hu as b,ir as x,no as S,ou as C,pu as w,su as T,tc as E,tl as ee,vl as D,ws as O}from"./index-C1h0zkNo.js";import{n as k,r as A}from"./settings-page-layout-BQTLh-86.js";import{n as j}from"./settings-loading-skeleton-BD4peoAv.js";import{n as M,t as N}from"./settings-form-section-BSDNBfHn.js";var P=e(t(),1),F=n();function I(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`&&v(e)).length}function L(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t,r=typeof n.defaultPreset==`string`&&n.defaultPreset.trim()?n.defaultPreset.trim():`default`,i=n.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i[r]:void 0,o=a&&typeof a==`object`&&!Array.isArray(a)?a.models:void 0;if(!o||typeof o!=`object`||Array.isArray(o))return``;let s=o,c=s.roles;if(!c||typeof c!=`object`||Array.isArray(c))return``;let l=c,u=typeof s.defaultRole==`string`&&s.defaultRole.trim()?s.defaultRole.trim():Object.keys(l)[0],d=u?l[u]:void 0;if(!d||typeof d!=`object`||Array.isArray(d))return``;let f=d.model;return typeof f==`string`?f.trim():``}function R(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 z(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function B(e){return e?`pass`:`fail`}function V(e){if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(e){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>({id:e.id,label:e.label,status:e.status,message:e.message,hints:e.hints,path:V(e.id),source:`doctor`})).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function U(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let e of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:V(r.id)})}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message: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??[])n.push(t);return n}function ne(e){let t=I(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=L(e.config),o=a.length>0,s=e.hasToken&&e.sseConnected,c=R(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=te(u),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:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(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:B(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=U({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics});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 re(e){return z(e)}function W(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 ie(){return l(`/api/doctor`)}async function ae(){return((await u(ie())).checks??[]).map(W).filter(e=>e!==null)}function oe(){return l(`/api/logs/health`)}async function se(){return u(oe())}function G(e){return e?`pass`:`warn`}function K(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function le(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await u(l(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:G(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:K(`local`)}]}if(e.backend===`cloakbrowser`){let e=await u(l(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:G(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:K(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await u(l(`/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:K(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:K(e.backend||`overview`)}]}function q(){let e=(0,F.c)(57),t=s(he),n=c(me),r;e[0]===n?r=e[1]:(r=o(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,l=x(pe),{data:u,error:f,isLoading:p,mutate:m}=S(!!t),_;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},e[2]=_):_=e[2];let{data:v,error:b,isLoading:C,mutate:w}=d(t?`setup-checklist-skills`:null,fe,_),T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},e[3]=T):T=e[3];let{data:E,error:ee,isLoading:D,mutate:O}=d(t?`setup-checklist-provider-meta`:null,h,T),k;e[4]===t?k=e[5]:(k=t?ie():null,e[4]=t,e[5]=k);let A;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},e[6]=A):A=e[6];let{data:j,error:M,isLoading:N,mutate:P}=d(k,ae,A),I;e[7]===t?I=e[8]:(I=t?oe():null,e[7]=t,e[8]=I);let L;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[9]=L):L=e[9];let{data:R,isLoading:z,mutate:B}=d(I,se,L);u?.payload?.config;let V=u?.payload?.config,H;e[10]===V?H=e[11]:(H=re(V),e[10]=V,e[11]=H);let te=t?H:null,U;e[12]===te?U=e[13]:(U=ce(te),e[12]=te,e[13]=U);let W;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(W={revalidateOnFocus:!1},e[14]=W):W=e[14];let{data:G,isLoading:K,mutate:le}=d(U,de,W),q;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(q={revalidateOnFocus:!1},e[15]=q):q=e[15],d(t?y:null,g,q);let J=!t||!p&&!C&&!D&&!N&&!z&&!K,Y=!!(f||b||ee||M),X;bb0:{if(!t||!J){X=null;break bb0}let n=v?.catalog?.length??0,r;if(e[16]!==G||e[17]!==u?.payload?.config||e[18]!==j||e[19]!==a.channelConfigured||e[20]!==a.channelMissing||e[21]!==a.gatewayOffline||e[22]!==a.gatewayOnline||e[23]!==a.modelConfigured||e[24]!==a.modelMissing||e[25]!==a.providersConfigured||e[26]!==a.providersMetaReady||e[27]!==a.providersMissing||e[28]!==a.skillsConfigured||e[29]!==a.skillsMissing||e[30]!==R||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==E||e[33]!==n||e[34]!==l||e[35]!==t){let o=E?.filter(ue).length??0,s=E?.length??0,c;e[37]===a.providersConfigured?c=e[38]:(c=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=c);let d;e[39]===a.providersMetaReady?d=e[40]:(d=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[39]=a.providersMetaReady,e[40]=d);let f;e[41]===a.modelConfigured?f=e[42]:(f=e=>a.modelConfigured.replace(`{{model}}`,e),e[41]=a.modelConfigured,e[42]=f);let p;e[43]===a.skillsConfigured?p=e[44]:(p=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[43]=a.skillsConfigured,e[44]=p),r=ne({hasToken:!!t,sseConnected:l,config:u?.payload?.config,skillCount:n,providerMeta:s>0?{configured:o,total:s}:null,doctorChecks:j,logsHealth:R,browserDiagnostics:G,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:c,providersMetaReady:d,providersMissing:a.providersMissing,modelConfigured:f,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:p,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[16]=G,e[17]=u?.payload?.config,e[18]=j,e[19]=a.channelConfigured,e[20]=a.channelMissing,e[21]=a.gatewayOffline,e[22]=a.gatewayOnline,e[23]=a.modelConfigured,e[24]=a.modelMissing,e[25]=a.providersConfigured,e[26]=a.providersMetaReady,e[27]=a.providersMissing,e[28]=a.skillsConfigured,e[29]=a.skillsMissing,e[30]=R,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=E,e[33]=n,e[34]=l,e[35]=t,e[36]=r}else r=e[36];X=r}let Z=X,Q;e[45]!==le||e[46]!==m||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==w?(Q=async()=>{await Promise.all([m(),w(),O(),P(),B(),le()])},e[45]=le,e[46]=m,e[47]=P,e[48]=B,e[49]=O,e[50]=w,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==Y||e[53]!==J||e[54]!==ge||e[55]!==Z?($={ready:J,error:Y,snapshot:Z,refresh:ge},e[52]=Y,e[53]=J,e[54]=ge,e[55]=Z,e[56]=$):$=e[56],$}function ue(e){return e.configured}function de(e){let[,t]=e;return le(t)}function fe(){return f()}function pe(e){return e.connectionState===`connected`}function me(e){return e.language}function he(e){return e.token}var J=r();function Y(e){return e===`pass`?`border-success/30 bg-success-soft text-success`:e===`warn`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge bg-surface-hover text-fg-muted`}function X(e){return e===`pass`?w:e===`warn`?m:e===`fail`?T:D}function Z(e,t){return e===`blocked`?{icon:T,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:m,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:C,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:w,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,F.c)(48),{tier:n,issueCount:r,onRunDoctor:s,ready:l,doctorRunning:u,doctorRunState:d}=e,f=c(ge),m,h,g,_,v,y,x,S,C,w,T;if(t[0]!==r||t[1]!==f||t[2]!==n){h=o(f).setupStatus;let e=Z(n,h),s=e.icon,c=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=c?(0,J.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(c)?.scrollIntoView({block:`start`,behavior:`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,J.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}):(0,J.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,J.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}),T=a(`rounded-xl p-4`,e.className),w=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,S=`flex min-w-0 gap-3`,C=(0,J.jsx)(s,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),v=`min-w-0`,y=(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),x=(0,J.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),g=`mt-2 text-xs opacity-75`,_=h.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=f,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]=C,t[12]=w,t[13]=T}else m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],x=t[9],S=t[10],C=t[11],w=t[12],T=t[13];let E;t[14]!==g||t[15]!==_?(E=(0,J.jsx)(`p`,{className:g,children:_}),t[14]=g,t[15]=_,t[16]=E):E=t[16];let D;t[17]!==E||t[18]!==v||t[19]!==y||t[20]!==x?(D=(0,J.jsxs)(`div`,{className:v,children:[y,x,E]}),t[17]=E,t[18]=v,t[19]=y,t[20]=x,t[21]=D):D=t[21];let k;t[22]!==D||t[23]!==S||t[24]!==C?(k=(0,J.jsxs)(`div`,{className:S,children:[C,D]}),t[22]=D,t[23]=S,t[24]=C,t[25]=k):k=t[25];let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=a(`inline-flex items-center gap-2 rounded-lg border border-edge bg-surface-base 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`,O.press),t[26]=A):A=t[26];let j=!l||u,M;t[27]===u?M=t[28]:(M=u?(0,J.jsx)(ee,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?h.health.runDoctorRunning:h.health.runDoctor,P;t[29]!==u||t[30]!==s||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,J.jsxs)(`button`,{type:`button`,className:A,onClick:s,disabled:j,"aria-busy":u,children:[M,N]}),t[29]=u,t[30]=s,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let I;t[35]!==m||t[36]!==P?(I=(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,P]}),t[35]=m,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==w?(L=(0,J.jsxs)(`div`,{className:w,children:[k,I]}),t[38]=k,t[39]=I,t[40]=w,t[41]=L):L=t[41];let R=u?h.health.doctorRunningMessage:d===`success`?h.health.doctorCompleteMessage:d===`error`?h.health.doctorFailedMessage:h.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,J.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:R}),t[42]=R,t[43]=z);let B;return t[44]!==L||t[45]!==z||t[46]!==T?(B=(0,J.jsxs)(`section`,{className:T,children:[L,z]}),t[44]=L,t[45]=z,t[46]=T,t[47]=B):B=t[47],B}function ge(e){return e.language}function $(e){let t=(0,F.c)(34),{issue:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,J.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,J.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.status?u=t[7]:(u=a(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,J.jsx)(`span`,{className:u,children:n.status}),t[8]=n.status,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.message?p=t[15]:(p=(0,J.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=p);let m;t[16]===n.hints[0]?m=t[17]:(m=n.hints[0]?(0,J.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=m);let h;t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,J.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}):null,t[22]=r,t[23]=n.path,t[24]=g):g=t[24];let _;t[25]!==g||t[26]!==c||t[27]!==h?(_=(0,J.jsxs)(J.Fragment,{children:[c,h,g]}),t[25]=g,t[26]=c,t[27]=h,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,J.jsx)(i,{to:n.path,className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v}),t[29]=v,t[30]=n.path,t[31]=e):e=t[31],e}let y;return t[32]===v?y=t[33]:(y=(0,J.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:v}),t[32]=v,t[33]=y),y}function _e(e){let t=(0,F.c)(27),{item:n,labels:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=a(`flex size-7 shrink-0 items-center justify-center rounded-full border`,Y(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,J.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,J.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,J.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,J.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,J.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,J.jsx)(b,{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,J.jsxs)(J.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,J.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,J.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function ve(e){let t=(0,F.c)(29),{signal:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,J.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.message?u=t[7]:(u=(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n.status?f=t[12]:(f=a(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,J.jsx)(`span`,{className:f,children:n.status}),t[13]=n.status,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==r||t[17]!==n.path?(m=n.path?(0,J.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=m):m=t[18];let h;t[19]!==c||t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,J.jsxs)(J.Fragment,{children:[c,d,p,m]}),t[19]=c,t[20]=d,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,J.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g}),t[24]=g,t[25]=n.path,t[26]=e):e=t[26],e}let _;return t[27]===g?_=t[28]:(_=(0,J.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:g}),t[27]=g,t[28]=_),_}function ye(){let e=o(c(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=q(),[s,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(`idle`),f=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],h=async()=>{if(!(s||!t)){l(!0),d(`idle`);try{await i(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,J.jsxs)(A,{gap:`gap-6`,children:[(0,J.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,J.jsxs)(`button`,{type:`button`,className:a(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge 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`,O.press),onClick:()=>void h(),disabled:!t||s,"aria-busy":s,children:[(0,J.jsx)(p,{className:a(`size-4`,(!t||s)&&`animate-spin`),"aria-hidden":!0}),s?e.health.runDoctorRunning:e.refresh]})}),n?(0,J.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,J.jsx)(j,{sections:2}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void h(),doctorRunning:s,doctorRunState:u}),(0,J.jsxs)(N,{id:`next-steps`,children:[(0,J.jsx)(M,{icon:r.issues.length?m:_,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,J.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,J.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,J.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,J.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,J.jsxs)(N,{children:[(0,J.jsx)(M,{icon:E,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),f.length?(0,J.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:f.map(t=>(0,J.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,J.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-panel/80 p-3 text-sm text-fg-muted shadow-surface`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{ye 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-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DP6tPKk-.js";import{l as s,n as c,r as l,s as u}from"./locale-store-CTwSy7yW.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$r as f,Cc as p,Gs as m,Hn as h,Qn as g,Ru as _,Ss as v,Zn as y,hu as b,ir as x,no as S,ou as C,pu as w,su as T,tc as E,tl as ee,vl as D,ws as O}from"./index-C0CGebQ1.js";import{n as k,r as A}from"./settings-page-layout-DgFSya2e.js";import{n as j}from"./settings-loading-skeleton-Bk58_cr7.js";import{n as M,t as N}from"./settings-form-section-C6ZbNpdy.js";var P=e(t(),1),F=n();function I(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`&&v(e)).length}function L(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t,r=typeof n.defaultPreset==`string`&&n.defaultPreset.trim()?n.defaultPreset.trim():`default`,i=n.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i[r]:void 0,o=a&&typeof a==`object`&&!Array.isArray(a)?a.models:void 0;if(!o||typeof o!=`object`||Array.isArray(o))return``;let s=o,c=s.roles;if(!c||typeof c!=`object`||Array.isArray(c))return``;let l=c,u=typeof s.defaultRole==`string`&&s.defaultRole.trim()?s.defaultRole.trim():Object.keys(l)[0],d=u?l[u]:void 0;if(!d||typeof d!=`object`||Array.isArray(d))return``;let f=d.model;return typeof f==`string`?f.trim():``}function R(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 z(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function B(e){return e?`pass`:`fail`}function V(e){if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(e){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>({id:e.id,label:e.label,status:e.status,message:e.message,hints:e.hints,path:V(e.id),source:`doctor`})).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function U(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let e of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:V(r.id)})}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message: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??[])n.push(t);return n}function ne(e){let t=I(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=L(e.config),o=a.length>0,s=e.hasToken&&e.sseConnected,c=R(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=te(u),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:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(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:B(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=U({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics});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 re(e){return z(e)}function W(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 ie(){return l(`/api/doctor`)}async function ae(){return((await u(ie())).checks??[]).map(W).filter(e=>e!==null)}function oe(){return l(`/api/logs/health`)}async function se(){return u(oe())}function G(e){return e?`pass`:`warn`}function K(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function le(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await u(l(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:G(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:K(`local`)}]}if(e.backend===`cloakbrowser`){let e=await u(l(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:G(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:K(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await u(l(`/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:K(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:K(e.backend||`overview`)}]}function q(){let e=(0,F.c)(57),t=s(he),n=c(me),r;e[0]===n?r=e[1]:(r=o(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,l=x(pe),{data:u,error:f,isLoading:p,mutate:m}=S(!!t),_;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},e[2]=_):_=e[2];let{data:v,error:b,isLoading:C,mutate:w}=d(t?`setup-checklist-skills`:null,fe,_),T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},e[3]=T):T=e[3];let{data:E,error:ee,isLoading:D,mutate:O}=d(t?`setup-checklist-provider-meta`:null,h,T),k;e[4]===t?k=e[5]:(k=t?ie():null,e[4]=t,e[5]=k);let A;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},e[6]=A):A=e[6];let{data:j,error:M,isLoading:N,mutate:P}=d(k,ae,A),I;e[7]===t?I=e[8]:(I=t?oe():null,e[7]=t,e[8]=I);let L;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[9]=L):L=e[9];let{data:R,isLoading:z,mutate:B}=d(I,se,L);u?.payload?.config;let V=u?.payload?.config,H;e[10]===V?H=e[11]:(H=re(V),e[10]=V,e[11]=H);let te=t?H:null,U;e[12]===te?U=e[13]:(U=ce(te),e[12]=te,e[13]=U);let W;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(W={revalidateOnFocus:!1},e[14]=W):W=e[14];let{data:G,isLoading:K,mutate:le}=d(U,de,W),q;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(q={revalidateOnFocus:!1},e[15]=q):q=e[15],d(t?y:null,g,q);let J=!t||!p&&!C&&!D&&!N&&!z&&!K,Y=!!(f||b||ee||M),X;bb0:{if(!t||!J){X=null;break bb0}let n=v?.catalog?.length??0,r;if(e[16]!==G||e[17]!==u?.payload?.config||e[18]!==j||e[19]!==a.channelConfigured||e[20]!==a.channelMissing||e[21]!==a.gatewayOffline||e[22]!==a.gatewayOnline||e[23]!==a.modelConfigured||e[24]!==a.modelMissing||e[25]!==a.providersConfigured||e[26]!==a.providersMetaReady||e[27]!==a.providersMissing||e[28]!==a.skillsConfigured||e[29]!==a.skillsMissing||e[30]!==R||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==E||e[33]!==n||e[34]!==l||e[35]!==t){let o=E?.filter(ue).length??0,s=E?.length??0,c;e[37]===a.providersConfigured?c=e[38]:(c=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=c);let d;e[39]===a.providersMetaReady?d=e[40]:(d=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[39]=a.providersMetaReady,e[40]=d);let f;e[41]===a.modelConfigured?f=e[42]:(f=e=>a.modelConfigured.replace(`{{model}}`,e),e[41]=a.modelConfigured,e[42]=f);let p;e[43]===a.skillsConfigured?p=e[44]:(p=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[43]=a.skillsConfigured,e[44]=p),r=ne({hasToken:!!t,sseConnected:l,config:u?.payload?.config,skillCount:n,providerMeta:s>0?{configured:o,total:s}:null,doctorChecks:j,logsHealth:R,browserDiagnostics:G,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:c,providersMetaReady:d,providersMissing:a.providersMissing,modelConfigured:f,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:p,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[16]=G,e[17]=u?.payload?.config,e[18]=j,e[19]=a.channelConfigured,e[20]=a.channelMissing,e[21]=a.gatewayOffline,e[22]=a.gatewayOnline,e[23]=a.modelConfigured,e[24]=a.modelMissing,e[25]=a.providersConfigured,e[26]=a.providersMetaReady,e[27]=a.providersMissing,e[28]=a.skillsConfigured,e[29]=a.skillsMissing,e[30]=R,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=E,e[33]=n,e[34]=l,e[35]=t,e[36]=r}else r=e[36];X=r}let Z=X,Q;e[45]!==le||e[46]!==m||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==w?(Q=async()=>{await Promise.all([m(),w(),O(),P(),B(),le()])},e[45]=le,e[46]=m,e[47]=P,e[48]=B,e[49]=O,e[50]=w,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==Y||e[53]!==J||e[54]!==ge||e[55]!==Z?($={ready:J,error:Y,snapshot:Z,refresh:ge},e[52]=Y,e[53]=J,e[54]=ge,e[55]=Z,e[56]=$):$=e[56],$}function ue(e){return e.configured}function de(e){let[,t]=e;return le(t)}function fe(){return f()}function pe(e){return e.connectionState===`connected`}function me(e){return e.language}function he(e){return e.token}var J=r();function Y(e){return e===`pass`?`border-success/30 bg-success-soft text-success`:e===`warn`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge bg-surface-hover text-fg-muted`}function X(e){return e===`pass`?w:e===`warn`?m:e===`fail`?T:D}function Z(e,t){return e===`blocked`?{icon:T,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:m,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:C,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:w,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,F.c)(48),{tier:n,issueCount:r,onRunDoctor:s,ready:l,doctorRunning:u,doctorRunState:d}=e,f=c(ge),m,h,g,_,v,y,x,S,C,w,T;if(t[0]!==r||t[1]!==f||t[2]!==n){h=o(f).setupStatus;let e=Z(n,h),s=e.icon,c=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=c?(0,J.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(c)?.scrollIntoView({block:`start`,behavior:`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,J.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}):(0,J.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,J.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}),T=a(`rounded-xl p-4`,e.className),w=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,S=`flex min-w-0 gap-3`,C=(0,J.jsx)(s,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),v=`min-w-0`,y=(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),x=(0,J.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),g=`mt-2 text-xs opacity-75`,_=h.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=f,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]=C,t[12]=w,t[13]=T}else m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],x=t[9],S=t[10],C=t[11],w=t[12],T=t[13];let E;t[14]!==g||t[15]!==_?(E=(0,J.jsx)(`p`,{className:g,children:_}),t[14]=g,t[15]=_,t[16]=E):E=t[16];let D;t[17]!==E||t[18]!==v||t[19]!==y||t[20]!==x?(D=(0,J.jsxs)(`div`,{className:v,children:[y,x,E]}),t[17]=E,t[18]=v,t[19]=y,t[20]=x,t[21]=D):D=t[21];let k;t[22]!==D||t[23]!==S||t[24]!==C?(k=(0,J.jsxs)(`div`,{className:S,children:[C,D]}),t[22]=D,t[23]=S,t[24]=C,t[25]=k):k=t[25];let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=a(`inline-flex items-center gap-2 rounded-lg border border-edge bg-surface-base 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`,O.press),t[26]=A):A=t[26];let j=!l||u,M;t[27]===u?M=t[28]:(M=u?(0,J.jsx)(ee,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?h.health.runDoctorRunning:h.health.runDoctor,P;t[29]!==u||t[30]!==s||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,J.jsxs)(`button`,{type:`button`,className:A,onClick:s,disabled:j,"aria-busy":u,children:[M,N]}),t[29]=u,t[30]=s,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let I;t[35]!==m||t[36]!==P?(I=(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,P]}),t[35]=m,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==w?(L=(0,J.jsxs)(`div`,{className:w,children:[k,I]}),t[38]=k,t[39]=I,t[40]=w,t[41]=L):L=t[41];let R=u?h.health.doctorRunningMessage:d===`success`?h.health.doctorCompleteMessage:d===`error`?h.health.doctorFailedMessage:h.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,J.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:R}),t[42]=R,t[43]=z);let B;return t[44]!==L||t[45]!==z||t[46]!==T?(B=(0,J.jsxs)(`section`,{className:T,children:[L,z]}),t[44]=L,t[45]=z,t[46]=T,t[47]=B):B=t[47],B}function ge(e){return e.language}function $(e){let t=(0,F.c)(34),{issue:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,J.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,J.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.status?u=t[7]:(u=a(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,J.jsx)(`span`,{className:u,children:n.status}),t[8]=n.status,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.message?p=t[15]:(p=(0,J.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=p);let m;t[16]===n.hints[0]?m=t[17]:(m=n.hints[0]?(0,J.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=m);let h;t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,J.jsx)(b,{className:`size-4`,"aria-hidden":!0})]}):null,t[22]=r,t[23]=n.path,t[24]=g):g=t[24];let _;t[25]!==g||t[26]!==c||t[27]!==h?(_=(0,J.jsxs)(J.Fragment,{children:[c,h,g]}),t[25]=g,t[26]=c,t[27]=h,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,J.jsx)(i,{to:n.path,className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v}),t[29]=v,t[30]=n.path,t[31]=e):e=t[31],e}let y;return t[32]===v?y=t[33]:(y=(0,J.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:v}),t[32]=v,t[33]=y),y}function _e(e){let t=(0,F.c)(27),{item:n,labels:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=a(`flex size-7 shrink-0 items-center justify-center rounded-full border`,Y(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,J.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,J.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,J.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,J.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,J.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,J.jsx)(b,{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,J.jsxs)(J.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,J.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,J.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function ve(e){let t=(0,F.c)(29),{signal:n,fixLabel:r}=e,o;t[0]===n.status?o=t[1]:(o=X(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,J.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.message?u=t[7]:(u=(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n.status?f=t[12]:(f=a(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,Y(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,J.jsx)(`span`,{className:f,children:n.status}),t[13]=n.status,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==r||t[17]!==n.path?(m=n.path?(0,J.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=m):m=t[18];let h;t[19]!==c||t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,J.jsxs)(J.Fragment,{children:[c,d,p,m]}),t[19]=c,t[20]=d,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,J.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g}),t[24]=g,t[25]=n.path,t[26]=e):e=t[26],e}let _;return t[27]===g?_=t[28]:(_=(0,J.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:g}),t[27]=g,t[28]=_),_}function ye(){let e=o(c(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=q(),[s,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(`idle`),f=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],h=async()=>{if(!(s||!t)){l(!0),d(`idle`);try{await i(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,J.jsxs)(A,{gap:`gap-6`,children:[(0,J.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,J.jsxs)(`button`,{type:`button`,className:a(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge 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`,O.press),onClick:()=>void h(),disabled:!t||s,"aria-busy":s,children:[(0,J.jsx)(p,{className:a(`size-4`,(!t||s)&&`animate-spin`),"aria-hidden":!0}),s?e.health.runDoctorRunning:e.refresh]})}),n?(0,J.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,J.jsx)(j,{sections:2}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void h(),doctorRunning:s,doctorRunState:u}),(0,J.jsxs)(N,{id:`next-steps`,children:[(0,J.jsx)(M,{icon:r.issues.length?m:_,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,J.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,J.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,J.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,J.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,J.jsxs)(N,{children:[(0,J.jsx)(M,{icon:E,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),f.length?(0,J.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:f.map(t=>(0,J.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,J.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-panel/80 p-3 text-sm text-fg-muted shadow-surface`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{ye as SetupStatusPanel};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-B2_kr5EA.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./preload-helper-zJ_50EbN.js";import{d as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./locale-store-DVGhFXRz.js";import{$i as s,Jl as c,Wl as l,Ya as u,Zi as d,ea as f,qi as p,ro as m}from"./index-C1h0zkNo.js";var h=e(t(),1),g=n();function _(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function v(){let{token:e}=i(),t=a(e=>e.language),n=t===`zh`?b:x,[v,S]=(0,h.useState)(null),[C,w]=(0,h.useState)(_),[T,E]=(0,h.useState)(!0),[D,O]=(0,h.useState)(null),k=(0,h.useMemo)(()=>{if(!v||!e||v.kind!==`file`)return null;let t=s(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:d(v.fileName,t),source:{kind:`share`,token:e}}},[v,e]);(0,h.useEffect)(()=>{if(!e){O(n.invalidLink),E(!1);return}let t=!1;return(async()=>{try{E(!0),O(null),w(_());let i=await fetch(o(`/s/${encodeURIComponent(e)}/meta`));if(!i.ok){t||O(i.status===404?n.notFound:n.expired);return}let a=await i.json();if(t)return;if(S(a),!a.valid){O(n.expired);return}if(a.kind!==`file`)return;let c=s(a.fileName,a.mimeType),l=d(a.fileName,c),p=f(l),m=o(`/s/${encodeURIComponent(e)}?inline=1`);if(p===`text`){if(a.fileSize>5242880){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let r=await e.text();t||w({..._(),textContent:r});return}if(p===`binary`){if(a.fileSize>33554432){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let i=await e.arrayBuffer();if(t)return;if(l===`pptx`){let{processPptx:e}=await r(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(i,a.fileName),n=t.length>u;w({textContent:null,binaryBuffer:i,extractedText:n?t.slice(0,u):t,extractedTextTruncated:n});return}w({..._(),binaryBuffer:i})}}catch(e){t||O(e instanceof Error?e.message:String(e))}finally{t||E(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let A=e?o(`/s/${encodeURIComponent(e)}?dl=1`):`#`,j=e?o(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return(0,g.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-surface-base`,children:[(0,g.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,g.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v?(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:v.fileName,children:v.fileName}):T?(0,g.jsx)(m,{className:`h-4 w-48 max-w-full`}):(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),v?(0,g.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[y(v.fileSize),` · `,n.expiresAt,` `,new Date(v.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]}),v?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`a`,{href:j,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,g.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.openInline]}),(0,g.jsxs)(`a`,{href:A,className:`inline-flex items-center gap-1 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:opacity-90`,download:v.fileName,children:[(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n.download]})]}):null]}),(0,g.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:T?(0,g.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,g.jsx)(m,{className:`h-5 w-56 max-w-full`}),(0,g.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,g.jsx)(m,{className:`h-4 w-full`}),(0,g.jsx)(m,{className:`h-4 w-11/12`}),(0,g.jsx)(m,{className:`h-4 w-10/12`}),(0,g.jsx)(m,{className:`h-4 w-3/4`})]}),(0,g.jsx)(m,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):D?(0,g.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,g.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,g.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:D})]}):v?.kind===`directory`?(0,g.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):k?(0,g.jsx)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,g.jsx)(p,{language:t,descriptor:k,loading:!1,loadError:null,textContent:C.textContent,binaryBuffer:C.binaryBuffer,extractedText:C.extractedText,extractedTextTruncated:C.extractedTextTruncated,actions:{onDownload:()=>{window.location.href=A},canDownload:!0}})}):null})]})}function y(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 b={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,download:`下载`,openInline:`在新窗口打开`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`},x={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,download:`Download`,openInline:`Open raw`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`};export{v as SharePreviewPage};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./preload-helper-zJ_50EbN.js";import{d as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./locale-store-CTwSy7yW.js";import{$i as s,Jl as c,Wl as l,Ya as u,Zi as d,ea as f,qi as p,ro as m}from"./index-C0CGebQ1.js";var h=e(t(),1),g=n();function _(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function v(){let{token:e}=i(),t=a(e=>e.language),n=t===`zh`?b:x,[v,S]=(0,h.useState)(null),[C,w]=(0,h.useState)(_),[T,E]=(0,h.useState)(!0),[D,O]=(0,h.useState)(null),k=(0,h.useMemo)(()=>{if(!v||!e||v.kind!==`file`)return null;let t=s(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:d(v.fileName,t),source:{kind:`share`,token:e}}},[v,e]);(0,h.useEffect)(()=>{if(!e){O(n.invalidLink),E(!1);return}let t=!1;return(async()=>{try{E(!0),O(null),w(_());let i=await fetch(o(`/s/${encodeURIComponent(e)}/meta`));if(!i.ok){t||O(i.status===404?n.notFound:n.expired);return}let a=await i.json();if(t)return;if(S(a),!a.valid){O(n.expired);return}if(a.kind!==`file`)return;let c=s(a.fileName,a.mimeType),l=d(a.fileName,c),p=f(l),m=o(`/s/${encodeURIComponent(e)}?inline=1`);if(p===`text`){if(a.fileSize>5242880){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let r=await e.text();t||w({..._(),textContent:r});return}if(p===`binary`){if(a.fileSize>33554432){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let i=await e.arrayBuffer();if(t)return;if(l===`pptx`){let{processPptx:e}=await r(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(i,a.fileName),n=t.length>u;w({textContent:null,binaryBuffer:i,extractedText:n?t.slice(0,u):t,extractedTextTruncated:n});return}w({..._(),binaryBuffer:i})}}catch(e){t||O(e instanceof Error?e.message:String(e))}finally{t||E(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let A=e?o(`/s/${encodeURIComponent(e)}?dl=1`):`#`,j=e?o(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return(0,g.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-surface-base`,children:[(0,g.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,g.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v?(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:v.fileName,children:v.fileName}):T?(0,g.jsx)(m,{className:`h-4 w-48 max-w-full`}):(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),v?(0,g.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[y(v.fileSize),` · `,n.expiresAt,` `,new Date(v.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]}),v?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`a`,{href:j,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,g.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.openInline]}),(0,g.jsxs)(`a`,{href:A,className:`inline-flex items-center gap-1 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:opacity-90`,download:v.fileName,children:[(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n.download]})]}):null]}),(0,g.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:T?(0,g.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,g.jsx)(m,{className:`h-5 w-56 max-w-full`}),(0,g.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,g.jsx)(m,{className:`h-4 w-full`}),(0,g.jsx)(m,{className:`h-4 w-11/12`}),(0,g.jsx)(m,{className:`h-4 w-10/12`}),(0,g.jsx)(m,{className:`h-4 w-3/4`})]}),(0,g.jsx)(m,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):D?(0,g.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,g.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,g.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:D})]}):v?.kind===`directory`?(0,g.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):k?(0,g.jsx)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,g.jsx)(p,{language:t,descriptor:k,loading:!1,loadError:null,textContent:C.textContent,binaryBuffer:C.binaryBuffer,extractedText:C.extractedText,extractedTextTruncated:C.extractedTextTruncated,actions:{onDownload:()=>{window.location.href=A},canDownload:!0}})}):null})]})}function y(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 b={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,download:`下载`,openInline:`在新窗口打开`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`},x={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,download:`Download`,openInline:`Open raw`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`};export{v as SharePreviewPage};