@xopcai/xopc 0.0.190 → 0.0.191

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 (104) 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/{agent-avatar-dicebear-9vAbkroX.js → agent-avatar-dicebear-DvEkT222.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agents-D1t4SfMQ.js → agents-CXyivfqY.js} +1 -1
  5. package/dist/gateway/static/root/assets/{app-management-settings-panel-DkFeIdBf.js → app-management-settings-panel-COpP_pKN.js} +1 -1
  6. package/dist/gateway/static/root/assets/{appearance-settings-Bxs8Fpaj.js → appearance-settings-DTVNUEDq.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-Cgrgu5OW.js → apps-page-DsE67BSO.js} +1 -1
  8. package/dist/gateway/static/root/assets/{archive-plugin-Ch2RmLCC.js → archive-plugin-IpX6VA0o.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-BhMQM_Ky.js → attachment-load-CKVFNUi1.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automations-page-CtJxstKh.js → automations-page-D0TVev47.js} +1 -1
  11. package/dist/gateway/static/root/assets/{binary-plugins-D6CqlymH.js → binary-plugins-BrfvfOS4.js} +1 -1
  12. package/dist/gateway/static/root/assets/{block-editor-ClL6HEg9.js → block-editor-D9sEfg32.js} +1 -1
  13. package/dist/gateway/static/root/assets/{browser-settings-page-DW99iDmD.js → browser-settings-page-DpZzq8j2.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-workflow-inputs-BYy48VhN.js → browser-workflow-inputs-BixZ5lCR.js} +1 -1
  15. package/dist/gateway/static/root/assets/{browser-workflows-page-zgLibuMH.js → browser-workflows-page-YEFuodJI.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CHUrT9EB.js → capabilities-settings-panel-B9Cmcuff.js} +2 -2
  17. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Cycrv0YV.js → capability-presets-settings-panel-C_EpuQtk.js} +1 -1
  18. package/dist/gateway/static/root/assets/{channels-settings-V96gPUAU.js → channels-settings-CvzD5qSv.js} +1 -1
  19. package/dist/gateway/static/root/assets/{connectors-api-DS9ED-EL.js → connectors-api-BMMqC0_9.js} +1 -1
  20. package/dist/gateway/static/root/assets/{connectors-page-BhlyQoQI.js → connectors-page-BKrm7tJ9.js} +1 -1
  21. package/dist/gateway/static/root/assets/{cron-expression-CkgsvhtW.js → cron-expression-Bm8koRoD.js} +1 -1
  22. package/dist/gateway/static/root/assets/{desktop-pet-Cv8rGhYW.js → desktop-pet-CMG3mcaJ.js} +1 -1
  23. package/dist/gateway/static/root/assets/{desktop-pet-settings-CIeJdwfV.js → desktop-pet-settings-D8aaPb0x.js} +1 -1
  24. package/dist/gateway/static/root/assets/{directory-picker-path-field-D8jXEiAY.js → directory-picker-path-field-C95yW03b.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-debug-page-CCZ9u6TZ.js → extension-debug-page-DsG7Z9lV.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-CV36ILRG.js → extension-page-CUAXEbAt.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-IyQrSILY.js → extension-settings-page-CsR7QOJo.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-D4_r5iJM.js → gateway-config-api-DL70Nakc.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-settings-CYlntpBH.js → gateway-settings-BgDxQ08c.js} +1 -1
  30. package/dist/gateway/static/root/assets/{heartbeat-settings-D4SyWob8.js → heartbeat-settings-BX7q55uZ.js} +1 -1
  31. package/dist/gateway/static/root/assets/{home-page-B2Kagoh8.js → home-page-C08Nen5T.js} +1 -1
  32. package/dist/gateway/static/root/assets/{index-CYT5DOzr.js → index-B-_CEvIX.js} +7 -7
  33. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BMhCuVBZ.js → keyboard-shortcuts-settings-Dt6wS5zW.js} +1 -1
  34. package/dist/gateway/static/root/assets/{local-app-workbench-page-BHYbFjqy.js → local-app-workbench-page-BQVC0tWq.js} +1 -1
  35. package/dist/gateway/static/root/assets/{local-apps-page-ijIe7_y2.js → local-apps-page-DcD3-N00.js} +1 -1
  36. package/dist/gateway/static/root/assets/{logs-page-IIn8Tess.js → logs-page-D6yvW-E4.js} +1 -1
  37. package/dist/gateway/static/root/assets/{management-settings--V_fovKD.js → management-settings-B6EVkJQy.js} +1 -1
  38. package/dist/gateway/static/root/assets/{markdown-split-Dt9-in6W.js → markdown-split-CHUjCnBh.js} +1 -1
  39. package/dist/gateway/static/root/assets/{media-plugins-B3pj_iO0.js → media-plugins-DRrtI2O0.js} +1 -1
  40. package/dist/gateway/static/root/assets/{notes-page-DZ366lIT.js → notes-page-fermYvpI.js} +1 -1
  41. package/dist/gateway/static/root/assets/{notes-workbench-S2sBVOLw.js → notes-workbench-BVCwabjq.js} +2 -2
  42. package/dist/gateway/static/root/assets/{page-tabs-C5ge434C.js → page-tabs-BO262zuu.js} +1 -1
  43. package/dist/gateway/static/root/assets/{preview-open-alternatives-BFa9DgSV.js → preview-open-alternatives-yZYTy-2e.js} +1 -1
  44. package/dist/gateway/static/root/assets/{product-open-page-Dc9CcWdu.js → product-open-page-Dgy8XWhR.js} +1 -1
  45. package/dist/gateway/static/root/assets/{project-detail-page-BilzoCJ7.js → project-detail-page-CS4Ujor7.js} +1 -1
  46. package/dist/gateway/static/root/assets/{projects-page-BoQUyacP.js → projects-page-DMtPC8c4.js} +1 -1
  47. package/dist/gateway/static/root/assets/{remote-access-hub-DUyUaCRF.js → remote-access-hub-BpfHZT88.js} +1 -1
  48. package/dist/gateway/static/root/assets/{schema-form-B84DckWe.js → schema-form-DdE4gtw_.js} +1 -1
  49. package/dist/gateway/static/root/assets/{sessions-page-Dzxlq1F0.js → sessions-page-BZkyrJBM.js} +1 -1
  50. package/dist/gateway/static/root/assets/settings-advanced-gate-DQlK0A4l.js +1 -0
  51. package/dist/gateway/static/root/assets/{settings-form-section-Dp9itvdy.js → settings-form-section-CiYU8AvV.js} +1 -1
  52. package/dist/gateway/static/root/assets/{settings-loading-skeleton-CCtlhoy7.js → settings-loading-skeleton-Bv03cWib.js} +1 -1
  53. package/dist/gateway/static/root/assets/{settings-page-DQmMKf8r.js → settings-page-C-LdINFj.js} +1 -1
  54. package/dist/gateway/static/root/assets/{settings-page-layout-EQIOJa_L.js → settings-page-layout-t_Ox1slk.js} +1 -1
  55. package/dist/gateway/static/root/assets/{setup-status-panel-Cwi-SPja.js → setup-status-panel-HRG_lK4_.js} +1 -1
  56. package/dist/gateway/static/root/assets/{share-preview-page-C4_B2jvf.js → share-preview-page-DF8gW6bo.js} +1 -1
  57. package/dist/gateway/static/root/assets/{shares-settings-CkyuGlZK.js → shares-settings-v_iLhxxa.js} +1 -1
  58. package/dist/gateway/static/root/assets/{skill-reload-api-BJCePQK5.js → skill-reload-api-S-bjtsXX.js} +1 -1
  59. package/dist/gateway/static/root/assets/{skills-page-BYWLfmJi.js → skills-page-BiNBfaX5.js} +1 -1
  60. package/dist/gateway/static/root/assets/{skills-page.utils-Jhm24i4h.js → skills-page.utils-DlnGtvAH.js} +1 -1
  61. package/dist/gateway/static/root/assets/{system-settings-panel-Dpx2ags2.js → system-settings-panel-Bv7GXFc6.js} +1 -1
  62. package/dist/gateway/static/root/assets/{task-detail-page-DLAdxI6e.js → task-detail-page-BhQcOpnx.js} +1 -1
  63. package/dist/gateway/static/root/assets/{typed-models-lib-DULmTHUB.js → typed-models-lib-4XBsLEuv.js} +1 -1
  64. package/dist/gateway/static/root/assets/{use-autosave-BrjVk5VH.js → use-autosave-BN2QgFGn.js} +1 -1
  65. package/dist/gateway/static/root/assets/{user-context-page-9AAFpGAL.js → user-context-page-PtcY7BoJ.js} +1 -1
  66. package/dist/gateway/static/root/assets/{voice-api-key-field-BISTPfq_.js → voice-api-key-field-DnhJtC5l.js} +1 -1
  67. package/dist/gateway/static/root/assets/{work-discovery-overlay-Wr-uF7VA.js → work-discovery-overlay-nmEAafFl.js} +1 -1
  68. package/dist/gateway/static/root/assets/{work-discovery-page-BWds95sL.js → work-discovery-page-C5Kwe_bc.js} +1 -1
  69. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DHqHP8_6.js → workflow-run-setup-panel-BnNWBDwz.js} +1 -1
  70. package/dist/gateway/static/root/assets/{workflows-page-0b4_DFHr.js → workflows-page-Z_qzaohv.js} +1 -1
  71. package/dist/gateway/static/root/index.html +1 -1
  72. package/dist/package.js +1 -1
  73. package/dist/src/agent/image/generation/openai-images-provider.d.ts +1 -1
  74. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  75. package/dist/src/agent/image/generation/provider-registry.d.ts +2 -0
  76. package/dist/src/agent/image/generation/provider-registry.js +20 -10
  77. package/dist/src/agent/image/generation/providers/xopc-cloud.d.ts +2 -0
  78. package/dist/src/agent/image/generation/providers/xopc-cloud.js +74 -0
  79. package/dist/src/agent/image/generation/types.d.ts +2 -2
  80. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  81. package/dist/src/cli/commands/onboard/model.d.ts +3 -0
  82. package/dist/src/cli/commands/onboard/model.js +19 -4
  83. package/dist/src/cli/commands/update.js +1 -1
  84. package/dist/src/config/agent-profile.js +1 -1
  85. package/dist/src/gateway/agents-admin.js +1 -1
  86. package/dist/src/gateway/hono/routes/local-apps.js +1 -1
  87. package/dist/src/gateway/hono/routes/models.js +9 -8
  88. package/dist/src/gateway/hono/routes/update.js +2 -2
  89. package/dist/src/gateway/index.js +1 -1
  90. package/dist/src/gateway/run-loop.js +1 -1
  91. package/dist/src/gateway/service.js +5 -5
  92. package/dist/src/infra/gateway-processes.js +1 -1
  93. package/dist/src/infra/update-restart.js +1 -1
  94. package/dist/src/infra/update-runner.js +2 -2
  95. package/dist/src/infra/update-startup.js +1 -1
  96. package/dist/src/providers/model-catalog-store.d.ts +15 -0
  97. package/dist/src/providers/model-catalog-store.js +14 -1
  98. package/dist/src/providers/model-catalog-sync-service.js +6 -0
  99. package/dist/src/providers/model-registry.js +4 -4
  100. package/dist/src/providers/register-runtime-providers.js +4 -4
  101. package/dist/src/providers/xopc-cloud-model-source.js +55 -8
  102. package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
  103. package/package.json +3 -3
  104. package/dist/gateway/static/root/assets/settings-advanced-gate-TzwlZxU6.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-B4XqB8I6.js";import{l as s,n as c,r as l,s as u}from"./locale-store-deR2zRaE.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ba as f,Co as p,Do as m,Dt as h,Ec as g,El as _,Eo as v,Fn as ee,Gc as y,Go as b,Ji as x,Js as S,Ki as C,La as w,Mn as T,Mt as E,Nn as D,Oc as O,Oo as te,Os as k,Ot as A,Pn as j,Qi as M,Qs as N,Ra as P,Rl as F,Ro as I,So as L,Tl as R,Wc as z,Wo as ne,Xi as B,Yi as re,Zi as ie,as as V,ds as H,ea as ae,fl as oe,gu as se,hu as ce,ia as le,is as U,kt as ue,lc as de,mc as fe,ms as W,na as pe,pc as G,ps as me,qc as he,qi as ge,ra as K,ta as _e,us as q,wo as ve,za as J,zo as ye}from"./index-CYT5DOzr.js";import{n as be,t as xe}from"./use-autosave-BrjVk5VH.js";import{t as Se}from"./settings-advanced-gate-TzwlZxU6.js";import{n as Ce,t as Y}from"./settings-form-section-Dp9itvdy.js";import{t as we}from"./page-tabs-C5ge434C.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`,g=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,_;t[5]===g?_=t[6]:(_=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`,g),t[5]=g,t[6]=_);let v;t[7]===c?v=t[8]:(v=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=v);let ee=r===`list`&&`sm:py-3`,y;t[9]===ee?y=t[10]:(y=a(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,ee),t[9]=ee,t[10]=y);let b;t[11]===n.sourceChannel?b=t[12]:(b=(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]=b);let x;t[13]===h?x=t[14]:(x=h?(0,Z.jsx)(fe,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=x);let S;t[15]===n.updatedAt?S=t[16]:(S=Ee(n.updatedAt),t[15]=n.updatedAt,t[16]=S);let C;t[17]===S?C=t[18]:(C=(0,Z.jsx)(`span`,{children:S}),t[17]=S,t[18]=C);let w;t[19]!==C||t[20]!==x?(w=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[x,C]}),t[19]=C,t[20]=x,t[21]=w):w=t[21];let T;t[22]!==w||t[23]!==y||t[24]!==b?(T=(0,Z.jsxs)(`div`,{className:y,children:[b,w]}),t[22]=w,t[23]=y,t[24]=b,t[25]=T):T=t[25];let E=r===`list`&&`sm:py-3`,D;t[26]===E?D=t[27]:(D=a(`min-w-0 flex-1 px-3 py-2`,E),t[26]=E,t[27]=D);let te=r===`list`&&`sm:items-start`,A;t[28]===te?A=t[29]:(A=a(`flex gap-3`,te),t[28]=te,t[29]=A);let j;t[30]!==s||t[31]!==o?(j=(0,Z.jsx)(le,{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]=j):j=t[32];let M;t[33]===d?M=t[34]:(M=(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]=M);let N;t[35]!==n.key||t[36]!==p?(N=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]=N):N=t[37];let P;t[38]!==M||t[39]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,N]}),t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==A||t[42]!==j||t[43]!==P?(F=(0,Z.jsxs)(`div`,{className:A,children:[j,P]}),t[41]=A,t[42]=j,t[43]=P,t[44]=F):F=t[44];let I;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(O,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=I):I=t[45];let L;t[46]===n.messageCount?L=t[47]:(L=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[I,n.messageCount]}),t[46]=n.messageCount,t[47]=L);let z;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(me,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=z):z=t[48];let ne;t[49]===n.estimatedTokens?ne=t[50]:(ne=De(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=ne);let B;t[51]===ne?B=t[52]:(B=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[z,ne]}),t[51]=ne,t[52]=B);let re;t[53]!==L||t[54]!==B?(re=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[L,B]}),t[53]=L,t[54]=B,t[55]=re):re=t[55];let ie;t[56]===n.tags?ie=t[57]:(ie=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]=ie);let V;t[58]!==D||t[59]!==F||t[60]!==re||t[61]!==ie?(V=(0,Z.jsxs)(`div`,{className:D,children:[F,re,ie]}),t[58]=D,t[59]=F,t[60]=re,t[61]=ie,t[62]=V):V=t[62];let H;t[63]===l?H=t[64]:(H=()=>l(`continue`),t[63]=l,t[64]=H);let ae;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(O,{className:`size-4`,strokeWidth:1.75}),t[65]=ae):ae=t[65];let oe;t[66]!==i.continueChat||t[67]!==H?(oe=(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.continueChat,"aria-label":i.continueChat,onClick:H,children:ae}),t[66]=i.continueChat,t[67]=H,t[68]=oe):oe=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:U,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(se,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(ce,{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 de;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(de=h?(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(fe,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=de):de=t[78];let W;t[79]===l?W=t[80]:(W=()=>l(`export`),t[79]=l,t[80]=W);let pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(R,{className:`size-4`,strokeWidth:1.75}),t[81]=pe):pe=t[81];let he;t[82]!==i.export||t[83]!==W?(he=(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.export,"aria-label":i.export,onClick:W,children:pe}),t[82]=i.export,t[83]=W,t[84]=he):he=t[84];let ge;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ge=a(U,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=ge):ge=t[85];let K;t[86]===l?K=t[87]:(K=()=>l(`delete`),t[86]=l,t[87]=K);let _e;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(k,{className:`size-4`,strokeWidth:1.75}),t[88]=_e):_e=t[88];let q;t[89]!==i.delete||t[90]!==K?(q=(0,Z.jsx)(`button`,{type:`button`,className:ge,title:i.delete,"aria-label":i.delete,onClick:K,children:_e}),t[89]=i.delete,t[90]=K,t[91]=q):q=t[91];let ve;t[92]!==oe||t[93]!==ue||t[94]!==de||t[95]!==he||t[96]!==q?(ve=(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:[oe,ue,de,he,q]}),t[92]=oe,t[93]=ue,t[94]=de,t[95]=he,t[96]=q,t[97]=ve):ve=t[97];let J;return t[98]!==c||t[99]!==T||t[100]!==V||t[101]!==_||t[102]!==ve||t[103]!==v?(J=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:_,onClick:c,onKeyDown:v,children:[T,V,ve]}),t[98]=c,t[99]=T,t[100]=V,t[101]=_,t[102]=ve,t[103]=v,t[104]=J):J=t[104],J}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 P()}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=h();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`,q,`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}=J(e),{data:i=[],isLoading:s}=d(e?j:null,ee,{revalidateOnFocus:!1}),l=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[u,p]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[m,h]=(0,X.useState)(``),_=(0,X.useRef)(!1),v=(0,X.useRef)(u.form);v.current=u.form;let y=(0,X.useRef)(null);A({enabled:e,parsed:l,dirty:_.current,trackedParsedRef:y,dispatch:p,onResetDirty:()=>{_.current=!1}});let b=u.form,x=u.baseline,S=!!(b&&x&&JSON.stringify(b)!==JSON.stringify(x)),C=(0,X.useCallback)(e=>{_.current=!0,p({type:`patch`,patch:e})},[]),w=(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]),T=xe({value:b,dirty:S,onSave:(0,X.useCallback)(async e=>{try{await Re(e),p({type:`saved`,value:e}),_.current=!!(v.current&&JSON.stringify(v.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,w(n)):null}});if(!e||!b)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(f,{className:`h-5 w-48`}),(0,Z.jsx)(f,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(f,{className:`h-36 w-full rounded-xl`})]})}):null;let D=We(b),O=Math.max(0,ze-b.reserveTokens),te=Math.min(Math.floor(ze*b.triggerThreshold),O),k=Math.min(100,te/ze*100),M=Math.min(100,O/ze*100),N=b.model?i.find(e=>e.id===b.model):void 0,P=N?.contextWindow&&b.summaryChunkTokens+b.summaryMaxTokens+4096>N.contextWindow,F=b.keepRecentTokens+b.reserveTokens>te,I=Math.round(b.summaryTimeoutMs*(b.summaryRetries+1)/1e3),L=e=>{let t=Be[e];C({...t,...b.model?{model:b.model}:{model:void 0},postCompactionSections:b.postCompactionSections})},R={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},z=()=>{let e=m.trim();!e||b.postCompactionSections.includes(e)||b.postCompactionSections.length>=12||(C({postCompactionSections:[...b.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(Y,{onBlurCapture:T.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:g,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(be,{status:T.status,error:T.error}),(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:b.enabled,onChange:e=>C({enabled:e.target.checked})}),b.enabled?t.enabled:t.disabled]})]})}),T.error?(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:T.error}):null,b.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:!b.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})]}),D===`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":D===e,className:a(`rounded-xl border px-3 py-3 text-left`,V.transition,V.focusRingPanel,D===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>L(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:R[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:R[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(te)})]}),(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:`${k}%`}})})]}),(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(O)})]}),(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:`${M}%`}})})]})]}),(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((b.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>C({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(b.reserveTokens)),value:b.reserveTokens,min:1024,step:1024,onChange:e=>C({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:b.recentTurnsPreserve,min:1,max:12,onChange:e=>C({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(b.keepRecentTokens)),value:b.keepRecentTokens,min:1e3,step:1e3,onChange:e=>C({keepRecentTokens:Math.floor(e)})})]}),F?(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)(E,{value:b.model??``,disabled:!b.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=>C({model:e})}),b.model?(0,Z.jsx)(H,{type:`button`,variant:`secondary`,onClick:()=>C({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:b.qualityGuard,onChange:e=>C({qualityGuard:e})})]}),b.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)(Se,{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:b.minMessagesBeforeCompact,min:2,onChange:e=>C({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((b.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>C({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:b.summaryMaxTokens,min:256,step:256,onChange:e=>C({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:b.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>C({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(I)),value:b.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>C({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:b.summaryRetries,min:0,max:5,onChange:e=>C({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:b.minToolResultKeepChars,min:200,step:100,onChange:e=>C({minToolResultKeepChars:Math.floor(e)})})]}),P?(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}),b.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:b.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`,V.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>C({postCompactionSections:b.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(W,{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:m,maxLength:120,disabled:b.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())}}),(0,Z.jsxs)(H,{type:`button`,variant:`secondary`,disabled:!m.trim()||b.postCompactionSections.length>=12,onClick:z,children:[(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}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}}})}),P()}function Qe(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,q,`dark:border-edge`)}var $e=h();function et({hasToken:e}){let t=o(c(e=>e.language)).sessions.config,{data:n,isLoading:r}=J(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=(0,X.useRef)(!1),p=(0,X.useRef)(l);p.current=l;let m=(0,X.useRef)(null);A({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:s,onResetDirty:()=>{d.current=!1}});let h=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),g=(0,X.useCallback)(e=>{d.current=!0,s({type:`patch`,patch:e})},[]),v=xe({value:l,dirty:h,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),s({type:`saved`,value:e}),d.current=!!(p.current&&JSON.stringify(p.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(f,{className:`h-5 w-40`}),(0,Z.jsx)(f,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:_,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(be,{status:v.status,error:v.error})}),(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)(I,{className:Qe(),value:l.dmScope,onChange:e=>g({dmScope:e.target.value}),children:[(0,Z.jsx)(ye,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(ye,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(ye,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(ye,{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();g({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();g({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:h,onExport:g,onDelete:_}=e,ee=i?.status===`archived`,y=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)(v,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,b)}),t[2]=S):S=t[2];let C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=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`,ne,`dark:border-edge`),t[3]=C):C=t[3];let w;t[4]!==i||t[5]!==s||t[6]!==o?(w=i&&o?(0,Z.jsx)(le,{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]=w):w=t[7];let T;t[8]!==c.unnamedSession||t[9]!==i?.name?(T=i?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=i?.name,t[10]=T):T=t[10];let E;t[11]===T?E=t[12]:(E=(0,Z.jsx)(te,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:T}),t[11]=T,t[12]=E);let D;t[13]!==w||t[14]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[w,E]}),t[13]=w,t[14]=E,t[15]=D):D=t[15];let O;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(W,{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)(p,{asChild:!0,children:(0,Z.jsx)(H,{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 A;t[19]!==D||t[20]!==k?(A=(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]=A):A=t[21];let j;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==i?(j=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]=j):j=t[26];let M;t[27]===j?M=t[28]:(M=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:j}),t[27]=j,t[28]=M);let N;t[29]!==c.detailExport||t[30]!==g?(N=(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:c.detailExport}),t[29]=c.detailExport,t[30]=g,t[31]=N):N=t[31];let P;t[32]!==ee||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(P=ee?(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=ee,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=P):P=t[37];let F;t[38]!==y||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==f||t[42]!==h?(F=y?(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:c.unpin}):(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:c.pin}),t[38]=y,t[39]=c.pin,t[40]=c.unpin,t[41]=f,t[42]=h,t[43]=F):F=t[43];let I;t[44]!==c.delete||t[45]!==_?(I=(0,Z.jsx)(H,{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]=I):I=t[46];let R;t[47]!==N||t[48]!==P||t[49]!==F||t[50]!==I?(R=(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:[N,P,F,I]})}),t[47]=N,t[48]=P,t[49]=F,t[50]=I,t[51]=R):R=t[51];let z;t[52]!==A||t[53]!==M||t[54]!==R?(z=(0,Z.jsxs)(m,{children:[S,(0,Z.jsxs)(ve,{className:C,"aria-describedby":void 0,children:[A,M,R]})]}),t[52]=A,t[53]=M,t[54]=R,t[55]=z):z=t[55];let B;return t[56]!==n||t[57]!==x||t[58]!==z?(B=(0,Z.jsx)(L,{open:n,onOpenChange:x,children:z}),t[56]=n,t[57]=x,t[58]=z,t[59]=B):B=t[59],B}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`?he:S})),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)(we,{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,w,{revalidateOnFocus:!1}),f=l?.defaultId??`main`,p=l?.items??[],[h,g]=i(),_=lt(h.get(`tab`)),ee=(0,X.useCallback)(e=>{let t=new URLSearchParams(h);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[h,g]),[S,E]=(0,X.useReducer)(ue,h,mt),{searchInput:O,debouncedSearch:k,statusFilter:A,viewMode:j,channelFilter:P,sessions:I,loading:R,error:se,hasMore:le,stats:U,detailOpen:de,detailLoading:W,detailSession:G,confirmOpen:me,confirmKey:q}=S;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=O.trim();k!==e&&E({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[O,k]);let J=h.toString(),ye=(0,X.useRef)(J);if(ye.current!==J){ye.current=J;let e=h.get(`q`)??``,t=h.get(`status`),n=h.get(`view`),r=(h.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();E({type:`patch`,patch:{...O===e?{}:{searchInput:e},...k===o?{}:{debouncedSearch:o},...A===i?{}:{statusFilter:i},...j===a?{}:{viewMode:a},...P===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(h),t=k.trim();t?e.set(`q`,t):e.delete(`q`),A===`all`?e.delete(`status`):e.set(`status`,A),j===`grid`?e.delete(`view`):e.set(`view`,j),P?e.set(`channel`,P):e.delete(`channel`),e.toString()!==h.toString()&&g(e,{replace:!0})},[k,h,g,A,j,P]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=!1;return(async()=>{E({type:`patch`,patch:{loading:!0,error:null}});try{let t=await ie({limit:it,offset:0,...k?{search:k}:{},...A===`all`?{}:{status:A},...P?{channel:P}:{}});if(e)return;E({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||E({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||E({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,_,k,A,P,t.loadError]),(0,X.useEffect)(()=>{!r||_!==`sessions`||B().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,_]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=()=>void u();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,_,u]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||E({type:`patch`,patch:{sessions:I.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:G&&G.key===t.key?{...G,name:t.name}:G}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,_,I,G]);let be=(0,X.useCallback)(async()=>{if(!(!r||R||!le)){E({type:`patch`,patch:{loading:!0,error:null}});try{let e=await ie({limit:it,offset:I.length,...k?{search:k}:{},...A===`all`?{}:{status:A},...P?{channel:P}:{}});E({type:`patch`,patch:{sessions:[...I,...e.items],hasMore:e.hasMore}})}catch(e){E({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{E({type:`patch`,patch:{loading:!1}})}}},[r,R,le,I.length,k,A,P,t.loadError]),xe=(0,X.useCallback)((e,t)=>{E({type:`patch`,patch:{sessions:I.map(n=>n.key===e?{...n,status:t}:n),detailSession:G&&G.key===e?{...G,status:t}:G}})},[I,G]),Se=(0,X.useCallback)(async e=>{E({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{E({type:`patch`,patch:{detailSession:await re(e)}})}catch{E({type:`patch`,patch:{detailOpen:!1}})}finally{E({type:`patch`,patch:{detailLoading:!1}})}},[]),Ce=e=>{Se(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){E({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await C(e),xe(e,`archived`);break;case`unarchive`:await ae(e),xe(e,`active`);break;case`pin`:await M(e),xe(e,`pinned`);break;case`unpin`:await _e(e),xe(e,`active`);break;case`export`:{let t=await x(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}B().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await ge(e),E({type:`patch`,patch:{sessions:I.filter(t=>t.key!==e),detailSession:G?.key===e?null:G,...G?.key===e?{detailOpen:!1}:{}}}),B().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te={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},Ee={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},De=[{key:`all`,label:t.filterAll,icon:he},{key:`active`,label:t.filterActive,icon:F},{key:`pinned`,label:t.filterPinned,icon:fe},{key:`archived`,label:t.filterArchived,icon:ce}],ke=(()=>{let e=Object.entries(U?.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:_,onChange:ee}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:_,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:_,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:De.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":A===e,onClick:()=>E({type:`patch`,patch:{statusFilter:e}}),className:a(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.focusRingPanel,A===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)(N,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:O,onChange:e=>E({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":k||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":!P,onClick:()=>E({type:`patch`,patch:{channelFilter:``}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.focusRingPanel,P?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":P===e,onClick:()=>E({type:`patch`,patch:{channelFilter:e}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.focusRingPanel,P===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,U?.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:U.byChannel[e]})]},e))]}),U?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[U.totalSessions,t.totalSessions],[U.activeSessions,t.activeSessions],[U.pinnedSessions,t.pinnedSessions],[U.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,se?(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:se}):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:I.length})}),(0,Z.jsxs)(`div`,{className:D,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(H,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":j===`grid`,onClick:()=>E({type:`patch`,patch:{viewMode:`grid`}}),className:a(T,`size-7 p-0`,j===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(y,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(H,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":j===`list`,onClick:()=>E({type:`patch`,patch:{viewMode:`list`}}),className:a(T,`size-9 p-0`,j===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`list`&&`text-accent-fg`),children:(0,Z.jsx)(z,{className:`size-3.5`,strokeWidth:1.5})})]})]}),R&&I.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))}):I.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)(oe,{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)(H,{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`,j===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":k||void 0,children:I.map(e=>{let t=K(e,f);return(0,Z.jsx)(Oe,{session:e,variant:j,labels:Te,sessionAgentId:t,sessionAgentAvatar:pe(t,p),onOpen:()=>Ce(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),le?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(H,{type:`button`,variant:`secondary`,disabled:R,onClick:()=>void be(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:de,loading:W,session:G,sessionAgentId:G?K(G,f):void 0,sessionAgentAvatar:G?pe(K(G,f),p):void 0,labels:Ee,onClose:()=>{E({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>G&&void Y(G.key,`archive`),onUnarchive:()=>G&&void Y(G.key,`unarchive`),onPin:()=>G&&void Y(G.key,`pin`),onUnpin:()=>G&&void Y(G.key,`unpin`),onExport:()=>G&&void Y(G.key,`export`),onDelete:()=>G&&E({type:`patch`,patch:{confirmKey:G.key,confirmOpen:!0}})}),(0,Z.jsx)(L,{open:me,onOpenChange:e=>E({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(v,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,b)}),(0,Z.jsxs)(ve,{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`,ne),children:[(0,Z.jsx)(te,{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:I.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)(H,{type:`button`,variant:`secondary`,onClick:()=>E({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(H,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{q&&we(q),E({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-B4XqB8I6.js";import{l as s,n as c,r as l,s as u}from"./locale-store-deR2zRaE.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ba as f,Co as p,Do as m,Dt as h,Ec as g,El as _,Eo as v,Fn as ee,Gc as y,Go as b,Ji as x,Js as S,Ki as C,La as w,Mn as T,Mt as E,Nn as D,Oc as O,Oo as te,Os as k,Ot as A,Pn as j,Qi as M,Qs as N,Ra as P,Rl as F,Ro as I,So as L,Tl as R,Wc as z,Wo as ne,Xi as B,Yi as re,Zi as ie,as as V,ds as H,ea as ae,fl as oe,gu as se,hu as ce,ia as le,is as U,kt as ue,lc as de,mc as fe,ms as W,na as pe,pc as G,ps as me,qc as he,qi as ge,ra as K,ta as _e,us as q,wo as ve,za as J,zo as ye}from"./index-B-_CEvIX.js";import{n as be,t as xe}from"./use-autosave-BN2QgFGn.js";import{t as Se}from"./settings-advanced-gate-DQlK0A4l.js";import{n as Ce,t as Y}from"./settings-form-section-CiYU8AvV.js";import{t as we}from"./page-tabs-BO262zuu.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`,g=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,_;t[5]===g?_=t[6]:(_=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`,g),t[5]=g,t[6]=_);let v;t[7]===c?v=t[8]:(v=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=v);let ee=r===`list`&&`sm:py-3`,y;t[9]===ee?y=t[10]:(y=a(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,ee),t[9]=ee,t[10]=y);let b;t[11]===n.sourceChannel?b=t[12]:(b=(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]=b);let x;t[13]===h?x=t[14]:(x=h?(0,Z.jsx)(fe,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=x);let S;t[15]===n.updatedAt?S=t[16]:(S=Ee(n.updatedAt),t[15]=n.updatedAt,t[16]=S);let C;t[17]===S?C=t[18]:(C=(0,Z.jsx)(`span`,{children:S}),t[17]=S,t[18]=C);let w;t[19]!==C||t[20]!==x?(w=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[x,C]}),t[19]=C,t[20]=x,t[21]=w):w=t[21];let T;t[22]!==w||t[23]!==y||t[24]!==b?(T=(0,Z.jsxs)(`div`,{className:y,children:[b,w]}),t[22]=w,t[23]=y,t[24]=b,t[25]=T):T=t[25];let E=r===`list`&&`sm:py-3`,D;t[26]===E?D=t[27]:(D=a(`min-w-0 flex-1 px-3 py-2`,E),t[26]=E,t[27]=D);let te=r===`list`&&`sm:items-start`,A;t[28]===te?A=t[29]:(A=a(`flex gap-3`,te),t[28]=te,t[29]=A);let j;t[30]!==s||t[31]!==o?(j=(0,Z.jsx)(le,{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]=j):j=t[32];let M;t[33]===d?M=t[34]:(M=(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]=M);let N;t[35]!==n.key||t[36]!==p?(N=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]=N):N=t[37];let P;t[38]!==M||t[39]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,N]}),t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==A||t[42]!==j||t[43]!==P?(F=(0,Z.jsxs)(`div`,{className:A,children:[j,P]}),t[41]=A,t[42]=j,t[43]=P,t[44]=F):F=t[44];let I;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(O,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=I):I=t[45];let L;t[46]===n.messageCount?L=t[47]:(L=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[I,n.messageCount]}),t[46]=n.messageCount,t[47]=L);let z;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(me,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=z):z=t[48];let ne;t[49]===n.estimatedTokens?ne=t[50]:(ne=De(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=ne);let B;t[51]===ne?B=t[52]:(B=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[z,ne]}),t[51]=ne,t[52]=B);let re;t[53]!==L||t[54]!==B?(re=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[L,B]}),t[53]=L,t[54]=B,t[55]=re):re=t[55];let ie;t[56]===n.tags?ie=t[57]:(ie=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]=ie);let V;t[58]!==D||t[59]!==F||t[60]!==re||t[61]!==ie?(V=(0,Z.jsxs)(`div`,{className:D,children:[F,re,ie]}),t[58]=D,t[59]=F,t[60]=re,t[61]=ie,t[62]=V):V=t[62];let H;t[63]===l?H=t[64]:(H=()=>l(`continue`),t[63]=l,t[64]=H);let ae;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(O,{className:`size-4`,strokeWidth:1.75}),t[65]=ae):ae=t[65];let oe;t[66]!==i.continueChat||t[67]!==H?(oe=(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.continueChat,"aria-label":i.continueChat,onClick:H,children:ae}),t[66]=i.continueChat,t[67]=H,t[68]=oe):oe=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:U,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(se,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(ce,{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 de;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(de=h?(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(G,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(fe,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=de):de=t[78];let W;t[79]===l?W=t[80]:(W=()=>l(`export`),t[79]=l,t[80]=W);let pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(R,{className:`size-4`,strokeWidth:1.75}),t[81]=pe):pe=t[81];let he;t[82]!==i.export||t[83]!==W?(he=(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.export,"aria-label":i.export,onClick:W,children:pe}),t[82]=i.export,t[83]=W,t[84]=he):he=t[84];let ge;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ge=a(U,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=ge):ge=t[85];let K;t[86]===l?K=t[87]:(K=()=>l(`delete`),t[86]=l,t[87]=K);let _e;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(k,{className:`size-4`,strokeWidth:1.75}),t[88]=_e):_e=t[88];let q;t[89]!==i.delete||t[90]!==K?(q=(0,Z.jsx)(`button`,{type:`button`,className:ge,title:i.delete,"aria-label":i.delete,onClick:K,children:_e}),t[89]=i.delete,t[90]=K,t[91]=q):q=t[91];let ve;t[92]!==oe||t[93]!==ue||t[94]!==de||t[95]!==he||t[96]!==q?(ve=(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:[oe,ue,de,he,q]}),t[92]=oe,t[93]=ue,t[94]=de,t[95]=he,t[96]=q,t[97]=ve):ve=t[97];let J;return t[98]!==c||t[99]!==T||t[100]!==V||t[101]!==_||t[102]!==ve||t[103]!==v?(J=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:_,onClick:c,onKeyDown:v,children:[T,V,ve]}),t[98]=c,t[99]=T,t[100]=V,t[101]=_,t[102]=ve,t[103]=v,t[104]=J):J=t[104],J}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 P()}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=h();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`,q,`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}=J(e),{data:i=[],isLoading:s}=d(e?j:null,ee,{revalidateOnFocus:!1}),l=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[u,p]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[m,h]=(0,X.useState)(``),_=(0,X.useRef)(!1),v=(0,X.useRef)(u.form);v.current=u.form;let y=(0,X.useRef)(null);A({enabled:e,parsed:l,dirty:_.current,trackedParsedRef:y,dispatch:p,onResetDirty:()=>{_.current=!1}});let b=u.form,x=u.baseline,S=!!(b&&x&&JSON.stringify(b)!==JSON.stringify(x)),C=(0,X.useCallback)(e=>{_.current=!0,p({type:`patch`,patch:e})},[]),w=(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]),T=xe({value:b,dirty:S,onSave:(0,X.useCallback)(async e=>{try{await Re(e),p({type:`saved`,value:e}),_.current=!!(v.current&&JSON.stringify(v.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,w(n)):null}});if(!e||!b)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(f,{className:`h-5 w-48`}),(0,Z.jsx)(f,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(f,{className:`h-36 w-full rounded-xl`})]})}):null;let D=We(b),O=Math.max(0,ze-b.reserveTokens),te=Math.min(Math.floor(ze*b.triggerThreshold),O),k=Math.min(100,te/ze*100),M=Math.min(100,O/ze*100),N=b.model?i.find(e=>e.id===b.model):void 0,P=N?.contextWindow&&b.summaryChunkTokens+b.summaryMaxTokens+4096>N.contextWindow,F=b.keepRecentTokens+b.reserveTokens>te,I=Math.round(b.summaryTimeoutMs*(b.summaryRetries+1)/1e3),L=e=>{let t=Be[e];C({...t,...b.model?{model:b.model}:{model:void 0},postCompactionSections:b.postCompactionSections})},R={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},z=()=>{let e=m.trim();!e||b.postCompactionSections.includes(e)||b.postCompactionSections.length>=12||(C({postCompactionSections:[...b.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(Y,{onBlurCapture:T.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:g,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(be,{status:T.status,error:T.error}),(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:b.enabled,onChange:e=>C({enabled:e.target.checked})}),b.enabled?t.enabled:t.disabled]})]})}),T.error?(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:T.error}):null,b.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:!b.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})]}),D===`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":D===e,className:a(`rounded-xl border px-3 py-3 text-left`,V.transition,V.focusRingPanel,D===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>L(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:R[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:R[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(te)})]}),(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:`${k}%`}})})]}),(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(O)})]}),(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:`${M}%`}})})]})]}),(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((b.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>C({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(b.reserveTokens)),value:b.reserveTokens,min:1024,step:1024,onChange:e=>C({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:b.recentTurnsPreserve,min:1,max:12,onChange:e=>C({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(b.keepRecentTokens)),value:b.keepRecentTokens,min:1e3,step:1e3,onChange:e=>C({keepRecentTokens:Math.floor(e)})})]}),F?(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)(E,{value:b.model??``,disabled:!b.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=>C({model:e})}),b.model?(0,Z.jsx)(H,{type:`button`,variant:`secondary`,onClick:()=>C({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:b.qualityGuard,onChange:e=>C({qualityGuard:e})})]}),b.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)(Se,{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:b.minMessagesBeforeCompact,min:2,onChange:e=>C({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((b.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>C({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:b.summaryMaxTokens,min:256,step:256,onChange:e=>C({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:b.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>C({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(I)),value:b.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>C({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:b.summaryRetries,min:0,max:5,onChange:e=>C({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:b.minToolResultKeepChars,min:200,step:100,onChange:e=>C({minToolResultKeepChars:Math.floor(e)})})]}),P?(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}),b.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:b.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`,V.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>C({postCompactionSections:b.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(W,{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:m,maxLength:120,disabled:b.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())}}),(0,Z.jsxs)(H,{type:`button`,variant:`secondary`,disabled:!m.trim()||b.postCompactionSections.length>=12,onClick:z,children:[(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}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}}})}),P()}function Qe(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,q,`dark:border-edge`)}var $e=h();function et({hasToken:e}){let t=o(c(e=>e.language)).sessions.config,{data:n,isLoading:r}=J(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=(0,X.useRef)(!1),p=(0,X.useRef)(l);p.current=l;let m=(0,X.useRef)(null);A({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:s,onResetDirty:()=>{d.current=!1}});let h=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),g=(0,X.useCallback)(e=>{d.current=!0,s({type:`patch`,patch:e})},[]),v=xe({value:l,dirty:h,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),s({type:`saved`,value:e}),d.current=!!(p.current&&JSON.stringify(p.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(f,{className:`h-5 w-40`}),(0,Z.jsx)(f,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:_,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(be,{status:v.status,error:v.error})}),(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)(I,{className:Qe(),value:l.dmScope,onChange:e=>g({dmScope:e.target.value}),children:[(0,Z.jsx)(ye,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(ye,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(ye,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(ye,{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();g({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();g({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:h,onExport:g,onDelete:_}=e,ee=i?.status===`archived`,y=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)(v,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,b)}),t[2]=S):S=t[2];let C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=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`,ne,`dark:border-edge`),t[3]=C):C=t[3];let w;t[4]!==i||t[5]!==s||t[6]!==o?(w=i&&o?(0,Z.jsx)(le,{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]=w):w=t[7];let T;t[8]!==c.unnamedSession||t[9]!==i?.name?(T=i?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=i?.name,t[10]=T):T=t[10];let E;t[11]===T?E=t[12]:(E=(0,Z.jsx)(te,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:T}),t[11]=T,t[12]=E);let D;t[13]!==w||t[14]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[w,E]}),t[13]=w,t[14]=E,t[15]=D):D=t[15];let O;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(W,{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)(p,{asChild:!0,children:(0,Z.jsx)(H,{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 A;t[19]!==D||t[20]!==k?(A=(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]=A):A=t[21];let j;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==i?(j=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]=j):j=t[26];let M;t[27]===j?M=t[28]:(M=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:j}),t[27]=j,t[28]=M);let N;t[29]!==c.detailExport||t[30]!==g?(N=(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:c.detailExport}),t[29]=c.detailExport,t[30]=g,t[31]=N):N=t[31];let P;t[32]!==ee||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(P=ee?(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=ee,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=P):P=t[37];let F;t[38]!==y||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==f||t[42]!==h?(F=y?(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:c.unpin}):(0,Z.jsx)(H,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:c.pin}),t[38]=y,t[39]=c.pin,t[40]=c.unpin,t[41]=f,t[42]=h,t[43]=F):F=t[43];let I;t[44]!==c.delete||t[45]!==_?(I=(0,Z.jsx)(H,{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]=I):I=t[46];let R;t[47]!==N||t[48]!==P||t[49]!==F||t[50]!==I?(R=(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:[N,P,F,I]})}),t[47]=N,t[48]=P,t[49]=F,t[50]=I,t[51]=R):R=t[51];let z;t[52]!==A||t[53]!==M||t[54]!==R?(z=(0,Z.jsxs)(m,{children:[S,(0,Z.jsxs)(ve,{className:C,"aria-describedby":void 0,children:[A,M,R]})]}),t[52]=A,t[53]=M,t[54]=R,t[55]=z):z=t[55];let B;return t[56]!==n||t[57]!==x||t[58]!==z?(B=(0,Z.jsx)(L,{open:n,onOpenChange:x,children:z}),t[56]=n,t[57]=x,t[58]=z,t[59]=B):B=t[59],B}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`?he:S})),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)(we,{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,w,{revalidateOnFocus:!1}),f=l?.defaultId??`main`,p=l?.items??[],[h,g]=i(),_=lt(h.get(`tab`)),ee=(0,X.useCallback)(e=>{let t=new URLSearchParams(h);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[h,g]),[S,E]=(0,X.useReducer)(ue,h,mt),{searchInput:O,debouncedSearch:k,statusFilter:A,viewMode:j,channelFilter:P,sessions:I,loading:R,error:se,hasMore:le,stats:U,detailOpen:de,detailLoading:W,detailSession:G,confirmOpen:me,confirmKey:q}=S;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=O.trim();k!==e&&E({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[O,k]);let J=h.toString(),ye=(0,X.useRef)(J);if(ye.current!==J){ye.current=J;let e=h.get(`q`)??``,t=h.get(`status`),n=h.get(`view`),r=(h.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();E({type:`patch`,patch:{...O===e?{}:{searchInput:e},...k===o?{}:{debouncedSearch:o},...A===i?{}:{statusFilter:i},...j===a?{}:{viewMode:a},...P===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(h),t=k.trim();t?e.set(`q`,t):e.delete(`q`),A===`all`?e.delete(`status`):e.set(`status`,A),j===`grid`?e.delete(`view`):e.set(`view`,j),P?e.set(`channel`,P):e.delete(`channel`),e.toString()!==h.toString()&&g(e,{replace:!0})},[k,h,g,A,j,P]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=!1;return(async()=>{E({type:`patch`,patch:{loading:!0,error:null}});try{let t=await ie({limit:it,offset:0,...k?{search:k}:{},...A===`all`?{}:{status:A},...P?{channel:P}:{}});if(e)return;E({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||E({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||E({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,_,k,A,P,t.loadError]),(0,X.useEffect)(()=>{!r||_!==`sessions`||B().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,_]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=()=>void u();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,_,u]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||E({type:`patch`,patch:{sessions:I.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:G&&G.key===t.key?{...G,name:t.name}:G}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,_,I,G]);let be=(0,X.useCallback)(async()=>{if(!(!r||R||!le)){E({type:`patch`,patch:{loading:!0,error:null}});try{let e=await ie({limit:it,offset:I.length,...k?{search:k}:{},...A===`all`?{}:{status:A},...P?{channel:P}:{}});E({type:`patch`,patch:{sessions:[...I,...e.items],hasMore:e.hasMore}})}catch(e){E({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{E({type:`patch`,patch:{loading:!1}})}}},[r,R,le,I.length,k,A,P,t.loadError]),xe=(0,X.useCallback)((e,t)=>{E({type:`patch`,patch:{sessions:I.map(n=>n.key===e?{...n,status:t}:n),detailSession:G&&G.key===e?{...G,status:t}:G}})},[I,G]),Se=(0,X.useCallback)(async e=>{E({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{E({type:`patch`,patch:{detailSession:await re(e)}})}catch{E({type:`patch`,patch:{detailOpen:!1}})}finally{E({type:`patch`,patch:{detailLoading:!1}})}},[]),Ce=e=>{Se(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){E({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await C(e),xe(e,`archived`);break;case`unarchive`:await ae(e),xe(e,`active`);break;case`pin`:await M(e),xe(e,`pinned`);break;case`unpin`:await _e(e),xe(e,`active`);break;case`export`:{let t=await x(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}B().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await ge(e),E({type:`patch`,patch:{sessions:I.filter(t=>t.key!==e),detailSession:G?.key===e?null:G,...G?.key===e?{detailOpen:!1}:{}}}),B().then(e=>E({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te={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},Ee={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},De=[{key:`all`,label:t.filterAll,icon:he},{key:`active`,label:t.filterActive,icon:F},{key:`pinned`,label:t.filterPinned,icon:fe},{key:`archived`,label:t.filterArchived,icon:ce}],ke=(()=>{let e=Object.entries(U?.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:_,onChange:ee}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:_,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:_,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:De.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":A===e,onClick:()=>E({type:`patch`,patch:{statusFilter:e}}),className:a(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.focusRingPanel,A===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)(N,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:O,onChange:e=>E({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":k||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":!P,onClick:()=>E({type:`patch`,patch:{channelFilter:``}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.focusRingPanel,P?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":P===e,onClick:()=>E({type:`patch`,patch:{channelFilter:e}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,V.transition,V.focusRingPanel,P===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,U?.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:U.byChannel[e]})]},e))]}),U?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[U.totalSessions,t.totalSessions],[U.activeSessions,t.activeSessions],[U.pinnedSessions,t.pinnedSessions],[U.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,se?(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:se}):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:I.length})}),(0,Z.jsxs)(`div`,{className:D,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(H,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":j===`grid`,onClick:()=>E({type:`patch`,patch:{viewMode:`grid`}}),className:a(T,`size-7 p-0`,j===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(y,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(H,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":j===`list`,onClick:()=>E({type:`patch`,patch:{viewMode:`list`}}),className:a(T,`size-9 p-0`,j===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`list`&&`text-accent-fg`),children:(0,Z.jsx)(z,{className:`size-3.5`,strokeWidth:1.5})})]})]}),R&&I.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))}):I.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)(oe,{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)(H,{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`,j===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":k||void 0,children:I.map(e=>{let t=K(e,f);return(0,Z.jsx)(Oe,{session:e,variant:j,labels:Te,sessionAgentId:t,sessionAgentAvatar:pe(t,p),onOpen:()=>Ce(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),le?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(H,{type:`button`,variant:`secondary`,disabled:R,onClick:()=>void be(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:de,loading:W,session:G,sessionAgentId:G?K(G,f):void 0,sessionAgentAvatar:G?pe(K(G,f),p):void 0,labels:Ee,onClose:()=>{E({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>G&&void Y(G.key,`archive`),onUnarchive:()=>G&&void Y(G.key,`unarchive`),onPin:()=>G&&void Y(G.key,`pin`),onUnpin:()=>G&&void Y(G.key,`unpin`),onExport:()=>G&&void Y(G.key,`export`),onDelete:()=>G&&E({type:`patch`,patch:{confirmKey:G.key,confirmOpen:!0}})}),(0,Z.jsx)(L,{open:me,onOpenChange:e=>E({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(v,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,b)}),(0,Z.jsxs)(ve,{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`,ne),children:[(0,Z.jsx)(te,{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:I.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)(H,{type:`button`,variant:`secondary`,onClick:()=>E({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(H,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{q&&we(q),E({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{Rr as e}from"./index-B-_CEvIX.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{as as r,hc as i}from"./index-CYT5DOzr.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)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}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`,r.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`,r.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)(i,{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{as as r,hc as i}from"./index-B-_CEvIX.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)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}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`,r.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`,r.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)(i,{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{Ba as n}from"./index-CYT5DOzr.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{Ba as n}from"./index-B-_CEvIX.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-B4XqB8I6.js";import{n as s}from"./locale-store-deR2zRaE.js";import{_o as c,bo as l,do as u,fo as d,go as f,ho as p,mo as m,po as h,uo as g,vo as _,xo as v,yo as y}from"./index-CYT5DOzr.js";var b=n(),x=e(t(),1),S=r(),C=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`capability-presets`,`gateway`,`devices`,`heartbeat`,`remote-access`,`shares`],w=(0,x.lazy)(()=>y().then(e=>({default:e.SetupStatusPanel}))),T=(0,x.lazy)(()=>u().then(e=>({default:e.AppearanceSettingsPanel}))),E=(0,x.lazy)(()=>c().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),D=(0,x.lazy)(()=>v().then(e=>({default:e.SystemSettingsPanel}))),O=(0,x.lazy)(()=>h().then(e=>({default:e.DesktopPetSettings}))),k=(0,x.lazy)(()=>g().then(e=>({default:e.AppManagementSettingsPanel}))),A=(0,x.lazy)(()=>p().then(e=>({default:e.GatewaySettingsPanel}))),j=(0,x.lazy)(()=>f().then(e=>({default:e.HeartbeatSettingsPanel}))),M=(0,x.lazy)(()=>_().then(e=>({default:e.RemoteAccessHub}))),N=(0,x.lazy)(()=>l().then(e=>({default:e.SharesSettingsPanel}))),P=(0,x.lazy)(()=>d().then(e=>({default:e.CapabilityPresetsSettingsPanel}))),F=(0,x.lazy)(()=>m().then(e=>({default:e.EndpointToolsManagementSettings})));function I(){let e=(0,b.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,S.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function L(e){return(0,S.jsx)(x.Suspense,{fallback:(0,S.jsx)(I,{}),children:(0,S.jsx)(e,{})})}function R(){let e=(0,b.c)(27),{section:t}=i(),n=s(z),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=o(n);if(!t||!C.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(w),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(T),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(E),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(D),e[11]=t):t=e[11],d=t;break bb0}if(s===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(O),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(k),e[13]=t):t=e[13],d=t;break bb0}if(s===`capability-presets`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(P),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(A),e[15]=t):t=e[15],d=t;break bb0}if(s===`devices`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(F),e[16]=t):t=e[16],d=t;break bb0}if(s===`heartbeat`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(j),e[17]=t):t=e[17],d=t;break bb0}if(s===`remote-access`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(M),e[18]=t):t=e[18],d=t;break bb0}if(s===`shares`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(N),e[19]=t):t=e[19],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,S.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[20]!==r||e[21]!==c?(f=(0,S.jsx)(`p`,{className:r,children:c}),e[20]=r,e[21]=c,e[22]=f):f=e[22];let p;return e[23]!==l||e[24]!==u||e[25]!==f?(p=(0,S.jsxs)(`div`,{className:l,children:[u,f]}),e[23]=l,e[24]=u,e[25]=f,e[26]=p):p=e[26],p}function z(e){return e.language}export{R as SettingsPage};
1
+ 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-B4XqB8I6.js";import{n as s}from"./locale-store-deR2zRaE.js";import{_o as c,bo as l,do as u,fo as d,go as f,ho as p,mo as m,po as h,uo as g,vo as _,xo as v,yo as y}from"./index-B-_CEvIX.js";var b=n(),x=e(t(),1),S=r(),C=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`capability-presets`,`gateway`,`devices`,`heartbeat`,`remote-access`,`shares`],w=(0,x.lazy)(()=>y().then(e=>({default:e.SetupStatusPanel}))),T=(0,x.lazy)(()=>u().then(e=>({default:e.AppearanceSettingsPanel}))),E=(0,x.lazy)(()=>c().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),D=(0,x.lazy)(()=>v().then(e=>({default:e.SystemSettingsPanel}))),O=(0,x.lazy)(()=>h().then(e=>({default:e.DesktopPetSettings}))),k=(0,x.lazy)(()=>g().then(e=>({default:e.AppManagementSettingsPanel}))),A=(0,x.lazy)(()=>p().then(e=>({default:e.GatewaySettingsPanel}))),j=(0,x.lazy)(()=>f().then(e=>({default:e.HeartbeatSettingsPanel}))),M=(0,x.lazy)(()=>_().then(e=>({default:e.RemoteAccessHub}))),N=(0,x.lazy)(()=>l().then(e=>({default:e.SharesSettingsPanel}))),P=(0,x.lazy)(()=>d().then(e=>({default:e.CapabilityPresetsSettingsPanel}))),F=(0,x.lazy)(()=>m().then(e=>({default:e.EndpointToolsManagementSettings})));function I(){let e=(0,b.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,S.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function L(e){return(0,S.jsx)(x.Suspense,{fallback:(0,S.jsx)(I,{}),children:(0,S.jsx)(e,{})})}function R(){let e=(0,b.c)(27),{section:t}=i(),n=s(z),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=o(n);if(!t||!C.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(w),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(T),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(E),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(D),e[11]=t):t=e[11],d=t;break bb0}if(s===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(O),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(k),e[13]=t):t=e[13],d=t;break bb0}if(s===`capability-presets`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(P),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(A),e[15]=t):t=e[15],d=t;break bb0}if(s===`devices`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(F),e[16]=t):t=e[16],d=t;break bb0}if(s===`heartbeat`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(j),e[17]=t):t=e[17],d=t;break bb0}if(s===`remote-access`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(M),e[18]=t):t=e[18],d=t;break bb0}if(s===`shares`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(N),e[19]=t):t=e[19],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,S.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[20]!==r||e[21]!==c?(f=(0,S.jsx)(`p`,{className:r,children:c}),e[20]=r,e[21]=c,e[22]=f):f=e[22];let p;return e[23]!==l||e[24]!==u||e[25]!==f?(p=(0,S.jsxs)(`div`,{className:l,children:[u,f]}),e[23]=l,e[24]=u,e[25]=f,e[26]=p):p=e[26],p}function z(e){return e.language}export{R as SettingsPage};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{xl as r}from"./index-CYT5DOzr.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{xl as r}from"./index-B-_CEvIX.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-B4XqB8I6.js";import{l as s,n as c,r as l,s as u}from"./locale-store-deR2zRaE.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ds as f,Fn as p,Fr as m,Is as h,Kl as g,Ma as _,Nc as v,Pn as y,Rl as b,Sn as x,Xc as S,Yl as C,_u as w,as as T,nc as ee,rs as E,za as D,zl as O}from"./index-CYT5DOzr.js";import{n as k,r as A}from"./settings-page-layout-EQIOJa_L.js";import{n as j}from"./settings-loading-skeleton-CCtlhoy7.js";import{n as M,t as N}from"./settings-form-section-Dp9itvdy.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`&&E(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.realtimeConnected,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 q(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 J(){let e=(0,F.c)(57),t=s(me),n=c(pe),r;e[0]===n?r=e[1]:(r=o(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,l=_(fe),{data:u,error:f,isLoading:m,mutate:h}=D(!!t),g;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},e[2]=g):g=e[2];let{data:v,error:b,isLoading:S,mutate:C}=d(t?`setup-checklist-skills`:null,de,g),w;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(w={revalidateOnFocus:!1},e[3]=w):w=e[3];let{data:T,error:ee,isLoading:E,mutate:O}=d(t?`setup-checklist-provider-meta`:null,x,w),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:q}=d(U,ue,W),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],d(t?y:null,p,J);let Y=!t||!m&&!S&&!E&&!N&&!z&&!K,X=!!(f||b||ee||M),Z;bb0:{if(!t||!Y){Z=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]!==T||e[33]!==l||e[34]!==n||e[35]!==t){let o=T?.filter(le).length??0,s=T?.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,realtimeConnected: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]=T,e[33]=l,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==q||e[46]!==h||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==C?(Q=async()=>{await Promise.all([h(),C(),O(),P(),B(),q()])},e[45]=q,e[46]=h,e[47]=P,e[48]=B,e[49]=O,e[50]=C,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==X||e[53]!==Y||e[54]!==ge||e[55]!==he?($={ready:Y,error:X,snapshot:he,refresh:ge},e[52]=X,e[53]=Y,e[54]=ge,e[55]=he,e[56]=$):$=e[56],$}function le(e){return e.configured}function ue(e){let[,t]=e;return q(t)}function de(){return m()}function fe(e){return e.connectionState===`connected`}function pe(e){return e.language}function me(e){return e.token}var Y=r();function X(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 Z(e){return e===`pass`?g:e===`warn`?f:e===`fail`?O:S}function he(e,t){return e===`blocked`?{icon:O,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:f,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:b,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:g,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),p,m,h,g,_,y,b,x,S,w,E;if(t[0]!==r||t[1]!==f||t[2]!==n){m=o(f).setupStatus;let e=he(n,m),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`;p=c?(0,Y.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,Y.jsx)(C,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.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,Y.jsx)(C,{className:`size-4`,"aria-hidden":!0})]}),E=a(`rounded-xl p-4`,e.className),w=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,x=`flex min-w-0 gap-3`,S=(0,Y.jsx)(s,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),_=`min-w-0`,y=(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),b=(0,Y.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),h=`mt-2 text-xs opacity-75`,g=m.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=f,t[2]=n,t[3]=p,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=y,t[9]=b,t[10]=x,t[11]=S,t[12]=w,t[13]=E}else p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],y=t[8],b=t[9],x=t[10],S=t[11],w=t[12],E=t[13];let D;t[14]!==h||t[15]!==g?(D=(0,Y.jsx)(`p`,{className:h,children:g}),t[14]=h,t[15]=g,t[16]=D):D=t[16];let O;t[17]!==D||t[18]!==_||t[19]!==y||t[20]!==b?(O=(0,Y.jsxs)(`div`,{className:_,children:[y,b,D]}),t[17]=D,t[18]=_,t[19]=y,t[20]=b,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==x||t[24]!==S?(k=(0,Y.jsxs)(`div`,{className:x,children:[S,O]}),t[22]=O,t[23]=x,t[24]=S,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`,T.press),t[26]=A):A=t[26];let j=!l||u,M;t[27]===u?M=t[28]:(M=u?(0,Y.jsx)(v,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?m.health.runDoctorRunning:m.health.runDoctor,P;t[29]!==u||t[30]!==s||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,Y.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]!==p||t[36]!==P?(I=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[p,P]}),t[35]=p,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==w?(L=(0,Y.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?m.health.doctorRunningMessage:d===`success`?m.health.doctorCompleteMessage:d===`error`?m.health.doctorFailedMessage:m.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,Y.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]!==E?(B=(0,Y.jsxs)(`section`,{className:E,children:[L,z]}),t[44]=L,t[45]=z,t[46]=E,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=Z(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,Y.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,Y.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`,X(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,Y.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,Y.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,Y.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,Y.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,Y.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,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,Y.jsx)(C,{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,Y.jsxs)(Y.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,Y.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,Y.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=Z(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`,X(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,Y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,Y.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,Y.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,Y.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,Y.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,Y.jsx)(C,{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,Y.jsxs)(Y.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,Y.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,Y.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=Z(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,Y.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,Y.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,Y.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,Y.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`,X(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,Y.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,Y.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,Y.jsxs)(Y.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,Y.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,Y.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}=J(),[s,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(`idle`),p=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],m=async()=>{if(!(s||!t)){l(!0),d(`idle`);try{await i(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,Y.jsxs)(A,{gap:`gap-6`,children:[(0,Y.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,Y.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`,T.press),onClick:()=>void m(),disabled:!t||s,"aria-busy":s,children:[(0,Y.jsx)(ee,{className:a(`size-4`,(!t||s)&&`animate-spin`),"aria-hidden":!0}),s?e.health.runDoctorRunning:e.refresh]})}),n?(0,Y.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,Y.jsx)(j,{sections:2}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void m(),doctorRunning:s,doctorRunState:u}),(0,Y.jsxs)(N,{id:`next-steps`,children:[(0,Y.jsx)(M,{icon:r.issues.length?f:w,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,Y.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,Y.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,Y.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(M,{icon:h,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),p.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:p.map(t=>(0,Y.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,Y.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-B4XqB8I6.js";import{l as s,n as c,r as l,s as u}from"./locale-store-deR2zRaE.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ds as f,Fn as p,Fr as m,Is as h,Kl as g,Ma as _,Nc as v,Pn as y,Rl as b,Sn as x,Xc as S,Yl as C,_u as w,as as T,nc as ee,rs as E,za as D,zl as O}from"./index-B-_CEvIX.js";import{n as k,r as A}from"./settings-page-layout-t_Ox1slk.js";import{n as j}from"./settings-loading-skeleton-Bv03cWib.js";import{n as M,t as N}from"./settings-form-section-CiYU8AvV.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`&&E(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.realtimeConnected,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 q(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 J(){let e=(0,F.c)(57),t=s(me),n=c(pe),r;e[0]===n?r=e[1]:(r=o(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,l=_(fe),{data:u,error:f,isLoading:m,mutate:h}=D(!!t),g;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},e[2]=g):g=e[2];let{data:v,error:b,isLoading:S,mutate:C}=d(t?`setup-checklist-skills`:null,de,g),w;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(w={revalidateOnFocus:!1},e[3]=w):w=e[3];let{data:T,error:ee,isLoading:E,mutate:O}=d(t?`setup-checklist-provider-meta`:null,x,w),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:q}=d(U,ue,W),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],d(t?y:null,p,J);let Y=!t||!m&&!S&&!E&&!N&&!z&&!K,X=!!(f||b||ee||M),Z;bb0:{if(!t||!Y){Z=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]!==T||e[33]!==l||e[34]!==n||e[35]!==t){let o=T?.filter(le).length??0,s=T?.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,realtimeConnected: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]=T,e[33]=l,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==q||e[46]!==h||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==C?(Q=async()=>{await Promise.all([h(),C(),O(),P(),B(),q()])},e[45]=q,e[46]=h,e[47]=P,e[48]=B,e[49]=O,e[50]=C,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==X||e[53]!==Y||e[54]!==ge||e[55]!==he?($={ready:Y,error:X,snapshot:he,refresh:ge},e[52]=X,e[53]=Y,e[54]=ge,e[55]=he,e[56]=$):$=e[56],$}function le(e){return e.configured}function ue(e){let[,t]=e;return q(t)}function de(){return m()}function fe(e){return e.connectionState===`connected`}function pe(e){return e.language}function me(e){return e.token}var Y=r();function X(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 Z(e){return e===`pass`?g:e===`warn`?f:e===`fail`?O:S}function he(e,t){return e===`blocked`?{icon:O,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:f,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:b,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:g,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),p,m,h,g,_,y,b,x,S,w,E;if(t[0]!==r||t[1]!==f||t[2]!==n){m=o(f).setupStatus;let e=he(n,m),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`;p=c?(0,Y.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,Y.jsx)(C,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.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,Y.jsx)(C,{className:`size-4`,"aria-hidden":!0})]}),E=a(`rounded-xl p-4`,e.className),w=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,x=`flex min-w-0 gap-3`,S=(0,Y.jsx)(s,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),_=`min-w-0`,y=(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),b=(0,Y.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),h=`mt-2 text-xs opacity-75`,g=m.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=f,t[2]=n,t[3]=p,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=y,t[9]=b,t[10]=x,t[11]=S,t[12]=w,t[13]=E}else p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],y=t[8],b=t[9],x=t[10],S=t[11],w=t[12],E=t[13];let D;t[14]!==h||t[15]!==g?(D=(0,Y.jsx)(`p`,{className:h,children:g}),t[14]=h,t[15]=g,t[16]=D):D=t[16];let O;t[17]!==D||t[18]!==_||t[19]!==y||t[20]!==b?(O=(0,Y.jsxs)(`div`,{className:_,children:[y,b,D]}),t[17]=D,t[18]=_,t[19]=y,t[20]=b,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==x||t[24]!==S?(k=(0,Y.jsxs)(`div`,{className:x,children:[S,O]}),t[22]=O,t[23]=x,t[24]=S,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`,T.press),t[26]=A):A=t[26];let j=!l||u,M;t[27]===u?M=t[28]:(M=u?(0,Y.jsx)(v,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?m.health.runDoctorRunning:m.health.runDoctor,P;t[29]!==u||t[30]!==s||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,Y.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]!==p||t[36]!==P?(I=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[p,P]}),t[35]=p,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==w?(L=(0,Y.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?m.health.doctorRunningMessage:d===`success`?m.health.doctorCompleteMessage:d===`error`?m.health.doctorFailedMessage:m.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,Y.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]!==E?(B=(0,Y.jsxs)(`section`,{className:E,children:[L,z]}),t[44]=L,t[45]=z,t[46]=E,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=Z(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,Y.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,Y.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`,X(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,Y.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,Y.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,Y.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,Y.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,Y.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,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,Y.jsx)(C,{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,Y.jsxs)(Y.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,Y.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,Y.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=Z(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`,X(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,Y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,Y.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,Y.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,Y.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,Y.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,Y.jsx)(C,{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,Y.jsxs)(Y.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,Y.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,Y.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=Z(n.status),t[0]=n.status,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=(0,Y.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,Y.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,Y.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,Y.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`,X(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,Y.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,Y.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,Y.jsxs)(Y.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,Y.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,Y.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}=J(),[s,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(`idle`),p=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],m=async()=>{if(!(s||!t)){l(!0),d(`idle`);try{await i(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,Y.jsxs)(A,{gap:`gap-6`,children:[(0,Y.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,Y.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`,T.press),onClick:()=>void m(),disabled:!t||s,"aria-busy":s,children:[(0,Y.jsx)(ee,{className:a(`size-4`,(!t||s)&&`animate-spin`),"aria-hidden":!0}),s?e.health.runDoctorRunning:e.refresh]})}),n?(0,Y.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,Y.jsx)(j,{sections:2}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void m(),doctorRunning:s,doctorRunState:u}),(0,Y.jsxs)(N,{id:`next-steps`,children:[(0,Y.jsx)(M,{icon:r.issues.length?f:w,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,Y.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,Y.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,Y.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(M,{icon:h,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),p.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:p.map(t=>(0,Y.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,Y.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-deR2zRaE.js";import{Ba as s,Fi as c,Li as l,Pa as u,Ri as d,Tl as f,ki as p,xl as m}from"./index-CYT5DOzr.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=l(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:c(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 s=l(a.fileName,a.mimeType),f=c(a.fileName,s),p=d(f),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(f===`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)(s,{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)(m,{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)(f,{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)(s,{className:`h-5 w-56 max-w-full`}),(0,g.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,g.jsx)(s,{className:`h-4 w-full`}),(0,g.jsx)(s,{className:`h-4 w-11/12`}),(0,g.jsx)(s,{className:`h-4 w-10/12`}),(0,g.jsx)(s,{className:`h-4 w-3/4`})]}),(0,g.jsx)(s,{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-deR2zRaE.js";import{Ba as s,Fi as c,Li as l,Pa as u,Ri as d,Tl as f,ki as p,xl as m}from"./index-B-_CEvIX.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=l(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:c(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 s=l(a.fileName,a.mimeType),f=c(a.fileName,s),p=d(f),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(f===`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)(s,{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)(m,{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)(f,{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)(s,{className:`h-5 w-56 max-w-full`}),(0,g.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,g.jsx)(s,{className:`h-4 w-full`}),(0,g.jsx)(s,{className:`h-4 w-11/12`}),(0,g.jsx)(s,{className:`h-4 w-10/12`}),(0,g.jsx)(s,{className:`h-4 w-3/4`})]}),(0,g.jsx)(s,{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};