@xopcai/xopc 0.0.112 → 0.0.113

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 (102) hide show
  1. package/dist/browser-ext/icons/icon-128.png +0 -0
  2. package/dist/browser-ext/icons/icon-16.png +0 -0
  3. package/dist/browser-ext/icons/icon-32.png +0 -0
  4. package/dist/browser-ext/icons/icon-48.png +0 -0
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/extensions/weixin/src/delivery-to.d.ts +3 -3
  8. package/dist/extensions/weixin/src/delivery-to.js.map +1 -1
  9. package/dist/gateway/static/root/apple-touch-icon.png +0 -0
  10. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-EhRp-ZMa.js → agent-avatar-dicebear-CBlklyNr.js} +1 -1
  11. package/dist/gateway/static/root/assets/{agent-browser-settings-page-H4foVCiS.js → agent-browser-settings-page-rGbKc2Hh.js} +1 -1
  12. package/dist/gateway/static/root/assets/{agent-defaults-tabbed-page-DDNw2oNU.js → agent-defaults-tabbed-page-CtwVbjOA.js} +1 -1
  13. package/dist/gateway/static/root/assets/{agents-E_X2kzS1.js → agents-CCBmGcwc.js} +3 -3
  14. package/dist/gateway/static/root/assets/{app-management-settings-panel-BIy7KEsM.js → app-management-settings-panel-28E_WfMe.js} +1 -1
  15. package/dist/gateway/static/root/assets/{appearance-settings-DGQG8NwA.js → appearance-settings-Do1z0XgJ.js} +1 -1
  16. package/dist/gateway/static/root/assets/{apps-page-BZLvInLr.js → apps-page-xwCsJS15.js} +1 -1
  17. package/dist/gateway/static/root/assets/{archive-plugin-uuQPupqx.js → archive-plugin-BAFlsov_.js} +1 -1
  18. package/dist/gateway/static/root/assets/{attachment-load-DBkv0cAv.js → attachment-load-V3qGPC3x.js} +1 -1
  19. package/dist/gateway/static/root/assets/{binary-plugins-DxxN_VAR.js → binary-plugins-DT8NvA6W.js} +1 -1
  20. package/dist/gateway/static/root/assets/{block-editor-CwnUlRmO.js → block-editor-CdLMEcHd.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-settings-BHvUKlzw.js → channels-settings-C044DcYk.js} +1 -1
  22. package/dist/gateway/static/root/assets/{config-api-BD-NcD5d.js → config-api-Bf5mjpu7.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-settings-VBzXcEXL.js → connectors-settings-8VEWUOTj.js} +1 -1
  24. package/dist/gateway/static/root/assets/{cron-api-C5DoipZA.js → cron-api--pAB_rps.js} +1 -1
  25. package/dist/gateway/static/root/assets/cron-page-DqmNGNOy.js +3 -0
  26. package/dist/gateway/static/root/assets/{dreaming-settings-DSVhXTPq.js → dreaming-settings-6UZE1FSK.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-debug-page-BDHA9o_e.js → extension-debug-page-BGhE7msg.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-page-DmDLVSPE.js → extension-page-CvpI45WG.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-settings-page-1124aHw_.js → extension-settings-page-DAmR5FUe.js} +1 -1
  30. package/dist/gateway/static/root/assets/{fetch-DOe56Wmy.js → fetch-NZmjSXLl.js} +1 -1
  31. package/dist/gateway/static/root/assets/{format-interval-label-tsMSvBSR.js → format-interval-label-qhth3BMV.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-config-api-CsD4FC9D.js → gateway-config-api-CaXBt-9R.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-settings-HQ8FBhY2.js → gateway-settings-DphpbLBc.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-startup-retry-C1zg7pH3.js → gateway-startup-retry-Be1omjh3.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goal-detail-page-BG3Onph0.js → goal-detail-page-bv0VRDaf.js} +1 -1
  36. package/dist/gateway/static/root/assets/goals-page-1Ywnt4Cb.js +2 -0
  37. package/dist/gateway/static/root/assets/{goals-settings-B5nI6lgz.js → goals-settings-ceEBjnfc.js} +1 -1
  38. package/dist/gateway/static/root/assets/{heartbeat-config-api-CIv42nJD.js → heartbeat-config-api-BzO6G4fD.js} +1 -1
  39. package/dist/gateway/static/root/assets/{heartbeat-settings-DFcVuJ3M.js → heartbeat-settings-DCST9-du.js} +1 -1
  40. package/dist/gateway/static/root/assets/{index-BTmbp2AU.js → index-Cxm6xsps.js} +59 -58
  41. package/dist/gateway/static/root/assets/{index-5A_ZaABy.css → index-b_R4tKqt.css} +1 -1
  42. package/dist/gateway/static/root/assets/{interval-presets-DGP3S7OB.js → interval-presets-DJmshV8n.js} +1 -1
  43. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-fETaDYQP.js → keyboard-shortcuts-settings-9AUUlQ5Q.js} +1 -1
  44. package/dist/gateway/static/root/assets/{logs-page-B1-b27lK.js → logs-page-B_wrxhee.js} +1 -1
  45. package/dist/gateway/static/root/assets/{markdown-split-CgeBJMOD.js → markdown-split-CYYELqAr.js} +1 -1
  46. package/dist/gateway/static/root/assets/{media-plugins-C30GzlV2.js → media-plugins-BEcMR2M8.js} +1 -1
  47. package/dist/gateway/static/root/assets/messages-CkT-lcgP.js +3 -0
  48. package/dist/gateway/static/root/assets/{models-hub-panel-DPcTS1-u.js → models-hub-panel-D0JDSbNu.js} +1 -1
  49. package/dist/gateway/static/root/assets/{note-detail-page-xeGb4owe.js → note-detail-page-DpFV-EO6.js} +2 -2
  50. package/dist/gateway/static/root/assets/{note-image-lightbox-t1g0qZYh.js → note-image-lightbox-DNAoPcmm.js} +1 -1
  51. package/dist/gateway/static/root/assets/{notes-page-C_TdnKBe.js → notes-page-CdkjTch8.js} +1 -1
  52. package/dist/gateway/static/root/assets/{preview-open-alternatives-DeWp9x5g.js → preview-open-alternatives-BPLz0AIv.js} +1 -1
  53. package/dist/gateway/static/root/assets/{remote-access-hub-BtkPmJIN.js → remote-access-hub-DSYVAi96.js} +1 -1
  54. package/dist/gateway/static/root/assets/{save-bar-controls-BOaAOJI3.js → save-bar-controls-CrWwWRVK.js} +1 -1
  55. package/dist/gateway/static/root/assets/{schedule-field-BLWLKqgw.js → schedule-field-CF2sadvN.js} +1 -1
  56. package/dist/gateway/static/root/assets/{schema-form-plqRFYT8.js → schema-form-Di5cKjYE.js} +1 -1
  57. package/dist/gateway/static/root/assets/{sessions-page-DOUjxzJm.js → sessions-page-CenkcVjF.js} +1 -1
  58. package/dist/gateway/static/root/assets/settings-advanced-gate-D9sva86V.js +1 -0
  59. package/dist/gateway/static/root/assets/{settings-collapsible-section-BP5zRrDI.js → settings-collapsible-section-Chh282jW.js} +1 -1
  60. package/dist/gateway/static/root/assets/{settings-form-section-Bv8MZplG.js → settings-form-section-Dq-83cQd.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-page-DmDfE1ww.js → settings-page-DL35U0x0.js} +1 -1
  62. package/dist/gateway/static/root/assets/{setup-status-panel-BEFwNcIZ.js → setup-status-panel-Ctwbp9Er.js} +1 -1
  63. package/dist/gateway/static/root/assets/{share-preview-page-4OX1YCgp.js → share-preview-page-0FXYnSUA.js} +1 -1
  64. package/dist/gateway/static/root/assets/{shares-settings-CbKmJZot.js → shares-settings-DIM3JNsr.js} +1 -1
  65. package/dist/gateway/static/root/assets/skill-reload-api-DAlNaNzL.js +1 -0
  66. package/dist/gateway/static/root/assets/skills-page-CLrHVzAt.js +2 -0
  67. package/dist/gateway/static/root/assets/{system-settings-panel-CGy4f_s2.js → system-settings-panel-W1pTcojB.js} +1 -1
  68. package/dist/gateway/static/root/assets/use-agent-defaults-form-BVRvkK7m.js +1 -0
  69. package/dist/gateway/static/root/assets/{use-channel-catalog-CjGHnDvN.js → use-channel-catalog-CgJibfMM.js} +1 -1
  70. package/dist/gateway/static/root/assets/{use-settings-tab-guard-BMMFa0oA.js → use-settings-tab-guard-Bw_qkRQE.js} +1 -1
  71. package/dist/gateway/static/root/assets/{voice-api-key-field-DnRbhMNq.js → voice-api-key-field-vYAO71Gn.js} +1 -1
  72. package/dist/gateway/static/root/assets/{voice-player-store-D5vzWwls.js → voice-player-store-C7lziaAx.js} +1 -1
  73. package/dist/gateway/static/root/assets/{workflow-page.utils-tjGpRVnw.js → workflow-page.utils-sgHjOXOm.js} +1 -1
  74. package/dist/gateway/static/root/assets/{workflows-page-DqqHKGj2.js → workflows-page-DYyOTmFx.js} +1 -1
  75. package/dist/gateway/static/root/favicon-16x16.png +0 -0
  76. package/dist/gateway/static/root/favicon-32x32.png +0 -0
  77. package/dist/gateway/static/root/favicon-icon.svg +1 -0
  78. package/dist/gateway/static/root/favicon.ico +0 -0
  79. package/dist/gateway/static/root/favicon.png +0 -0
  80. package/dist/gateway/static/root/favicon.svg +24 -17
  81. package/dist/gateway/static/root/index.html +5 -5
  82. package/dist/gateway/static/root/logo-dark.svg +23 -15
  83. package/dist/gateway/static/root/logo.svg +23 -16
  84. package/dist/package.js +1 -1
  85. package/dist/src/agent/service/process-direct-streaming.js +9 -4
  86. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  87. package/dist/src/ai-assist/text-assist.d.ts +3 -0
  88. package/dist/src/ai-assist/text-assist.js +25 -7
  89. package/dist/src/ai-assist/text-assist.js.map +1 -1
  90. package/dist/src/channels/plugins/types.adapters.d.ts +2 -2
  91. package/dist/src/cron/executor.js.map +1 -1
  92. package/dist/src/cron/types.d.ts +2 -2
  93. package/dist/src/session/store-reader.d.ts +5 -0
  94. package/dist/src/session/store-reader.js +1 -0
  95. package/package.json +1 -1
  96. package/dist/gateway/static/root/assets/cron-page-BLTpdm34.js +0 -3
  97. package/dist/gateway/static/root/assets/goals-page-DgeKn8zL.js +0 -2
  98. package/dist/gateway/static/root/assets/messages-BUUfPaZ9.js +0 -3
  99. package/dist/gateway/static/root/assets/settings-advanced-gate-qK_bnTrw.js +0 -1
  100. package/dist/gateway/static/root/assets/skill-reload-api-YdtnUHtK.js +0 -1
  101. package/dist/gateway/static/root/assets/skills-page-DwW1IzQ0.js +0 -2
  102. package/dist/gateway/static/root/assets/use-agent-defaults-form-BMuMvzl_.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{gi as i,pi as a}from"./index-BTmbp2AU.js";var o=t();e();var s=n();function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function u(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function d(e){return e[`x-hidden`]===!0}function f(e){let t=e.properties;if(!c(t))return[];let n=[];for(let[e,r]of Object.entries(t))c(r)&&(d(r)||n.push({key:e,sub:r,order:l(r),group:u(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function p(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function m(e){let t=(0,o.c)(38),{name:n,s:r,value:c,onChange:l,disabled:u}=e,d=typeof r.description==`string`?r.description:void 0,f=(typeof r[`x-placeholder`]==`string`?r[`x-placeholder`]:null)||d,p=r.format;if(Array.isArray(r.enum)&&r.enum.every(g)){let e;t[0]===d?e=t[1]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[0]=d,t[1]=e);let i;t[2]===l?i=t[3]:(i=e=>l(e.target.value),t[2]=l,t[3]=i);let a;t[4]===r.enum?a=t[5]:(a=r.enum.map(h),t[4]=r.enum,t[5]=a);let o;t[6]!==u||t[7]!==n||t[8]!==i||t[9]!==a||t[10]!==c?(o=(0,s.jsx)(`select`,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:c,disabled:u,onChange:i,children:a}),t[6]=u,t[7]=n,t[8]=i,t[9]=a,t[10]=c,t[11]=o):o=t[11];let f;return t[12]!==e||t[13]!==o?(f=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,o]}),t[12]=e,t[13]=o,t[14]=f):f=t[14],f}if(p===`password`){let e;t[15]===d?e=t[16]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[15]=d,t[16]=e);let n;t[17]!==u||t[18]!==l||t[19]!==f||t[20]!==c?(n=(0,s.jsx)(i,{value:c,onChange:l,placeholder:f,labels:a,disabled:u,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=u,t[18]=l,t[19]=f,t[20]=c,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let m;t[25]===d?m=t[26]:(m=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[25]=d,t[26]=m);let _;t[27]===l?_=t[28]:(_=e=>l(e.target.value),t[27]=l,t[28]=_);let v;t[29]!==u||t[30]!==n||t[31]!==f||t[32]!==_||t[33]!==c?(v=(0,s.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:c,placeholder:f,disabled:u,onChange:_}),t[29]=u,t[30]=n,t[31]=f,t[32]=_,t[33]=c,t[34]=v):v=t[34];let y;return t[35]!==m||t[36]!==v?(y=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,v]}),t[35]=m,t[36]=v,t[37]=y):y=t[37],y}function h(e){return(0,s.jsx)(`option`,{value:e,children:e},e)}function g(e){return typeof e==`string`}function _(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,c=typeof n.description==`string`?n.description:void 0,l;t[0]===c?l=t[1]:(l=c?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:c}):null,t[0]=c,t[1]=l);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,s.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==l||t[9]!==f?(p=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,f]}),t[8]=l,t[9]=f,t[10]=p):p=t[10],p}function v(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:c}=e,l=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:c?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,s.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===l?f=t[7]:(f=(0,s.jsx)(`span`,{children:l}),t[6]=l,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,s.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function y(e){let t=(0,o.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:l}=e,u=typeof n.description==`string`?n.description:void 0,d=n.items,f=c(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=l?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==u||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===u?_=t[12]:(_=u?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:u}):null,t[11]=u,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,s.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=u,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,s.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=l?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,s.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,s.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function b(e){let t=(0,o.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:l,labels:u}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,o;t[2]===a?o=t[3]:(o=e=>a(e),t[2]=a,t[3]=o);let c;t[4]!==l||t[5]!==u||t[6]!==r||t[7]!==n||t[8]!==o?(c=(0,s.jsx)(v,{s:r,value:n,disabled:l,onChange:o,labels:u}),t[4]=l,t[5]=u,t[6]=r,t[7]=n,t[8]=o,t[9]=c):c=t[9];let d;return t[10]!==e||t[11]!==c?(d=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[10]=e,t[11]=c,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,o;t[15]!==l||t[16]!==a||t[17]!==r||t[18]!==n?(o=(0,s.jsx)(_,{s:r,value:n,disabled:l,onChange:a}),t[15]=l,t[16]=a,t[17]=r,t[18]=n,t[19]=o):o=t[19];let c;return t[20]!==e||t[21]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[20]=e,t[21]=o,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let o=typeof i==`string`?i:``,c;t[25]!==l||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==o?(c=(0,s.jsx)(m,{name:n,s:r,value:o,disabled:l,onChange:a}),t[25]=l,t[26]=n,t[27]=a,t[28]=r,t[29]=o,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=c(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(x)?i.map(String):[],t[36]=i,t[37]=n);let o;t[38]!==l||t[39]!==u||t[40]!==a||t[41]!==r||t[42]!==n?(o=(0,s.jsx)(y,{s:r,value:n,disabled:l,onChange:a,labels:u}),t[38]=l,t[39]=u,t[40]=a,t[41]=r,t[42]=n,t[43]=o):o=t[43];let c;return t[44]!==e||t[45]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[44]=e,t[45]=o,t[46]=c):c=t[46],c}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=c(i)?i:{},t[47]=i,t[48]=e);let n=e,o;t[49]===f?o=t[50]:(o=(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=o);let d;t[51]!==l||t[52]!==u||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,s.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,s.jsx)(S,{schema:r,values:n,onChange:a,disabled:l,labels:u})}),t[51]=l,t[52]=u,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==o||t[58]!==d?(p=(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[o,d]}),t[57]=o,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==u||t[61]!==d||t[62]!==f?(p=u?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=u,t[61]=d,t[62]=f,t[63]=p):p=t[63];let h;return t[64]===p?h=t[65]:(h=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=h),h}function x(e){return typeof e==`string`||typeof e==`number`}function S(e){let t=(0,o.c)(28),{schema:n,values:i,onChange:a,disabled:l,className:u,labels:d}=e,m=l===void 0?!1:l,h;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],h=e;break bb0}let e;t[1]===n?e=t[2]:(e=f(n),t[1]=n,t[2]=e),h=e}let g=h,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=p(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==a||t[7]!==i?(y=(e,t)=>{a({...i,[e]:t})},t[6]=a,t[7]=i,t[8]=y):y=t[8];let x=y;if(n.type!==`object`||!c(n.properties)||g.length===0)return null;let S,w;if(t[9]!==u||t[10]!==m||t[11]!==v||t[12]!==d||t[13]!==x||t[14]!==i){let e=Array.from(v.keys()).sort(C);t[17]===u?S=t[18]:(S=r(`flex flex-col gap-4`,u),t[17]=u,t[18]=S);let n;t[19]!==m||t[20]!==v||t[21]!==d||t[22]!==x||t[23]!==i?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,s.jsx)(b,{k:e.key,sub:e.sub,value:i[e.key],onValue:t=>x(e.key,t),disabled:m,labels:d},e.key));return e===``?(0,s.jsx)(`div`,{children:t},`default`):(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,s.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=m,t[20]=v,t[21]=d,t[22]=x,t[23]=i,t[24]=n):n=t[24],w=e.map(n),t[9]=u,t[10]=m,t[11]=v,t[12]=d,t[13]=x,t[14]=i,t[15]=S,t[16]=w}else S=t[15],w=t[16];let T;return t[25]!==S||t[26]!==w?(T=(0,s.jsx)(`div`,{className:S,children:w}),t[25]=S,t[26]=w,t[27]=T):T=t[27],T}function C(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{S as t};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{gi as i,pi as a}from"./index-Cxm6xsps.js";var o=t();e();var s=n();function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function u(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function d(e){return e[`x-hidden`]===!0}function f(e){let t=e.properties;if(!c(t))return[];let n=[];for(let[e,r]of Object.entries(t))c(r)&&(d(r)||n.push({key:e,sub:r,order:l(r),group:u(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function p(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function m(e){let t=(0,o.c)(38),{name:n,s:r,value:c,onChange:l,disabled:u}=e,d=typeof r.description==`string`?r.description:void 0,f=(typeof r[`x-placeholder`]==`string`?r[`x-placeholder`]:null)||d,p=r.format;if(Array.isArray(r.enum)&&r.enum.every(g)){let e;t[0]===d?e=t[1]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[0]=d,t[1]=e);let i;t[2]===l?i=t[3]:(i=e=>l(e.target.value),t[2]=l,t[3]=i);let a;t[4]===r.enum?a=t[5]:(a=r.enum.map(h),t[4]=r.enum,t[5]=a);let o;t[6]!==u||t[7]!==n||t[8]!==i||t[9]!==a||t[10]!==c?(o=(0,s.jsx)(`select`,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:c,disabled:u,onChange:i,children:a}),t[6]=u,t[7]=n,t[8]=i,t[9]=a,t[10]=c,t[11]=o):o=t[11];let f;return t[12]!==e||t[13]!==o?(f=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,o]}),t[12]=e,t[13]=o,t[14]=f):f=t[14],f}if(p===`password`){let e;t[15]===d?e=t[16]:(e=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[15]=d,t[16]=e);let n;t[17]!==u||t[18]!==l||t[19]!==f||t[20]!==c?(n=(0,s.jsx)(i,{value:c,onChange:l,placeholder:f,labels:a,disabled:u,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=u,t[18]=l,t[19]=f,t[20]=c,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let m;t[25]===d?m=t[26]:(m=d?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:d}):null,t[25]=d,t[26]=m);let _;t[27]===l?_=t[28]:(_=e=>l(e.target.value),t[27]=l,t[28]=_);let v;t[29]!==u||t[30]!==n||t[31]!==f||t[32]!==_||t[33]!==c?(v=(0,s.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:c,placeholder:f,disabled:u,onChange:_}),t[29]=u,t[30]=n,t[31]=f,t[32]=_,t[33]=c,t[34]=v):v=t[34];let y;return t[35]!==m||t[36]!==v?(y=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,v]}),t[35]=m,t[36]=v,t[37]=y):y=t[37],y}function h(e){return(0,s.jsx)(`option`,{value:e,children:e},e)}function g(e){return typeof e==`string`}function _(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,c=typeof n.description==`string`?n.description:void 0,l;t[0]===c?l=t[1]:(l=c?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:c}):null,t[0]=c,t[1]=l);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,s.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==l||t[9]!==f?(p=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,f]}),t[8]=l,t[9]=f,t[10]=p):p=t[10],p}function v(e){let t=(0,o.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:c}=e,l=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:c?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,s.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===l?f=t[7]:(f=(0,s.jsx)(`span`,{children:l}),t[6]=l,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,s.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function y(e){let t=(0,o.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:l}=e,u=typeof n.description==`string`?n.description:void 0,d=n.items,f=c(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=l?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==u||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===u?_=t[12]:(_=u?(0,s.jsx)(`label`,{className:`text-xs text-fg-muted`,children:u}):null,t[11]=u,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,s.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=u,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,s.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=l?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,s.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,s.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function b(e){let t=(0,o.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:l,labels:u}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,o;t[2]===a?o=t[3]:(o=e=>a(e),t[2]=a,t[3]=o);let c;t[4]!==l||t[5]!==u||t[6]!==r||t[7]!==n||t[8]!==o?(c=(0,s.jsx)(v,{s:r,value:n,disabled:l,onChange:o,labels:u}),t[4]=l,t[5]=u,t[6]=r,t[7]=n,t[8]=o,t[9]=c):c=t[9];let d;return t[10]!==e||t[11]!==c?(d=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[10]=e,t[11]=c,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,o;t[15]!==l||t[16]!==a||t[17]!==r||t[18]!==n?(o=(0,s.jsx)(_,{s:r,value:n,disabled:l,onChange:a}),t[15]=l,t[16]=a,t[17]=r,t[18]=n,t[19]=o):o=t[19];let c;return t[20]!==e||t[21]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[20]=e,t[21]=o,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let o=typeof i==`string`?i:``,c;t[25]!==l||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==o?(c=(0,s.jsx)(m,{name:n,s:r,value:o,disabled:l,onChange:a}),t[25]=l,t[26]=n,t[27]=a,t[28]=r,t[29]=o,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=c(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,s.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(x)?i.map(String):[],t[36]=i,t[37]=n);let o;t[38]!==l||t[39]!==u||t[40]!==a||t[41]!==r||t[42]!==n?(o=(0,s.jsx)(y,{s:r,value:n,disabled:l,onChange:a,labels:u}),t[38]=l,t[39]=u,t[40]=a,t[41]=r,t[42]=n,t[43]=o):o=t[43];let c;return t[44]!==e||t[45]!==o?(c=(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[e,o]}),t[44]=e,t[45]=o,t[46]=c):c=t[46],c}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=c(i)?i:{},t[47]=i,t[48]=e);let n=e,o;t[49]===f?o=t[50]:(o=(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=o);let d;t[51]!==l||t[52]!==u||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,s.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,s.jsx)(S,{schema:r,values:n,onChange:a,disabled:l,labels:u})}),t[51]=l,t[52]=u,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==o||t[58]!==d?(p=(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[o,d]}),t[57]=o,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==u||t[61]!==d||t[62]!==f?(p=u?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=u,t[61]=d,t[62]=f,t[63]=p):p=t[63];let h;return t[64]===p?h=t[65]:(h=(0,s.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=h),h}function x(e){return typeof e==`string`||typeof e==`number`}function S(e){let t=(0,o.c)(28),{schema:n,values:i,onChange:a,disabled:l,className:u,labels:d}=e,m=l===void 0?!1:l,h;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],h=e;break bb0}let e;t[1]===n?e=t[2]:(e=f(n),t[1]=n,t[2]=e),h=e}let g=h,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=p(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==a||t[7]!==i?(y=(e,t)=>{a({...i,[e]:t})},t[6]=a,t[7]=i,t[8]=y):y=t[8];let x=y;if(n.type!==`object`||!c(n.properties)||g.length===0)return null;let S,w;if(t[9]!==u||t[10]!==m||t[11]!==v||t[12]!==d||t[13]!==x||t[14]!==i){let e=Array.from(v.keys()).sort(C);t[17]===u?S=t[18]:(S=r(`flex flex-col gap-4`,u),t[17]=u,t[18]=S);let n;t[19]!==m||t[20]!==v||t[21]!==d||t[22]!==x||t[23]!==i?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,s.jsx)(b,{k:e.key,sub:e.sub,value:i[e.key],onValue:t=>x(e.key,t),disabled:m,labels:d},e.key));return e===``?(0,s.jsx)(`div`,{children:t},`default`):(0,s.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,s.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,s.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=m,t[20]=v,t[21]=d,t[22]=x,t[23]=i,t[24]=n):n=t[24],w=e.map(n),t[9]=u,t[10]=m,t[11]=v,t[12]=d,t[13]=x,t[14]=i,t[15]=S,t[16]=w}else S=t[15],w=t[16];let T;return t[25]!==S||t[26]!==w?(T=(0,s.jsx)(`div`,{className:S,children:w}),t[25]=S,t[26]=w,t[27]=T):T=t[27],T}function C(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{S 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"./cn-JdwAhgNB.js";import{t as a}from"./messages-BUUfPaZ9.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-DOe56Wmy.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$r as d,Aa as f,Ai as p,B as m,Cr as h,Ds as ee,Ha as g,Hi as _,Jn as v,Jr as y,Kn as b,Mo as te,No as x,Oi as S,Qr as ne,R as C,Wo as w,Xr as re,Zr as T,_n as E,_r as D,ao as O,ar as k,bi as A,br as j,cr as M,dr as N,fr as P,gn as F,io as I,ja as L,ji as R,ki as z,la as B,lr as V,oo as H,or as ie,pa as ae,pr as oe,qa as U,qn as W,qr as G,sr as se,ur as K,vs as ce,wo as le,wr as ue,xi as q,yr as de,ys as fe,z as J}from"./index-BTmbp2AU.js";import{n as pe,t as Y}from"./settings-form-section-Bv8MZplG.js";var X=e(t(),1),Z=n(),Q=r();function me(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 he(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ge(e){let t=(0,Z.c)(105),{session:n,variant:r,labels:a,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:l}=e,u;t[0]!==a.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||a.unnamedSession,t[0]=a.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,m;t[3]===n.name?m=t[4]:(m=n.name?.trim(),t[3]=n.name,t[4]=m);let h=!!m,ee=n.status===`archived`,y=n.status===`pinned`,b=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,x;t[5]===b?x=t[6]:(x=i(`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`,b),t[5]=b,t[6]=x);let S;t[7]===c?S=t[8]:(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=S);let ne=r===`list`&&`sm:py-3`,C;t[9]===ne?C=t[10]:(C=i(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,ne),t[9]=ne,t[10]=C);let w;t[11]===n.sourceChannel?w=t[12]:(w=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=w);let re;t[13]===y?re=t[14]:(re=y?(0,Q.jsx)(L,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=y,t[14]=re);let T;t[15]===n.updatedAt?T=t[16]:(T=me(n.updatedAt),t[15]=n.updatedAt,t[16]=T);let E;t[17]===T?E=t[18]:(E=(0,Q.jsx)(`span`,{children:T}),t[17]=T,t[18]=E);let D;t[19]!==E||t[20]!==re?(D=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[re,E]}),t[19]=E,t[20]=re,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==C||t[24]!==w?(O=(0,Q.jsxs)(`div`,{className:C,children:[w,D]}),t[22]=D,t[23]=C,t[24]=w,t[25]=O):O=t[25];let k=r===`list`&&`sm:py-3`,j;t[26]===k?j=t[27]:(j=i(`min-w-0 flex-1 px-3 py-2`,k),t[26]=k,t[27]=j);let M=r===`list`&&`sm:items-start`,N;t[28]===M?N=t[29]:(N=i(`flex gap-3`,M),t[28]=M,t[29]=N);let P;t[30]!==s||t[31]!==o?(P=(0,Q.jsx)(v,{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]=P):P=t[32];let F;t[33]===d?F=t[34]:(F=(0,Q.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]=F);let I;t[35]!==n.key||t[36]!==h?(I=h?(0,Q.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]=h,t[37]=I):I=t[37];let R;t[38]!==F||t[39]!==I?(R=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[F,I]}),t[38]=F,t[39]=I,t[40]=R):R=t[40];let z;t[41]!==N||t[42]!==P||t[43]!==R?(z=(0,Q.jsxs)(`div`,{className:N,children:[P,R]}),t[41]=N,t[42]=P,t[43]=R,t[44]=z):z=t[44];let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(g,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=B):B=t[45];let V;t[46]===n.messageCount?V=t[47]:(V=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[B,n.messageCount]}),t[46]=n.messageCount,t[47]=V);let H;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Q.jsx)(p,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=H):H=t[48];let ie;t[49]===n.estimatedTokens?ie=t[50]:(ie=he(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=ie);let ae;t[51]===ie?ae=t[52]:(ae=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[H,ie]}),t[51]=ie,t[52]=ae);let oe;t[53]!==V||t[54]!==ae?(oe=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[V,ae]}),t[53]=V,t[54]=ae,t[55]=oe):oe=t[55];let U;t[56]===n.tags?U=t[57]:(U=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ye),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=U);let W;t[58]!==j||t[59]!==z||t[60]!==oe||t[61]!==U?(W=(0,Q.jsxs)(`div`,{className:j,children:[z,oe,U]}),t[58]=j,t[59]=z,t[60]=oe,t[61]=U,t[62]=W):W=t[62];let G;t[63]===l?G=t[64]:(G=()=>l(`continue`),t[63]=l,t[64]=G);let se;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(g,{className:`size-4`,strokeWidth:1.75}),t[65]=se):se=t[65];let K;t[66]!==a.continueChat||t[67]!==G?(K=(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.continueChat,"aria-label":a.continueChat,onClick:G,children:se}),t[66]=a.continueChat,t[67]=G,t[68]=K):K=t[68];let le;t[69]!==ee||t[70]!==a.archive||t[71]!==a.unarchive||t[72]!==l?(le=ee?(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.unarchive,"aria-label":a.unarchive,onClick:()=>l(`unarchive`),children:(0,Q.jsx)(fe,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.archive,"aria-label":a.archive,onClick:()=>l(`archive`),children:(0,Q.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}),t[69]=ee,t[70]=a.archive,t[71]=a.unarchive,t[72]=l,t[73]=le):le=t[73];let ue;t[74]!==y||t[75]!==a.pin||t[76]!==a.unpin||t[77]!==l?(ue=y?(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.unpin,"aria-label":a.unpin,onClick:()=>l(`unpin`),children:(0,Q.jsx)(f,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.pin,"aria-label":a.pin,onClick:()=>l(`pin`),children:(0,Q.jsx)(L,{className:`size-4`,strokeWidth:1.75})}),t[74]=y,t[75]=a.pin,t[76]=a.unpin,t[77]=l,t[78]=ue):ue=t[78];let q;t[79]===l?q=t[80]:(q=()=>l(`export`),t[79]=l,t[80]=q);let de;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Q.jsx)(te,{className:`size-4`,strokeWidth:1.75}),t[81]=de):de=t[81];let J;t[82]!==a.export||t[83]!==q?(J=(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.export,"aria-label":a.export,onClick:q,children:de}),t[82]=a.export,t[83]=q,t[84]=J):J=t[84];let pe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(pe=i(A,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=pe):pe=t[85];let Y;t[86]===l?Y=t[87]:(Y=()=>l(`delete`),t[86]=l,t[87]=Y);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(_,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let ge;t[89]!==a.delete||t[90]!==Y?(ge=(0,Q.jsx)(`button`,{type:`button`,className:pe,title:a.delete,"aria-label":a.delete,onClick:Y,children:X}),t[89]=a.delete,t[90]=Y,t[91]=ge):ge=t[91];let $;t[92]!==K||t[93]!==le||t[94]!==ue||t[95]!==J||t[96]!==ge?($=(0,Q.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:ve,onKeyDown:_e,children:[K,le,ue,J,ge]}),t[92]=K,t[93]=le,t[94]=ue,t[95]=J,t[96]=ge,t[97]=$):$=t[97];let be;return t[98]!==c||t[99]!==O||t[100]!==W||t[101]!==x||t[102]!==$||t[103]!==S?(be=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:x,onClick:c,onKeyDown:S,children:[O,W,$]}),t[98]=c,t[99]=O,t[100]=W,t[101]=x,t[102]=$,t[103]=S,t[104]=be):be=t[104],be}function _e(e){return e.stopPropagation()}function ve(e){return e.stopPropagation()}function ye(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function be(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function xe(e){let t=$(e)?e:{},n=$(t.session)?t.session:{},r=$(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:be(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Se(e){await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),de()}function Ce(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,S,`dark:border-edge`)}var we=C();function Te({hasToken:e}){let t=a(o(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]),[s,c]=(0,X.useReducer)(we,{form:null,baseline:null}),l=s.form,u=s.baseline,[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),h=(0,X.useRef)(!1),ee=(0,X.useRef)(null);J({enabled:e,parsed:i,dirty:h.current,trackedParsedRef:ee,dispatch:c,onResetDirty:()=>{h.current=!1}});let g=l&&u&&JSON.stringify(l)!==JSON.stringify(u),_=(0,X.useCallback)(e=>{h.current=!0,c({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(U,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(pe,{icon:x,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(z,{type:`button`,variant:`secondary`,disabled:!g||d,onClick:()=>c({type:`discard`}),children:t.discard}),(0,Q.jsx)(z,{type:`button`,variant:`primary`,disabled:!g||d,onClick:()=>{(async()=>{f(!0),m(null);try{await Se(l),h.current=!1,c({type:`saved`,value:l})}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{f(!1)}})()},children:d?t.saving:t.save})]}),p?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(`select`,{className:Ce(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Q.jsx)(`option`,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(`option`,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(`option`,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(`option`,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(`input`,{type:`number`,min:0,className:Ce(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(`input`,{type:`number`,min:1,className:Ce(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function Ee(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 De(e){let t=(0,Z.c)(60),{open:n,loading:r,session:a,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:f,onPin:p,onUnpin:m,onExport:h,onDelete:ee}=e,g=a?.status===`archived`,_=a?.status===`pinned`,b;t[0]===l?b=t[1]:(b=e=>!e&&l(),t[0]=l,t[1]=b);let te;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Q.jsx)(re,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,E)}),t[2]=te):te=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(`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`,F,`dark:border-edge`),t[3]=x):x=t[3];let S;t[4]!==a||t[5]!==s||t[6]!==o?(S=a&&o?(0,Q.jsx)(v,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=a,t[5]=s,t[6]=o,t[7]=S):S=t[7];let C;t[8]!==c.unnamedSession||t[9]!==a?.name?(C=a?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=a?.name,t[10]=C):C=t[10];let w;t[11]===C?w=t[12]:(w=(0,Q.jsx)(d,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:C}),t[11]=C,t[12]=w);let D;t[13]!==S||t[14]!==w?(D=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[S,w]}),t[13]=S,t[14]=w,t[15]=D):D=t[15];let O;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(R,{className:`size-5`,strokeWidth:1.75}),t[16]=O):O=t[16];let k;t[17]===c.close?k=t[18]:(k=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsx)(z,{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,Q.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]!==a?(j=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.detailLoading}):a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:a.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[a.messageCount,` msgs · `,a.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:c.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:a.messages.map(Oe)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=a,t[26]=j):j=t[26];let M;t[27]===j?M=t[28]:(M=(0,Q.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]!==h?(N=(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:c.detailExport}),t[29]=c.detailExport,t[30]=h,t[31]=N):N=t[31];let P;t[32]!==g||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==f?(P=g?(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:c.unarchive}):(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=g,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=f,t[37]=P):P=t[37];let I;t[38]!==_||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==p||t[42]!==m?(I=_?(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:c.unpin}):(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.pin}),t[38]=_,t[39]=c.pin,t[40]=c.unpin,t[41]=p,t[42]=m,t[43]=I):I=t[43];let L;t[44]!==c.delete||t[45]!==ee?(L=(0,Q.jsx)(z,{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:ee,children:c.delete}),t[44]=c.delete,t[45]=ee,t[46]=L):L=t[46];let B;t[47]!==N||t[48]!==P||t[49]!==I||t[50]!==L?(B=(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N,P,I,L]})}),t[47]=N,t[48]=P,t[49]=I,t[50]=L,t[51]=B):B=t[51];let V;t[52]!==A||t[53]!==M||t[54]!==B?(V=(0,Q.jsxs)(T,{children:[te,(0,Q.jsxs)(y,{className:x,"aria-describedby":void 0,children:[A,M,B]})]}),t[52]=A,t[53]=M,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==n||t[57]!==b||t[58]!==V?(H=(0,Q.jsx)(ne,{open:n,onOpenChange:b,children:V}),t[56]=n,t[57]=b,t[58]=V,t[59]=H):H=t[59],H}function Oe(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:Ee(e.content)})]},`${e.timestamp??``}-${e.role}-${Ee(e.content).slice(0,24)}`)}var ke=20;function Ae(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var je=new Set([`all`,`active`,`pinned`,`archived`]),Me=new Set([`grid`,`list`]),Ne=[`sessions`,`settings`];function Pe(e){return e&&Ne.includes(e)?e:`sessions`}function Fe(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function Ie(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Le(e){let t=(0,Z.c)(11),{s:n,activeTab:r,onChange:a}=e,o=n.tabsAriaLabel,s;t[0]!==r||t[1]!==a?(s=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=Ne.indexOf(r);t<0||a(Ne[(t+(e.key===`ArrowRight`?1:-1)+Ne.length)%Ne.length])},t[0]=r,t[1]=a,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==a||t[5]!==n?(c=Ne.map(e=>{let t=e===`sessions`?H:B,o=e===r;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o,"aria-controls":`sessions-panel-${e}`,id:`sessions-tab-${e}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,q.press,o?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>a(e),children:[(0,Q.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:Fe(n,e)})]},e)}),t[3]=r,t[4]=a,t[5]=n,t[6]=c):c=t[6];let l;return t[7]!==n.tabsAriaLabel||t[8]!==s||t[9]!==c?(l=(0,Q.jsx)(`nav`,{"aria-label":o,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:s,children:c}),t[7]=n.tabsAriaLabel,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Re(e){let t=(0,Z.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 border border-edge 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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Fe(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Ie(n,r)})]}),(0,Q.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,Q.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 ze(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:je.has(t)?t:`all`,viewMode:Me.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 Be(){let e=a(o(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:c,mutate:l}=u(r?[`gateway-chat-agents`,n]:null,D,{revalidateOnFocus:!1}),f=c?.defaultId??`main`,p=c?.items??[],[g,_]=ee(),v=Pe(g.get(`tab`)),te=(0,X.useCallback)(e=>{let t=new URLSearchParams(g);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),_(t,{replace:!0})},[g,_]),[x,S]=(0,X.useReducer)(m,g,ze),{searchInput:C,debouncedSearch:A,statusFilter:j,viewMode:R,channelFilter:B,sessions:U,loading:G,error:de,hasMore:fe,stats:J,detailOpen:pe,detailLoading:Y,detailSession:Z,confirmOpen:me,confirmKey:he}=x;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=C.trim();A!==e&&S({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[C,A]);let _e=g.toString(),ve=(0,X.useRef)(_e);if(ve.current!==_e){ve.current=_e;let e=g.get(`q`)??``,t=g.get(`status`),n=g.get(`view`),r=(g.get(`channel`)??``).trim(),i=je.has(t)?t:`all`,a=Me.has(n)?n:`grid`,o=e.trim();S({type:`patch`,patch:{...C===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...j===i?{}:{statusFilter:i},...R===a?{}:{viewMode:a},...B===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(g),t=A.trim();t?e.set(`q`,t):e.delete(`q`),j===`all`?e.delete(`status`):e.set(`status`,j),R===`grid`?e.delete(`view`):e.set(`view`,R),B?e.set(`channel`,B):e.delete(`channel`),e.toString()!==g.toString()&&_(e,{replace:!0})},[A,g,_,j,R,B]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=!1;return(async()=>{S({type:`patch`,patch:{loading:!0,error:null}});try{let t=await K({limit:ke,offset:0,...A?{search:A}:{},...j===`all`?{}:{status:j},...B?{channel:B}:{}});if(e)return;S({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||S({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||S({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,v,A,j,B,t.loadError]),(0,X.useEffect)(()=>{!r||v!==`sessions`||V().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,v]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=()=>void l();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,v,l]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||S({type:`patch`,patch:{sessions:U.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:Z&&Z.key===t.key?{...Z,name:t.name}:Z}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,v,U,Z]);let ye=(0,X.useCallback)(async()=>{if(!(!r||G||!fe)){S({type:`patch`,patch:{loading:!0,error:null}});try{let e=await K({limit:ke,offset:U.length,...A?{search:A}:{},...j===`all`?{}:{status:j},...B?{channel:B}:{}});S({type:`patch`,patch:{sessions:[...U,...e.items],hasMore:e.hasMore}})}catch(e){S({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{S({type:`patch`,patch:{loading:!1}})}}},[r,G,fe,U.length,A,j,B,t.loadError]),$=(0,X.useCallback)((e,t)=>{S({type:`patch`,patch:{sessions:U.map(n=>n.key===e?{...n,status:t}:n),detailSession:Z&&Z.key===e?{...Z,status:t}:Z}})},[U,Z]),be=(0,X.useCallback)(async e=>{S({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{S({type:`patch`,patch:{detailSession:await M(e)}})}catch{S({type:`patch`,patch:{detailOpen:!1}})}finally{S({type:`patch`,patch:{detailLoading:!1}})}},[]),xe=e=>{be(e)},Se=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){S({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await k(e),$(e,`archived`);break;case`unarchive`:await P(e),$(e,`active`);break;case`pin`:await N(e),$(e,`pinned`);break;case`unpin`:await oe(e),$(e,`active`);break;case`export`:{let t=await se(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}V().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await ie(e),S({type:`patch`,patch:{sessions:U.filter(t=>t.key!==e),detailSession:Z?.key===e?null:Z,...Z?.key===e?{detailOpen:!1}:{}}}),V().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we={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},Oe=[{key:`all`,label:t.filterAll,icon:H},{key:`active`,label:t.filterActive,icon:w},{key:`pinned`,label:t.filterPinned,icon:L},{key:`archived`,label:t.filterArchived,icon:ce}],Ne=(()=>{let e=Object.entries(J?.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,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,Q.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Q.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Q.jsx)(Le,{s:t,activeTab:v,onChange:te}),(0,Q.jsx)(Re,{s:t,id:`settings`,activeTab:v,plain:!0,children:(0,Q.jsx)(Te,{hasToken:r})}),(0,Q.jsxs)(Re,{s:t,id:`sessions`,activeTab:v,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Oe.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":j===e,onClick:()=>S({type:`patch`,patch:{statusFilter:e}}),className:i(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,j===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,Q.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Q.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,Q.jsx)(ae,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:C,onChange:e=>S({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":A||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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!B,onClick:()=>S({type:`patch`,patch:{channelFilter:``}}),className:i(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,B?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Ne.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":B===e,onClick:()=>S({type:`patch`,patch:{channelFilter:e}}),className:i(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,B===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,J?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:J.byChannel[e]})]},e))]}),J?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[J.totalSessions,t.totalSessions],[J.activeSessions,t.activeSessions],[J.pinnedSessions,t.pinnedSessions],[J.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,de?(0,Q.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:de}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Ae(t.sessionCount,{count:U.length})}),(0,Q.jsxs)(`div`,{className:ue,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(z,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":R===`grid`,onClick:()=>S({type:`patch`,patch:{viewMode:`grid`}}),className:i(h,`size-7 p-0`,R===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(O,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(z,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":R===`list`,onClick:()=>S({type:`patch`,patch:{viewMode:`list`}}),className:i(h,`size-9 p-0`,R===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`list`&&`text-accent-fg`),children:(0,Q.jsx)(I,{className:`size-3.5`,strokeWidth:1.5})})]})]}),G&&U.length===0?(0,Q.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,Q.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):U.length===0?(0,Q.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,Q.jsx)(le,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Q.jsx)(z,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:i(`grid min-w-0 gap-3`,R===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:U.map(e=>{let t=W(e,f);return(0,Q.jsx)(ge,{session:e,variant:R,labels:we,sessionAgentId:t,sessionAgentAvatar:b(t,p),onOpen:()=>xe(e.key),onAction:t=>void Se(e.key,t)},e.key)})}),fe?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(z,{type:`button`,variant:`secondary`,disabled:G,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(De,{open:pe,loading:Y,session:Z,sessionAgentId:Z?W(Z,f):void 0,sessionAgentAvatar:Z?b(W(Z,f),p):void 0,labels:Ee,onClose:()=>{S({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>Z&&void Se(Z.key,`archive`),onUnarchive:()=>Z&&void Se(Z.key,`unarchive`),onPin:()=>Z&&void Se(Z.key,`pin`),onUnpin:()=>Z&&void Se(Z.key,`unpin`),onExport:()=>Z&&void Se(Z.key,`export`),onDelete:()=>Z&&S({type:`patch`,patch:{confirmKey:Z.key,confirmOpen:!0}})}),(0,Q.jsx)(ne,{open:me,onOpenChange:e=>S({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(T,{children:[(0,Q.jsx)(re,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,E)}),(0,Q.jsxs)(y,{className:i(`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`,F),children:[(0,Q.jsx)(d,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:he?Ae(t.deleteSessionMessage,{name:U.find(e=>e.key===he)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(z,{type:`button`,variant:`secondary`,onClick:()=>S({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(z,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{he&&Ce(he),S({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 py-16 text-center text-sm text-fg-muted sm:px-8 lg:max-w-app-main`,children:t.needToken})}export{Be 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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-NZmjSXLl.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$r as d,Aa as f,Ai as p,B as m,Cr as h,Ds as ee,Ha as g,Hi as _,Jn as v,Jr as y,Kn as b,Mo as te,No as x,Oi as S,Qr as ne,R as C,Wo as w,Xr as re,Zr as T,_n as E,_r as D,ao as O,ar as k,bi as A,br as j,cr as M,dr as N,fr as P,gn as F,io as I,ja as L,ji as R,ki as z,la as B,lr as V,oo as H,or as ie,pa as ae,pr as oe,qa as U,qn as W,qr as G,sr as se,ur as K,vs as ce,wo as le,wr as ue,xi as q,yr as de,ys as fe,z as J}from"./index-Cxm6xsps.js";import{n as pe,t as Y}from"./settings-form-section-Dq-83cQd.js";var X=e(t(),1),Z=n(),Q=r();function me(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 he(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ge(e){let t=(0,Z.c)(105),{session:n,variant:r,labels:a,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:l}=e,u;t[0]!==a.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||a.unnamedSession,t[0]=a.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,m;t[3]===n.name?m=t[4]:(m=n.name?.trim(),t[3]=n.name,t[4]=m);let h=!!m,ee=n.status===`archived`,y=n.status===`pinned`,b=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,x;t[5]===b?x=t[6]:(x=i(`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`,b),t[5]=b,t[6]=x);let S;t[7]===c?S=t[8]:(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=S);let ne=r===`list`&&`sm:py-3`,C;t[9]===ne?C=t[10]:(C=i(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,ne),t[9]=ne,t[10]=C);let w;t[11]===n.sourceChannel?w=t[12]:(w=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=w);let re;t[13]===y?re=t[14]:(re=y?(0,Q.jsx)(L,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=y,t[14]=re);let T;t[15]===n.updatedAt?T=t[16]:(T=me(n.updatedAt),t[15]=n.updatedAt,t[16]=T);let E;t[17]===T?E=t[18]:(E=(0,Q.jsx)(`span`,{children:T}),t[17]=T,t[18]=E);let D;t[19]!==E||t[20]!==re?(D=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[re,E]}),t[19]=E,t[20]=re,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==C||t[24]!==w?(O=(0,Q.jsxs)(`div`,{className:C,children:[w,D]}),t[22]=D,t[23]=C,t[24]=w,t[25]=O):O=t[25];let k=r===`list`&&`sm:py-3`,j;t[26]===k?j=t[27]:(j=i(`min-w-0 flex-1 px-3 py-2`,k),t[26]=k,t[27]=j);let M=r===`list`&&`sm:items-start`,N;t[28]===M?N=t[29]:(N=i(`flex gap-3`,M),t[28]=M,t[29]=N);let P;t[30]!==s||t[31]!==o?(P=(0,Q.jsx)(v,{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]=P):P=t[32];let F;t[33]===d?F=t[34]:(F=(0,Q.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]=F);let I;t[35]!==n.key||t[36]!==h?(I=h?(0,Q.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]=h,t[37]=I):I=t[37];let R;t[38]!==F||t[39]!==I?(R=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[F,I]}),t[38]=F,t[39]=I,t[40]=R):R=t[40];let z;t[41]!==N||t[42]!==P||t[43]!==R?(z=(0,Q.jsxs)(`div`,{className:N,children:[P,R]}),t[41]=N,t[42]=P,t[43]=R,t[44]=z):z=t[44];let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(g,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=B):B=t[45];let V;t[46]===n.messageCount?V=t[47]:(V=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[B,n.messageCount]}),t[46]=n.messageCount,t[47]=V);let H;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Q.jsx)(p,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=H):H=t[48];let ie;t[49]===n.estimatedTokens?ie=t[50]:(ie=he(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=ie);let ae;t[51]===ie?ae=t[52]:(ae=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[H,ie]}),t[51]=ie,t[52]=ae);let oe;t[53]!==V||t[54]!==ae?(oe=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[V,ae]}),t[53]=V,t[54]=ae,t[55]=oe):oe=t[55];let U;t[56]===n.tags?U=t[57]:(U=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ye),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=U);let W;t[58]!==j||t[59]!==z||t[60]!==oe||t[61]!==U?(W=(0,Q.jsxs)(`div`,{className:j,children:[z,oe,U]}),t[58]=j,t[59]=z,t[60]=oe,t[61]=U,t[62]=W):W=t[62];let G;t[63]===l?G=t[64]:(G=()=>l(`continue`),t[63]=l,t[64]=G);let se;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(g,{className:`size-4`,strokeWidth:1.75}),t[65]=se):se=t[65];let K;t[66]!==a.continueChat||t[67]!==G?(K=(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.continueChat,"aria-label":a.continueChat,onClick:G,children:se}),t[66]=a.continueChat,t[67]=G,t[68]=K):K=t[68];let le;t[69]!==ee||t[70]!==a.archive||t[71]!==a.unarchive||t[72]!==l?(le=ee?(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.unarchive,"aria-label":a.unarchive,onClick:()=>l(`unarchive`),children:(0,Q.jsx)(fe,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.archive,"aria-label":a.archive,onClick:()=>l(`archive`),children:(0,Q.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}),t[69]=ee,t[70]=a.archive,t[71]=a.unarchive,t[72]=l,t[73]=le):le=t[73];let ue;t[74]!==y||t[75]!==a.pin||t[76]!==a.unpin||t[77]!==l?(ue=y?(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.unpin,"aria-label":a.unpin,onClick:()=>l(`unpin`),children:(0,Q.jsx)(f,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.pin,"aria-label":a.pin,onClick:()=>l(`pin`),children:(0,Q.jsx)(L,{className:`size-4`,strokeWidth:1.75})}),t[74]=y,t[75]=a.pin,t[76]=a.unpin,t[77]=l,t[78]=ue):ue=t[78];let q;t[79]===l?q=t[80]:(q=()=>l(`export`),t[79]=l,t[80]=q);let de;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Q.jsx)(te,{className:`size-4`,strokeWidth:1.75}),t[81]=de):de=t[81];let J;t[82]!==a.export||t[83]!==q?(J=(0,Q.jsx)(`button`,{type:`button`,className:A,title:a.export,"aria-label":a.export,onClick:q,children:de}),t[82]=a.export,t[83]=q,t[84]=J):J=t[84];let pe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(pe=i(A,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=pe):pe=t[85];let Y;t[86]===l?Y=t[87]:(Y=()=>l(`delete`),t[86]=l,t[87]=Y);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(_,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let ge;t[89]!==a.delete||t[90]!==Y?(ge=(0,Q.jsx)(`button`,{type:`button`,className:pe,title:a.delete,"aria-label":a.delete,onClick:Y,children:X}),t[89]=a.delete,t[90]=Y,t[91]=ge):ge=t[91];let $;t[92]!==K||t[93]!==le||t[94]!==ue||t[95]!==J||t[96]!==ge?($=(0,Q.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:ve,onKeyDown:_e,children:[K,le,ue,J,ge]}),t[92]=K,t[93]=le,t[94]=ue,t[95]=J,t[96]=ge,t[97]=$):$=t[97];let be;return t[98]!==c||t[99]!==O||t[100]!==W||t[101]!==x||t[102]!==$||t[103]!==S?(be=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:x,onClick:c,onKeyDown:S,children:[O,W,$]}),t[98]=c,t[99]=O,t[100]=W,t[101]=x,t[102]=$,t[103]=S,t[104]=be):be=t[104],be}function _e(e){return e.stopPropagation()}function ve(e){return e.stopPropagation()}function ye(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function be(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function xe(e){let t=$(e)?e:{},n=$(t.session)?t.session:{},r=$(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:be(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Se(e){await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),de()}function Ce(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,S,`dark:border-edge`)}var we=C();function Te({hasToken:e}){let t=a(o(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]),[s,c]=(0,X.useReducer)(we,{form:null,baseline:null}),l=s.form,u=s.baseline,[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),h=(0,X.useRef)(!1),ee=(0,X.useRef)(null);J({enabled:e,parsed:i,dirty:h.current,trackedParsedRef:ee,dispatch:c,onResetDirty:()=>{h.current=!1}});let g=l&&u&&JSON.stringify(l)!==JSON.stringify(u),_=(0,X.useCallback)(e=>{h.current=!0,c({type:`patch`,patch:e})},[]);return!e||!l?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(U,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(pe,{icon:x,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(z,{type:`button`,variant:`secondary`,disabled:!g||d,onClick:()=>c({type:`discard`}),children:t.discard}),(0,Q.jsx)(z,{type:`button`,variant:`primary`,disabled:!g||d,onClick:()=>{(async()=>{f(!0),m(null);try{await Se(l),h.current=!1,c({type:`saved`,value:l})}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{f(!1)}})()},children:d?t.saving:t.save})]}),p?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(`select`,{className:Ce(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Q.jsx)(`option`,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(`option`,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(`option`,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(`option`,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(`input`,{type:`number`,min:0,className:Ce(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(`input`,{type:`number`,min:1,className:Ce(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function Ee(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 De(e){let t=(0,Z.c)(60),{open:n,loading:r,session:a,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:f,onPin:p,onUnpin:m,onExport:h,onDelete:ee}=e,g=a?.status===`archived`,_=a?.status===`pinned`,b;t[0]===l?b=t[1]:(b=e=>!e&&l(),t[0]=l,t[1]=b);let te;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Q.jsx)(re,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,E)}),t[2]=te):te=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(`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`,F,`dark:border-edge`),t[3]=x):x=t[3];let S;t[4]!==a||t[5]!==s||t[6]!==o?(S=a&&o?(0,Q.jsx)(v,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=a,t[5]=s,t[6]=o,t[7]=S):S=t[7];let C;t[8]!==c.unnamedSession||t[9]!==a?.name?(C=a?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=a?.name,t[10]=C):C=t[10];let w;t[11]===C?w=t[12]:(w=(0,Q.jsx)(d,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:C}),t[11]=C,t[12]=w);let D;t[13]!==S||t[14]!==w?(D=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[S,w]}),t[13]=S,t[14]=w,t[15]=D):D=t[15];let O;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(R,{className:`size-5`,strokeWidth:1.75}),t[16]=O):O=t[16];let k;t[17]===c.close?k=t[18]:(k=(0,Q.jsx)(G,{asChild:!0,children:(0,Q.jsx)(z,{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,Q.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]!==a?(j=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.detailLoading}):a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:a.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[a.messageCount,` msgs · `,a.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:c.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:a.messages.map(Oe)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=a,t[26]=j):j=t[26];let M;t[27]===j?M=t[28]:(M=(0,Q.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]!==h?(N=(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:c.detailExport}),t[29]=c.detailExport,t[30]=h,t[31]=N):N=t[31];let P;t[32]!==g||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==f?(P=g?(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:c.unarchive}):(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=g,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=f,t[37]=P):P=t[37];let I;t[38]!==_||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==p||t[42]!==m?(I=_?(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:c.unpin}):(0,Q.jsx)(z,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.pin}),t[38]=_,t[39]=c.pin,t[40]=c.unpin,t[41]=p,t[42]=m,t[43]=I):I=t[43];let L;t[44]!==c.delete||t[45]!==ee?(L=(0,Q.jsx)(z,{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:ee,children:c.delete}),t[44]=c.delete,t[45]=ee,t[46]=L):L=t[46];let B;t[47]!==N||t[48]!==P||t[49]!==I||t[50]!==L?(B=(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N,P,I,L]})}),t[47]=N,t[48]=P,t[49]=I,t[50]=L,t[51]=B):B=t[51];let V;t[52]!==A||t[53]!==M||t[54]!==B?(V=(0,Q.jsxs)(T,{children:[te,(0,Q.jsxs)(y,{className:x,"aria-describedby":void 0,children:[A,M,B]})]}),t[52]=A,t[53]=M,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==n||t[57]!==b||t[58]!==V?(H=(0,Q.jsx)(ne,{open:n,onOpenChange:b,children:V}),t[56]=n,t[57]=b,t[58]=V,t[59]=H):H=t[59],H}function Oe(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:Ee(e.content)})]},`${e.timestamp??``}-${e.role}-${Ee(e.content).slice(0,24)}`)}var ke=20;function Ae(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var je=new Set([`all`,`active`,`pinned`,`archived`]),Me=new Set([`grid`,`list`]),Ne=[`sessions`,`settings`];function Pe(e){return e&&Ne.includes(e)?e:`sessions`}function Fe(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function Ie(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Le(e){let t=(0,Z.c)(11),{s:n,activeTab:r,onChange:a}=e,o=n.tabsAriaLabel,s;t[0]!==r||t[1]!==a?(s=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=Ne.indexOf(r);t<0||a(Ne[(t+(e.key===`ArrowRight`?1:-1)+Ne.length)%Ne.length])},t[0]=r,t[1]=a,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==a||t[5]!==n?(c=Ne.map(e=>{let t=e===`sessions`?H:B,o=e===r;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o,"aria-controls":`sessions-panel-${e}`,id:`sessions-tab-${e}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,q.press,o?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>a(e),children:[(0,Q.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:Fe(n,e)})]},e)}),t[3]=r,t[4]=a,t[5]=n,t[6]=c):c=t[6];let l;return t[7]!==n.tabsAriaLabel||t[8]!==s||t[9]!==c?(l=(0,Q.jsx)(`nav`,{"aria-label":o,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:s,children:c}),t[7]=n.tabsAriaLabel,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Re(e){let t=(0,Z.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 border border-edge 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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Fe(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Ie(n,r)})]}),(0,Q.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,Q.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 ze(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:je.has(t)?t:`all`,viewMode:Me.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 Be(){let e=a(o(e=>e.language)),t=e.sessions,n=s(e=>e.token),r=!!n,{data:c,mutate:l}=u(r?[`gateway-chat-agents`,n]:null,D,{revalidateOnFocus:!1}),f=c?.defaultId??`main`,p=c?.items??[],[g,_]=ee(),v=Pe(g.get(`tab`)),te=(0,X.useCallback)(e=>{let t=new URLSearchParams(g);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),_(t,{replace:!0})},[g,_]),[x,S]=(0,X.useReducer)(m,g,ze),{searchInput:C,debouncedSearch:A,statusFilter:j,viewMode:R,channelFilter:B,sessions:U,loading:G,error:de,hasMore:fe,stats:J,detailOpen:pe,detailLoading:Y,detailSession:Z,confirmOpen:me,confirmKey:he}=x;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=C.trim();A!==e&&S({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[C,A]);let _e=g.toString(),ve=(0,X.useRef)(_e);if(ve.current!==_e){ve.current=_e;let e=g.get(`q`)??``,t=g.get(`status`),n=g.get(`view`),r=(g.get(`channel`)??``).trim(),i=je.has(t)?t:`all`,a=Me.has(n)?n:`grid`,o=e.trim();S({type:`patch`,patch:{...C===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...j===i?{}:{statusFilter:i},...R===a?{}:{viewMode:a},...B===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(g),t=A.trim();t?e.set(`q`,t):e.delete(`q`),j===`all`?e.delete(`status`):e.set(`status`,j),R===`grid`?e.delete(`view`):e.set(`view`,R),B?e.set(`channel`,B):e.delete(`channel`),e.toString()!==g.toString()&&_(e,{replace:!0})},[A,g,_,j,R,B]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=!1;return(async()=>{S({type:`patch`,patch:{loading:!0,error:null}});try{let t=await K({limit:ke,offset:0,...A?{search:A}:{},...j===`all`?{}:{status:j},...B?{channel:B}:{}});if(e)return;S({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||S({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||S({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,v,A,j,B,t.loadError]),(0,X.useEffect)(()=>{!r||v!==`sessions`||V().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,v]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=()=>void l();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,v,l]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||S({type:`patch`,patch:{sessions:U.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:Z&&Z.key===t.key?{...Z,name:t.name}:Z}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,v,U,Z]);let ye=(0,X.useCallback)(async()=>{if(!(!r||G||!fe)){S({type:`patch`,patch:{loading:!0,error:null}});try{let e=await K({limit:ke,offset:U.length,...A?{search:A}:{},...j===`all`?{}:{status:j},...B?{channel:B}:{}});S({type:`patch`,patch:{sessions:[...U,...e.items],hasMore:e.hasMore}})}catch(e){S({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{S({type:`patch`,patch:{loading:!1}})}}},[r,G,fe,U.length,A,j,B,t.loadError]),$=(0,X.useCallback)((e,t)=>{S({type:`patch`,patch:{sessions:U.map(n=>n.key===e?{...n,status:t}:n),detailSession:Z&&Z.key===e?{...Z,status:t}:Z}})},[U,Z]),be=(0,X.useCallback)(async e=>{S({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{S({type:`patch`,patch:{detailSession:await M(e)}})}catch{S({type:`patch`,patch:{detailOpen:!1}})}finally{S({type:`patch`,patch:{detailLoading:!1}})}},[]),xe=e=>{be(e)},Se=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){S({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await k(e),$(e,`archived`);break;case`unarchive`:await P(e),$(e,`active`);break;case`pin`:await N(e),$(e,`pinned`);break;case`unpin`:await oe(e),$(e,`active`);break;case`export`:{let t=await se(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}V().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await ie(e),S({type:`patch`,patch:{sessions:U.filter(t=>t.key!==e),detailSession:Z?.key===e?null:Z,...Z?.key===e?{detailOpen:!1}:{}}}),V().then(e=>S({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we={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},Oe=[{key:`all`,label:t.filterAll,icon:H},{key:`active`,label:t.filterActive,icon:w},{key:`pinned`,label:t.filterPinned,icon:L},{key:`archived`,label:t.filterArchived,icon:ce}],Ne=(()=>{let e=Object.entries(J?.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,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,Q.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Q.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Q.jsx)(Le,{s:t,activeTab:v,onChange:te}),(0,Q.jsx)(Re,{s:t,id:`settings`,activeTab:v,plain:!0,children:(0,Q.jsx)(Te,{hasToken:r})}),(0,Q.jsxs)(Re,{s:t,id:`sessions`,activeTab:v,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Oe.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":j===e,onClick:()=>S({type:`patch`,patch:{statusFilter:e}}),className:i(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,j===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,Q.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Q.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,Q.jsx)(ae,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:C,onChange:e=>S({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":A||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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!B,onClick:()=>S({type:`patch`,patch:{channelFilter:``}}),className:i(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,B?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Ne.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":B===e,onClick:()=>S({type:`patch`,patch:{channelFilter:e}}),className:i(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,q.transition,q.focusRingPanel,B===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,J?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:J.byChannel[e]})]},e))]}),J?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[J.totalSessions,t.totalSessions],[J.activeSessions,t.activeSessions],[J.pinnedSessions,t.pinnedSessions],[J.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,de?(0,Q.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:de}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Ae(t.sessionCount,{count:U.length})}),(0,Q.jsxs)(`div`,{className:ue,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(z,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":R===`grid`,onClick:()=>S({type:`patch`,patch:{viewMode:`grid`}}),className:i(h,`size-7 p-0`,R===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(O,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(z,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":R===`list`,onClick:()=>S({type:`patch`,patch:{viewMode:`list`}}),className:i(h,`size-9 p-0`,R===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`list`&&`text-accent-fg`),children:(0,Q.jsx)(I,{className:`size-3.5`,strokeWidth:1.5})})]})]}),G&&U.length===0?(0,Q.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,Q.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):U.length===0?(0,Q.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,Q.jsx)(le,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Q.jsx)(z,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:i(`grid min-w-0 gap-3`,R===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:U.map(e=>{let t=W(e,f);return(0,Q.jsx)(ge,{session:e,variant:R,labels:we,sessionAgentId:t,sessionAgentAvatar:b(t,p),onOpen:()=>xe(e.key),onAction:t=>void Se(e.key,t)},e.key)})}),fe?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(z,{type:`button`,variant:`secondary`,disabled:G,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(De,{open:pe,loading:Y,session:Z,sessionAgentId:Z?W(Z,f):void 0,sessionAgentAvatar:Z?b(W(Z,f),p):void 0,labels:Ee,onClose:()=>{S({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>Z&&void Se(Z.key,`archive`),onUnarchive:()=>Z&&void Se(Z.key,`unarchive`),onPin:()=>Z&&void Se(Z.key,`pin`),onUnpin:()=>Z&&void Se(Z.key,`unpin`),onExport:()=>Z&&void Se(Z.key,`export`),onDelete:()=>Z&&S({type:`patch`,patch:{confirmKey:Z.key,confirmOpen:!0}})}),(0,Q.jsx)(ne,{open:me,onOpenChange:e=>S({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(T,{children:[(0,Q.jsx)(re,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,E)}),(0,Q.jsxs)(y,{className:i(`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`,F),children:[(0,Q.jsx)(d,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:he?Ae(t.deleteSessionMessage,{name:U.find(e=>e.key===he)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(z,{type:`button`,variant:`secondary`,onClick:()=>S({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(z,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{he&&Ce(he),S({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 py-16 text-center text-sm text-fg-muted sm:px-8 lg:max-w-app-main`,children:t.needToken})}export{Be as SessionsPage};
@@ -0,0 +1 @@
1
+ import{Zt as e}from"./index-Cxm6xsps.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{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{rs as a}from"./index-BTmbp2AU.js";import{t as o}from"./settings-advanced-gate-qK_bnTrw.js";var s=n(),c=e(t(),1),l=r();function u(e){let t=(0,s.c)(26),{showLabel:n,hideLabel:r,icon:u,hint:d,children:f,className:p,defaultOpen:m,advancedOnly:h}=e,g=h===void 0?!1:h,[_,v]=(0,c.useState)(m??!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>v(e.currentTarget.open),t[0]=y):y=t[0];let b;t[1]===p?b=t[2]:(b=i(`group rounded-2xl bg-surface-base open:pb-1`,p),t[1]=p,t[2]=b);let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,l.jsx)(a,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=x):x=t[3];let S;t[4]===u?S=t[5]:(S=u?(0,l.jsx)(u,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=u,t[5]=S);let C;t[6]===n?C=t[7]:(C=(0,l.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=C);let w;t[8]===r?w=t[9]:(w=(0,l.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=w);let T;t[10]!==S||t[11]!==C||t[12]!==w?(T=(0,l.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[x,S,C,w]}),t[10]=S,t[11]=C,t[12]=w,t[13]=T):T=t[13];let E;t[14]===d?E=t[15]:(E=d?(0,l.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:d}):null,t[14]=d,t[15]=E);let D;t[16]!==f||t[17]!==E?(D=(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[E,f]}),t[16]=f,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==_||t[20]!==D||t[21]!==b||t[22]!==T?(O=(0,l.jsxs)(`details`,{open:_,onToggle:y,className:b,children:[T,D]}),t[19]=_,t[20]=D,t[21]=b,t[22]=T,t[23]=O):O=t[23];let k=O;if(g){let e;return t[24]===k?e=t[25]:(e=(0,l.jsx)(o,{children:k}),t[24]=k,t[25]=e),e}return k}export{u as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{rs as a}from"./index-Cxm6xsps.js";import{t as o}from"./settings-advanced-gate-D9sva86V.js";var s=n(),c=e(t(),1),l=r();function u(e){let t=(0,s.c)(26),{showLabel:n,hideLabel:r,icon:u,hint:d,children:f,className:p,defaultOpen:m,advancedOnly:h}=e,g=h===void 0?!1:h,[_,v]=(0,c.useState)(m??!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>v(e.currentTarget.open),t[0]=y):y=t[0];let b;t[1]===p?b=t[2]:(b=i(`group rounded-2xl bg-surface-base open:pb-1`,p),t[1]=p,t[2]=b);let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,l.jsx)(a,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=x):x=t[3];let S;t[4]===u?S=t[5]:(S=u?(0,l.jsx)(u,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=u,t[5]=S);let C;t[6]===n?C=t[7]:(C=(0,l.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=C);let w;t[8]===r?w=t[9]:(w=(0,l.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=w);let T;t[10]!==S||t[11]!==C||t[12]!==w?(T=(0,l.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[x,S,C,w]}),t[10]=S,t[11]=C,t[12]=w,t[13]=T):T=t[13];let E;t[14]===d?E=t[15]:(E=d?(0,l.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:d}):null,t[14]=d,t[15]=E);let D;t[16]!==f||t[17]!==E?(D=(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[E,f]}),t[16]=f,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==_||t[20]!==D||t[21]!==b||t[22]!==T?(O=(0,l.jsxs)(`details`,{open:_,onToggle:y,className:b,children:[T,D]}),t[19]=_,t[20]=D,t[21]=b,t[22]=T,t[23]=O):O=t[23];let k=O;if(g){let e;return t[24]===k?e=t[25]:(e=(0,l.jsx)(o,{children:k}),t[24]=k,t[25]=e),e}return k}export{u as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Ma as r,xi as i}from"./index-BTmbp2AU.js";var a=e();function o(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(6),{children:r,className:i,id:c}=e,l;t[0]===i?l=t[1]:(l=n(o(),i),t[0]=i,t[1]=l);let u;return t[2]!==r||t[3]!==c||t[4]!==l?(u=(0,s.jsx)(`section`,{id:c,className:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u):u=t[5],u}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(26),{icon:o,title:c,subtitle:u,trailing:d,className:f,iconInteractive:p,iconLeading:m}=e,h;t[0]===o?h=t[1]:(h=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=h);let g=m??h,_;t[2]===m?_=t[3]:(_=m?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press),t[2]=m,t[3]=_);let v=_,y=!!(p&&m),b;t[4]===f?b=t[5]:(b=n(`mb-5 flex items-start gap-3`,f),t[4]=f,t[5]=b);let x;t[6]!==p||t[7]!==m||t[8]!==g||t[9]!==v||t[10]!==y?(x=p?y?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:p.id,onClick:p.onClick,"aria-label":p.ariaLabel,className:v,children:g}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:p.id,onClick:p.onClick,"aria-label":p.ariaLabel,className:v,children:g}):(0,s.jsx)(`div`,{className:n(m?`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":!m,children:g}),t[6]=p,t[7]=m,t[8]=g,t[9]=v,t[10]=y,t[11]=x):x=t[11];let S;t[12]===c?S=t[13]:(S=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=S);let C;t[14]===u?C=t[15]:(C=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[14]=u,t[15]=C);let w;t[16]!==S||t[17]!==C?(w=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[16]=S,t[17]=C,t[18]=w):w=t[18];let T;t[19]===d?T=t[20]:(T=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[19]=d,t[20]=T);let E;return t[21]!==b||t[22]!==x||t[23]!==w||t[24]!==T?(E=(0,s.jsxs)(`div`,{className:b,children:[x,w,T]}),t[21]=b,t[22]=x,t[23]=w,t[24]=T,t[25]=E):E=t[25],E}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{Ma as r,xi as i}from"./index-Cxm6xsps.js";var a=e();function o(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(6),{children:r,className:i,id:c}=e,l;t[0]===i?l=t[1]:(l=n(o(),i),t[0]=i,t[1]=l);let u;return t[2]!==r||t[3]!==c||t[4]!==l?(u=(0,s.jsx)(`section`,{id:c,className:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u):u=t[5],u}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(26),{icon:o,title:c,subtitle:u,trailing:d,className:f,iconInteractive:p,iconLeading:m}=e,h;t[0]===o?h=t[1]:(h=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=h);let g=m??h,_;t[2]===m?_=t[3]:(_=m?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press),t[2]=m,t[3]=_);let v=_,y=!!(p&&m),b;t[4]===f?b=t[5]:(b=n(`mb-5 flex items-start gap-3`,f),t[4]=f,t[5]=b);let x;t[6]!==p||t[7]!==m||t[8]!==g||t[9]!==v||t[10]!==y?(x=p?y?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:p.id,onClick:p.onClick,"aria-label":p.ariaLabel,className:v,children:g}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:p.id,onClick:p.onClick,"aria-label":p.ariaLabel,className:v,children:g}):(0,s.jsx)(`div`,{className:n(m?`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":!m,children:g}),t[6]=p,t[7]=m,t[8]=g,t[9]=v,t[10]=y,t[11]=x):x=t[11];let S;t[12]===c?S=t[13]:(S=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=S);let C;t[14]===u?C=t[15]:(C=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[14]=u,t[15]=C);let w;t[16]!==S||t[17]!==C?(w=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[16]=S,t[17]=C,t[18]=w):w=t[18];let T;t[19]===d?T=t[20]:(T=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[19]=d,t[20]=T);let E;return t[21]!==b||t[22]!==x||t[23]!==w||t[24]!==T?(E=(0,s.jsxs)(`div`,{className:b,children:[x,w,T]}),t[21]=b,t[22]=x,t[23]=w,t[24]=T,t[25]=E):E=t[25],E}export{u 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"./messages-BUUfPaZ9.js";import{t as a}from"./locale-store-DjbfSsfA.js";import{Br as o,Cs as s,Es as c,Fr as l,Gr as u,Hr as d,Ir as f,Lr as p,Mr as m,Nr as h,Pr as g,Rr as _,Ur as v,Vr as y,Wr as b,jr as x,zr as S}from"./index-BTmbp2AU.js";var C=n(),w=e(t(),1),T=r(),E=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`app-management`,`agent-defaults`,`agent-browser`,`connectors`,`credentials`,`gateway`,`heartbeat`,`tunnel`,`remote-access`,`shares`,`goals`,`dreams`],D=(0,w.lazy)(()=>v().then(e=>({default:e.SetupStatusPanel}))),O=(0,w.lazy)(()=>m().then(e=>({default:e.AgentDefaultsTabbedPage}))),k=(0,w.lazy)(()=>x().then(e=>({default:e.AgentBrowserSettingsPage}))),A=(0,w.lazy)(()=>l().then(e=>({default:e.ConnectorsSettingsPanel}))),j=(0,w.lazy)(()=>g().then(e=>({default:e.AppearanceSettingsPanel}))),M=(0,w.lazy)(()=>o().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),N=(0,w.lazy)(()=>u().then(e=>({default:e.SystemSettingsPanel}))),P=(0,w.lazy)(()=>h().then(e=>({default:e.AppManagementSettingsPanel}))),F=(0,w.lazy)(()=>y().then(e=>({default:e.ModelsHubPanel}))),I=(0,w.lazy)(()=>p().then(e=>({default:e.GatewaySettingsPanel}))),L=(0,w.lazy)(()=>S().then(e=>({default:e.HeartbeatSettingsPanel}))),R=(0,w.lazy)(()=>d().then(e=>({default:e.RemoteAccessHub}))),z=(0,w.lazy)(()=>b().then(e=>({default:e.SharesSettingsPanel}))),B=(0,w.lazy)(()=>f().then(e=>({default:e.DreamingSettingsPanel}))),V=(0,w.lazy)(()=>_().then(e=>({default:e.GoalsSettingsPanel})));function H(){let e=(0,C.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main flex-1 px-4 py-8`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function U(e){return(0,T.jsx)(w.Suspense,{fallback:(0,T.jsx)(H,{}),children:(0,T.jsx)(e,{})})}function W(){let e=(0,C.c)(32),{section:t}=c(),n=a(G),r,o,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let a=i(n);if(t===`agent`||t===`agents`){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsx)(s,{to:`/agents`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}if(!t||!E.includes(t)){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsx)(s,{to:`/settings/overview`,replace:!0}),e[8]=t):t=e[8],d=t;break bb0}if(t===`tunnel`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsx)(s,{to:`/settings/remote-access`,replace:!0}),e[9]=t):t=e[9],d=t;break bb0}let c=t;if(c===`overview`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(D),e[10]=t):t=e[10],d=t;break bb0}let f=a.settingsSections[c];if(c===`agent-defaults`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(O),e[11]=t):t=e[11],d=t;break bb0}if(c===`agent-browser`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(k),e[12]=t):t=e[12],d=t;break bb0}if(c===`connectors`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(A),e[13]=t):t=e[13],d=t;break bb0}if(c===`appearance`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(j),e[14]=t):t=e[14],d=t;break bb0}if(c===`keyboard-shortcuts`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(M),e[15]=t):t=e[15],d=t;break bb0}if(c===`system`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(N),e[16]=t):t=e[16],d=t;break bb0}if(c===`app-management`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(P),e[17]=t):t=e[17],d=t;break bb0}if(c===`credentials`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(F),e[18]=t):t=e[18],d=t;break bb0}if(c===`gateway`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(I),e[19]=t):t=e[19],d=t;break bb0}if(c===`heartbeat`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(L),e[20]=t):t=e[20],d=t;break bb0}if(c===`tunnel`||c===`remote-access`){let t;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(R),e[21]=t):t=e[21],d=t;break bb0}if(c===`shares`){let t;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(z),e[22]=t):t=e[22],d=t;break bb0}if(c===`dreams`){let t;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(B),e[23]=t):t=e[23],d=t;break bb0}if(c===`goals`){let t;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(V),e[24]=t):t=e[24],d=t;break bb0}l=`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,u=(0,T.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,o=a.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=o,e[4]=l,e[5]=u,e[6]=d}else r=e[2],o=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[25]!==r||e[26]!==o?(f=(0,T.jsx)(`p`,{className:r,children:o}),e[25]=r,e[26]=o,e[27]=f):f=e[27];let p;return e[28]!==l||e[29]!==u||e[30]!==f?(p=(0,T.jsxs)(`div`,{className:l,children:[u,f]}),e[28]=l,e[29]=u,e[30]=f,e[31]=p):p=e[31],p}function G(e){return e.language}export{W 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{t as i}from"./messages-CkT-lcgP.js";import{t as a}from"./locale-store-DjbfSsfA.js";import{Br as o,Cs as s,Es as c,Fr as l,Gr as u,Hr as d,Ir as f,Lr as p,Mr as m,Nr as h,Pr as g,Rr as _,Ur as v,Vr as y,Wr as b,jr as x,zr as S}from"./index-Cxm6xsps.js";var C=n(),w=e(t(),1),T=r(),E=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`app-management`,`agent-defaults`,`agent-browser`,`connectors`,`credentials`,`gateway`,`heartbeat`,`tunnel`,`remote-access`,`shares`,`goals`,`dreams`],D=(0,w.lazy)(()=>v().then(e=>({default:e.SetupStatusPanel}))),O=(0,w.lazy)(()=>m().then(e=>({default:e.AgentDefaultsTabbedPage}))),k=(0,w.lazy)(()=>x().then(e=>({default:e.AgentBrowserSettingsPage}))),A=(0,w.lazy)(()=>l().then(e=>({default:e.ConnectorsSettingsPanel}))),j=(0,w.lazy)(()=>g().then(e=>({default:e.AppearanceSettingsPanel}))),M=(0,w.lazy)(()=>o().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),N=(0,w.lazy)(()=>u().then(e=>({default:e.SystemSettingsPanel}))),P=(0,w.lazy)(()=>h().then(e=>({default:e.AppManagementSettingsPanel}))),F=(0,w.lazy)(()=>y().then(e=>({default:e.ModelsHubPanel}))),I=(0,w.lazy)(()=>p().then(e=>({default:e.GatewaySettingsPanel}))),L=(0,w.lazy)(()=>S().then(e=>({default:e.HeartbeatSettingsPanel}))),R=(0,w.lazy)(()=>d().then(e=>({default:e.RemoteAccessHub}))),z=(0,w.lazy)(()=>b().then(e=>({default:e.SharesSettingsPanel}))),B=(0,w.lazy)(()=>f().then(e=>({default:e.DreamingSettingsPanel}))),V=(0,w.lazy)(()=>_().then(e=>({default:e.GoalsSettingsPanel})));function H(){let e=(0,C.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main flex-1 px-4 py-8`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function U(e){return(0,T.jsx)(w.Suspense,{fallback:(0,T.jsx)(H,{}),children:(0,T.jsx)(e,{})})}function W(){let e=(0,C.c)(32),{section:t}=c(),n=a(G),r,o,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let a=i(n);if(t===`agent`||t===`agents`){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsx)(s,{to:`/agents`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}if(!t||!E.includes(t)){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsx)(s,{to:`/settings/overview`,replace:!0}),e[8]=t):t=e[8],d=t;break bb0}if(t===`tunnel`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsx)(s,{to:`/settings/remote-access`,replace:!0}),e[9]=t):t=e[9],d=t;break bb0}let c=t;if(c===`overview`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(D),e[10]=t):t=e[10],d=t;break bb0}let f=a.settingsSections[c];if(c===`agent-defaults`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(O),e[11]=t):t=e[11],d=t;break bb0}if(c===`agent-browser`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(k),e[12]=t):t=e[12],d=t;break bb0}if(c===`connectors`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(A),e[13]=t):t=e[13],d=t;break bb0}if(c===`appearance`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(j),e[14]=t):t=e[14],d=t;break bb0}if(c===`keyboard-shortcuts`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(M),e[15]=t):t=e[15],d=t;break bb0}if(c===`system`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(N),e[16]=t):t=e[16],d=t;break bb0}if(c===`app-management`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(P),e[17]=t):t=e[17],d=t;break bb0}if(c===`credentials`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(F),e[18]=t):t=e[18],d=t;break bb0}if(c===`gateway`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(I),e[19]=t):t=e[19],d=t;break bb0}if(c===`heartbeat`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(L),e[20]=t):t=e[20],d=t;break bb0}if(c===`tunnel`||c===`remote-access`){let t;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(R),e[21]=t):t=e[21],d=t;break bb0}if(c===`shares`){let t;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(z),e[22]=t):t=e[22],d=t;break bb0}if(c===`dreams`){let t;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(B),e[23]=t):t=e[23],d=t;break bb0}if(c===`goals`){let t;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(t=U(V),e[24]=t):t=e[24],d=t;break bb0}l=`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,u=(0,T.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,o=a.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=o,e[4]=l,e[5]=u,e[6]=d}else r=e[2],o=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[25]!==r||e[26]!==o?(f=(0,T.jsx)(`p`,{className:r,children:o}),e[25]=r,e[26]=o,e[27]=f):f=e[27];let p;return e[28]!==l||e[29]!==u||e[30]!==f?(p=(0,T.jsxs)(`div`,{className:l,children:[u,f]}),e[28]=l,e[29]=u,e[30]=f,e[31]=p):p=e[31],p}function G(e){return e.language}export{W as SettingsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-BUUfPaZ9.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-DOe56Wmy.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Go as d,Jt as f,Q as p,Qi as m,Ss as h,Vi as g,Vt as _,Wo as v,Zo as y,ba as ee,br as b,ct as x,ot as S,qa as C,st as w,ts as T,uo as E,xi as te,xs as D,yi as O}from"./index-BTmbp2AU.js";import{n as k,t as A}from"./settings-form-section-Bv8MZplG.js";var j=e(t(),1),M=n();function N(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`&&O(e)).length}function P(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults;if(!n||typeof n!=`object`||Array.isArray(n))return``;let r=n.model;return typeof r==`string`?r.trim():``}function F(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 I(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t.defaults;if(!n||typeof n!=`object`||Array.isArray(n))return{enabled:!1,backend:`extension`};let r=n.browser;if(!r||typeof r!=`object`||Array.isArray(r))return{enabled:!1,backend:`extension`};let i=r;return{enabled:i.enabled===!0,backend:typeof i.backend==`string`&&i.backend.trim()?i.backend.trim():`extension`}}function L(e){return e?`pass`:`fail`}function R(e){if(e===`provider-auth`)return`/settings/credentials`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/settings/agent-defaults?tab=workspace`;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===`cron-health`)return`/settings/goals`;if(e===`version-check`)return`/settings/app-management`}function z(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function B(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:R(e.id),source:`doctor`})).toSorted((e,t)=>z(t.status)-z(e.status)||e.label.localeCompare(t.label))}function V(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`,`cron-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:R(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=N(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=P(e.config),o=a.length>0,s=e.hasToken&&e.sseConnected,c=F(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=B(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},{id:`presets`,done:e.presetsDone,optional:!0,detail:e.presetsDone?e.labels.presetsConfigured:e.labels.presetsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:L(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:L(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/credentials`},{id:`defaultModel`,status:L(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/agent-defaults`},{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=V({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,presetsDone:e.presetsDone,agentCount:e.agentCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function re(e){return I(e)}function H(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 c(`/api/doctor`)}async function ae(){return((await l(ie())).checks??[]).map(H).filter(e=>e!==null)}function oe(){return c(`/api/logs/health`)}async function se(){return l(oe())}function U(e){return e?`pass`:`warn`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function le(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await l(c(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:U(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser?tab=local`}]}if(e.backend===`cloakbrowser`){let e=await l(c(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:U(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:`/settings/agent-browser?tab=cloakbrowser`}]}if(e.backend===`extension`){let e=await l(c(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser?tab=extension`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:`/settings/agent-browser`}]}function ue(e){return!!(e&&e.length>1)}function W(){let e=(0,M.c)(62),t=s(ge),n=o(he),r;e[0]===n?r=e[1]:(r=a(n),e[0]=n,e[1]=r);let i=r,c=i.setupStatus.labels,l=x(me),{data:d,error:f,isLoading:m,mutate:h}=b(!!t),g;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},e[2]=g):g=e[2];let{data:v,error:y,isLoading:ee,mutate:C}=u(t?`setup-checklist-skills`:null,pe,g),T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},e[3]=T):T=e[3];let{data:E,error:te,isLoading:D,mutate:O}=u(t?`setup-checklist-provider-meta`:null,p,T),k;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(k={revalidateOnFocus:!1},e[4]=k):k=e[4];let{data:A,error:j,isLoading:N,mutate:P}=u(t?`setup-checklist-agents`:null,_,k),F;e[5]===t?F=e[6]:(F=t?ie():null,e[5]=t,e[6]=F);let I;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(I={revalidateOnFocus:!1},e[7]=I):I=e[7];let{data:L,error:R,isLoading:z,mutate:B}=u(F,ae,I),V;e[8]===t?V=e[9]:(V=t?oe():null,e[8]=t,e[9]=V);let H;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(H={revalidateOnFocus:!1},e[10]=H):H=e[10];let{data:U,isLoading:le,mutate:W}=u(V,se,H);d?.payload?.config;let G=d?.payload?.config,K;e[11]===G?K=e[12]:(K=re(G),e[11]=G,e[12]=K);let q=t?K:null,J;e[13]===q?J=e[14]:(J=ce(q),e[13]=q,e[14]=J);let Y;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(Y={revalidateOnFocus:!1},e[15]=Y):Y=e[15];let{data:X,isLoading:_e,mutate:Z}=u(J,fe,Y),Q;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(Q={revalidateOnFocus:!1},e[16]=Q):Q=e[16],u(t?S:null,w,Q);let $=!t||!m&&!ee&&!D&&!N&&!z&&!le&&!_e,ve=!!(f||y||te||j||R),ye;bb0:{if(!t||!$){ye=null;break bb0}let n=v?.catalog?.length??0,r;if(e[17]!==A?.agents||e[18]!==X||e[19]!==d?.payload?.config||e[20]!==L||e[21]!==c.channelConfigured||e[22]!==c.channelMissing||e[23]!==c.gatewayOffline||e[24]!==c.gatewayOnline||e[25]!==c.modelConfigured||e[26]!==c.modelMissing||e[27]!==c.presetsConfigured||e[28]!==c.presetsMissing||e[29]!==c.providersConfigured||e[30]!==c.providersMetaReady||e[31]!==c.providersMissing||e[32]!==c.skillsConfigured||e[33]!==c.skillsMissing||e[34]!==U||e[35]!==i.setupStatus.requiredCompleteMessage||e[36]!==E||e[37]!==n||e[38]!==l||e[39]!==t){let a=E?.filter(de).length??0,o=E?.length??0,s=A?.agents.length??0,u=ue(A?.agents),f;e[41]===c.providersConfigured?f=e[42]:(f=e=>c.providersConfigured.replace(`{{count}}`,String(e)),e[41]=c.providersConfigured,e[42]=f);let p;e[43]===c.providersMetaReady?p=e[44]:(p=(e,t)=>c.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[43]=c.providersMetaReady,e[44]=p);let m;e[45]===c.modelConfigured?m=e[46]:(m=e=>c.modelConfigured.replace(`{{model}}`,e),e[45]=c.modelConfigured,e[46]=m);let h;e[47]===c.skillsConfigured?h=e[48]:(h=e=>c.skillsConfigured.replace(`{{count}}`,String(e)),e[47]=c.skillsConfigured,e[48]=h),r=ne({hasToken:!!t,sseConnected:l,config:d?.payload?.config,skillCount:n,providerMeta:o>0?{configured:a,total:o}:null,doctorChecks:L,logsHealth:U,browserDiagnostics:X,presetsDone:u,agentCount:s,labels:{gatewayOnline:c.gatewayOnline,gatewayOffline:c.gatewayOffline,providersConfigured:f,providersMetaReady:p,providersMissing:c.providersMissing,modelConfigured:m,modelMissing:c.modelMissing,channelConfigured:c.channelConfigured,channelMissing:c.channelMissing,skillsConfigured:h,skillsMissing:c.skillsMissing,presetsConfigured:c.presetsConfigured.replace(`{{count}}`,String(s)),presetsMissing:c.presetsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[17]=A?.agents,e[18]=X,e[19]=d?.payload?.config,e[20]=L,e[21]=c.channelConfigured,e[22]=c.channelMissing,e[23]=c.gatewayOffline,e[24]=c.gatewayOnline,e[25]=c.modelConfigured,e[26]=c.modelMissing,e[27]=c.presetsConfigured,e[28]=c.presetsMissing,e[29]=c.providersConfigured,e[30]=c.providersMetaReady,e[31]=c.providersMissing,e[32]=c.skillsConfigured,e[33]=c.skillsMissing,e[34]=U,e[35]=i.setupStatus.requiredCompleteMessage,e[36]=E,e[37]=n,e[38]=l,e[39]=t,e[40]=r}else r=e[40];ye=r}let be=ye,xe;e[49]!==P||e[50]!==Z||e[51]!==h||e[52]!==B||e[53]!==W||e[54]!==O||e[55]!==C?(xe=async()=>{await Promise.all([h(),C(),O(),P(),B(),W(),Z()])},e[49]=P,e[50]=Z,e[51]=h,e[52]=B,e[53]=W,e[54]=O,e[55]=C,e[56]=xe):xe=e[56];let Se=xe,Ce;return e[57]!==ve||e[58]!==$||e[59]!==Se||e[60]!==be?(Ce={ready:$,error:ve,snapshot:be,refresh:Se},e[57]=ve,e[58]=$,e[59]=Se,e[60]=be,e[61]=Ce):Ce=e[61],Ce}function de(e){return e.configured}function fe(e){let[,t]=e;return le(t)}function pe(){return f()}function me(e){return e.connectionState===`connected`}function he(e){return e.language}function ge(e){return e.token}var G=r();function K(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 q(e){return e===`pass`?y:e===`warn`?g:e===`fail`?d:E}function J(e,t){return e===`blocked`?{icon:d,className:`border-red-500/30 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:g,className:`border-amber-500/30 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:v,className:`border-edge bg-surface-panel text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:y,className:`border-success/30 bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Y(e){let t=(0,M.c)(48),{tier:n,issueCount:r,onRunDoctor:s,ready:c,doctorRunning:l,doctorRunState:u}=e,d=o(X),f,p,m,g,_,v,y,b,x,S,w;if(t[0]!==r||t[1]!==d||t[2]!==n){p=a(d).setupStatus;let e=J(n,p),o=e.icon,s=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;f=s?(0,G.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(s)?.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,G.jsx)(T,{className:`size-4`,"aria-hidden":!0})]}):(0,G.jsxs)(h,{to:c,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,G.jsx)(T,{className:`size-4`,"aria-hidden":!0})]}),w=i(`rounded-xl border px-4 py-4`,e.className),S=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,b=`flex min-w-0 gap-3`,x=(0,G.jsx)(o,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),_=`min-w-0`,v=(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),y=(0,G.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),m=`mt-2 text-xs opacity-75`,g=p.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=d,t[2]=n,t[3]=f,t[4]=p,t[5]=m,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=b,t[11]=x,t[12]=S,t[13]=w}else f=t[3],p=t[4],m=t[5],g=t[6],_=t[7],v=t[8],y=t[9],b=t[10],x=t[11],S=t[12],w=t[13];let E;t[14]!==m||t[15]!==g?(E=(0,G.jsx)(`p`,{className:m,children:g}),t[14]=m,t[15]=g,t[16]=E):E=t[16];let D;t[17]!==E||t[18]!==_||t[19]!==v||t[20]!==y?(D=(0,G.jsxs)(`div`,{className:_,children:[v,y,E]}),t[17]=E,t[18]=_,t[19]=v,t[20]=y,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==b||t[24]!==x?(O=(0,G.jsxs)(`div`,{className:b,children:[x,D]}),t[22]=D,t[23]=b,t[24]=x,t[25]=O):O=t[25];let k;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(k=i(`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`,te.press),t[26]=k):k=t[26];let A=!c||l,j;t[27]===l?j=t[28]:(j=l?(0,G.jsx)(C,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,G.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=l,t[28]=j);let N=l?p.health.runDoctorRunning:p.health.runDoctor,P;t[29]!==l||t[30]!==s||t[31]!==A||t[32]!==j||t[33]!==N?(P=(0,G.jsxs)(`button`,{type:`button`,className:k,onClick:s,disabled:A,"aria-busy":l,children:[j,N]}),t[29]=l,t[30]=s,t[31]=A,t[32]=j,t[33]=N,t[34]=P):P=t[34];let F;t[35]!==f||t[36]!==P?(F=(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[f,P]}),t[35]=f,t[36]=P,t[37]=F):F=t[37];let I;t[38]!==O||t[39]!==F||t[40]!==S?(I=(0,G.jsxs)(`div`,{className:S,children:[O,F]}),t[38]=O,t[39]=F,t[40]=S,t[41]=I):I=t[41];let L=l?p.health.doctorRunningMessage:u===`success`?p.health.doctorCompleteMessage:u===`error`?p.health.doctorFailedMessage:p.health.doctorIdleMessage,R;t[42]===L?R=t[43]:(R=(0,G.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:L}),t[42]=L,t[43]=R);let z;return t[44]!==I||t[45]!==R||t[46]!==w?(z=(0,G.jsxs)(`section`,{className:w,children:[I,R]}),t[44]=I,t[45]=R,t[46]=w,t[47]=z):z=t[47],z}function X(e){return e.language}function _e(e){let t=(0,M.c)(34),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=q(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,G.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,G.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.status?l=t[7]:(l=i(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,K(n.status)),t[6]=n.status,t[7]=l);let u;t[8]!==n.status||t[9]!==l?(u=(0,G.jsx)(`span`,{className:l,children:n.status}),t[8]=n.status,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==c||t[12]!==u?(d=(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[11]=c,t[12]=u,t[13]=d):d=t[13];let f;t[14]===n.message?f=t[15]:(f=(0,G.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=f);let p;t[16]===n.hints[0]?p=t[17]:(p=n.hints[0]?(0,G.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=p);let m;t[18]!==d||t[19]!==f||t[20]!==p?(m=(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,f,p]}),t[18]=d,t[19]=f,t[20]=p,t[21]=m):m=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,G.jsx)(T,{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]!==s||t[27]!==m?(_=(0,G.jsxs)(G.Fragment,{children:[s,m,g]}),t[25]=g,t[26]=s,t[27]=m,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,G.jsx)(h,{to:n.path,className:`flex items-start gap-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3 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,G.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3`,children:v}),t[32]=v,t[33]=y),y}function Z(e){let t=(0,M.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=q(n.status),t[0]=n.status,t[1]=a);let o=a,s=r[n.id]??n.title,c;t[2]===n.status?c=t[3]:(c=i(`flex size-7 shrink-0 items-center justify-center rounded-full border`,K(n.status)),t[2]=n.status,t[3]=c);let l;t[4]===o?l=t[5]:(l=(0,G.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,G.jsx)(`span`,{className:c,children:l}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===s?d=t[10]:(d=(0,G.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=d);let f;t[11]===n.detail?f=t[12]:(f=(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=f);let p;t[13]!==d||t[14]!==f?(p=(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;t[16]===n.path?m=t[17]:(m=n.path?(0,G.jsx)(T,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=m);let g;t[18]!==u||t[19]!==p||t[20]!==m?(g=(0,G.jsxs)(G.Fragment,{children:[u,p,m]}),t[18]=u,t[19]=p,t[20]=m,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,G.jsx)(h,{to:n.path,className:`flex items-center gap-3 rounded-lg px-3 py-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,G.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg px-3 py-3`,children:_}),t[25]=_,t[26]=v),v}function Q(e){let t=(0,M.c)(29),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=q(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,G.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,G.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]===n.status?d=t[12]:(d=i(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,K(n.status)),t[11]=n.status,t[12]=d);let f;t[13]!==n.status||t[14]!==d?(f=(0,G.jsx)(`span`,{className:d,children:n.status}),t[13]=n.status,t[14]=d,t[15]=f):f=t[15];let p;t[16]!==r||t[17]!==n.path?(p=n.path?(0,G.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=p):p=t[18];let m;t[19]!==s||t[20]!==u||t[21]!==f||t[22]!==p?(m=(0,G.jsxs)(G.Fragment,{children:[s,u,f,p]}),t[19]=s,t[20]=u,t[21]=f,t[22]=p,t[23]=m):m=t[23];let g=m;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,G.jsx)(h,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5 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,G.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5`,children:g}),t[27]=g,t[28]=_),_}function $(){let e=a(o(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:s}=W(),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(`idle`),f=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(c||!t)){l(!0),d(`idle`);try{await s(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:e.title}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.subtitle})]}),(0,G.jsxs)(`button`,{type:`button`,className:i(`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`,te.press),onClick:()=>void p(),disabled:!t||c,"aria-busy":c,children:[(0,G.jsx)(ee,{className:i(`size-4`,(!t||c)&&`animate-spin`),"aria-hidden":!0}),c?e.health.runDoctorRunning:e.refresh]})]}),n?(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,"aria-busy":!0,children:[(0,G.jsx)(C,{className:`size-4 animate-spin`,"aria-hidden":!0}),e.loading]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void p(),doctorRunning:c,doctorRunState:u}),(0,G.jsxs)(A,{id:`next-steps`,children:[(0,G.jsx)(k,{icon:r.issues.length?g:D,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,G.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,G.jsx)(_e,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,G.jsx)(`div`,{className:`mt-4 divide-y divide-edge-subtle rounded-lg border border-edge-subtle bg-surface-panel`,children:r.readiness.map(t=>(0,G.jsx)(Z,{item:t,labels:e.readinessLabels},t.id))})]}),(0,G.jsxs)(A,{children:[(0,G.jsx)(k,{icon:m,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),f.length?(0,G.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:f.map(t=>(0,G.jsx)(Q,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,G.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{$ 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"./cn-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-NZmjSXLl.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Go as d,Jt as f,Q as p,Qi as m,Ss as h,Vi as g,Vt as _,Wo as v,Zo as y,ba as ee,br as b,ct as x,ot as S,qa as C,st as w,ts as T,uo as E,xi as te,xs as D,yi as O}from"./index-Cxm6xsps.js";import{n as k,t as A}from"./settings-form-section-Dq-83cQd.js";var j=e(t(),1),M=n();function N(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`&&O(e)).length}function P(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults;if(!n||typeof n!=`object`||Array.isArray(n))return``;let r=n.model;return typeof r==`string`?r.trim():``}function F(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 I(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t.defaults;if(!n||typeof n!=`object`||Array.isArray(n))return{enabled:!1,backend:`extension`};let r=n.browser;if(!r||typeof r!=`object`||Array.isArray(r))return{enabled:!1,backend:`extension`};let i=r;return{enabled:i.enabled===!0,backend:typeof i.backend==`string`&&i.backend.trim()?i.backend.trim():`extension`}}function L(e){return e?`pass`:`fail`}function R(e){if(e===`provider-auth`)return`/settings/credentials`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/settings/agent-defaults?tab=workspace`;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===`cron-health`)return`/settings/goals`;if(e===`version-check`)return`/settings/app-management`}function z(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function B(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:R(e.id),source:`doctor`})).toSorted((e,t)=>z(t.status)-z(e.status)||e.label.localeCompare(t.label))}function V(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`,`cron-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:R(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=N(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=P(e.config),o=a.length>0,s=e.hasToken&&e.sseConnected,c=F(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=B(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},{id:`presets`,done:e.presetsDone,optional:!0,detail:e.presetsDone?e.labels.presetsConfigured:e.labels.presetsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:L(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:L(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/credentials`},{id:`defaultModel`,status:L(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/agent-defaults`},{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=V({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,presetsDone:e.presetsDone,agentCount:e.agentCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function re(e){return I(e)}function H(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 c(`/api/doctor`)}async function ae(){return((await l(ie())).checks??[]).map(H).filter(e=>e!==null)}function oe(){return c(`/api/logs/health`)}async function se(){return l(oe())}function U(e){return e?`pass`:`warn`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function le(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await l(c(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:U(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser?tab=local`}]}if(e.backend===`cloakbrowser`){let e=await l(c(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:U(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:`/settings/agent-browser?tab=cloakbrowser`}]}if(e.backend===`extension`){let e=await l(c(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser?tab=extension`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:`/settings/agent-browser`}]}function ue(e){return!!(e&&e.length>1)}function W(){let e=(0,M.c)(62),t=s(ge),n=o(he),r;e[0]===n?r=e[1]:(r=a(n),e[0]=n,e[1]=r);let i=r,c=i.setupStatus.labels,l=x(me),{data:d,error:f,isLoading:m,mutate:h}=b(!!t),g;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},e[2]=g):g=e[2];let{data:v,error:y,isLoading:ee,mutate:C}=u(t?`setup-checklist-skills`:null,pe,g),T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},e[3]=T):T=e[3];let{data:E,error:te,isLoading:D,mutate:O}=u(t?`setup-checklist-provider-meta`:null,p,T),k;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(k={revalidateOnFocus:!1},e[4]=k):k=e[4];let{data:A,error:j,isLoading:N,mutate:P}=u(t?`setup-checklist-agents`:null,_,k),F;e[5]===t?F=e[6]:(F=t?ie():null,e[5]=t,e[6]=F);let I;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(I={revalidateOnFocus:!1},e[7]=I):I=e[7];let{data:L,error:R,isLoading:z,mutate:B}=u(F,ae,I),V;e[8]===t?V=e[9]:(V=t?oe():null,e[8]=t,e[9]=V);let H;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(H={revalidateOnFocus:!1},e[10]=H):H=e[10];let{data:U,isLoading:le,mutate:W}=u(V,se,H);d?.payload?.config;let G=d?.payload?.config,K;e[11]===G?K=e[12]:(K=re(G),e[11]=G,e[12]=K);let q=t?K:null,J;e[13]===q?J=e[14]:(J=ce(q),e[13]=q,e[14]=J);let Y;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(Y={revalidateOnFocus:!1},e[15]=Y):Y=e[15];let{data:X,isLoading:_e,mutate:Z}=u(J,fe,Y),Q;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(Q={revalidateOnFocus:!1},e[16]=Q):Q=e[16],u(t?S:null,w,Q);let $=!t||!m&&!ee&&!D&&!N&&!z&&!le&&!_e,ve=!!(f||y||te||j||R),ye;bb0:{if(!t||!$){ye=null;break bb0}let n=v?.catalog?.length??0,r;if(e[17]!==A?.agents||e[18]!==X||e[19]!==d?.payload?.config||e[20]!==L||e[21]!==c.channelConfigured||e[22]!==c.channelMissing||e[23]!==c.gatewayOffline||e[24]!==c.gatewayOnline||e[25]!==c.modelConfigured||e[26]!==c.modelMissing||e[27]!==c.presetsConfigured||e[28]!==c.presetsMissing||e[29]!==c.providersConfigured||e[30]!==c.providersMetaReady||e[31]!==c.providersMissing||e[32]!==c.skillsConfigured||e[33]!==c.skillsMissing||e[34]!==U||e[35]!==i.setupStatus.requiredCompleteMessage||e[36]!==E||e[37]!==n||e[38]!==l||e[39]!==t){let a=E?.filter(de).length??0,o=E?.length??0,s=A?.agents.length??0,u=ue(A?.agents),f;e[41]===c.providersConfigured?f=e[42]:(f=e=>c.providersConfigured.replace(`{{count}}`,String(e)),e[41]=c.providersConfigured,e[42]=f);let p;e[43]===c.providersMetaReady?p=e[44]:(p=(e,t)=>c.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[43]=c.providersMetaReady,e[44]=p);let m;e[45]===c.modelConfigured?m=e[46]:(m=e=>c.modelConfigured.replace(`{{model}}`,e),e[45]=c.modelConfigured,e[46]=m);let h;e[47]===c.skillsConfigured?h=e[48]:(h=e=>c.skillsConfigured.replace(`{{count}}`,String(e)),e[47]=c.skillsConfigured,e[48]=h),r=ne({hasToken:!!t,sseConnected:l,config:d?.payload?.config,skillCount:n,providerMeta:o>0?{configured:a,total:o}:null,doctorChecks:L,logsHealth:U,browserDiagnostics:X,presetsDone:u,agentCount:s,labels:{gatewayOnline:c.gatewayOnline,gatewayOffline:c.gatewayOffline,providersConfigured:f,providersMetaReady:p,providersMissing:c.providersMissing,modelConfigured:m,modelMissing:c.modelMissing,channelConfigured:c.channelConfigured,channelMissing:c.channelMissing,skillsConfigured:h,skillsMissing:c.skillsMissing,presetsConfigured:c.presetsConfigured.replace(`{{count}}`,String(s)),presetsMissing:c.presetsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[17]=A?.agents,e[18]=X,e[19]=d?.payload?.config,e[20]=L,e[21]=c.channelConfigured,e[22]=c.channelMissing,e[23]=c.gatewayOffline,e[24]=c.gatewayOnline,e[25]=c.modelConfigured,e[26]=c.modelMissing,e[27]=c.presetsConfigured,e[28]=c.presetsMissing,e[29]=c.providersConfigured,e[30]=c.providersMetaReady,e[31]=c.providersMissing,e[32]=c.skillsConfigured,e[33]=c.skillsMissing,e[34]=U,e[35]=i.setupStatus.requiredCompleteMessage,e[36]=E,e[37]=n,e[38]=l,e[39]=t,e[40]=r}else r=e[40];ye=r}let be=ye,xe;e[49]!==P||e[50]!==Z||e[51]!==h||e[52]!==B||e[53]!==W||e[54]!==O||e[55]!==C?(xe=async()=>{await Promise.all([h(),C(),O(),P(),B(),W(),Z()])},e[49]=P,e[50]=Z,e[51]=h,e[52]=B,e[53]=W,e[54]=O,e[55]=C,e[56]=xe):xe=e[56];let Se=xe,Ce;return e[57]!==ve||e[58]!==$||e[59]!==Se||e[60]!==be?(Ce={ready:$,error:ve,snapshot:be,refresh:Se},e[57]=ve,e[58]=$,e[59]=Se,e[60]=be,e[61]=Ce):Ce=e[61],Ce}function de(e){return e.configured}function fe(e){let[,t]=e;return le(t)}function pe(){return f()}function me(e){return e.connectionState===`connected`}function he(e){return e.language}function ge(e){return e.token}var G=r();function K(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 q(e){return e===`pass`?y:e===`warn`?g:e===`fail`?d:E}function J(e,t){return e===`blocked`?{icon:d,className:`border-red-500/30 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:g,className:`border-amber-500/30 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:v,className:`border-edge bg-surface-panel text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:y,className:`border-success/30 bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Y(e){let t=(0,M.c)(48),{tier:n,issueCount:r,onRunDoctor:s,ready:c,doctorRunning:l,doctorRunState:u}=e,d=o(X),f,p,m,g,_,v,y,b,x,S,w;if(t[0]!==r||t[1]!==d||t[2]!==n){p=a(d).setupStatus;let e=J(n,p),o=e.icon,s=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;f=s?(0,G.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(s)?.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,G.jsx)(T,{className:`size-4`,"aria-hidden":!0})]}):(0,G.jsxs)(h,{to:c,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,G.jsx)(T,{className:`size-4`,"aria-hidden":!0})]}),w=i(`rounded-xl border px-4 py-4`,e.className),S=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,b=`flex min-w-0 gap-3`,x=(0,G.jsx)(o,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),_=`min-w-0`,v=(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),y=(0,G.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),m=`mt-2 text-xs opacity-75`,g=p.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=d,t[2]=n,t[3]=f,t[4]=p,t[5]=m,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=b,t[11]=x,t[12]=S,t[13]=w}else f=t[3],p=t[4],m=t[5],g=t[6],_=t[7],v=t[8],y=t[9],b=t[10],x=t[11],S=t[12],w=t[13];let E;t[14]!==m||t[15]!==g?(E=(0,G.jsx)(`p`,{className:m,children:g}),t[14]=m,t[15]=g,t[16]=E):E=t[16];let D;t[17]!==E||t[18]!==_||t[19]!==v||t[20]!==y?(D=(0,G.jsxs)(`div`,{className:_,children:[v,y,E]}),t[17]=E,t[18]=_,t[19]=v,t[20]=y,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==b||t[24]!==x?(O=(0,G.jsxs)(`div`,{className:b,children:[x,D]}),t[22]=D,t[23]=b,t[24]=x,t[25]=O):O=t[25];let k;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(k=i(`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`,te.press),t[26]=k):k=t[26];let A=!c||l,j;t[27]===l?j=t[28]:(j=l?(0,G.jsx)(C,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,G.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=l,t[28]=j);let N=l?p.health.runDoctorRunning:p.health.runDoctor,P;t[29]!==l||t[30]!==s||t[31]!==A||t[32]!==j||t[33]!==N?(P=(0,G.jsxs)(`button`,{type:`button`,className:k,onClick:s,disabled:A,"aria-busy":l,children:[j,N]}),t[29]=l,t[30]=s,t[31]=A,t[32]=j,t[33]=N,t[34]=P):P=t[34];let F;t[35]!==f||t[36]!==P?(F=(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[f,P]}),t[35]=f,t[36]=P,t[37]=F):F=t[37];let I;t[38]!==O||t[39]!==F||t[40]!==S?(I=(0,G.jsxs)(`div`,{className:S,children:[O,F]}),t[38]=O,t[39]=F,t[40]=S,t[41]=I):I=t[41];let L=l?p.health.doctorRunningMessage:u===`success`?p.health.doctorCompleteMessage:u===`error`?p.health.doctorFailedMessage:p.health.doctorIdleMessage,R;t[42]===L?R=t[43]:(R=(0,G.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:L}),t[42]=L,t[43]=R);let z;return t[44]!==I||t[45]!==R||t[46]!==w?(z=(0,G.jsxs)(`section`,{className:w,children:[I,R]}),t[44]=I,t[45]=R,t[46]=w,t[47]=z):z=t[47],z}function X(e){return e.language}function _e(e){let t=(0,M.c)(34),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=q(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,G.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,G.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.status?l=t[7]:(l=i(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,K(n.status)),t[6]=n.status,t[7]=l);let u;t[8]!==n.status||t[9]!==l?(u=(0,G.jsx)(`span`,{className:l,children:n.status}),t[8]=n.status,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==c||t[12]!==u?(d=(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[11]=c,t[12]=u,t[13]=d):d=t[13];let f;t[14]===n.message?f=t[15]:(f=(0,G.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=f);let p;t[16]===n.hints[0]?p=t[17]:(p=n.hints[0]?(0,G.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=p);let m;t[18]!==d||t[19]!==f||t[20]!==p?(m=(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,f,p]}),t[18]=d,t[19]=f,t[20]=p,t[21]=m):m=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,G.jsx)(T,{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]!==s||t[27]!==m?(_=(0,G.jsxs)(G.Fragment,{children:[s,m,g]}),t[25]=g,t[26]=s,t[27]=m,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,G.jsx)(h,{to:n.path,className:`flex items-start gap-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3 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,G.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3`,children:v}),t[32]=v,t[33]=y),y}function Z(e){let t=(0,M.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=q(n.status),t[0]=n.status,t[1]=a);let o=a,s=r[n.id]??n.title,c;t[2]===n.status?c=t[3]:(c=i(`flex size-7 shrink-0 items-center justify-center rounded-full border`,K(n.status)),t[2]=n.status,t[3]=c);let l;t[4]===o?l=t[5]:(l=(0,G.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,G.jsx)(`span`,{className:c,children:l}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===s?d=t[10]:(d=(0,G.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=d);let f;t[11]===n.detail?f=t[12]:(f=(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=f);let p;t[13]!==d||t[14]!==f?(p=(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;t[16]===n.path?m=t[17]:(m=n.path?(0,G.jsx)(T,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=m);let g;t[18]!==u||t[19]!==p||t[20]!==m?(g=(0,G.jsxs)(G.Fragment,{children:[u,p,m]}),t[18]=u,t[19]=p,t[20]=m,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,G.jsx)(h,{to:n.path,className:`flex items-center gap-3 rounded-lg px-3 py-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,G.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg px-3 py-3`,children:_}),t[25]=_,t[26]=v),v}function Q(e){let t=(0,M.c)(29),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=q(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,G.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,G.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]===n.status?d=t[12]:(d=i(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,K(n.status)),t[11]=n.status,t[12]=d);let f;t[13]!==n.status||t[14]!==d?(f=(0,G.jsx)(`span`,{className:d,children:n.status}),t[13]=n.status,t[14]=d,t[15]=f):f=t[15];let p;t[16]!==r||t[17]!==n.path?(p=n.path?(0,G.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=p):p=t[18];let m;t[19]!==s||t[20]!==u||t[21]!==f||t[22]!==p?(m=(0,G.jsxs)(G.Fragment,{children:[s,u,f,p]}),t[19]=s,t[20]=u,t[21]=f,t[22]=p,t[23]=m):m=t[23];let g=m;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,G.jsx)(h,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5 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,G.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5`,children:g}),t[27]=g,t[28]=_),_}function $(){let e=a(o(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:s}=W(),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(`idle`),f=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(c||!t)){l(!0),d(`idle`);try{await s(),d(`success`)}catch{d(`error`)}finally{l(!1)}}};return(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:e.title}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.subtitle})]}),(0,G.jsxs)(`button`,{type:`button`,className:i(`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`,te.press),onClick:()=>void p(),disabled:!t||c,"aria-busy":c,children:[(0,G.jsx)(ee,{className:i(`size-4`,(!t||c)&&`animate-spin`),"aria-hidden":!0}),c?e.health.runDoctorRunning:e.refresh]})]}),n?(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,"aria-busy":!0,children:[(0,G.jsx)(C,{className:`size-4 animate-spin`,"aria-hidden":!0}),e.loading]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void p(),doctorRunning:c,doctorRunState:u}),(0,G.jsxs)(A,{id:`next-steps`,children:[(0,G.jsx)(k,{icon:r.issues.length?g:D,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,G.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,G.jsx)(_e,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,G.jsx)(`div`,{className:`mt-4 divide-y divide-edge-subtle rounded-lg border border-edge-subtle bg-surface-panel`,children:r.readiness.map(t=>(0,G.jsx)(Z,{item:t,labels:e.readinessLabels},t.id))})]}),(0,G.jsxs)(A,{children:[(0,G.jsx)(k,{icon:m,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),f.length?(0,G.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:f.map(t=>(0,G.jsx)(Q,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,G.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{$ as SetupStatusPanel};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-RnGYy9bC.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{t as i}from"./locale-store-DjbfSsfA.js";import{i as a}from"./fetch-DOe56Wmy.js";import{Es as o,Hn as s,Mo as c,Rn as l,Un as u,Wn as d,ko as f,mr as p,qa as m}from"./index-BTmbp2AU.js";var h=e(t(),1),g=n();function _(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function v(){let{token:e}=o(),t=i(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=u(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:s(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(a(`/s/${encodeURIComponent(e)}/meta`));if(!i.ok){t||O(i.status===404?n.notFound:n.expired);return}let o=await i.json();if(t)return;if(S(o),!o.valid){O(n.expired);return}if(o.kind!==`file`)return;let c=u(o.fileName,o.mimeType),l=s(o.fileName,c),f=d(l),m=a(`/s/${encodeURIComponent(e)}?inline=1`);if(f===`text`){if(o.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(f===`binary`){if(o.fileSize>33554432){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let i=await e.arrayBuffer();if(t)return;if(l===`pptx`){let{processPptx:e}=await r(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(i,o.fileName),n=t.length>p;w({textContent:null,binaryBuffer:i,extractedText:n?t.slice(0,p):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?a(`/s/${encodeURIComponent(e)}?dl=1`):`#`,j=e?a(`/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:[(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:v?.fileName??``,children:v?.fileName??n.loading}),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)(f,{className:`size-3.5`,"aria-hidden":!0}),n.openInline]}),(0,g.jsxs)(`a`,{href:A,className:`inline-flex items-center gap-1 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:opacity-90`,download:v.fileName,children:[(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n.download]})]}):null]}),(0,g.jsx)(`main`,{className:`mx-auto flex min-h-0 w-full max-w-app-main flex-1 flex-col px-4 py-6`,children:T?(0,g.jsxs)(`div`,{className:`flex min-h-[50vh] items-center justify-center text-sm text-fg-muted`,children:[(0,g.jsx)(m,{className:`mr-2 size-4 animate-spin`}),n.loading]}):D?(0,g.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-6 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 border border-edge bg-surface-panel p-6 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 border border-edge bg-surface-panel`,children:(0,g.jsx)(l,{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={loading:`加载中...`,error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,download:`下载`,openInline:`在新窗口打开`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`},x={loading:`Loading...`,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{t as i}from"./locale-store-DjbfSsfA.js";import{i as a}from"./fetch-NZmjSXLl.js";import{Es as o,Hn as s,Mo as c,Rn as l,Un as u,Wn as d,ko as f,mr as p,qa as m}from"./index-Cxm6xsps.js";var h=e(t(),1),g=n();function _(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function v(){let{token:e}=o(),t=i(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=u(v.fileName,v.mimeType);return{id:`share:${e}:${v.fileName}`,context:`share`,fileName:v.fileName,mimeType:t,size:v.fileSize,type:s(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(a(`/s/${encodeURIComponent(e)}/meta`));if(!i.ok){t||O(i.status===404?n.notFound:n.expired);return}let o=await i.json();if(t)return;if(S(o),!o.valid){O(n.expired);return}if(o.kind!==`file`)return;let c=u(o.fileName,o.mimeType),l=s(o.fileName,c),f=d(l),m=a(`/s/${encodeURIComponent(e)}?inline=1`);if(f===`text`){if(o.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(f===`binary`){if(o.fileSize>33554432){O(n.tooLarge);return}let e=await fetch(m);if(!e.ok){O(n.expired);return}let i=await e.arrayBuffer();if(t)return;if(l===`pptx`){let{processPptx:e}=await r(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(i,o.fileName),n=t.length>p;w({textContent:null,binaryBuffer:i,extractedText:n?t.slice(0,p):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?a(`/s/${encodeURIComponent(e)}?dl=1`):`#`,j=e?a(`/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:[(0,g.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:v?.fileName??``,children:v?.fileName??n.loading}),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)(f,{className:`size-3.5`,"aria-hidden":!0}),n.openInline]}),(0,g.jsxs)(`a`,{href:A,className:`inline-flex items-center gap-1 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:opacity-90`,download:v.fileName,children:[(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n.download]})]}):null]}),(0,g.jsx)(`main`,{className:`mx-auto flex min-h-0 w-full max-w-app-main flex-1 flex-col px-4 py-6`,children:T?(0,g.jsxs)(`div`,{className:`flex min-h-[50vh] items-center justify-center text-sm text-fg-muted`,children:[(0,g.jsx)(m,{className:`mr-2 size-4 animate-spin`}),n.loading]}):D?(0,g.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-6 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 border border-edge bg-surface-panel p-6 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 border border-edge bg-surface-panel`,children:(0,g.jsx)(l,{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={loading:`加载中...`,error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,download:`下载`,openInline:`在新窗口打开`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`},x={loading:`Loading...`,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};