@xopcai/xopc 0.0.402 → 0.0.404

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 (168) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DF_bLVLU.js → agent-avatar-dicebear-CdwFK70g.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BMj9HwIQ.js +1 -0
  5. package/dist/gateway/static/root/assets/{agents-admin-api-DvSe10zu.js → agents-admin-api-D6XzhsQy.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-hrm6V8Dp.js +77 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-Cr_dcDOi.js → app-management-settings-panel-Rg9jOmoj.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-C5TsJu_t.js → appearance-settings-S3yp0GUO.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-ChrJSB_2.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-CpsVjh9E.js → archive-plugin-J7hwA5cs.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-Db1YnE2r.js → automations-page-Cesz1cjw.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-workspace-DdopDyED.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-DYdnW_Fa.js → binary-plugins-Bg4Se8Kg.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-HZ37eyhY.js → block-editor-Bw1sO9YH.js} +40 -40
  15. package/dist/gateway/static/root/assets/{browser-automation-inputs-B-V9Vc6B.js → browser-automation-inputs-Y46Mf8aY.js} +1 -1
  16. package/dist/gateway/static/root/assets/browser-automations-page-BcNjBdFQ.js +3 -0
  17. package/dist/gateway/static/root/assets/browser-settings-page-ByeqxrSF.js +3 -0
  18. package/dist/gateway/static/root/assets/{capabilities-glv1DeRI.js → capabilities-CIv3LUQk.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capabilities-page-DEZJFRU_.js → capabilities-page-BUTQSo3A.js} +2 -2
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-B-Uwmjbo.js +8 -0
  21. package/dist/gateway/static/root/assets/{capability-header-actions-BBPBfpGd.js → capability-header-actions-BGGJKzPL.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-z6iuM4HE.js +1 -0
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-DQWv9Smb.js → chat-terminal-dock-oMmP0flJ.js} +2 -2
  24. package/dist/gateway/static/root/assets/{computer-settings-page-CyPqxL6X.js → computer-settings-page-CERhSG5W.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connector-service-page-DmCt-Kgx.js → connector-service-page-DyW3mLTh.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-CdMwhiio.js +1 -0
  27. package/dist/gateway/static/root/assets/{date-picker-aOgNPu_Y.js → date-picker-CO3Jhdzg.js} +1 -1
  28. package/dist/gateway/static/root/assets/{dependency-picker-oALjIlhN.js → dependency-picker-DbyMpo5J.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-pp9_jT3M.js → desktop-pet-DJ9OAPJs.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-BZCCh5T4.js → desktop-pet-settings-CNrNXWlk.js} +1 -1
  31. package/dist/gateway/static/root/assets/{device-pairing-wizard-DpKzQlqA.js → device-pairing-wizard-TzK-VCuf.js} +1 -1
  32. package/dist/gateway/static/root/assets/{directory-picker-path-field-LSNVNUaG.js → directory-picker-path-field-BmFgRA8G.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-debug-page-Bvy_tPme.js → extension-debug-page-C3ZpHHYc.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-D3J8-8AM.js → extension-page-gfOwpT2R.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-F6KLsxCY.js → extension-settings-page-BS7cDqZJ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-DAir1JsW.js → gateway-config-swr-BvuySoCX.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-realtime-dE0XrVAT.js → gateway-realtime-SBtdXzco.js} +1 -1
  38. package/dist/gateway/static/root/assets/gateway-realtime-store-dKq2fm2X.js +1 -0
  39. package/dist/gateway/static/root/assets/gateway-settings-UB6hyqcj.js +1 -0
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-CqyGHM2M.js → gateway-startup-retry-CEpuztYK.js} +1 -1
  41. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BCCIvIlA.js → highlighted-body-KQOG7T2V-BRfDRn2k.js} +1 -1
  42. package/dist/gateway/static/root/assets/home-page-DBUnR1DO.js +2 -0
  43. package/dist/gateway/static/root/assets/{image-generation-api-DjQXmXWa.js → image-generation-api-BoMWmqwF.js} +1 -1
  44. package/dist/gateway/static/root/assets/{imports-page-Bg5N_9Vg.js → imports-page-CPiPsiEP.js} +1 -1
  45. package/dist/gateway/static/root/assets/{index-cmsFpzI8.js → index-DmURUvvA.js} +114 -114
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BxH3LBLL.js → keyboard-shortcuts-settings-D9y8h4dR.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-DoAmV6on.js +1 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-CsTZ1d01.js → local-apps-page-CE6Ag8oQ.js} +1 -1
  49. package/dist/gateway/static/root/assets/{local-session-drafts-fhip41-L.js → local-session-drafts-DhJjHCfQ.js} +1 -1
  50. package/dist/gateway/static/root/assets/{locale-store-Jnhw2WMv.js → locale-store-D5h-Ha6-.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-DFysUb2k.js +2 -0
  52. package/dist/gateway/static/root/assets/management-settings-CmXPsu0I.js +1 -0
  53. package/dist/gateway/static/root/assets/{markdown-view-B58RypQ4.js → markdown-view-CthsQiiO.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-CGq_o7tI.js → media-plugins-DvfdiczR.js} +1 -1
  55. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-SuiLTd5Y.js +1 -0
  56. package/dist/gateway/static/root/assets/{messages-DBvKzlCl.js → messages-Bwv-AOYl.js} +2 -2
  57. package/dist/gateway/static/root/assets/note-detail-panel-BpddDFQt.js +5 -0
  58. package/dist/gateway/static/root/assets/note-image-lightbox-CMLVzPsQ.js +1 -0
  59. package/dist/gateway/static/root/assets/notes-page-DQ4KZsWt.js +8 -0
  60. package/dist/gateway/static/root/assets/{page-context-capture-button-BH9WwSgw.js → page-context-capture-button-BcxVEGa2.js} +1 -1
  61. package/dist/gateway/static/root/assets/personal-page-CCQDxb7E.js +1 -0
  62. package/dist/gateway/static/root/assets/plugin-details-dialog-CGFQ_-bG.js +1 -0
  63. package/dist/gateway/static/root/assets/plugin-presentation-DF1gfuGf.js +1 -0
  64. package/dist/gateway/static/root/assets/{preview-open-alternatives-rJ3l8Ii4.js → preview-open-alternatives-CXjjpXVx.js} +1 -1
  65. package/dist/gateway/static/root/assets/{product-open-page-CuzuFyIk.js → product-open-page-DqiyvM4c.js} +1 -1
  66. package/dist/gateway/static/root/assets/{product-preview-content-Dw2DstzN.js → product-preview-content-f7Q4giA3.js} +1 -1
  67. package/dist/gateway/static/root/assets/project-detail-page-PBK7vXK5.js +1 -0
  68. package/dist/gateway/static/root/assets/projects-page-DO_pIhy-.js +1 -0
  69. package/dist/gateway/static/root/assets/{registry-api-BbUEMGcj.js → registry-api-Bf0hVPNV.js} +1 -1
  70. package/dist/gateway/static/root/assets/{remote-access-hub-CpEq4PU0.js → remote-access-hub-BFtELmg0.js} +1 -1
  71. package/dist/gateway/static/root/assets/{runtime-tools-api-D0xtCTXr.js → runtime-tools-api-ByH1meP7.js} +1 -1
  72. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CNar1-_V.js → runtime-tools-settings-panel-B9Beu-oK.js} +1 -1
  73. package/dist/gateway/static/root/assets/{schema-form-D_cAMxj5.js → schema-form-ZAX7C5uI.js} +1 -1
  74. package/dist/gateway/static/root/assets/{session-api-CAKgrbgz.js → session-api-fVuszA_P.js} +1 -1
  75. package/dist/gateway/static/root/assets/{session-manager-D_N7qha7.js → session-manager-BUMUjup5.js} +1 -1
  76. package/dist/gateway/static/root/assets/sessions-page-D27knqOl.js +1 -0
  77. package/dist/gateway/static/root/assets/settings-advanced-gate-CDzdr1zW.js +1 -0
  78. package/dist/gateway/static/root/assets/{settings-form-section-DvLxOebb.js → settings-form-section-BTUFu5KS.js} +1 -1
  79. package/dist/gateway/static/root/assets/{settings-page-C6Tl6TD4.js → settings-page-YFr6zzh7.js} +1 -1
  80. package/dist/gateway/static/root/assets/setup-status-panel-C5Jszsd1.js +1 -0
  81. package/dist/gateway/static/root/assets/{share-preview-page-BLraXBAe.js → share-preview-page-CsfrvY_G.js} +1 -1
  82. package/dist/gateway/static/root/assets/shares-settings-BW6BNot0.js +1 -0
  83. package/dist/gateway/static/root/assets/{skill-api-BE_i8VdM.js → skill-api-o3HSgF_K.js} +1 -1
  84. package/dist/gateway/static/root/assets/skill-reload-api-BJsPnE87.js +1 -0
  85. package/dist/gateway/static/root/assets/skills-page-Kuf2t7MG.js +2 -0
  86. package/dist/gateway/static/root/assets/{style-pk3FR76e.js → style-DOz6lLJB.js} +1 -1
  87. package/dist/gateway/static/root/assets/{system-settings-panel-M550B6Mj.js → system-settings-panel-B69rR6vw.js} +1 -1
  88. package/dist/gateway/static/root/assets/task-detail-page-DOb97OLI.js +2 -0
  89. package/dist/gateway/static/root/assets/{task-expandable-content-HdEeV_0-.js → task-expandable-content-BZCJqajv.js} +1 -1
  90. package/dist/gateway/static/root/assets/tracing-settings-page-BIq3Ayeg.js +1 -0
  91. package/dist/gateway/static/root/assets/{tunnel-api-CC_TCY7S.js → tunnel-api-V9pJ8fUo.js} +1 -1
  92. package/dist/gateway/static/root/assets/usage-page-DZdpti28.js +1 -0
  93. package/dist/gateway/static/root/assets/{use-autosave-DrxAqqzV.js → use-autosave-BnMIUc_5.js} +1 -1
  94. package/dist/gateway/static/root/assets/user-model-page-BEgJ97hp.js +2 -0
  95. package/dist/gateway/static/root/assets/{voice-api-key-field-Bu4paIbu.js → voice-api-key-field-1h6fMaZL.js} +1 -1
  96. package/dist/gateway/static/root/assets/{voice-config-api-T3nM4buh.js → voice-config-api-CRjdZdJF.js} +1 -1
  97. package/dist/gateway/static/root/assets/{work-discovery-overlay-3TAUYZF4.js → work-discovery-overlay-CVNqSNz8.js} +1 -1
  98. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-sgFaaLoB.js → workflow-run-setup-panel-Dq63AthQ.js} +2 -2
  99. package/dist/gateway/static/root/assets/workflows-page-CfA1iwZu.js +6 -0
  100. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DMZelX5s.js → xopc-cloud-account-card-BsW2acj1.js} +1 -1
  101. package/dist/gateway/static/root/index.html +14 -14
  102. package/dist/package.js +1 -1
  103. package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
  104. package/dist/src/agent/tool-manuals/computer.js +2 -2
  105. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  106. package/dist/src/cli/commands/extension.js +1 -1
  107. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  108. package/dist/src/cli/commands/onboard.js +1 -1
  109. package/dist/src/computer/broker.d.ts +2 -0
  110. package/dist/src/computer/broker.js +64 -19
  111. package/dist/src/computer/diagnostics.d.ts +6 -0
  112. package/dist/src/computer/diagnostics.js +7 -2
  113. package/dist/src/computer/keyboard.d.ts +2 -0
  114. package/dist/src/computer/keyboard.js +31 -0
  115. package/dist/src/computer/model-adapter.d.ts +6 -0
  116. package/dist/src/computer/model-adapter.js +76 -4
  117. package/dist/src/computer/runtime.d.ts +9 -1
  118. package/dist/src/computer/runtime.js +73 -5
  119. package/dist/src/computer/semantic-plan.d.ts +41 -0
  120. package/dist/src/computer/semantic-plan.js +95 -0
  121. package/dist/src/computer/task-state.js +3 -2
  122. package/dist/src/extensions/update.js +1 -1
  123. package/dist/src/gateway/auth.d.ts +2 -0
  124. package/dist/src/gateway/auth.js +13 -4
  125. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  126. package/dist/src/gateway/hono/routes/config.js +1 -1
  127. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  128. package/dist/src/gateway/security/audit.js +3 -3
  129. package/dist/src/gateway/service/config-coordinator.js +1 -1
  130. package/dist/src/gateway/service.js +2 -2
  131. package/dist/src/infra/update-restart.js +1 -1
  132. package/dist/src/infra/update-runner.js +1 -1
  133. package/package.json +4 -4
  134. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CB96Cbva.js +0 -1
  135. package/dist/gateway/static/root/assets/agents-C97HREhT.js +0 -77
  136. package/dist/gateway/static/root/assets/apps-page-erjVBKui.js +0 -1
  137. package/dist/gateway/static/root/assets/automations-workspace-iTSZBSZf.js +0 -6
  138. package/dist/gateway/static/root/assets/browser-automations-page-D0lBDbJO.js +0 -3
  139. package/dist/gateway/static/root/assets/browser-settings-page-DIbXx7Ux.js +0 -3
  140. package/dist/gateway/static/root/assets/capabilities-settings-panel-BfdoIjPK.js +0 -8
  141. package/dist/gateway/static/root/assets/channels-CapZyaWK.js +0 -1
  142. package/dist/gateway/static/root/assets/connectors-page-3xUE-PGt.js +0 -1
  143. package/dist/gateway/static/root/assets/gateway-realtime-store-CPlVuu0d.js +0 -1
  144. package/dist/gateway/static/root/assets/gateway-settings-_YecsQF1.js +0 -1
  145. package/dist/gateway/static/root/assets/home-page-DUoecphg.js +0 -2
  146. package/dist/gateway/static/root/assets/local-app-workbench-page-C7RejhJl.js +0 -1
  147. package/dist/gateway/static/root/assets/logs-page-uLju0b0e.js +0 -2
  148. package/dist/gateway/static/root/assets/management-settings-BkTmllrn.js +0 -1
  149. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DdlL1T6J.js +0 -1
  150. package/dist/gateway/static/root/assets/note-detail-panel-Cps8VMV6.js +0 -5
  151. package/dist/gateway/static/root/assets/note-image-lightbox-BYNLO2pt.js +0 -1
  152. package/dist/gateway/static/root/assets/notes-page-CdmoFpQ9.js +0 -8
  153. package/dist/gateway/static/root/assets/personal-page-UKNVJRDn.js +0 -1
  154. package/dist/gateway/static/root/assets/plugin-details-dialog-gvBSFAhm.js +0 -1
  155. package/dist/gateway/static/root/assets/plugin-presentation-C0la7V8t.js +0 -1
  156. package/dist/gateway/static/root/assets/project-detail-page-C0XssfWQ.js +0 -1
  157. package/dist/gateway/static/root/assets/projects-page-cT6yy_Xk.js +0 -1
  158. package/dist/gateway/static/root/assets/sessions-page-D5qR92KP.js +0 -1
  159. package/dist/gateway/static/root/assets/settings-advanced-gate-eKqVXNOq.js +0 -1
  160. package/dist/gateway/static/root/assets/setup-status-panel-DuN4e4iO.js +0 -1
  161. package/dist/gateway/static/root/assets/shares-settings-u2Y5Ljhu.js +0 -1
  162. package/dist/gateway/static/root/assets/skill-reload-api-1xNCuBFH.js +0 -1
  163. package/dist/gateway/static/root/assets/skills-page-Clye5gro.js +0 -2
  164. package/dist/gateway/static/root/assets/task-detail-page-DqFhFqWu.js +0 -2
  165. package/dist/gateway/static/root/assets/tracing-settings-page-nXw76P46.js +0 -1
  166. package/dist/gateway/static/root/assets/usage-page-BZ0t4KYM.js +0 -1
  167. package/dist/gateway/static/root/assets/user-model-page-BAQOJoHC.js +0 -2
  168. package/dist/gateway/static/root/assets/workflows-page-CxNXNDNc.js +0 -6
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./download-Dk-ZjtO6.js";import{t as o}from"./folder-open-CyzJ19I9.js";import{t as s}from"./plus-Q2yW6OE7.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./messages-Bwv-AOYl.js";import{t as u}from"./cn-0WouolD0.js";import{a as d,c as f,n as p,r as m}from"./locale-store-D5h-Ha6-.js";import{a as h,n as g,o as _,r as ee,s as v,t as te}from"./dist-BGTk37IG.js";import{a as y,c as b,f as ne,n as x,o as S,p as C,r as w,s as T,t as E}from"./session-api-fVuszA_P.js";import{i as D}from"./vendor-swr-BIWyz7Rc.js";import{n as O,r as k}from"./gateway-config-swr-BvuySoCX.js";import{n as A,t as j}from"./registry-api-Bf0hVPNV.js";import{$i as M,$t as N,Ao as P,Bu as F,Fc as I,G as L,Hd as R,Ic as z,Kc as B,Mf as re,Nf as V,Nl as ie,No as ae,Qt as oe,Rc as H,Rs as U,Ru as se,Su as ce,ad as le,au as ue,cd as de,do as fe,ds as W,eo as pe,fs as G,is as me,nf as he,no as ge,od as _e,qd as ve,so as ye,to as be,tu as K,uo as xe,vs as Se,xu as Ce,ys as we}from"./index-DmURUvvA.js";import{t as q}from"./number-input-DDeqHK-G.js";import{n as Te,r as Ee}from"./settings-page-layout-Dx5S-Msc.js";import{n as De,t as J}from"./settings-form-section-BTUFu5KS.js";import{n as Oe,t as Y}from"./use-autosave-BnMIUc_5.js";import{t as ke}from"./settings-advanced-gate-CDzdr1zW.js";var X=e(t(),1),Ae=n(),Z=r();function je(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 Me(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function Ne(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function Pe(e){let t=(0,Ae.c)(124),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:d}=e,f;t[0]!==i.unnamedSession||t[1]!==n.name?(f=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=f):f=t[2];let m=f,h=p(Re),g;t[3]!==h||t[4]!==n?(g=fe(n,l(h).sidebar.sessionFilters),t[3]=h,t[4]=n,t[5]=g):g=t[5];let _=g,ee;t[6]===n.name?ee=t[7]:(ee=n.name?.trim(),t[6]=n.name,t[7]=ee);let v=!!ee,te=n.status===`archived`,y=n.status===`pinned`,b=n.usage,ne;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==b?(ne=b?.calls?b.costCompleteness===`unknown`?i.costUnknown:`${b.costCompleteness===`partial`?`≥ `:`≈ `}${Ne(b.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=b,t[11]=ne):ne=t[11];let x=ne,S=b?.calls?b.costCompleteness===`partial`?i.costPartial:b.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,C=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,w;t[12]===C?w=t[13]:(w=u(`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`,C),t[12]=C,t[13]=w);let T;t[14]===c?T=t[15]:(T=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=T);let E=r===`list`&&`sm:py-3`,D;t[16]===E?D=t[17]:(D=u(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,E),t[16]=E,t[17]=D);let O;t[18]===n?O=t[19]:(O=(0,Z.jsx)(xe,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=O);let k;t[20]===_?k=t[21]:(k=(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:_}),t[20]=_,t[21]=k);let A;t[22]!==O||t[23]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[O,k]}),t[22]=O,t[23]=k,t[24]=A):A=t[24];let j;t[25]===y?j=t[26]:(j=y?(0,Z.jsx)(ce,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=y,t[26]=j);let M;t[27]===n.updatedAt?M=t[28]:(M=je(n.updatedAt),t[27]=n.updatedAt,t[28]=M);let N;t[29]===M?N=t[30]:(N=(0,Z.jsx)(`span`,{children:M}),t[29]=M,t[30]=N);let P;t[31]!==j||t[32]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[j,N]}),t[31]=j,t[32]=N,t[33]=P):P=t[33];let L;t[34]!==A||t[35]!==P||t[36]!==D?(L=(0,Z.jsxs)(`div`,{className:D,children:[A,P]}),t[34]=A,t[35]=P,t[36]=D,t[37]=L):L=t[37];let z=r===`list`&&`sm:py-3`,B;t[38]===z?B=t[39]:(B=u(`min-w-0 flex-1 px-3 py-2`,z),t[38]=z,t[39]=B);let oe=r===`list`&&`sm:items-start`,H;t[40]===oe?H=t[41]:(H=u(`flex gap-3`,oe),t[40]=oe,t[41]=H);let U;t[42]!==s||t[43]!==o?(U=(0,Z.jsx)(ae,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=s,t[43]=o,t[44]=U):U=t[44];let se;t[45]===m?se=t[46]:(se=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:m,children:m}),t[45]=m,t[46]=se);let le;t[47]!==n.key||t[48]!==v?(le=v?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[47]=n.key,t[48]=v,t[49]=le):le=t[49];let ue;t[50]!==se||t[51]!==le?(ue=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[se,le]}),t[50]=se,t[51]=le,t[52]=ue):ue=t[52];let de;t[53]!==H||t[54]!==U||t[55]!==ue?(de=(0,Z.jsxs)(`div`,{className:H,children:[U,ue]}),t[53]=H,t[54]=U,t[55]=ue,t[56]=de):de=t[56];let W;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(F,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=W):W=t[57];let pe;t[58]===n.messageCount?pe=t[59]:(pe=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[W,n.messageCount]}),t[58]=n.messageCount,t[59]=pe);let G;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(R,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=G):G=t[60];let me=b?.totalTokens??0,he;t[61]!==h||t[62]!==me?(he=Me(me,h),t[61]=h,t[62]=me,t[63]=he):he=t[63];let ge;t[64]!==i.tokens||t[65]!==he?(ge=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[G,he,` `,i.tokens]}),t[64]=i.tokens,t[65]=he,t[66]=ge):ge=t[66];let _e;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(ve,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=_e):_e=t[67];let ye;t[68]!==x||t[69]!==S?(ye=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:S,children:[_e,x]}),t[68]=x,t[69]=S,t[70]=ye):ye=t[70];let be;t[71]!==pe||t[72]!==ge||t[73]!==ye?(be=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[pe,ge,ye]}),t[71]=pe,t[72]=ge,t[73]=ye,t[74]=be):be=t[74];let K;t[75]===n.tags?K=t[76]:(K=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Le),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=K);let Se;t[77]!==B||t[78]!==de||t[79]!==be||t[80]!==K?(Se=(0,Z.jsxs)(`div`,{className:B,children:[de,be,K]}),t[77]=B,t[78]=de,t[79]=be,t[80]=K,t[81]=Se):Se=t[81];let we;t[82]===d?we=t[83]:(we=()=>d(`continue`),t[82]=d,t[83]=we);let q;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(F,{className:`size-4`,strokeWidth:1.75}),t[84]=q):q=t[84];let Te;t[85]!==i.continueChat||t[86]!==we?(Te=(0,Z.jsx)(`button`,{type:`button`,className:I,title:i.continueChat,"aria-label":i.continueChat,onClick:we,children:q}),t[85]=i.continueChat,t[86]=we,t[87]=Te):Te=t[87];let Ee;t[88]!==te||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==d?(Ee=te?(0,Z.jsx)(`button`,{type:`button`,className:I,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>d(`unarchive`),children:(0,Z.jsx)(V,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:I,title:i.archive,"aria-label":i.archive,onClick:()=>d(`archive`),children:(0,Z.jsx)(re,{className:`size-4`,strokeWidth:1.75})}),t[88]=te,t[89]=i.archive,t[90]=i.unarchive,t[91]=d,t[92]=Ee):Ee=t[92];let De;t[93]!==y||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==d?(De=y?(0,Z.jsx)(`button`,{type:`button`,className:I,title:i.unpin,"aria-label":i.unpin,onClick:()=>d(`unpin`),children:(0,Z.jsx)(Ce,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:I,title:i.pin,"aria-label":i.pin,onClick:()=>d(`pin`),children:(0,Z.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}),t[93]=y,t[94]=i.pin,t[95]=i.unpin,t[96]=d,t[97]=De):De=t[97];let J;t[98]===d?J=t[99]:(J=()=>d(`export`),t[98]=d,t[99]=J);let Oe;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Z.jsx)(a,{className:`size-4`,strokeWidth:1.75}),t[100]=Oe):Oe=t[100];let Y;t[101]!==i.export||t[102]!==J?(Y=(0,Z.jsx)(`button`,{type:`button`,className:I,title:i.export,"aria-label":i.export,onClick:J,children:Oe}),t[101]=i.export,t[102]=J,t[103]=Y):Y=t[103];let ke;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(ke=u(I,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=ke):ke=t[104];let X;t[105]===d?X=t[106]:(X=()=>d(`delete`),t[105]=d,t[106]=X);let Pe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75}),t[107]=Pe):Pe=t[107];let ze;t[108]!==i.delete||t[109]!==X?(ze=(0,Z.jsx)(`button`,{type:`button`,className:ke,title:i.delete,"aria-label":i.delete,onClick:X,children:Pe}),t[108]=i.delete,t[109]=X,t[110]=ze):ze=t[110];let Be;t[111]!==Te||t[112]!==Ee||t[113]!==De||t[114]!==Y||t[115]!==ze?(Be=(0,Z.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Ie,onKeyDown:Fe,children:[Te,Ee,De,Y,ze]}),t[111]=Te,t[112]=Ee,t[113]=De,t[114]=Y,t[115]=ze,t[116]=Be):Be=t[116];let Ve;return t[117]!==c||t[118]!==L||t[119]!==Se||t[120]!==Be||t[121]!==w||t[122]!==T?(Ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:w,onClick:c,onKeyDown:T,children:[L,Se,Be]}),t[117]=c,t[118]=L,t[119]=Se,t[120]=Be,t[121]=w,t[122]=T,t[123]=Ve):Ve=t[123],Ve}function Fe(e){return e.stopPropagation()}function Ie(e){return e.stopPropagation()}function Le(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Re(e){return e.language}function ze(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Be(e,t){return t.find(t=>t.id===e)?.avatar}var Ve={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function He(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ue(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function We(e){let t=He(e)?e:{},n=He(t.userContext)?t.userContext:{},r=He(n.contextPlanning)?n.contextPlanning:{},i=He(r.compaction)?r.compaction:{},a=Ve,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Ue(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ge(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ke(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function qe(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ke(e))}),await O()}var Je=128e3,Ye={balanced:Ve,preserve:{...Ve,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Ve,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Xe=pe();function Ze(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,U,`dark:border-edge`)}function Qe(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function $e(e){let t=Qe(e);for(let[e,n]of Object.entries(Ye))if(t===Qe(n))return e;return`custom`}function et(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Ae.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Ze(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(q,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tt(e){let t=(0,Ae.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function nt({hasToken:e}){let t=l(p(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=k(e),{data:i=[],isLoading:a}=D(e?j:null,A,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:We(n.payload.config),[n]),[d,f]=(0,X.useReducer)(Xe,{form:null,baseline:null}),[m,h]=(0,X.useState)(``),g=(0,X.useRef)(!1),_=(0,X.useRef)(d.form);_.current=d.form;let ee=(0,X.useRef)(null);be({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:ee,dispatch:f,onResetDirty:()=>{g.current=!1}});let v=d.form,te=d.baseline,y=!!(v&&te&&JSON.stringify(v)!==JSON.stringify(te)),b=(0,X.useCallback)(e=>{g.current=!0,f({type:`patch`,patch:e})},[]),ne=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),x=Y({value:v,dirty:y,onSave:(0,X.useCallback)(async e=>{try{await qe(e),f({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ge(e);return n?t.invalidValue.replace(`{{field}}`,ne(n)):null}});if(!e||!v)return r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(H,{className:`h-5 w-48`}),(0,Z.jsx)(H,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(H,{className:`h-36 w-full rounded-xl`})]})}):null;let S=$e(v),C=Math.max(0,Je-v.reserveTokens),w=Math.min(Math.floor(Je*v.triggerThreshold),C),T=Math.min(100,w/Je*100),E=Math.min(100,C/Je*100),O=v.model?i.find(e=>e.id===v.model):void 0,N=O?.contextWindow&&v.summaryChunkTokens+v.summaryMaxTokens+4096>O.contextWindow,P=v.keepRecentTokens+v.reserveTokens>w,F=Math.round(v.summaryTimeoutMs*(v.summaryRetries+1)/1e3),I=e=>{let t=Ye[e];b({...t,...v.model?{model:v.model}:{model:void 0},postCompactionSections:v.postCompactionSections})},R={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},re=()=>{let e=m.trim();!e||v.postCompactionSections.includes(e)||v.postCompactionSections.length>=12||(b({postCompactionSections:[...v.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(J,{onBlurCapture:x.onBlurCapture,children:[(0,Z.jsx)(De,{icon:se,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Oe,{status:x.status,error:x.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:v.enabled,onChange:e=>b({enabled:e.target.checked})}),v.enabled?t.enabled:t.disabled]})]})}),x.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:x.error}):null,v.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!v.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),S===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":S===e,className:u(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,z.transition,z.focusRingPanel,S===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>I(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:R[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:R[e].hint})]},e))})]}),(0,Z.jsxs)(L,{title:t.advancedTitle,summary:S===`custom`?t.presetCustom:t.presetHint,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:et(w)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${T}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:et(C)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${E}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((v.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>b({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,et(v.reserveTokens)),value:v.reserveTokens,min:1024,step:1024,onChange:e=>b({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:v.recentTurnsPreserve,min:1,max:12,onChange:e=>b({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,et(v.keepRecentTokens)),value:v.keepRecentTokens,min:1e3,step:1e3,onChange:e=>b({keepRecentTokens:Math.floor(e)})})]}),P?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(M,{value:v.model??``,disabled:!v.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>b({model:e})}),v.model?(0,Z.jsx)(B,{type:`button`,variant:`secondary`,onClick:()=>b({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(tt,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:v.qualityGuard,onChange:e=>b({qualityGuard:e})}),(0,Z.jsx)(tt,{label:t.gapAudit,hint:t.gapAuditHint,checked:v.gapAudit,onChange:e=>b({gapAudit:e})})]}),v.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning})]}),(0,Z.jsx)(ke,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:v.minMessagesBeforeCompact,min:2,onChange:e=>b({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((v.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>b({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:v.summaryMaxTokens,min:256,step:256,onChange:e=>b({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:v.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>b({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(F)),value:v.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>b({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:v.summaryRetries,min:0,max:5,onChange:e=>b({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:v.minToolResultKeepChars,min:200,step:100,onChange:e=>b({minToolResultKeepChars:Math.floor(e)})})]}),N?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),v.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:v.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:u(`text-fg-muted hover:text-fg`,z.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>b({postCompactionSections:v.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(c,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:Ze(),value:m,maxLength:120,disabled:v.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),re())}}),(0,Z.jsxs)(B,{type:`button`,variant:`secondary`,disabled:!m.trim()||v.postCompactionSections.length>=12,onClick:re,children:[(0,Z.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function rt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function it(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function at(e){let t=rt(e)?e:{},n=rt(t.session)?t.session:{},r=rt(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:it(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function ot(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),O()}function st(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,U,`dark:border-edge`)}var ct=pe();function lt({hasToken:e}){let t=l(p(e=>e.language)).sessions.config,{data:n,isLoading:r}=k(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:at(n.payload.config),[n]),[a,o]=(0,X.useReducer)(ct,{form:null,baseline:null}),s=a.form,c=a.baseline,u=(0,X.useRef)(!1),d=(0,X.useRef)(s);d.current=s;let f=(0,X.useRef)(null);be({enabled:e,parsed:i,dirty:u.current,trackedParsedRef:f,dispatch:o,onResetDirty:()=>{u.current=!1}});let m=!!(s&&c&&JSON.stringify(s)!==JSON.stringify(c)),h=(0,X.useCallback)(e=>{u.current=!0,o({type:`patch`,patch:e})},[]),g=Y({value:s,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await ot(e),o({type:`saved`,value:e}),u.current=!!(d.current&&JSON.stringify(d.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!s?r?(0,Z.jsx)(J,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(H,{className:`h-5 w-40`}),(0,Z.jsx)(H,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(J,{onBlurCapture:g.onBlurCapture,children:[(0,Z.jsx)(De,{icon:R,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(Oe,{status:g.status,error:g.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(L,{title:t.dmScope,summary:s.dmScope,children:(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(W,{className:st(),value:s.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(G,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(G,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(G,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(G,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(q,{allowEmpty:!0,type:`number`,min:0,className:st(),value:s.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsx)(L,{title:t.maxEntries,summary:s.maxEntries??t.unsetPlaceholder,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(q,{allowEmpty:!0,type:`number`,min:1,className:st(),value:s.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})})]})]})}function ut(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 dt(e){let t=(0,Ae.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:l,onArchive:d,onUnarchive:f,onPin:p,onUnpin:m,onExport:y,onDelete:b}=e,ne=i?.status===`archived`,x=i?.status===`pinned`,S;t[0]===l?S=t[1]:(S=e=>!e&&l(),t[0]=l,t[1]=S);let C;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(h,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,we)}),t[2]=C):C=t[2];let w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=u(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,Se,`dark:border-edge`),t[3]=w):w=t[3];let T;t[4]!==i||t[5]!==o||t[6]!==a?(T=i&&a?(0,Z.jsx)(ae,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=T):T=t[7];let E;t[8]!==s.unnamedSession||t[9]!==i?.name?(E=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=E):E=t[10];let D;t[11]===E?D=t[12]:(D=(0,Z.jsx)(v,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:E}),t[11]=E,t[12]=D);let O;t[13]!==T||t[14]!==D?(O=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[T,D]}),t[13]=T,t[14]=D,t[15]=O):O=t[15];let k;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(c,{className:`size-5`,strokeWidth:1.75}),t[16]=k):k=t[16];let A;t[17]===s.close?A=t[18]:(A=(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsx)(B,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:k})}),t[17]=s.close,t[18]=A);let j;t[19]!==O||t[20]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[O,A]}),t[19]=O,t[20]=A,t[21]=j):j=t[21];let M;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(M=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ft)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=M):M=t[26];let N;t[27]===M?N=t[28]:(N=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:M}),t[27]=M,t[28]=N);let P;t[29]!==s.detailExport||t[30]!==y?(P=(0,Z.jsx)(B,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:s.detailExport}),t[29]=s.detailExport,t[30]=y,t[31]=P):P=t[31];let F;t[32]!==ne||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==d||t[36]!==f?(F=ne?(0,Z.jsx)(B,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unarchive}):(0,Z.jsx)(B,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.archive}),t[32]=ne,t[33]=s.archive,t[34]=s.unarchive,t[35]=d,t[36]=f,t[37]=F):F=t[37];let I;t[38]!==x||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==p||t[42]!==m?(I=x?(0,Z.jsx)(B,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.unpin}):(0,Z.jsx)(B,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.pin}),t[38]=x,t[39]=s.pin,t[40]=s.unpin,t[41]=p,t[42]=m,t[43]=I):I=t[43];let L;t[44]!==s.delete||t[45]!==b?(L=(0,Z.jsx)(B,{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:b,children:s.delete}),t[44]=s.delete,t[45]=b,t[46]=L):L=t[46];let R;t[47]!==P||t[48]!==F||t[49]!==I||t[50]!==L?(R=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P,F,I,L]})}),t[47]=P,t[48]=F,t[49]=I,t[50]=L,t[51]=R):R=t[51];let z;t[52]!==j||t[53]!==N||t[54]!==R?(z=(0,Z.jsxs)(_,{children:[C,(0,Z.jsxs)(ee,{className:w,"aria-describedby":void 0,children:[j,N,R]})]}),t[52]=j,t[53]=N,t[54]=R,t[55]=z):z=t[55];let re;return t[56]!==n||t[57]!==S||t[58]!==z?(re=(0,Z.jsx)(te,{open:n,onOpenChange:S,children:z}),t[56]=n,t[57]=S,t[58]=z,t[59]=re):re=t[59],re}function ft(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ut(e.content)})]},`${e.timestamp??``}-${e.role}-${ut(e.content).slice(0,24)}`)}var pt=20;function mt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ht=new Set([`all`,`active`,`pinned`,`archived`]),gt=new Set([`grid`,`list`]),_t=[`sessions`,`settings`];function vt(e){return e&&_t.includes(e)?e:`sessions`}function yt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function bt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function xt(e){let t=(0,Ae.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=_t.map(e=>({id:e,label:yt(n,e),icon:e===`sessions`?de:K})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(me,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function St(e){let t=(0,Ae.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:yt(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:bt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function Ct(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ht.has(t)?t:`all`,viewMode:gt.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 wt(){let e=l(p(e=>e.language)),t=e.sessions,n=f(e=>e.conversationId),r=!!n,{data:a,mutate:s}=D(r?[`gateway-chat-agents`,n]:null,ye,{revalidateOnFocus:!1}),c=a?.defaultId??`main`,d=a?.items??[],[m,g]=i(),O=vt(m.get(`tab`)),k=(0,X.useCallback)(e=>{let t=new URLSearchParams(m);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[m,g]),[A,j]=(0,X.useReducer)(ge,m,Ct),{searchInput:M,debouncedSearch:F,statusFilter:I,viewMode:L,channelFilter:R,sessions:V,loading:ie,error:ae,hasMore:H,stats:U,detailOpen:se,detailLoading:fe,detailSession:W,confirmOpen:pe,confirmKey:G}=A;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=M.trim();F!==e&&j({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[M,F]);let me=m.toString(),ve=(0,X.useRef)(me);if(ve.current!==me){ve.current=me;let e=m.get(`q`)??``,t=m.get(`status`),n=m.get(`view`),r=(m.get(`channel`)??``).trim(),i=ht.has(t)?t:`all`,a=gt.has(n)?n:`grid`,o=e.trim();j({type:`patch`,patch:{...M===e?{}:{searchInput:e},...F===o?{}:{debouncedSearch:o},...I===i?{}:{statusFilter:i},...L===a?{}:{viewMode:a},...R===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(m),t=F.trim();t?e.set(`q`,t):e.delete(`q`),I===`all`?e.delete(`status`):e.set(`status`,I),L===`grid`?e.delete(`view`):e.set(`view`,L),R?e.set(`channel`,R):e.delete(`channel`),e.toString()!==m.toString()&&g(e,{replace:!0})},[F,m,g,I,L,R]),(0,X.useEffect)(()=>{if(!r||O!==`sessions`)return;let e=!1;return(async()=>{j({type:`patch`,patch:{loading:!0,error:null}});try{let t=await T({limit:pt,offset:0,...F?{search:F}:{},...I===`all`?{}:{status:I},...R?{channel:R}:{}});if(e)return;j({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||j({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||j({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,O,F,I,R,t.loadError]),(0,X.useEffect)(()=>{!r||O!==`sessions`||S().then(e=>j({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,O]),(0,X.useEffect)(()=>{if(!r||O!==`sessions`)return;let e=()=>void s();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,O,s]),(0,X.useEffect)(()=>{if(!r||O!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||j({type:`patch`,patch:{sessions:V.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:W&&W.key===t.key?{...W,name:t.name}:W}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,O,V,W]);let be=(0,X.useCallback)(async()=>{if(!(!r||ie||!H)){j({type:`patch`,patch:{loading:!0,error:null}});try{let e=await T({limit:pt,offset:V.length,...F?{search:F}:{},...I===`all`?{}:{status:I},...R?{channel:R}:{}});j({type:`patch`,patch:{sessions:[...V,...e.items],hasMore:e.hasMore}})}catch(e){j({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{j({type:`patch`,patch:{loading:!1}})}}},[r,ie,H,V.length,F,I,R,t.loadError]),K=(0,X.useCallback)((e,t)=>{j({type:`patch`,patch:{sessions:V.map(n=>n.key===e?{...n,status:t}:n),detailSession:W&&W.key===e?{...W,status:t}:W}})},[V,W]),xe=(0,X.useCallback)(async e=>{j({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{j({type:`patch`,patch:{detailSession:await y(e)}})}catch{j({type:`patch`,patch:{detailOpen:!1}})}finally{j({type:`patch`,patch:{detailLoading:!1}})}},[]),Ce=e=>{xe(e)},q=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){j({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await E(e),K(e,`archived`);break;case`unarchive`:await ne(e),K(e,`active`);break;case`pin`:await b(e),K(e,`pinned`);break;case`unpin`:await C(e),K(e,`active`);break;case`export`:{let t=await w(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}S().then(e=>j({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},De=async e=>{try{await x(e),j({type:`patch`,patch:{sessions:V.filter(t=>t.key!==e),detailSession:W?.key===e?null:W,...W?.key===e?{detailOpen:!1}:{}}}),S().then(e=>j({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},J={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},Oe={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},Y=[{key:`all`,label:t.filterAll,icon:de},{key:`active`,label:t.filterActive,icon:he},{key:`pinned`,label:t.filterPinned,icon:ce},{key:`archived`,label:t.filterArchived,icon:re}],ke=(()=>{let e=Object.entries(U?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(Ee,{gap:`gap-6`,children:[(0,Z.jsx)(Te,{title:t.title}),(0,Z.jsx)(xt,{s:t,activeTab:O,onChange:k}),(0,Z.jsx)(St,{s:t,id:`settings`,activeTab:O,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(nt,{hasToken:r}),(0,Z.jsx)(lt,{hasToken:r})]})}),(0,Z.jsxs)(St,{s:t,id:`sessions`,activeTab:O,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(P,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.tabsSessions,indicatorClassName:`rounded-xl bg-accent-soft`,children:Y.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":I===e,onClick:()=>j({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,z.transition,z.focusRingPanel,I===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(ue,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:M,onChange:e=>j({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":F||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(P,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":t.filterChannelLabel,indicatorClassName:`rounded-xl bg-accent-soft`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!R,onClick:()=>j({type:`patch`,patch:{channelFilter:``}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,z.transition,z.focusRingPanel,R?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":R===e,onClick:()=>j({type:`patch`,patch:{channelFilter:e}}),className:u(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,z.transition,z.focusRingPanel,R===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,U?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:U.byChannel[e]})]},e))]}),U?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[U.totalSessions,t.totalSessions],[U.activeSessions,t.activeSessions],[U.pinnedSessions,t.pinnedSessions],[U.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,ae?(0,Z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:ae}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:mt(t.sessionCount,{count:V.length})}),(0,Z.jsxs)(P,{className:N,role:`group`,"aria-label":t.layoutToggleGroup,indicatorClassName:`rounded-pill bg-surface-panel shadow-sm dark:ring-1 dark:ring-edge-strong/40`,children:[(0,Z.jsx)(B,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":L===`grid`,onClick:()=>j({type:`patch`,patch:{viewMode:`grid`}}),className:u(oe,`size-7 p-0`,L===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,L===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(_e,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(B,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":L===`list`,onClick:()=>j({type:`patch`,patch:{viewMode:`list`}}),className:u(oe,`size-9 p-0`,L===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,L===`list`&&`text-accent-fg`),children:(0,Z.jsx)(le,{className:`size-3.5`,strokeWidth:1.5})})]})]}),ie&&V.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):V.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(o,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(B,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,L===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":F||void 0,children:V.map(e=>{let t=ze(e,c);return(0,Z.jsx)(Pe,{session:e,variant:L,labels:J,sessionAgentId:t,sessionAgentAvatar:Be(t,d),onOpen:()=>Ce(e.key),onAction:t=>void q(e.key,t)},e.key)})}),H?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(B,{type:`button`,variant:`secondary`,disabled:ie,onClick:()=>void be(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(dt,{open:se,loading:fe,session:W,sessionAgentId:W?ze(W,c):void 0,sessionAgentAvatar:W?Be(ze(W,c),d):void 0,labels:Oe,onClose:()=>{j({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>W&&void q(W.key,`archive`),onUnarchive:()=>W&&void q(W.key,`unarchive`),onPin:()=>W&&void q(W.key,`pin`),onUnpin:()=>W&&void q(W.key,`unpin`),onExport:()=>W&&void q(W.key,`export`),onDelete:()=>W&&j({type:`patch`,patch:{confirmKey:W.key,confirmOpen:!0}})}),(0,Z.jsx)(te,{open:pe,onOpenChange:e=>j({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(_,{children:[(0,Z.jsx)(h,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,we)}),(0,Z.jsxs)(ee,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,Se),children:[(0,Z.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:G?mt(t.deleteSessionMessage,{name:V.find(e=>e.key===G)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(B,{type:`button`,variant:`secondary`,onClick:()=>j({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(B,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{G&&De(G),j({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{wt as SessionsPage};
@@ -0,0 +1 @@
1
+ import{Hn as e}from"./index-DmURUvvA.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-0WouolD0.js";import{Ic as r,xu as i}from"./index-cmsFpzI8.js";var a=e();function o(){return`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}var l=`mt-0.5 flex size-7 shrink-0 items-center justify-center text-fg-muted transition-colors`;function u(e){let t=(0,a.c)(27),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v,y;if(t[2]!==p||t[3]!==m||t[4]!==h||t[5]!==_){let e=h?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r.press),a=!!(m&&h);t[8]===p?v=t[9]:(v=n(`mb-4 flex items-start gap-2.5`,p),t[8]=p,t[9]=v),y=m?a?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:n(`touch-target`,e),children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(i,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:n(`touch-target`,e),children:_}):(0,s.jsx)(`div`,{className:n(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[2]=p,t[3]=m,t[4]=h,t[5]=_,t[6]=v,t[7]=y}else v=t[6],y=t[7];let b;t[10]===c?b=t[11]:(b=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[10]=c,t[11]=b);let x;t[12]!==b||t[13]!==f?(x=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[b,f]}),t[12]=b,t[13]=f,t[14]=x):x=t[14];let S;t[15]===u?S=t[16]:(S=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[15]=u,t[16]=S);let C;t[17]!==x||t[18]!==S?(C=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S]}),t[17]=x,t[18]=S,t[19]=C):C=t[19];let w;t[20]===d?w=t[21]:(w=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[20]=d,t[21]=w);let T;return t[22]!==v||t[23]!==y||t[24]!==C||t[25]!==w?(T=(0,s.jsxs)(`div`,{className:v,children:[y,C,w]}),t[22]=v,t[23]=y,t[24]=C,t[25]=w,t[26]=T):T=t[26],T}export{u as n,o as r,c as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-0WouolD0.js";import{Ic as r,wu as i}from"./index-DmURUvvA.js";var a=e();function o(){return`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}var l=`mt-0.5 flex size-7 shrink-0 items-center justify-center text-fg-muted transition-colors`;function u(e){let t=(0,a.c)(27),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v,y;if(t[2]!==p||t[3]!==m||t[4]!==h||t[5]!==_){let e=h?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r.press),a=!!(m&&h);t[8]===p?v=t[9]:(v=n(`mb-4 flex items-start gap-2.5`,p),t[8]=p,t[9]=v),y=m?a?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:n(`touch-target`,e),children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(i,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:n(`touch-target`,e),children:_}):(0,s.jsx)(`div`,{className:n(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[2]=p,t[3]=m,t[4]=h,t[5]=_,t[6]=v,t[7]=y}else v=t[6],y=t[7];let b;t[10]===c?b=t[11]:(b=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[10]=c,t[11]=b);let x;t[12]!==b||t[13]!==f?(x=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[b,f]}),t[12]=b,t[13]=f,t[14]=x):x=t[14];let S;t[15]===u?S=t[16]:(S=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[15]=u,t[16]=S);let C;t[17]!==x||t[18]!==S?(C=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S]}),t[17]=x,t[18]=S,t[19]=C):C=t[19];let w;t[20]===d?w=t[21]:(w=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[20]=d,t[21]=w);let T;return t[22]!==v||t[23]!==y||t[24]!==C||t[25]!==w?(T=(0,s.jsxs)(`div`,{className:v,children:[y,C,w]}),t[22]=v,t[23]=y,t[24]=C,t[25]=w,t[26]=T):T=t[26],T}export{u as n,o as r,c as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,r as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./messages-DBvKzlCl.js";import{n as s}from"./locale-store-Jnhw2WMv.js";import{$o as c,Jo as l,Ko as u,Qo as d,Xo as f,Yo as p,Zo as m,es as h,ns as g,qo as _,rs as v,ts as y}from"./index-cmsFpzI8.js";var b=n(),x=e(t(),1),S=r(),C=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`agent-defaults`,`gateway`,`runtimes`,`devices`,`remote-access`,`shares`],w=(0,x.lazy)(()=>y().then(e=>({default:e.SetupStatusPanel}))),T=(0,x.lazy)(()=>l().then(e=>({default:e.AppearanceSettingsPanel}))),E=(0,x.lazy)(()=>d().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),D=(0,x.lazy)(()=>v().then(e=>({default:e.SystemSettingsPanel}))),O=(0,x.lazy)(()=>p().then(e=>({default:e.DesktopPetSettings}))),k=(0,x.lazy)(()=>_().then(e=>({default:e.AppManagementSettingsPanel}))),A=(0,x.lazy)(()=>m().then(e=>({default:e.GatewaySettingsPanel}))),j=(0,x.lazy)(()=>h().then(e=>({default:e.RuntimeToolsSettingsPanel}))),M=(0,x.lazy)(()=>c().then(e=>({default:e.RemoteAccessHub}))),N=(0,x.lazy)(()=>g().then(e=>({default:e.SharesSettingsPanel}))),P=(0,x.lazy)(()=>u().then(e=>({default:e.AgentDefaultsSettingsPanel}))),F=(0,x.lazy)(()=>f().then(e=>({default:e.EndpointToolsManagementSettings})));function I(){let e=(0,b.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,S.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function L(e){return(0,S.jsx)(x.Suspense,{fallback:(0,S.jsx)(I,{}),children:(0,S.jsx)(e,{})})}function R(){let e=(0,b.c)(27),{section:t}=i(),n=s(z),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=o(n);if(!t||!C.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(w),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(T),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(E),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(D),e[11]=t):t=e[11],d=t;break bb0}if(s===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(O),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(k),e[13]=t):t=e[13],d=t;break bb0}if(s===`agent-defaults`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(P),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(A),e[15]=t):t=e[15],d=t;break bb0}if(s===`runtimes`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(j),e[16]=t):t=e[16],d=t;break bb0}if(s===`devices`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(F),e[17]=t):t=e[17],d=t;break bb0}if(s===`remote-access`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(M),e[18]=t):t=e[18],d=t;break bb0}if(s===`shares`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(N),e[19]=t):t=e[19],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,S.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[20]!==r||e[21]!==c?(f=(0,S.jsx)(`p`,{className:r,children:c}),e[20]=r,e[21]=c,e[22]=f):f=e[22];let p;return e[23]!==l||e[24]!==u||e[25]!==f?(p=(0,S.jsxs)(`div`,{className:l,children:[u,f]}),e[23]=l,e[24]=u,e[25]=f,e[26]=p):p=e[26],p}function z(e){return e.language}export{R as SettingsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,r as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./messages-Bwv-AOYl.js";import{n as s}from"./locale-store-D5h-Ha6-.js";import{$o as c,Jo as l,Ko as u,Qo as d,Xo as f,Yo as p,Zo as m,es as h,ns as g,qo as _,rs as v,ts as y}from"./index-DmURUvvA.js";var b=n(),x=e(t(),1),S=r(),C=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`agent-defaults`,`gateway`,`runtimes`,`devices`,`remote-access`,`shares`],w=(0,x.lazy)(()=>y().then(e=>({default:e.SetupStatusPanel}))),T=(0,x.lazy)(()=>l().then(e=>({default:e.AppearanceSettingsPanel}))),E=(0,x.lazy)(()=>d().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),D=(0,x.lazy)(()=>v().then(e=>({default:e.SystemSettingsPanel}))),O=(0,x.lazy)(()=>p().then(e=>({default:e.DesktopPetSettings}))),k=(0,x.lazy)(()=>_().then(e=>({default:e.AppManagementSettingsPanel}))),A=(0,x.lazy)(()=>m().then(e=>({default:e.GatewaySettingsPanel}))),j=(0,x.lazy)(()=>h().then(e=>({default:e.RuntimeToolsSettingsPanel}))),M=(0,x.lazy)(()=>c().then(e=>({default:e.RemoteAccessHub}))),N=(0,x.lazy)(()=>g().then(e=>({default:e.SharesSettingsPanel}))),P=(0,x.lazy)(()=>u().then(e=>({default:e.AgentDefaultsSettingsPanel}))),F=(0,x.lazy)(()=>f().then(e=>({default:e.EndpointToolsManagementSettings})));function I(){let e=(0,b.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,S.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,S.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function L(e){return(0,S.jsx)(x.Suspense,{fallback:(0,S.jsx)(I,{}),children:(0,S.jsx)(e,{})})}function R(){let e=(0,b.c)(27),{section:t}=i(),n=s(z),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=o(n);if(!t||!C.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,S.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(w),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(T),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(E),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(D),e[11]=t):t=e[11],d=t;break bb0}if(s===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(O),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(k),e[13]=t):t=e[13],d=t;break bb0}if(s===`agent-defaults`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(P),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(A),e[15]=t):t=e[15],d=t;break bb0}if(s===`runtimes`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(j),e[16]=t):t=e[16],d=t;break bb0}if(s===`devices`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(F),e[17]=t):t=e[17],d=t;break bb0}if(s===`remote-access`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(M),e[18]=t):t=e[18],d=t;break bb0}if(s===`shares`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=L(N),e[19]=t):t=e[19],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,S.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[20]!==r||e[21]!==c?(f=(0,S.jsx)(`p`,{className:r,children:c}),e[20]=r,e[21]=c,e[22]=f):f=e[22];let p;return e[23]!==l||e[24]!==u||e[25]!==f?(p=(0,S.jsxs)(`div`,{className:l,children:[u,f]}),e[23]=l,e[24]=u,e[25]=f,e[26]=p):p=e[26],p}function z(e){return e.language}export{R as SettingsPage};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./messages-Bwv-AOYl.js";import{t as s}from"./cn-0WouolD0.js";import{a as c,c as l,n as u,r as d}from"./locale-store-D5h-Ha6-.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{r as p}from"./gateway-config-swr-BvuySoCX.js";import{n as m}from"./gateway-realtime-store-dKq2fm2X.js";import{n as h,t as g}from"./registry-api-Bf0hVPNV.js";import{Hl as _,Ic as v,Ju as y,Kc as b,Ml as x,On as S,Pf as C,Ps as w,Rc as T,Wt as E,df as D,du as ee,nf as O,os as k,pd as A,ra as j,rf as M}from"./index-DmURUvvA.js";import{n as N,r as P}from"./settings-page-layout-Dx5S-Msc.js";import{n as F,t as I}from"./settings-form-section-BTUFu5KS.js";import{t as L}from"./settings-advanced-gate-CDzdr1zW.js";import{r as R,t as te}from"./runtime-tools-api-ByH1meP7.js";var z=n(),B=e(t(),1),V=r();function H(){let e=u(e=>e.language)===`zh`,t=o(e?`zh`:`en`).runtimeToolsSettings,{data:n,error:r,mutate:i}=f(d(`/api/runtime-tools`),te),[a,s]=(0,B.useState)(),[c,l]=(0,B.useState)(),p=n?.payload.statuses??[],m=p.some(e=>![`ready`,`disabled`,`unsupported`].includes(e.state));async function h(t,r){s(t),l(void 0);try{await R({runtime:t,action:r?`repair`:`install`,version:n?.payload.config[t].version,onProgress:e=>l(e.message)}),await i(),l(e?`操作完成,已刷新执行环境状态。`:`Completed and refreshed environment status.`)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(void 0)}}return(0,V.jsxs)(`details`,{open:m||void 0,className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,V.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[e?`执行环境状态`:`Execution environment status`,n?` · ${p.filter(e=>e.state===`ready`).length}/${p.length}`:``]}),r?(0,V.jsxs)(`div`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[t.loadError,(0,V.jsx)(b,{variant:`ghost`,onClick:()=>void i(),children:t.refresh})]}):n?(0,V.jsx)(`div`,{className:`mt-3 space-y-3`,children:p.map(e=>(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg`,children:t.runtimeNames[e.runtime]}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.message})]}),n.payload.config.enabled&&n.payload.config[e.runtime].enabled&&![`ready`,`disabled`,`unsupported`,`installing`].includes(e.state)?(0,V.jsx)(b,{disabled:!!a,onClick:()=>void h(e.runtime,e.repairable),children:a===e.runtime?t.working:e.repairable?t.repair:t.install}):null]},e.runtime))}):(0,V.jsx)(T,{className:`mt-3 h-20`}),c?(0,V.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-fg-muted`,children:c}):null]})}function U(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`&&w(e)).length}function W(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function G(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 K(e){if(!e||typeof e!=`object`)return{enabled:!1,driverKind:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,driverKind:`extension`};let n=t,r=n.driver&&typeof n.driver==`object`&&!Array.isArray(n.driver)?n.driver:void 0;return{enabled:n.enabled===!0,driverKind:typeof r?.kind==`string`&&r.kind.trim()?r.kind.trim():`extension`}}function q(e){return e?`pass`:`fail`}function ne(e){if(e===`tool-runtimes`)return`/settings/runtimes`;if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/capabilities/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/capabilities/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function J(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function Y(e,t){let n=e.match(/^Run(?::|\s)(.*)$/i);if(n?.[1])return t.runCommand(n[1].trim());let r=e.match(/^Install(?::|\s)(.*)$/i);if(r?.[1])return t.installCommand(r[1].trim());let i=e.match(/^Start(?::|\s)(.*)$/i);return i?.[1]?t.startCommand(i[1].trim()):e}function X(e,t){if(!t)return e;let n=e.message;if(e.id===`tool-runtimes`){let r=e.message.match(/^(.*) runtime is not installed\.$/),i=e.message.match(/^(.*) runtime installation is invalid\.$/);r?.[1]?n=t.runtimeMissing(r[1]):i?.[1]&&(n=t.runtimeInvalid(i[1]))}else if(e.id===`gateway-service`)if(e.message===`Gateway is not installed as a system service.`)n=t.gatewayNotInstalled;else{let r=e.message.match(/^Service backend unavailable: (.*)$/),i=e.message.match(/^Gateway service is installed but not running \(status: (.*)\)\.$/);r?.[1]?n=t.gatewayUnavailable(r[1]):i?.[1]&&(n=t.gatewayNotRunning(i[1]))}else e.id===`provider-auth`&&e.message===`No API keys detected for configured providers.`&&(n=t.providerAuthMissing);return{...e,label:t.labels[e.id]??e.label,message:n,hints:e.hints.map(e=>Y(e,t))}}function Z(e,t){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>{let n=X(e,t);return{id:n.id,label:n.label,status:n.status,message:n.message,hints:n.hints,path:ne(n.id),source:`doctor`}}).toSorted((e,t)=>J(t.status)-J(e.status)||e.label.localeCompare(t.label))}function re(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let r of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let i=t.get(r);if(i){let t=X(i,e.copy);n.push({id:t.id,label:t.label,status:t.status,message:t.message,path:ne(t.id)})}}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:e.copy?.labels[`logs-health`]??`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.copy?e.logsHealth.shuttingDown?e.copy.logsShuttingDown:t>0?e.copy.logsErrors(t):e.copy.logsHealthy:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[]){let r=t.message;if(e.copy){r={"Local Chromium is installed.":e.copy.chromiumInstalled,"Local Chromium is not installed.":e.copy.chromiumNotInstalled,"Chrome extension bridge is connected.":e.copy.extensionConnected,"Chrome extension needs refresh.":e.copy.extensionNeedsRefresh,"Chrome extension is installed but not connected.":e.copy.extensionNotConnected,"Chrome extension is not installed.":e.copy.extensionNotInstalled}[t.message]??t.message;let n=t.message.match(/^Browser driver "(.*)" is configured\.$/);n?.[1]&&(r=e.copy.browserDriverConfigured(n[1]))}n.push({...t,label:e.copy?.labels[t.id]??t.label,message:r})}return n}function ie(e){let t=U(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=W(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=G(e.config),l=e.skillCount>0,u=(e.doctorChecks??[]).filter(t=>!e.isElectron||t.id!==`gateway-service`),d=Z(u,e.labels.diagnostics),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:q(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:q(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:q(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=re({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics,copy:e.labels.diagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function ae(e){return K(e)}function oe(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 se(){return d(`/api/doctor`)}async function ce(){return((await c(se())).checks??[]).map(oe).filter(e=>e!==null)}function le(){return d(`/api/logs/health`)}async function ue(){return c(le())}function Q(e){return e?`pass`:`warn`}function de(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function fe(e){if(!e.enabled)return[];if(e.driverKind===`playwright`){let e=await c(d(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:Q(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser`}]}if(e.driverKind===`extension`){let e=await c(d(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser driver "${e.driverKind}" is configured.`,path:`/settings/agent-browser`}]}function $(){let e=(0,z.c)(95),t=l(ve),n=u(_e),r;e[0]===n?r=e[1]:(r=o(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,s=i.setupStatus.diagnostics,c=m(ge),{data:d,error:_,isLoading:v,mutate:y}=p(!!t),b;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(b={revalidateOnFocus:!1},e[2]=b):b=e[2];let{data:x,error:S,isLoading:C,mutate:w}=f(t?`setup-checklist-skills`:null,he,b),T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},e[3]=T):T=e[3];let{data:D,error:ee,isLoading:O,mutate:A}=f(t?`setup-checklist-provider-meta`:null,E,T),j;e[4]===t?j=e[5]:(j=t?se():null,e[4]=t,e[5]=j);let M;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(M={revalidateOnFocus:!1},e[6]=M):M=e[6];let{data:N,error:P,isLoading:F,mutate:I}=f(j,ce,M),L;e[7]===t?L=e[8]:(L=t?le():null,e[7]=t,e[8]=L);let R;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},e[9]=R):R=e[9];let{data:te,isLoading:B,mutate:V}=f(L,ue,R);d?.payload?.config;let H=d?.payload?.config,U;e[10]===H?U=e[11]:(U=ae(H),e[10]=H,e[11]=U);let W=t?U:null,G;e[12]===W?G=e[13]:(G=de(W),e[12]=W,e[13]=G);let K;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(K={revalidateOnFocus:!1},e[14]=K):K=e[14];let{data:q,isLoading:ne,mutate:J}=f(G,me,K),Y;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(Y={revalidateOnFocus:!1},e[15]=Y):Y=e[15],f(t?g:null,h,Y);let X=!t||!v&&!C&&!O&&!F&&!B&&!ne,Z=!!(_||S||ee||P),re;bb0:{if(!t||!X){re=null;break bb0}let n=x?.catalog?.length??0,r;if(e[16]!==q||e[17]!==d?.payload?.config||e[18]!==s.browserDriverConfigured||e[19]!==s.chromiumInstalled||e[20]!==s.chromiumNotInstalled||e[21]!==s.extensionConnected||e[22]!==s.extensionNeedsRefresh||e[23]!==s.extensionNotConnected||e[24]!==s.extensionNotInstalled||e[25]!==s.gatewayNotInstalled||e[26]!==s.gatewayNotRunning||e[27]!==s.gatewayUnavailable||e[28]!==s.installCommand||e[29]!==s.labels||e[30]!==s.logsErrors||e[31]!==s.logsHealthy||e[32]!==s.logsShuttingDown||e[33]!==s.providerAuthMissing||e[34]!==s.runCommand||e[35]!==s.runtimeInvalid||e[36]!==s.runtimeMissing||e[37]!==s.startCommand||e[38]!==N||e[39]!==a.channelConfigured||e[40]!==a.channelMissing||e[41]!==a.gatewayOffline||e[42]!==a.gatewayOnline||e[43]!==a.modelConfigured||e[44]!==a.modelMissing||e[45]!==a.providersConfigured||e[46]!==a.providersMetaReady||e[47]!==a.providersMissing||e[48]!==a.skillsConfigured||e[49]!==a.skillsMissing||e[50]!==te||e[51]!==i.setupStatus.requiredCompleteMessage||e[52]!==D||e[53]!==c||e[54]!==n||e[55]!==t){let o=D?.filter(pe).length??0,l=D?.length??0,u;e[57]===a.providersConfigured?u=e[58]:(u=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[57]=a.providersConfigured,e[58]=u);let f;e[59]===a.providersMetaReady?f=e[60]:(f=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[59]=a.providersMetaReady,e[60]=f);let p;e[61]===a.modelConfigured?p=e[62]:(p=e=>a.modelConfigured.replace(`{{model}}`,e),e[61]=a.modelConfigured,e[62]=p);let m;e[63]===a.skillsConfigured?m=e[64]:(m=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[63]=a.skillsConfigured,e[64]=m);let h;e[65]===s.runtimeMissing?h=e[66]:(h=e=>s.runtimeMissing.replace(`{{runtimes}}`,e),e[65]=s.runtimeMissing,e[66]=h);let g;e[67]===s.runtimeInvalid?g=e[68]:(g=e=>s.runtimeInvalid.replace(`{{runtimes}}`,e),e[67]=s.runtimeInvalid,e[68]=g);let _;e[69]===s.gatewayUnavailable?_=e[70]:(_=e=>s.gatewayUnavailable.replace(`{{detail}}`,e),e[69]=s.gatewayUnavailable,e[70]=_);let v;e[71]===s.gatewayNotRunning?v=e[72]:(v=e=>s.gatewayNotRunning.replace(`{{status}}`,e),e[71]=s.gatewayNotRunning,e[72]=v);let y;e[73]===s.runCommand?y=e[74]:(y=e=>s.runCommand.replace(`{{command}}`,e),e[73]=s.runCommand,e[74]=y);let b;e[75]===s.installCommand?b=e[76]:(b=e=>s.installCommand.replace(`{{command}}`,e),e[75]=s.installCommand,e[76]=b);let x;e[77]===s.startCommand?x=e[78]:(x=e=>s.startCommand.replace(`{{command}}`,e),e[77]=s.startCommand,e[78]=x);let S;e[79]===s.logsErrors?S=e[80]:(S=e=>s.logsErrors.replace(`{{count}}`,String(e)),e[79]=s.logsErrors,e[80]=S);let C;e[81]===s.browserDriverConfigured?C=e[82]:(C=e=>s.browserDriverConfigured.replace(`{{driver}}`,e),e[81]=s.browserDriverConfigured,e[82]=C),r=ie({isElectron:k(),hasToken:!!t,realtimeConnected:c,config:d?.payload?.config,skillCount:n,providerMeta:l>0?{configured:o,total:l}:null,doctorChecks:N,logsHealth:te,browserDiagnostics:q,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:u,providersMetaReady:f,providersMissing:a.providersMissing,modelConfigured:p,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:m,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage,diagnostics:{labels:s.labels,runtimeMissing:h,runtimeInvalid:g,gatewayNotInstalled:s.gatewayNotInstalled,gatewayUnavailable:_,gatewayNotRunning:v,providerAuthMissing:s.providerAuthMissing,runCommand:y,installCommand:b,startCommand:x,logsHealthy:s.logsHealthy,logsShuttingDown:s.logsShuttingDown,logsErrors:S,chromiumInstalled:s.chromiumInstalled,chromiumNotInstalled:s.chromiumNotInstalled,extensionConnected:s.extensionConnected,extensionNeedsRefresh:s.extensionNeedsRefresh,extensionNotConnected:s.extensionNotConnected,extensionNotInstalled:s.extensionNotInstalled,browserDriverConfigured:C}}}),e[16]=q,e[17]=d?.payload?.config,e[18]=s.browserDriverConfigured,e[19]=s.chromiumInstalled,e[20]=s.chromiumNotInstalled,e[21]=s.extensionConnected,e[22]=s.extensionNeedsRefresh,e[23]=s.extensionNotConnected,e[24]=s.extensionNotInstalled,e[25]=s.gatewayNotInstalled,e[26]=s.gatewayNotRunning,e[27]=s.gatewayUnavailable,e[28]=s.installCommand,e[29]=s.labels,e[30]=s.logsErrors,e[31]=s.logsHealthy,e[32]=s.logsShuttingDown,e[33]=s.providerAuthMissing,e[34]=s.runCommand,e[35]=s.runtimeInvalid,e[36]=s.runtimeMissing,e[37]=s.startCommand,e[38]=N,e[39]=a.channelConfigured,e[40]=a.channelMissing,e[41]=a.gatewayOffline,e[42]=a.gatewayOnline,e[43]=a.modelConfigured,e[44]=a.modelMissing,e[45]=a.providersConfigured,e[46]=a.providersMetaReady,e[47]=a.providersMissing,e[48]=a.skillsConfigured,e[49]=a.skillsMissing,e[50]=te,e[51]=i.setupStatus.requiredCompleteMessage,e[52]=D,e[53]=c,e[54]=n,e[55]=t,e[56]=r}else r=e[56];re=r}let oe=re,Q;e[83]!==J||e[84]!==y||e[85]!==I||e[86]!==V||e[87]!==A||e[88]!==w?(Q=async()=>{await Promise.all([y(),w(),A(),I(),V(),J()])},e[83]=J,e[84]=y,e[85]=I,e[86]=V,e[87]=A,e[88]=w,e[89]=Q):Q=e[89];let fe=Q,$;return e[90]!==Z||e[91]!==X||e[92]!==fe||e[93]!==oe?($={ready:X,error:Z,snapshot:oe,refresh:fe},e[90]=Z,e[91]=X,e[92]=fe,e[93]=oe,e[94]=$):$=e[94],$}function pe(e){return e.configured}function me(e){let[,t]=e;return fe(t)}function he(){return j()}function ge(e){return e.connectionState===`connected`}function _e(e){return e.language}function ve(e){return e.conversationId}function ye(e){return e===`pass`?`bg-success-soft text-success`:e===`warn`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`bg-red-500/10 text-red-700 dark:text-red-300`:`bg-surface-hover text-fg-muted`}function be(e){return e===`pass`?a:e===`warn`?x:e===`fail`?M:A}function xe(e,t){return e===`blocked`?{icon:M,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:x,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:O,className:`bg-surface-hover/50 text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Se(e){let t=(0,z.c)(46),{tier:n,issueCount:r,onRunDoctor:a,ready:c,doctorRunning:l,doctorRunState:d}=e,f=u(Ce),p,m,h,g,_,b,x,S,C;if(t[0]!==r||t[1]!==f||t[2]!==n){m=o(f).setupStatus;let e=xe(n,m),a=e.icon,c=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;p=c?(0,V.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(c)?.scrollIntoView({block:`start`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,V.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):(0,V.jsxs)(i,{to:l,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,V.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}),C=s(`rounded-xl p-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,V.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),h=`min-w-0`,g=(0,V.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),_=r>0?(0,V.jsx)(`p`,{className:`mt-1 text-sm opacity-80`,children:m.health.issueCount.replace(`{{count}}`,String(r))}):null,t[0]=r,t[1]=f,t[2]=n,t[3]=p,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=b,t[9]=x,t[10]=S,t[11]=C}else p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],b=t[8],x=t[9],S=t[10],C=t[11];let w;t[12]!==h||t[13]!==g||t[14]!==_?(w=(0,V.jsxs)(`div`,{className:h,children:[g,_]}),t[12]=h,t[13]=g,t[14]=_,t[15]=w):w=t[15];let T;t[16]!==b||t[17]!==x||t[18]!==w?(T=(0,V.jsxs)(`div`,{className:b,children:[x,w]}),t[16]=b,t[17]=x,t[18]=w,t[19]=T):T=t[19];let E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=s(`inline-flex items-center gap-2 rounded-lg bg-surface-base/70 px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,v.press),t[20]=E):E=t[20];let O=!c||l,k;t[21]===l?k=t[22]:(k=l?(0,V.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,V.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[21]=l,t[22]=k);let A=l?m.health.runDoctorRunning:m.health.runDoctor,j;t[23]!==l||t[24]!==a||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,V.jsxs)(`button`,{type:`button`,className:E,onClick:a,disabled:O,"aria-busy":l,children:[k,A]}),t[23]=l,t[24]=a,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==p||t[30]!==j?(M=(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[p,j]}),t[29]=p,t[30]=j,t[31]=M):M=t[31];let N;t[32]!==M||t[33]!==S||t[34]!==T?(N=(0,V.jsxs)(`div`,{className:S,children:[T,M]}),t[32]=M,t[33]=S,t[34]=T,t[35]=N):N=t[35];let P;t[36]!==d||t[37]!==l||t[38]!==m.health.doctorCompleteMessage||t[39]!==m.health.doctorFailedMessage||t[40]!==m.health.doctorRunningMessage?(P=l||d!==`idle`?(0,V.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:l?m.health.doctorRunningMessage:d===`success`?m.health.doctorCompleteMessage:m.health.doctorFailedMessage}):null,t[36]=d,t[37]=l,t[38]=m.health.doctorCompleteMessage,t[39]=m.health.doctorFailedMessage,t[40]=m.health.doctorRunningMessage,t[41]=P):P=t[41];let F;return t[42]!==N||t[43]!==P||t[44]!==C?(F=(0,V.jsxs)(`section`,{className:C,children:[N,P]}),t[42]=N,t[43]=P,t[44]=C,t[45]=F):F=t[45],F}function Ce(e){return e.language}function we(e){let t=(0,z.c)(26),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=be(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,V.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,V.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,V.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]===n.hints[0]?u=t[9]:(u=n.hints[0]?(0,V.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[8]=n.hints[0],t[9]=u);let d;t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l,u]}),t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==r||t[15]!==n.path?(f=n.path?(0,V.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,V.jsx)(D,{className:`size-4`,"aria-hidden":!0})]}):null,t[14]=r,t[15]=n.path,t[16]=f):f=t[16];let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,V.jsxs)(V.Fragment,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m=p;if(n.path){let e;return t[21]!==m||t[22]!==n.path?(e=(0,V.jsx)(i,{to:n.path,className:`flex items-start gap-3 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m}),t[21]=m,t[22]=n.path,t[23]=e):e=t[23],e}let h;return t[24]===m?h=t[25]:(h=(0,V.jsx)(`div`,{className:`flex items-start gap-3 px-1 py-3`,children:m}),t[24]=m,t[25]=h),h}function Te(e){let t=(0,z.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=be(n.status),t[0]=n.status,t[1]=a);let o=a,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=s(`flex size-7 shrink-0 items-center justify-center rounded-full`,ye(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===o?u=t[5]:(u=(0,V.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,V.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,V.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,V.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,V.jsx)(D,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,V.jsxs)(V.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,V.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,V.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function Ee(e){let t=(0,z.c)(23),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=be(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,V.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,V.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,V.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,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==r||t[12]!==n.path?(d=n.path?(0,V.jsx)(`span`,{className:`sr-only`,children:r}):null,t[11]=r,t[12]=n.path,t[13]=d):d=t[13];let f;t[14]!==s||t[15]!==u||t[16]!==d?(f=(0,V.jsxs)(V.Fragment,{children:[s,u,d]}),t[14]=s,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p=f;if(n.path){let e;return t[18]!==p||t[19]!==n.path?(e=(0,V.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:p}),t[18]=p,t[19]=n.path,t[20]=e):e=t[20],e}let m;return t[21]===p?m=t[22]:(m=(0,V.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 px-1 py-3`,children:p}),t[21]=p,t[22]=m),m}function De(){let e=o(u(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=$(),[a,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(`idle`),d=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],f=async()=>{if(!(a||!t)){s(!0),l(`idle`);try{await i(),l(`success`)}catch{l(`error`)}finally{s(!1)}}};return(0,V.jsxs)(P,{gap:`gap-6`,children:[(0,V.jsx)(N,{title:e.title}),n?(0,V.jsx)(`p`,{className:`rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,V.jsx)(S,{sections:2}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Se,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void f(),doctorRunning:a,doctorRunState:c}),(0,V.jsxs)(I,{id:`next-steps`,children:[(0,V.jsx)(F,{icon:r.issues.length?x:C,title:e.nextStepsTitle}),r.issues.length?(0,V.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:r.issues.slice(0,8).map(t=>(0,V.jsx)(we,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,V.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:bg-surface-base/45`,children:r.readiness.map(t=>(0,V.jsx)(Te,{item:t,labels:e.readinessLabels},t.id))})]}),(0,V.jsx)(H,{}),(0,V.jsx)(L,{children:(0,V.jsxs)(I,{children:[(0,V.jsx)(F,{icon:_,title:e.diagnosticsTitle}),d.length?(0,V.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:d.map(t=>(0,V.jsx)(Ee,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,V.jsx)(`p`,{className:`mt-3 py-2 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})})]})]})}export{De as SetupStatusPanel};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-Db4nTY5N.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/pdf-runtime-DU_sMPjG.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{m as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./markdown-view-B58RypQ4.js";import{t as s}from"./messages-DBvKzlCl.js";import{t as c}from"./cn-0WouolD0.js";import{n as l,r as u}from"./locale-store-Jnhw2WMv.js";import{t as d}from"./copy-to-clipboard-HOJ79TWv.js";import{t as f}from"./attachment-utils-core-BIOUBrpT.js";import{Ha as p,Lc as m,Rc as h,Va as g,Zs as _,ca as v,sa as y,za as b,zc as x}from"./index-cmsFpzI8.js";var S=e(t(),1),C=n(),w=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,T=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,E=/!\[([^\]]*)\]\[([^\]]+)\]/g;function D(e,t){let n=new Map;for(let t of e.matchAll(w))n.set(O(t[1]??``),t[2]??``);return e.replace(T,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(E,(e,r,i)=>{let a=n.get(O(i));return a?`[${r.trim()||t}](${a})`:e})}function O(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var k=r();function A(e){return(0,k.jsx)(m,{source:e.source,incomplete:!e.closed,streaming:!1,copy:!0})}function j(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function M(e){let t=(0,C.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:o,setExpanded:l}=y(),u=s(a.language),f;t[0]===u?f=t[1]:(f=async()=>{let e=await d(window.location.href);_(e?`success`:`warning`,e?u.sharesSettings.copied:u.clipboard.copyFailed)},t[0]=u,t[1]=f);let p=f,m=o&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,h;t[2]===m?h=t[3]:(h=c(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,m),t[2]=m,t[3]=h);let g;t[4]!==l||t[5]!==a.loadError||t[6]!==a.loading?(g=!a.loading&&!a.loadError?()=>l(N):void 0,t[4]=l,t[5]=a.loadError,t[6]=a.loading,t[7]=g):g=t[7];let b;t[8]===i?b=t[9]:(b=()=>window.location.assign(i),t[8]=i,t[9]=b);let x;t[10]===p?x=t[11]:(x=()=>void p(),t[10]=p,t[11]=x);let S=a.loading||!!a.loadError,w;t[12]!==x||t[13]!==S?(w={onClick:x,disabled:S},t[12]=x,t[13]=S,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==o||t[18]!==n||t[19]!==g||t[20]!==b||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:o,onToggleExpanded:g,onClose:b,share:w,openInBrowser:T},t[17]=o,t[18]=n,t[19]=g,t[20]=b,t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==a||t[25]!==E?(D=(0,k.jsx)(v,{...a,header:E}),t[24]=a,t[25]=E,t[26]=D):D=t[26];let O;return t[27]!==D||t[28]!==h?(O=(0,k.jsx)(`div`,{className:h,children:D}),t[27]=D,t[28]=h,t[29]=O):O=t[29],O}function N(e){return!e}function P(){let{token:e}=a(),t=l(e=>e.language),n=t===`zh`?L:R,[r,s]=(0,S.useState)(null),[c,d]=(0,S.useState)(j),[m,_]=(0,S.useState)(!0),[v,y]=(0,S.useState)(null),[C,w]=(0,S.useState)(null),[T,E]=(0,S.useState)(null),O=(0,S.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=g(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:b(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,S.useEffect)(()=>{if(!e){y(n.invalidLink),_(!1);return}let t=!1;return(async()=>{try{_(!0),y(null),d(j()),w(null),E(null);let r=await fetch(u(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||y(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(s(a),!a.valid){y(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(u(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){y(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&w(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let o=g(a.fileName,a.mimeType),c=b(a.fileName,o),l=p(c),m=u(`/s/${encodeURIComponent(e)}?inline=1`);if(l===`text`){if(a.fileSize>5242880){y(n.tooLarge);return}let e=await fetch(m);if(!e.ok){y(n.expired);return}let r=await e.text();t||d({...j(),textContent:r});return}if(l===`binary`){if(a.fileSize>33554432){y(n.tooLarge);return}let e=await fetch(m);if(!e.ok){y(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-Db4nTY5N.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>f;d({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,f):t,extractedTextTruncated:n});return}d({...j(),binaryBuffer:r})}}catch(e){t||y(e instanceof Error?e.message:String(e))}finally{t||_(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let N=e?u(`/s/${encodeURIComponent(e)}?dl=1`):`#`,P=e?u(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return O&&r&&e?(0,k.jsx)(M,{language:t,descriptor:O,loading:m,loadError:v,textContent:c.textContent,binaryBuffer:c.binaryBuffer,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,subtitle:(0,k.jsxs)(`span`,{className:`truncate`,children:[I(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:P,landingUrl:u(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=N},canDownload:!m&&!v}}):(0,k.jsx)(x,{children:(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,k.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,k.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):m?(0,k.jsx)(h,{className:`h-4 w-48 max-w-full`}):(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,k.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[I(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,k.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:m?(0,k.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,k.jsx)(h,{className:`h-5 w-56 max-w-full`}),(0,k.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,k.jsx)(h,{className:`h-4 w-full`}),(0,k.jsx)(h,{className:`h-4 w-11/12`}),(0,k.jsx)(h,{className:`h-4 w-10/12`}),(0,k.jsx)(h,{className:`h-4 w-3/4`})]}),(0,k.jsx)(h,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):v?(0,k.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,k.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,k.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v})]}):r?.kind===`directory`?(0,k.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&C?(0,k.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,k.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:C.title}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(C.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(C.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),C.description?(0,k.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-inset px-4 py-3 text-sm leading-6 text-fg-muted`,children:C.description}):null,(0,k.jsx)(o,{content:D(C.markdown,n.remoteImageBlocked),className:`mt-8`,renderChart:A}),(0,k.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&T?(0,k.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,k.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,k.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:T.title}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(T.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(T.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),T.description?(0,k.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:T.description}):null]}),(0,k.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[T.messages.map(e=>(0,k.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,k.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-inset px-4 py-3`:`px-1 py-1`,children:[(0,k.jsx)(o,{content:D(e.markdown,n.remoteImageBlocked),renderChart:A}),T.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,k.jsx)(F,{attachment:e},e.id)),T.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,k.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:e.toolName}),(0,k.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,k.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),T.toolActivities.filter(e=>!e.messageId).map(e=>(0,k.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,k.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})})}function F(e){let t=(0,C.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,k.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,k.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=I(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,k.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function I(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 L={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},R={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{P as SharePreviewPage};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{m as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./markdown-view-CthsQiiO.js";import{t as s}from"./messages-Bwv-AOYl.js";import{t as c}from"./cn-0WouolD0.js";import{n as l,r as u}from"./locale-store-D5h-Ha6-.js";import{t as d}from"./copy-to-clipboard-HOJ79TWv.js";import{t as f}from"./attachment-utils-core-BIOUBrpT.js";import{Ha as p,Lc as m,Rc as h,Va as g,Zs as _,ca as v,sa as y,za as b,zc as x}from"./index-DmURUvvA.js";var S=e(t(),1),C=n(),w=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,T=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,E=/!\[([^\]]*)\]\[([^\]]+)\]/g;function D(e,t){let n=new Map;for(let t of e.matchAll(w))n.set(O(t[1]??``),t[2]??``);return e.replace(T,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(E,(e,r,i)=>{let a=n.get(O(i));return a?`[${r.trim()||t}](${a})`:e})}function O(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var k=r();function A(e){return(0,k.jsx)(m,{source:e.source,incomplete:!e.closed,streaming:!1,copy:!0})}function j(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function M(e){let t=(0,C.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:o,setExpanded:l}=y(),u=s(a.language),f;t[0]===u?f=t[1]:(f=async()=>{let e=await d(window.location.href);_(e?`success`:`warning`,e?u.sharesSettings.copied:u.clipboard.copyFailed)},t[0]=u,t[1]=f);let p=f,m=o&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,h;t[2]===m?h=t[3]:(h=c(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,m),t[2]=m,t[3]=h);let g;t[4]!==l||t[5]!==a.loadError||t[6]!==a.loading?(g=!a.loading&&!a.loadError?()=>l(N):void 0,t[4]=l,t[5]=a.loadError,t[6]=a.loading,t[7]=g):g=t[7];let b;t[8]===i?b=t[9]:(b=()=>window.location.assign(i),t[8]=i,t[9]=b);let x;t[10]===p?x=t[11]:(x=()=>void p(),t[10]=p,t[11]=x);let S=a.loading||!!a.loadError,w;t[12]!==x||t[13]!==S?(w={onClick:x,disabled:S},t[12]=x,t[13]=S,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==o||t[18]!==n||t[19]!==g||t[20]!==b||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:o,onToggleExpanded:g,onClose:b,share:w,openInBrowser:T},t[17]=o,t[18]=n,t[19]=g,t[20]=b,t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==a||t[25]!==E?(D=(0,k.jsx)(v,{...a,header:E}),t[24]=a,t[25]=E,t[26]=D):D=t[26];let O;return t[27]!==D||t[28]!==h?(O=(0,k.jsx)(`div`,{className:h,children:D}),t[27]=D,t[28]=h,t[29]=O):O=t[29],O}function N(e){return!e}function P(){let{token:e}=a(),t=l(e=>e.language),n=t===`zh`?L:R,[r,s]=(0,S.useState)(null),[c,d]=(0,S.useState)(j),[m,_]=(0,S.useState)(!0),[v,y]=(0,S.useState)(null),[C,w]=(0,S.useState)(null),[T,E]=(0,S.useState)(null),O=(0,S.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=g(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:b(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,S.useEffect)(()=>{if(!e){y(n.invalidLink),_(!1);return}let t=!1;return(async()=>{try{_(!0),y(null),d(j()),w(null),E(null);let r=await fetch(u(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||y(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(s(a),!a.valid){y(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(u(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){y(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&w(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let o=g(a.fileName,a.mimeType),c=b(a.fileName,o),l=p(c),m=u(`/s/${encodeURIComponent(e)}?inline=1`);if(l===`text`){if(a.fileSize>5242880){y(n.tooLarge);return}let e=await fetch(m);if(!e.ok){y(n.expired);return}let r=await e.text();t||d({...j(),textContent:r});return}if(l===`binary`){if(a.fileSize>33554432){y(n.tooLarge);return}let e=await fetch(m);if(!e.ok){y(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-Db4nTY5N.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>f;d({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,f):t,extractedTextTruncated:n});return}d({...j(),binaryBuffer:r})}}catch(e){t||y(e instanceof Error?e.message:String(e))}finally{t||_(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let N=e?u(`/s/${encodeURIComponent(e)}?dl=1`):`#`,P=e?u(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return O&&r&&e?(0,k.jsx)(M,{language:t,descriptor:O,loading:m,loadError:v,textContent:c.textContent,binaryBuffer:c.binaryBuffer,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,subtitle:(0,k.jsxs)(`span`,{className:`truncate`,children:[I(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:P,landingUrl:u(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=N},canDownload:!m&&!v}}):(0,k.jsx)(x,{children:(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,k.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,k.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):m?(0,k.jsx)(h,{className:`h-4 w-48 max-w-full`}):(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,k.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[I(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,k.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:m?(0,k.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,k.jsx)(h,{className:`h-5 w-56 max-w-full`}),(0,k.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,k.jsx)(h,{className:`h-4 w-full`}),(0,k.jsx)(h,{className:`h-4 w-11/12`}),(0,k.jsx)(h,{className:`h-4 w-10/12`}),(0,k.jsx)(h,{className:`h-4 w-3/4`})]}),(0,k.jsx)(h,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):v?(0,k.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,k.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,k.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v})]}):r?.kind===`directory`?(0,k.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&C?(0,k.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,k.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:C.title}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(C.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(C.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),C.description?(0,k.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-inset px-4 py-3 text-sm leading-6 text-fg-muted`,children:C.description}):null,(0,k.jsx)(o,{content:D(C.markdown,n.remoteImageBlocked),className:`mt-8`,renderChart:A}),(0,k.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&T?(0,k.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,k.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,k.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:T.title}),(0,k.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(T.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(T.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),T.description?(0,k.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:T.description}):null]}),(0,k.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[T.messages.map(e=>(0,k.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,k.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,k.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-inset px-4 py-3`:`px-1 py-1`,children:[(0,k.jsx)(o,{content:D(e.markdown,n.remoteImageBlocked),renderChart:A}),T.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,k.jsx)(F,{attachment:e},e.id)),T.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,k.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:e.toolName}),(0,k.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,k.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),T.toolActivities.filter(e=>!e.messageId).map(e=>(0,k.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,k.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})})}function F(e){let t=(0,C.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,k.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,k.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=I(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,k.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function I(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 L={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},R={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{P as SharePreviewPage};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./copy-Dv6d4Dvw.js";import{t as s}from"./folder-open-CyzJ19I9.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./messages-Bwv-AOYl.js";import{t as d}from"./cn-0WouolD0.js";import{a as f,c as p,n as m,r as h}from"./locale-store-D5h-Ha6-.js";import{a as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{t as S}from"./copy-to-clipboard-HOJ79TWv.js";import{i as ee}from"./vendor-swr-BIWyz7Rc.js";import{n as C,r as w}from"./gateway-config-swr-BvuySoCX.js";import{o as te}from"./agents-admin-api-D6XzhsQy.js";import{Aa as T,Bu as E,Ca as D,Da as ne,Dn as O,Ea as k,It as A,Ju as j,Kc as M,Nl as N,Oa as P,Pd as F,Rc as I,Rn as re,Rs as L,Ta as R,Vl as z,Xd as B,Ya as V,Za as H,Zd as U,_a as ie,ba as ae,da as oe,ds as se,du as ce,fs as W,ga as le,ha as ue,is as de,ka as fe,no as pe,pa as me,pf as he,va as ge,wa as _e,xa as ve,yd as ye}from"./index-DmURUvvA.js";import{t as be}from"./number-input-DDeqHK-G.js";import{n as xe,r as Se,t as G}from"./settings-page-layout-Dx5S-Msc.js";import{t as K}from"./settings-form-section-BTUFu5KS.js";var q=e(t(),1),Ce=n(),J={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],noteEnabled:!0,noteMaxTotalSizeMb:250,noteMaxAttachmentCount:50,siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function we(){return structuredClone(J)}var Y=36e5,Te=864e5,X=1048576;function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ee(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function De(e){let t=Z(e)?e:{},n=Z(t.gateway)?t.gateway:{},r=Z(n.share)?n.share:{},i=Z(r.directory)?r.directory:{},a=Z(r.note)?r.note:{},o=Z(n.siteShare)?n.siteShare:{},s=Z(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):J.defaultTtlHours*Y,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):J.maxTtlDays*Te,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):J.maxFileSizeMb*X,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):J.directoryMaxFolderSizeMb*X,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):J.siteDefaultTtlHours*Y,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):J.siteMaxTtlDays*Te,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):J.siteMaxRootDirSizeMb*X,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):J.noteMaxTotalSizeMb*X;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/Y)),maxTtlDays:Math.max(1,Math.round(l/Te)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):J.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/X)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/X)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):J.directoryMaxFileCount,inlinePreviewMimes:Ee(r.inlinePreviewMimes,32).length?Ee(r.inlinePreviewMimes,32):[...J.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/X)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):J.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/Y)),siteMaxTtlDays:Math.max(1,Math.round(p/Te)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):J.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/X)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):J.siteMaxFileCount}}function Oe(e){let t=e.defaultTtlHours*Y,n=e.maxTtlDays*Te,r=e.siteDefaultTtlHours*Y,i=e.siteMaxTtlDays*Te;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:e.noteMaxTotalSizeMb<1||e.noteMaxTotalSizeMb>2048?`Maximum Note snapshot size must be between 1 MB and 2 GB.`:e.noteMaxAttachmentCount<0||e.noteMaxAttachmentCount>500?`Maximum Note attachment count must be between 0 and 500.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function ke(e){let t=Oe(e);if(t)throw Error(t);await f(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*Y,maxTtlMs:e.maxTtlDays*Te,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*X,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*X,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*X,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*Y,maxTtlMs:e.siteMaxTtlDays*Te,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*X,maxFileCount:e.siteMaxFileCount}}}})}),C()}var Q=r();function Ae(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,L,`dark:border-edge`)}function je({hasToken:e}){let t=u(m(e=>e.language)).sharesSettings,{data:n,isLoading:r}=w(e),i=(0,q.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(De(n.payload.config)),[n]),a=(0,q.useRef)(!1),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),[p,h]=(0,q.useState)(!1),g=o??i,_=i,v=(0,q.useMemo)(()=>!g||!_?!1:JSON.stringify(g)!==JSON.stringify(_),[g,_]),y=(0,q.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),b=(0,q.useCallback)(async()=>{if(!(!g||c)){l(!0),f(null),h(!1);try{await ke(g),a.current=!1,s(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){f(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[g,c,t.policySaveError]),x=(0,q.useCallback)(()=>{a.current=!1,s(null),f(null),h(!1)},[]);return!e||!g?r?(0,Q.jsx)(K,{children:(0,Q.jsx)(O,{rows:2})}):null:(0,Q.jsxs)(K,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[p?(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Q.jsx)(M,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>y(we()),children:t.policyUseRecommended}),(0,Q.jsx)(M,{type:`button`,variant:`secondary`,disabled:!v||c,onClick:x,children:t.policyDiscard}),(0,Q.jsx)(M,{type:`button`,variant:`primary`,disabled:!v||c,onClick:()=>void b(),children:c?t.policySaving:t.policySave})]})]}),v?(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,d?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Q.jsx)(Me,{t,form:g,onChange:y})]})}function Me(e){let t=(0,Ce.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,Q.jsx)($,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,Q.jsx)($,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,Q.jsx)($,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,Q.jsx)($,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let ee=!r.enabled,C;t[47]===i?C=t[48]:(C=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=C);let w;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==ee||t[53]!==C?(w=(0,Q.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:ee,onChange:C}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=ee,t[53]=C,t[54]=w):w=t[54];let te=!r.enabled,T;t[55]===i?T=t[56]:(T=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=T);let E;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==te||t[61]!==T?(E=(0,Q.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:te,onChange:T}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=te,t[61]=T,t[62]=E):E=t[62];let D;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==w||t[67]!==E||t[68]!==p?(D=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,w,E]}),t[63]=g,t[64]=y,t[65]=S,t[66]=w,t[67]=E,t[68]=p,t[69]=D):D=t[69];let ne=!r.enabled,O;t[70]===i?O=t[71]:(O=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=O);let k;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==ne||t[75]!==O?(k=(0,Q.jsx)(Ne,{t:n,values:r.inlinePreviewMimes,disabled:ne,onChange:O}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=ne,t[75]=O,t[76]=k):k=t[76];let A;t[77]!==D||t[78]!==k||t[79]!==s||t[80]!==u?(A=(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[s,u,D,k]}),t[77]=D,t[78]=k,t[79]=s,t[80]=u,t[81]=A):A=t[81];let j;t[82]===n.policyNoteSection?j=t[83]:(j=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=j);let M;t[84]===n.policyNoteSectionHint?M=t[85]:(M=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=M);let N;t[86]!==j||t[87]!==M?(N=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[j,M]}),t[86]=j,t[87]=M,t[88]=N):N=t[88];let P;t[89]===i?P=t[90]:(P=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=P);let F;t[91]!==r.noteEnabled||t[92]!==P?(F=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:P}),t[91]=r.noteEnabled,t[92]=P,t[93]=F):F=t[93];let I;t[94]!==n.policyNoteEnabled||t[95]!==F?(I=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[F,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=F,t[96]=I):I=t[96];let re=!r.enabled||!r.noteEnabled,L;t[97]===i?L=t[98]:(L=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=L);let R;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==re||t[103]!==L?(R=(0,Q.jsx)($,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:re,onChange:L}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=re,t[103]=L,t[104]=R):R=t[104];let z=!r.enabled||!r.noteEnabled,B;t[105]===i?B=t[106]:(B=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=B);let V;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==z||t[111]!==B?(V=(0,Q.jsx)($,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:z,onChange:B}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=z,t[111]=B,t[112]=V):V=t[112];let H;t[113]!==R||t[114]!==V?(H=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[R,V]}),t[113]=R,t[114]=V,t[115]=H):H=t[115];let U;t[116]!==N||t[117]!==I||t[118]!==H?(U=(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[N,I,H]}),t[116]=N,t[117]=I,t[118]=H,t[119]=U):U=t[119];let ie;t[120]===n.policySiteSection?ie=t[121]:(ie=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=ie);let ae;t[122]===n.policySiteSectionHint?ae=t[123]:(ae=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=ae);let oe;t[124]!==ie||t[125]!==ae?(oe=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[ie,ae]}),t[124]=ie,t[125]=ae,t[126]=oe):oe=t[126];let se;t[127]===i?se=t[128]:(se=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=se);let ce;t[129]!==r.siteEnabled||t[130]!==se?(ce=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:se}),t[129]=r.siteEnabled,t[130]=se,t[131]=ce):ce=t[131];let W;t[132]!==n.policySiteEnabled||t[133]!==ce?(W=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ce,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=ce,t[134]=W):W=t[134];let le=!r.siteEnabled,ue;t[135]===i?ue=t[136]:(ue=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=ue);let de;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==le||t[141]!==ue?(de=(0,Q.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:le,onChange:ue}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=le,t[141]=ue,t[142]=de):de=t[142];let fe=!r.siteEnabled,pe;t[143]===i?pe=t[144]:(pe=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=pe);let me;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==fe||t[149]!==pe?(me=(0,Q.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:fe,onChange:pe}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=fe,t[149]=pe,t[150]=me):me=t[150];let he=!r.siteEnabled,ge;t[151]===i?ge=t[152]:(ge=e=>i({maxActiveSites:e}),t[151]=i,t[152]=ge);let _e;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==he||t[157]!==ge?(_e=(0,Q.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:he,onChange:ge}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=he,t[157]=ge,t[158]=_e):_e=t[158];let ve=!r.siteEnabled,ye;t[159]===i?ye=t[160]:(ye=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=ye);let be;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==ve||t[165]!==ye?(be=(0,Q.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:ve,onChange:ye}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=ve,t[165]=ye,t[166]=be):be=t[166];let xe=!r.siteEnabled,Se;t[167]===i?Se=t[168]:(Se=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=Se);let G;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==xe||t[173]!==Se?(G=(0,Q.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:xe,onChange:Se}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=xe,t[173]=Se,t[174]=G):G=t[174];let K;t[175]!==de||t[176]!==me||t[177]!==_e||t[178]!==be||t[179]!==G?(K=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[de,me,_e,be,G]}),t[175]=de,t[176]=me,t[177]=_e,t[178]=be,t[179]=G,t[180]=K):K=t[180];let q;t[181]!==oe||t[182]!==W||t[183]!==K?(q=(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[oe,W,K]}),t[181]=oe,t[182]=W,t[183]=K,t[184]=q):q=t[184];let J;return t[185]!==A||t[186]!==U||t[187]!==q?(J=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[A,U,q]}),t[185]=A,t[186]=U,t[187]=q,t[188]=J):J=t[188],J}function $(e){let t=(0,Ce.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=u):u=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=d(Ae(),`max-w-xs font-mono text-xs`),t[3]=f):f=t[3];let p;t[4]!==s||t[5]!==o||t[6]!==l?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==p||t[13]!==a?(m=(0,Q.jsx)(be,{id:n,type:`number`,min:o,max:s,disabled:c,className:f,value:a,onChange:p}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==u||t[18]!==m||t[19]!==h?(g=(0,Q.jsxs)(`div`,{children:[u,m,h]}),t[17]=u,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function Ne(e){let t=(0,Ce.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,Q.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let f;t[11]===u?f=t[12]:(f=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=f);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=d(Ae(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Q.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==c||t[21]!==l||t[22]!==f||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[c,l,f,g]}),t[20]=c,t[21]=l,t[22]=f,t[23]=g,t[24]=_):_=t[24],_}function Pe(e){let t=(0,Ce.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:o,conversationId:c,agentId:f}=e,h=o===void 0?`any`:o,S=u(m(Le)),C=S.workspace,w=S.sharesSettings,T=oe(Ie),{data:E}=ee(p(Fe)?`picker-agents-list`:null,te),D;bb0:{let e;t[0]===f?e=t[1]:(e=f?.trim(),t[0]=f,t[1]=e);let n=e;if(n){D=n;break bb0}let r;t[2]===T?r=t[3]:(r=T.trim(),t[2]=T,t[3]=r);let i=r;if(i){D=i;break bb0}if(E?.defaultId){D=E.defaultId;break bb0}if(E?.agents?.[0]?.id){D=E.agents[0].id;break bb0}D=``}let ne=D,[O,k]=(0,q.useState)(ne),A,N;t[4]===ne?(A=t[5],N=t[6]):(A=()=>{k(ne)},N=[ne],t[4]=ne,t[5]=A,t[6]=N),(0,q.useEffect)(A,N);let{tree:P,loading:F,error:I,loadRoot:L,loadChildren:R,reset:z}=me(O,c??null),B;t[7]===a?B=t[8]:(B=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=B);let[H,U]=(0,q.useState)(B),ie;t[9]!==a||t[10]!==L||t[11]!==n||t[12]!==z||t[13]!==U?(ie=()=>{if(!n){z(),U(a?{path:a,isDirectory:!1}:null);return}L()},t[9]=a,t[10]=L,t[11]=n,t[12]=z,t[13]=U,t[14]=ie):ie=t[14];let ae;t[15]!==c||t[16]!==a||t[17]!==L||t[18]!==n||t[19]!==O||t[20]!==z?(ae=[n,O,c,L,z,a],t[15]=c,t[16]=a,t[17]=L,t[18]=n,t[19]=O,t[20]=z,t[21]=ae):ae=t[21],(0,q.useEffect)(ie,ae);let le;t[22]===R?le=t[23]:(le=e=>{R(e)},t[22]=R,t[23]=le);let ue=le,de=H!==null&&(h===`any`||h===`file`&&!H.isDirectory||h===`directory`&&H.isDirectory),fe;bb1:{if(!H){fe=w.pickerHintNone;break bb1}if(h===`file`&&H.isDirectory){fe=w.pickerHintNeedsFile;break bb1}if(h===`directory`&&!H.isDirectory){fe=w.pickerHintNeedsDirectory;break bb1}fe=`${H.isDirectory?`📁`:`📄`} ${H.path}`}let pe=fe,he=E?.agents??[],ge;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Q.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=ge):ge=t[24];let _e;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(_e=d(`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-overlay shadow-popover outline-none`),t[25]=_e):_e=t[25];let ve;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(s,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=ve):ve=t[26];let ye=S.cron.refresh,be=S.cron.refresh,xe;t[27]===L?xe=t[28]:(xe=()=>void L(),t[27]=L,t[28]=xe);let Se=F&&`animate-spin`,G;t[29]===Se?G=t[30]:(G=d(`size-4`,Se),t[29]=Se,t[30]=G);let K;t[31]===G?K=t[32]:(K=(0,Q.jsx)(ce,{className:G,"aria-hidden":!0}),t[31]=G,t[32]=K);let J;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Q.jsx)(l,{className:`size-4`}),t[33]=J):J=t[33];let we;t[34]!==I||t[35]!==C.loadError?(we=I?(0,Q.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[C.loadError,`: `,I]}):null,t[34]=I,t[35]=C.loadError,t[36]=we):we=t[36];let Y;t[37]!==ue||t[38]!==F||t[39]!==H?.path||t[40]!==U||t[41]!==C.emptyDir||t[42]!==C.title||t[43]!==P?(Y=F&&P.length===0?(0,Q.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Q.jsx)(j,{className:`size-4 animate-spin`}),C.title,`…`]}):(0,Q.jsx)(V,{tree:P,selectedPath:H?.path??null,onSelectFile:e=>U({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>U({path:e,isDirectory:t}),onExpandDir:ue,onAction:void 0,emptyHint:C.emptyDir}),t[37]=ue,t[38]=F,t[39]=H?.path,t[40]=U,t[41]=C.emptyDir,t[42]=C.title,t[43]=P,t[44]=Y):Y=t[44];let Te;t[45]!==we||t[46]!==Y?(Te=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[we,Y]}),t[45]=we,t[46]=Y,t[47]=Te):Te=t[47];let X;t[48]===pe?X=t[49]:(X=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:pe}),t[48]=pe,t[49]=X);let Z;t[50]===r?Z=t[51]:(Z=()=>r(!1),t[50]=r,t[51]=Z);let Ee;t[52]!==w.cancel||t[53]!==Z?(Ee=(0,Q.jsx)(M,{type:`button`,variant:`ghost`,onClick:Z,children:w.cancel}),t[52]=w.cancel,t[53]=Z,t[54]=Ee):Ee=t[54];let De=!de,Oe;t[55]!==i||t[56]!==r||t[57]!==O||t[58]!==H?(Oe=()=>{H&&(i({...H,agentId:O}),r(!1))},t[55]=i,t[56]=r,t[57]=O,t[58]=H,t[59]=Oe):Oe=t[59];let ke;t[60]!==w.pickerConfirm||t[61]!==De||t[62]!==Oe?(ke=(0,Q.jsx)(M,{type:`button`,disabled:De,onClick:Oe,children:w.pickerConfirm}),t[60]=w.pickerConfirm,t[61]=De,t[62]=Oe,t[63]=ke):ke=t[63];let Ae;t[64]!==Ee||t[65]!==ke?(Ae=(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Ee,ke]}),t[64]=Ee,t[65]=ke,t[66]=Ae):Ae=t[66];let je;return t[67]!==X||t[68]!==Ae?(je=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[X,Ae]}),t[67]=X,t[68]=Ae,t[69]=je):je=t[69],(0,Q.jsx)(x,{open:n,onOpenChange:r,children:(0,Q.jsxs)(v,{children:[ge,(0,Q.jsxs)(y,{className:_e,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[ve,(0,Q.jsx)(b,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:w.pickerTitle}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:ye,"aria-label":be,disabled:F,onClick:xe,children:K}),(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C.close,children:J})})]}),he.length>0?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:w.pickerAgentLabel}),(0,Q.jsx)(se,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:O,onChange:e=>{k(e.target.value),U(null)},children:he.map(e=>(0,Q.jsxs)(W,{value:e.id,children:[re(e,S.agentsSettings),e.id===E?.defaultId?` ★`:``]},e.id))})]}):null,Te,je]})]})})}function Fe(e){return e.conversationId}function Ie(e){return e.agentId}function Le(e){return e.language}var Re=[`shares`,`policy`];function ze(e){let t=(e??``).trim();return Re.includes(t)?t:`shares`}function Be(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Ve(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var He=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function Ue(){let e=(0,Ce.c)(23),t=m(Ge),n=u(t).sharesSettings,r=!!p(We),[a,o]=i(),s;e[0]===a?s=e[1]:(s=ze(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let d=l;if(!r)return(0,Q.jsx)(Se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let f={shares:n.tabShares,policy:n.tabPolicy},h=Re.map(e=>({id:e,label:f[e]})),g;e[4]===n.title?g=e[5]:(g=(0,Q.jsx)(xe,{title:n.title}),e[4]=n.title,e[5]=g);let _;e[6]!==c||e[7]!==d||e[8]!==n.tabsAria||e[9]!==h?(_=(0,Q.jsx)(de,{items:h,activeTab:c,onChange:d,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[6]=c,e[7]=d,e[8]=n.tabsAria,e[9]=h,e[10]=_):_=e[10];let v;e[11]!==c||e[12]!==r||e[13]!==t||e[14]!==n?(v=c===`shares`?(0,Q.jsx)(Ke,{t:n,language:t}):(0,Q.jsx)(je,{hasToken:r}),e[11]=c,e[12]=r,e[13]=t,e[14]=n,e[15]=v):v=e[15];let y;e[16]!==c||e[17]!==v?(y=(0,Q.jsx)(G,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[16]=c,e[17]=v,e[18]=y):y=e[18];let b;return e[19]!==g||e[20]!==_||e[21]!==y?(b=(0,Q.jsxs)(Se,{children:[g,_,y]}),e[19]=g,e[20]=_,e[21]=y,e[22]=b):b=e[22],b}function We(e){return e.conversationId}function Ge(e){return e.language}function Ke(e){let t=(0,Ce.c)(79),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=ee(`shares-list`,D,i),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:3e4},t[1]=l):l=t[1];let u=ee(`hosted-publications-list`,ve,l),f;t[2]===a?.payload?.shares?f=t[3]:(f=a?.payload?.shares??[],t[2]=a?.payload?.shares,t[3]=f);let p=f,[m,h]=(0,q.useState)(!1),g;bb0:{if(m){g=p;break bb0}let e;t[4]===p?e=t[5]:(e=p.filter(Ze),t[4]=p,t[5]=e),g=e}let _=g,v;t[6]===p?v=t[7]:(v=p.filter(Xe),t[6]=p,t[7]=v);let y=v.length,b;t[8]===p?b=t[9]:(b=p.filter(Ye),t[8]=p,t[9]=b);let x=b.length,S;t[10]===c?S=t[11]:(S=()=>void c(),t[10]=c,t[11]=S);let C;t[12]!==n||t[13]!==S?(C=(0,Q.jsx)(rt,{t:n,onCreated:S}),t[12]=n,t[13]=S,t[14]=C):C=t[14];let w=u.data?.connected===!0,te=u.data?.publishingAllowed===!0,T;t[15]===u?T=t[16]:(T=()=>void u.mutate(),t[15]=u,t[16]=T);let E;t[17]!==r||t[18]!==te||t[19]!==T||t[20]!==w?(E=(0,Q.jsx)(Qe,{language:r,connected:w,publishingAllowed:te,onCreated:T}),t[17]=r,t[18]=te,t[19]=T,t[20]=w,t[21]=E):E=t[21];let ne=m?n.allSharesTitle:n.listTitle,O;t[22]===y?O=t[23]:(O=y>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,y,`)`]}),t[22]=y,t[23]=O);let k;t[24]!==ne||t[25]!==O?(k=(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[ne,O]}),t[24]=ne,t[25]=O,t[26]=k):k=t[26];let A;t[27]===c?A=t[28]:(A=()=>void c(),t[27]=c,t[28]=A);let j=s&&`animate-spin`,N;t[29]===j?N=t[30]:(N=d(`size-3.5`,j),t[29]=j,t[30]=N);let P;t[31]===N?P=t[32]:(P=(0,Q.jsx)(ce,{className:N}),t[31]=N,t[32]=P);let F;t[33]!==s||t[34]!==A||t[35]!==P?(F=(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:A,disabled:s,children:P}),t[33]=s,t[34]=A,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==x||t[38]!==m||t[39]!==n.hideExpired||t[40]!==n.showExpired?(I=x>0&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>h(Je),children:m?n.hideExpired:n.showExpired}),t[37]=x,t[38]=m,t[39]=n.hideExpired,t[40]=n.showExpired,t[41]=I):I=t[41];let re;t[42]!==F||t[43]!==I?(re=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F,I]}),t[42]=F,t[43]=I,t[44]=re):re=t[44];let L;t[45]!==k||t[46]!==re?(L=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[k,re]}),t[45]=k,t[46]=re,t[47]=L):L=t[47];let R;t[48]!==a||t[49]!==o||t[50]!==_||t[51]!==s||t[52]!==r||t[53]!==c||t[54]!==n?(R=s&&!a?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(qe)}):o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Q.jsx)(`span`,{children:n.error}),(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):_.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:_.map(e=>(0,Q.jsx)(at,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[48]=a,t[49]=o,t[50]=_,t[51]=s,t[52]=r,t[53]=c,t[54]=n,t[55]=R):R=t[55];let z;t[56]!==x||t[57]!==c||t[58]!==m||t[59]!==n?(z=x>0&&m&&(0,Q.jsx)(ot,{t:n,onCleaned:()=>void c()}),t[56]=x,t[57]=c,t[58]=m,t[59]=n,t[60]=z):z=t[60];let B;t[61]!==L||t[62]!==R||t[63]!==z?(B=(0,Q.jsxs)(K,{children:[L,R,z]}),t[61]=L,t[62]=R,t[63]=z,t[64]=B):B=t[64];let V;t[65]===u?V=t[66]:(V=()=>void u.mutate(),t[65]=u,t[66]=V);let H;t[67]!==u.data||t[68]!==u.error||t[69]!==u.isLoading||t[70]!==r||t[71]!==n||t[72]!==V?(H=(0,Q.jsx)($e,{data:u.data,error:u.error,isLoading:u.isLoading,language:r,t:n,onChanged:V}),t[67]=u.data,t[68]=u.error,t[69]=u.isLoading,t[70]=r,t[71]=n,t[72]=V,t[73]=H):H=t[73];let U;return t[74]!==E||t[75]!==B||t[76]!==H||t[77]!==C?(U=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[C,E,B,H]}),t[74]=E,t[75]=B,t[76]=H,t[77]=C,t[78]=U):U=t[78],U}function qe(e,t){return(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(I,{className:`h-4 w-2/3`}),(0,Q.jsx)(I,{className:`mt-2 h-3 w-1/2`})]}),(0,Q.jsx)(I,{className:`h-7 w-20 rounded-md`})]})},t)}function Je(e){return!e}function Ye(e){return e.expired||e.revoked}function Xe(e){return!e.expired&&!e.revoked}function Ze(e){return!e.expired&&!e.revoked}function Qe({language:e,connected:t,publishingAllowed:n,onCreated:r}){let i=e===`zh`,[a,o]=(0,q.useState)(``),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(6048e5),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(null),[ee,C]=(0,q.useState)(null),w=async()=>{if(a.trim()){y(!0),C(null);try{x(await le({path:a.trim(),title:m.trim()||void 0,ttlMs:g,spaFallback:!0,...c?{agentId:c}:{}})),r()}catch(e){C(e instanceof Error?e.message:String(e))}finally{y(!1)}}};return(0,Q.jsxs)(K,{children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(B,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`发布静态网站`:`Publish static website`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i?`把工作区内的 HTML 文件,或包含 index.html 的网站目录,发布到隔离的托管域名。`:`Publish an HTML file or a website directory containing index.html to the isolated hosted origin.`}),t&&!n?(0,Q.jsx)(`p`,{className:`mt-3 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning`,children:i?`管理员已暂停你的公网分享能力。已有远端链接当前不可访问;你仍可在下方撤销它们。`:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but you can still revoke them below.`}):null,(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-[1fr_12rem]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`input`,{value:a,onChange:e=>{o(e.target.value),d(!1),x(null)},placeholder:i?`选择 HTML 文件或网站目录`:`Select an HTML file or website directory`,className:`h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`}),(0,Q.jsxs)(M,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>p(!0),children:[a&&!u?(0,Q.jsx)(F,{className:`size-4`}):(0,Q.jsx)(s,{className:`size-4`}),a?i?`更换`:`Change`:i?`选择`:`Browse`]})]}),(0,Q.jsxs)(se,{value:String(g),onChange:e=>_(Number(e.target.value)),children:[(0,Q.jsx)(W,{value:`86400000`,children:i?`24 小时`:`24 hours`}),(0,Q.jsx)(W,{value:`604800000`,children:i?`7 天`:`7 days`}),(0,Q.jsx)(W,{value:`2592000000`,children:i?`30 天`:`30 days`})]}),(0,Q.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:i?`网站标题(可选)`:`Site title (optional)`,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent sm:col-span-2`})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,Q.jsxs)(M,{type:`button`,onClick:()=>void w(),disabled:!a.trim()||v||!t||!n,children:[v?(0,Q.jsx)(j,{className:`size-4 animate-spin`}):(0,Q.jsx)(B,{className:`size-4`}),v?i?`发布中…`:`Publishing…`:i?`发布网站`:`Publish site`]}),b?(0,Q.jsxs)(`button`,{type:`button`,className:`min-w-0 truncate text-xs text-accent hover:underline`,onClick:()=>void S(b.shareUrl),children:[b.shareUrl,` · `,b.fileCount,` `,i?`个文件`:`files`,` · `,Be(b.totalBytes)]}):null]}),ee?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:ee}):null]})]}),(0,Q.jsx)(Pe,{open:f,onOpenChange:p,initialPath:a||void 0,agentId:c||void 0,selectKind:`any`,onConfirm:e=>{o(e.path),l(e.agentId),d(e.isDirectory),x(null),C(null)}})]})}function $e(e){let t=(0,Ce.c)(18),{data:n,error:r,isLoading:i,language:a,t:o,onChanged:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(B,{className:`size-4 text-accent`,"aria-hidden":!0}),t[0]=c):c=t[0];let l;t[1]===o.hostedTitle?l=t[2]:(l=(0,Q.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[c,o.hostedTitle]}),t[1]=o.hostedTitle,t[2]=l);let u;t[3]===o.hostedHint?u=t[4]:(u=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.hostedHint}),t[3]=o.hostedHint,t[4]=u);let d;t[5]!==l||t[6]!==u?(d=(0,Q.jsx)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:(0,Q.jsxs)(`div`,{children:[l,u]})}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==r||t[10]!==i||t[11]!==a||t[12]!==s||t[13]!==o?(f=i&&!n?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:2}).map(et)}):r?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o.error}):n?.connected?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[n.publishingAllowed?null:(0,Q.jsx)(`p`,{className:`rounded-md bg-warning-soft px-3 py-2 text-xs text-warning`,children:a===`zh`?`管理员已暂停公网分享。已有托管链接当前不可访问,也不能更新;撤销操作仍然可用。`:`An administrator has paused public sharing. Existing hosted links are unavailable and cannot be updated; revocation remains available.`}),n.publications.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedEmpty}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.publications.map(e=>(0,Q.jsx)(tt,{publication:e,language:a,t:o,publishingAllowed:n.publishingAllowed,onChanged:s},e.id))})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedDisconnected}),(0,Q.jsx)(A,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:s})]}),t[8]=n,t[9]=r,t[10]=i,t[11]=a,t[12]=s,t[13]=o,t[14]=f):f=t[14];let p;return t[15]!==d||t[16]!==f?(p=(0,Q.jsxs)(K,{children:[d,f]}),t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function et(e,t){return(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:[(0,Q.jsx)(I,{className:`h-4 w-2/3`}),(0,Q.jsx)(I,{className:`mt-2 h-3 w-1/2`})]},t)}function tt({publication:e,language:t,t:n,publishingAllowed:r,onChanged:i}){let[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1),v=Date.now()>=new Date(e.expiresAt).getTime(),y=e.status===`active`&&!v,b=e.status===`revoked`?n.statusRevoked:v?n.statusExpired:e.status===`staging`?t===`zh`?`准备中`:`Staging`:n.statusActive,x=e.kind===`note_document`?z:e.kind===`static_site`?B:E,ee=e.kind===`note_document`?t===`zh`?`笔记文档`:`Note document`:e.kind===`static_site`?t===`zh`?`静态网站`:`Static website`:t===`zh`?`会话快照`:`Conversation snapshot`,C=(0,q.useCallback)(async()=>{e.shareUrl&&await S(e.shareUrl)&&(p(!0),window.setTimeout(()=>p(!1),2e3))},[e.shareUrl]),w=(0,q.useCallback)(async()=>{c(!1),u(!0);try{await R(e.id),i()}catch{}finally{u(!1)}},[e.id,i]),te=(0,q.useCallback)(async()=>{if(!(!e.revision||e.revision<=1)){h(!0);try{let t=(await ae(e.id)).find(t=>t.revision<e.revision);if(!t)return;await ne(e.id,e.revision,t.revision),i()}catch{}finally{h(!1)}}},[e.id,e.revision,i]),T=(0,q.useCallback)(async()=>{_(!0);try{await _e(e.id),i()}catch{}finally{_(!1)}},[e.id,i]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2.5`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,Q.jsx)(`span`,{className:d(`text-xs font-medium`,y?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`),children:b})]}),(0,Q.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[ee,` · `,n.hostedRevision,` `,e.revision??`—`,` · `,e.managedFromThisDevice?n.hostedThisDevice:n.hostedOtherDevice]}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{children:[t===`zh`?`浏览`:`Views`,`: `,e.viewCount,e.maxViews===null?``:` / ${e.maxViews}`]}),(0,Q.jsx)(`span`,{children:v?n.statusExpired:Ve(e.expiresAt,t)}),e.description?(0,Q.jsx)(`span`,{className:`italic`,children:e.description}):null]})]}),y?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.shareUrl?(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:!r,title:n.copyUrl,onClick:()=>void C(),children:f?(0,Q.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(o,{className:`size-3.5`})}):null,(e.revision??0)>1?(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:m||!r,onClick:()=>void te(),title:t===`zh`?`回滚上一版本`:`Roll back one revision`,children:m?(0,Q.jsx)(j,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(ye,{className:`size-3.5`})}):null,e.kind===`static_site`&&e.managedFromThisDevice?(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:g||!r,onClick:()=>void T(),title:t===`zh`?`发布工作区中的最新版本`:`Publish latest workspace version`,children:(0,Q.jsx)(ce,{className:d(`size-3.5`,g&&`animate-spin`)})}):null,(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,disabled:l,onClick:()=>c(!0),children:l?(0,Q.jsx)(j,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(N,{className:`size-3.5`})})]}):null]})}),(0,Q.jsx)(H,{open:s,title:n.revokeConfirmTitle,description:n.revokeConfirmBody,confirmLabel:n.revokeConfirmLabel,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void w(),onCancel:()=>c(!1)})]})}var nt={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function rt({t:e,onCreated:t}){let[n,r]=(0,q.useReducer)(pe,nt),{expanded:i,path:a,isDirectory:o,agentId:s,ttlMs:l,maxViews:u,description:f,directoryMode:p,creating:m,result:h,errorMsg:g,resultDialogOpen:_,pickerOpen:v}=n,y=(0,q.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await ie({path:a.trim(),ttlMs:l,maxViews:u,description:f.trim()||void 0,...s?{agentId:s}:{},...o?{kind:`directory`,directoryMode:p}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,o,s,l,u,f,p,t]),b=(0,q.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Q.jsxs)(K,{children:[(0,Q.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:d(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:o?`📁`:`📄`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,Q.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Q.jsxs)(M,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Q.jsx)(F,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),o?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Q.jsxs)(se,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:p,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Q.jsx)(W,{value:`browse`,children:e.directoryModeBrowse}),(0,Q.jsx)(W,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Q.jsx)(se,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:l,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:He.map(t=>(0,Q.jsx)(W,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Q.jsxs)(se,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:u??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Q.jsx)(W,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Q.jsx)(W,{value:`1`,children:`1`}),(0,Q.jsx)(W,{value:`5`,children:`5`}),(0,Q.jsx)(W,{value:`10`,children:`10`}),(0,Q.jsx)(W,{value:`50`,children:`50`}),(0,Q.jsx)(W,{value:`100`,children:`100`})]})]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Q.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:f,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsxs)(M,{type:`button`,disabled:m||!a.trim(),onClick:()=>void y(),children:[m?(0,Q.jsx)(j,{className:`size-4 animate-spin`}):(0,Q.jsx)(c,{className:`size-4`}),m?e.creating:e.createButton]}),(0,Q.jsx)(M,{type:`button`,variant:`ghost`,onClick:()=>{b(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),g&&(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g})]}),(0,Q.jsx)(fe,{open:_,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:h}),(0,Q.jsx)(Pe,{open:v,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Q.jsxs)(M,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Q.jsx)(c,{className:`size-4`}),e.createTitle]})}var it={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function at({share:e,t,language:n,onRevoked:r,onExtended:i}){let[s,c]=(0,q.useReducer)(pe,it),{revokeOpen:l,revoking:u,linksOpen:f,urlCopied:p,copyFailed:m,extending:h}=s,g=!e.expired&&!e.revoked,_=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,v=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,y=(0,q.useCallback)(async()=>{c({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await k(e.id),r()}catch{}finally{c({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),b=(0,q.useCallback)(async()=>{if(c({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await S(e.shareUrl)){c({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>c({type:`patch`,patch:{copyFailed:!1}}),2500);return}c({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>c({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),x=(0,q.useCallback)(async()=>{c({type:`patch`,patch:{extending:!0}});try{await ge(e.id,864e5),i()}catch{}finally{c({type:`patch`,patch:{extending:!1}})}},[e.id,i]),ee=`share-links-${e.id}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:d(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":f,"aria-controls":ee,onClick:()=>c({type:`patch`,patch:{linksOpen:!f}}),children:[(0,Q.jsx)(he,{className:d(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,f?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,Q.jsx)(z,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,Q.jsx)(E,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,Q.jsx)(F,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:d(`text-xs font-medium`,v),children:_})]}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`:e.kind===`session`?n===`zh`?`会话快照 · ${e.messageCount??0} 条消息 · 版本 ${e.snapshotRevision??1}`:`Conversation snapshot · ${e.messageCount??0} messages · revision ${e.snapshotRevision??1}`:e.workspaceRelativePath}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Be(e.fileSize)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(U,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Ve(e.expiresAt,n)]}),(0,Q.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Q.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:g&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void b(),children:p?(0,Q.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(o,{className:`size-3.5`})}),(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void x(),disabled:h,title:t.extend,children:h?(0,Q.jsx)(j,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(U,{className:`size-3.5`})}),(0,Q.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>c({type:`patch`,patch:{revokeOpen:!0}}),disabled:u,children:u?(0,Q.jsx)(j,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(N,{className:`size-3.5`})})]})})]}),g&&f?(0,Q.jsxs)(`div`,{id:ee,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Q.jsx)(T,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),m?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(P,{reachability:e.reachability})})]}):null]}),(0,Q.jsx)(H,{open:l,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void y(),onCancel:()=>c({type:`patch`,patch:{revokeOpen:!1}})})]})}function ot({t:e,onCleaned:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(!1),o=(0,q.useCallback)(async()=>{r(!1),a(!0);try{await ue(),t()}catch{}finally{a(!1)}},[t]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(M,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,Q.jsx)(j,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(N,{className:`size-3.5`}),e.cleanExpired]})}),(0,Q.jsx)(H,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{Ue as SharesSettingsPanel};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-0WouolD0.js";import{c as r,i,r as a}from"./locale-store-Jnhw2WMv.js";import{ia as o}from"./index-cmsFpzI8.js";import"./skill-reload-api-1xNCuBFH.js";var s=`https://skillhub.cn`,c=`https://clawhub.ai`;function l(e){let t=e.trim();return t?`${s}/skills/${encodeURIComponent(t)}`:null}function u(e){let t=e.trim();return t?`${c}/${encodeURIComponent(t)}`:null}function d(e,t){return e===`skillhub`?l(t):e===`clawhub`?u(t):null}function f(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function p(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function m(e){return e.filter(e=>e.type!==`collision`)}function h(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function g(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}var _=e(),v=t(),y=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function b(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function x(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function S(e){let t=(0,_.c)(9),{name:r,className:i}=e,a;t[0]===r?a=t[1]:(a=x(r),t[0]=r,t[1]=a);let o=a,s=y[b(r)%y.length],c;t[2]!==i||t[3]!==s.dark||t[4]!==s.light?(c=n(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,i),t[2]=i,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,v.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}async function C(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`),n.append(`target`,t.target??`global`);let i=new Headers,o=await fetch(a(`/api/skills/upload`),{method:`POST`,headers:i,body:n});o.status===401&&r.getState().onUnauthorized();let s=await o.json().catch(()=>({}));if(!o.ok)throw Error(s.error||`HTTP ${o.status}`);if(!s.payload?.skillId)throw Error(`Invalid response`);return s.payload}async function w(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,r=await i(a(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!r.ok)throw Error(await o(r))}async function T(e,t){let n=await i(a(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await o(n))}function E(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function D(e){let t=new URLSearchParams;E(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let n=t.toString(),r=await i(a(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function O(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),E(t,e.provider);let n=t.toString(),r=await i(a(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function k(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;E(r,t?.provider);let s=r.toString(),c=await i(a(`/api/skills/marketplace/packages/${n}${s?`?${s}`:``}`),{cache:`no-store`});if(!c.ok)throw Error(await o(c));let l=(await c.json()).payload;if(!l?.name||!l.skillDocPreview||typeof l.skillDocPreview.name!=`string`||typeof l.skillDocPreview.description!=`string`||typeof l.skillDocPreview.bodyMarkdown!=`string`||typeof l.skillDocPreview.disableModelInvocation!=`boolean`||!l.skillDocPreview.metadata||typeof l.skillDocPreview.metadata!=`object`||typeof l.skillDocPreview.metadata.name!=`string`||typeof l.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return l}async function A(e){let t=await i(a(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`global`,...e})});if(!t.ok)throw Error(await o(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function j(e){let t=await i(a(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function M(){let e=await i(a(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function N(){let e=await i(a(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}export{g as _,N as a,A as c,S as d,m as f,d as g,f as h,M as i,T as l,p as m,D as n,O as o,h as p,k as r,j as s,w as t,C as u};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-0WouolD0.js";import{c as r,i,r as a}from"./locale-store-D5h-Ha6-.js";import{ia as o}from"./index-DmURUvvA.js";import"./skill-reload-api-BJsPnE87.js";var s=`https://skillhub.cn`,c=`https://clawhub.ai`;function l(e){let t=e.trim();return t?`${s}/skills/${encodeURIComponent(t)}`:null}function u(e){let t=e.trim();return t?`${c}/${encodeURIComponent(t)}`:null}function d(e,t){return e===`skillhub`?l(t):e===`clawhub`?u(t):null}function f(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function p(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function m(e){return e.filter(e=>e.type!==`collision`)}function h(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function g(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}var _=e(),v=t(),y=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function b(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function x(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function S(e){let t=(0,_.c)(9),{name:r,className:i}=e,a;t[0]===r?a=t[1]:(a=x(r),t[0]=r,t[1]=a);let o=a,s=y[b(r)%y.length],c;t[2]!==i||t[3]!==s.dark||t[4]!==s.light?(c=n(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,i),t[2]=i,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,v.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}async function C(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`),n.append(`target`,t.target??`global`);let i=new Headers,o=await fetch(a(`/api/skills/upload`),{method:`POST`,headers:i,body:n});o.status===401&&r.getState().onUnauthorized();let s=await o.json().catch(()=>({}));if(!o.ok)throw Error(s.error||`HTTP ${o.status}`);if(!s.payload?.skillId)throw Error(`Invalid response`);return s.payload}async function w(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,r=await i(a(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!r.ok)throw Error(await o(r))}async function T(e,t){let n=await i(a(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await o(n))}function E(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function D(e){let t=new URLSearchParams;E(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let n=t.toString(),r=await i(a(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function O(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),E(t,e.provider);let n=t.toString(),r=await i(a(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function k(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;E(r,t?.provider);let s=r.toString(),c=await i(a(`/api/skills/marketplace/packages/${n}${s?`?${s}`:``}`),{cache:`no-store`});if(!c.ok)throw Error(await o(c));let l=(await c.json()).payload;if(!l?.name||!l.skillDocPreview||typeof l.skillDocPreview.name!=`string`||typeof l.skillDocPreview.description!=`string`||typeof l.skillDocPreview.bodyMarkdown!=`string`||typeof l.skillDocPreview.disableModelInvocation!=`boolean`||!l.skillDocPreview.metadata||typeof l.skillDocPreview.metadata!=`object`||typeof l.skillDocPreview.metadata.name!=`string`||typeof l.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return l}async function A(e){let t=await i(a(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`global`,...e})});if(!t.ok)throw Error(await o(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function j(e){let t=await i(a(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function M(){let e=await i(a(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function N(){let e=await i(a(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}export{g as _,N as a,A as c,S as d,m as f,d as g,f as h,M as i,T as l,p as m,D as n,O as o,h as p,k as r,j as s,w as t,C as u};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,r as n}from"./locale-store-D5h-Ha6-.js";import{ia as r}from"./index-DmURUvvA.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};