@xopcai/xopc 0.0.475 → 0.0.476

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 (136) 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/server/chunks.bin +916 -865
  4. package/dist/gateway/server/chunks.json +1 -1
  5. package/dist/gateway/server/schema.sql +13 -0
  6. package/dist/gateway/server/upgrades/281_session_agent_reactions.sql +13 -0
  7. package/dist/gateway/static/root/assets/{apps-page-BknrhGJ9.js → apps-page-B9Ho8S53.js} +1 -1
  8. package/dist/gateway/static/root/assets/{automations-page-C1s0jwt9.js → automations-page-BL6ASYrU.js} +1 -1
  9. package/dist/gateway/static/root/assets/{automations-workspace-DIwYmYb1.js → automations-workspace-BFk-AF43.js} +2 -2
  10. package/dist/gateway/static/root/assets/{capabilities-page-2vSlbM-C.js → capabilities-page-D9EpUcuB.js} +2 -2
  11. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CfEq0ob4.js → capabilities-settings-panel-ComYXaP1.js} +1 -1
  12. package/dist/gateway/static/root/assets/{channels-Bi0L3VP1.js → channels-Aa2Iun4r.js} +1 -1
  13. package/dist/gateway/static/root/assets/chat-page-BbahuZ59.js +72 -0
  14. package/dist/gateway/static/root/assets/{chat-terminal-dock-CYAZic7B.js → chat-terminal-dock-BALrP7_l.js} +1 -1
  15. package/dist/gateway/static/root/assets/{connectors-page-Bn6Z5xfy.js → connectors-page-BUqNvStL.js} +1 -1
  16. package/dist/gateway/static/root/assets/{extension-debug-page-CNrjzlYX.js → extension-debug-page-gW4GEEcj.js} +1 -1
  17. package/dist/gateway/static/root/assets/{extension-iframe-host-DnautIj8.js → extension-iframe-host-DOPywUKI.js} +1 -1
  18. package/dist/gateway/static/root/assets/{extension-message-router-D81YD6lm.js → extension-message-router-TTAx3dPv.js} +1 -1
  19. package/dist/gateway/static/root/assets/{extension-page-BEY_ML_j.js → extension-page-Iq7vFC-g.js} +1 -1
  20. package/dist/gateway/static/root/assets/{extension-provider-CrMilva_.js → extension-provider-BNnLkq95.js} +1 -1
  21. package/dist/gateway/static/root/assets/{extension-settings-page-QRbfKUay.js → extension-settings-page-C0oLjaz6.js} +1 -1
  22. package/dist/gateway/static/root/assets/{home-page-Cs1kOdTH.js → home-page-pT-lEQsu.js} +3 -3
  23. package/dist/gateway/static/root/assets/index-BtHMU5k4.css +1 -0
  24. package/dist/gateway/static/root/assets/{index-D0R_YIRE.js → index-DdEh8KeB.js} +5 -5
  25. package/dist/gateway/static/root/assets/{local-app-workbench-page-DLGY-zR3.js → local-app-workbench-page-ReBczGac.js} +1 -1
  26. package/dist/gateway/static/root/assets/{note-detail-panel-BS7pKIMu.js → note-detail-panel-DAhIT6xP.js} +3 -3
  27. package/dist/gateway/static/root/assets/{notes-page-DBz5y6aX.js → notes-page-zAJJ2OiQ.js} +1 -1
  28. package/dist/gateway/static/root/assets/{page-context-capture-button-Dtvz4KwD.js → page-context-capture-button-Bd__UBi9.js} +1 -1
  29. package/dist/gateway/static/root/assets/{personal-page-DpmhcQoZ.js → personal-page-DHik8uj6.js} +1 -1
  30. package/dist/gateway/static/root/assets/{personal-profile-settings-KGDtrQK7.js → personal-profile-settings-Cd2xUVbw.js} +1 -1
  31. package/dist/gateway/static/root/assets/{personal-settings-panel-DBlUrnCy.js → personal-settings-panel-CHRra9hc.js} +1 -1
  32. package/dist/gateway/static/root/assets/{preview-runtime-BWkErYI2.js → preview-runtime-MJUo7XlD.js} +1 -1
  33. package/dist/gateway/static/root/assets/{project-detail-page-D6Y3kdtF.js → project-detail-page-BBF8eVJa.js} +1 -1
  34. package/dist/gateway/static/root/assets/{route-preload-CvsNMwNp.js → route-preload-Bl10PwKS.js} +2 -2
  35. package/dist/gateway/static/root/assets/{routine-panel-Cudq6VgR.js → routine-panel-BjqenuXU.js} +2 -2
  36. package/dist/gateway/static/root/assets/{session-manager-CJvUtul5.js → session-manager-fvJusKsK.js} +1 -1
  37. package/dist/gateway/static/root/assets/{settings-page-DEU9sOgT.js → settings-page-B_8kxJQW.js} +1 -1
  38. package/dist/gateway/static/root/assets/{share-preview-page-BRQ6t9CI.js → share-preview-page-C49EIXte.js} +1 -1
  39. package/dist/gateway/static/root/assets/{shares-settings-CQSN1jLt.js → shares-settings-C_ITdQqP.js} +1 -1
  40. package/dist/gateway/static/root/assets/{space-page-Cjp2j2Xx.js → space-page-DmvjU1jc.js} +1 -1
  41. package/dist/gateway/static/root/assets/{task-detail-page-CH7jSUWA.js → task-detail-page-DHYm_bsg.js} +1 -1
  42. package/dist/gateway/static/root/assets/{task-header-title-DemBzQyz.js → task-header-title-Buwr7WTV.js} +1 -1
  43. package/dist/gateway/static/root/assets/{task-result-evidence-ZKcxDYVE.js → task-result-evidence-DpV1mZJA.js} +1 -1
  44. package/dist/gateway/static/root/assets/{use-composer-attachments-O2une3Cn.js → use-composer-attachments-4FKbf6PB.js} +1 -1
  45. package/dist/gateway/static/root/assets/{use-file-preview-expanded-6TirYKSr.js → use-file-preview-expanded-CRBn6UTd.js} +1 -1
  46. package/dist/gateway/static/root/assets/{use-personal-work-CaO6D7sJ.js → use-personal-work-srLCZOam.js} +1 -1
  47. package/dist/gateway/static/root/assets/{use-realtime-voice-D3hr1-yf.js → use-realtime-voice-tyo85cre.js} +1 -1
  48. package/dist/gateway/static/root/assets/{use-workspace-tree-D6IwkuTh.js → use-workspace-tree-VwHdfiR8.js} +1 -1
  49. package/dist/gateway/static/root/assets/{voice-settings-BgdC-Ae5.js → voice-settings-DOajN2ay.js} +1 -1
  50. package/dist/gateway/static/root/assets/{workspace-api-DdVYTEEV.js → workspace-api-CIfedJeG.js} +2 -2
  51. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BTLLCHMI.js → workspace-file-preview-dialog-Xi5feqPq.js} +1 -1
  52. package/dist/gateway/static/root/index.html +17 -17
  53. package/dist/package.js +1 -1
  54. package/dist/src/agent/agent-manager.d.ts +1 -0
  55. package/dist/src/agent/agent-manager.js +1 -0
  56. package/dist/src/agent/mcp/conversation-setup.d.ts +1 -0
  57. package/dist/src/agent/mcp/conversation-setup.js +24 -0
  58. package/dist/src/agent/service.js +1 -0
  59. package/dist/src/agent/service.types.d.ts +1 -0
  60. package/dist/src/agent/tools/capability-catalog-tool.d.ts +10 -0
  61. package/dist/src/agent/tools/capability-catalog-tool.js +63 -0
  62. package/dist/src/agent/tools/factory.d.ts +1 -0
  63. package/dist/src/agent/tools/factory.js +25 -0
  64. package/dist/src/agent/tools/xopc-use-tool.d.ts +1 -0
  65. package/dist/src/agent/tools/xopc-use-tool.js +2 -1
  66. package/dist/src/agent-config/schema.d.ts +3 -0
  67. package/dist/src/agent-config/schema.js +1 -0
  68. package/dist/src/capabilities/capability-catalog.d.ts +47 -0
  69. package/dist/src/capabilities/capability-catalog.js +162 -0
  70. package/dist/src/capabilities/store-connector.d.ts +1 -0
  71. package/dist/src/capabilities/store-connector.js +6 -3
  72. package/dist/src/chat-commands/builtins/config.js +1 -1
  73. package/dist/src/chat-commands/context.js +1 -1
  74. package/dist/src/cli/commands/agent.js +1 -1
  75. package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -1
  76. package/dist/src/cli/commands/doctor/checks/database-schema.js +5 -5
  77. package/dist/src/cli/commands/extension-dev.js +1 -1
  78. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  79. package/dist/src/cli/commands/extension.js +1 -1
  80. package/dist/src/cli/commands/onboard/channels/registry.js +1 -1
  81. package/dist/src/cli/commands/skills.js +1 -1
  82. package/dist/src/cli/extension-cli-register.js +1 -1
  83. package/dist/src/cli/utils/session.js +1 -1
  84. package/dist/src/config/index.js +1 -1
  85. package/dist/src/config/schema.d.ts +2 -0
  86. package/dist/src/config/schema.js +6 -3
  87. package/dist/src/extensions/index.js +2 -2
  88. package/dist/src/extensions/loader.js +1 -1
  89. package/dist/src/extensions/update.js +1 -1
  90. package/dist/src/gateway/agent-reactions/reaction.d.ts +27 -0
  91. package/dist/src/gateway/agent-reactions/reaction.js +186 -0
  92. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  93. package/dist/src/gateway/hono/routes/capabilities.js +27 -0
  94. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  95. package/dist/src/gateway/hono/routes/home.js +1 -1
  96. package/dist/src/gateway/hono/routes/mobile-capability-actions.d.ts +4 -0
  97. package/dist/src/gateway/hono/routes/mobile-capability-actions.js +290 -0
  98. package/dist/src/gateway/hono/routes/music-generation.js +1 -0
  99. package/dist/src/gateway/hono/routes/personal-agent.js +15 -6
  100. package/dist/src/gateway/hono/routes/sessions.js +34 -1
  101. package/dist/src/gateway/security/gateway-scopes.js +3 -0
  102. package/dist/src/gateway/service/agent-runner.d.ts +2 -0
  103. package/dist/src/gateway/service/agent-runner.js +5 -1
  104. package/dist/src/gateway/service/config-coordinator.d.ts +1 -0
  105. package/dist/src/gateway/service/config-coordinator.js +1 -1
  106. package/dist/src/gateway/service/run-gateway-agent.d.ts +3 -0
  107. package/dist/src/gateway/service/run-gateway-agent.js +43 -1
  108. package/dist/src/gateway/service/task-conversation-query-service.d.ts +4 -0
  109. package/dist/src/gateway/service.js +19 -10
  110. package/dist/src/home-intelligence/host.js +5 -5
  111. package/dist/src/personal-agent/repository.d.ts +1 -0
  112. package/dist/src/personal-agent/repository.js +1 -0
  113. package/dist/src/personal-agent/service.d.ts +2 -2
  114. package/dist/src/personal-agent/service.js +6 -3
  115. package/dist/src/providers/model-call.js +1 -0
  116. package/dist/src/realtime/runtime.js +1 -0
  117. package/dist/src/session/client-history.d.ts +1 -0
  118. package/dist/src/session/client-history.js +2 -0
  119. package/dist/src/session/types.d.ts +4 -0
  120. package/dist/src/storage/sqlite/agent-reaction-repository.d.ts +15 -0
  121. package/dist/src/storage/sqlite/agent-reaction-repository.js +73 -0
  122. package/dist/src/storage/sqlite/row-mappers.js +1 -1
  123. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  124. package/dist/src/storage/sqlite/schema.js +7 -7
  125. package/dist/src/storage/sqlite/schema.sql +13 -0
  126. package/dist/src/storage/sqlite/upgrades/281_session_agent_reactions.sql +13 -0
  127. package/dist/src/tui/backends/embedded-backend.js +1 -1
  128. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  129. package/dist/src/tui/tui-commands.js +1 -1
  130. package/dist/src/tui/tui-management.js +1 -1
  131. package/dist/src/tui/tui.js +1 -1
  132. package/dist/src/usage/recorder.js +6 -2
  133. package/dist/src/usage/types.d.ts +1 -0
  134. package/package.json +2 -2
  135. package/dist/gateway/static/root/assets/chat-page-DV7fS7_1.js +0 -72
  136. package/dist/gateway/static/root/assets/index-g7f1Sp02.css +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i}from"./chunk-KS7C4IRE-BPb7KheU.js";import{i as a,l as o,n as s,o as c}from"./locale-store-B4o4aDCg.js";import{t as l}from"./messages-hlOsXkQ7.js";import{a as u,n as d,o as f,r as p,s as m,t as h}from"./dist-CY7CS_D3.js";import{t as g}from"./check-DUBLcKHA.js";import{t as _}from"./chevron-down-ccbiQQz_.js";import{n as v,r as y}from"./popover-select-CLsphyzA.js";import{i as b}from"./file-tree-utils-DJs1faGv.js";import{t as x}from"./cloud-C4-yfnnk.js";import{t as S}from"./copy-Dv6d4Dvw.js";import{t as C}from"./file-text-D12HbeVy.js";import{t as w}from"./folder-open-CyzJ19I9.js";import{t as T}from"./history-DXH_9jsE.js";import{t as E}from"./loader-circle-CifKLtgG.js";import{t as D}from"./message-square-fVE7Ghj1.js";import{t as O}from"./plus-Q2yW6OE7.js";import{t as ee}from"./refresh-cw-BRlGaq2w.js";import{t as k}from"./sticky-note-fzP7NAJq.js";import{t as A}from"./trash-2-DusmjVPV.js";import{n as j,r as M,t as N}from"./share-link-dialog-3RNzFIH3.js";import{t as P}from"./x-B_N4OPjy.js";import{t as F}from"./cn-0WouolD0.js";import{t as I}from"./skeleton-DzdOeGYz.js";import{i as te}from"./vendor-swr-CdRzEUwF.js";import{n as L,r as R}from"./gateway-config-swr-2VOPSLSq.js";import{o as z}from"./agents-admin-api-_mp_Ew1u.js";import{t as B}from"./button-ChmVQg9O.js";import{t as V}from"./copy-to-clipboard-HOJ79TWv.js";import{s as H}from"./form-field-width-DJw_jULe.js";import{t as U}from"./page-tabs-DoYMKhVO.js";import{n as W}from"./agent-display-names-Bje7vfSn.js";import{r as G}from"./settings-form-draft-Dy10ldo8.js";import{t as K}from"./confirm-dialog-DkviAS5j.js";import{t as ne}from"./file-tree-CYUkQR1t.js";import{a as q,b as re,c as ie,g as ae,l as oe,m as se,o as ce,r as le,t as ue,v as de,x as fe}from"./shares-api-B532SLIU.js";import{t as pe}from"./use-workspace-tree-D6IwkuTh.js";import{t as me}from"./workspace-editor-agent-store-Bh4FYwVq.js";import{t as he}from"./settings-loading-skeleton-CAoOV17i.js";import{t as ge}from"./oauth-provider-connect-3QGibJMl.js";import{t as _e}from"./number-input-El7Szeln.js";import{n as ve,t as ye}from"./settings-page-header-DKgbD0Bc.js";import{t as be}from"./settings-page-layout-BE3vLWp_.js";import{t as J}from"./settings-form-section-num14vSv.js";var Y=e(t(),1),xe=n(),X={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 Se(){return structuredClone(X)}var Z=36e5,Ce=864e5,Q=1048576;function we(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Te(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 Ee(e){let t=we(e)?e:{},n=we(t.gateway)?t.gateway:{},r=we(n.share)?n.share:{},i=we(r.directory)?r.directory:{},a=we(r.note)?r.note:{},o=we(n.siteShare)?n.siteShare:{},s=we(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):X.defaultTtlHours*Z,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):X.maxTtlDays*Ce,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):X.maxFileSizeMb*Q,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):X.directoryMaxFolderSizeMb*Q,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):X.siteDefaultTtlHours*Z,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):X.siteMaxTtlDays*Ce,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):X.siteMaxRootDirSizeMb*Q,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):X.noteMaxTotalSizeMb*Q;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/Z)),maxTtlDays:Math.max(1,Math.round(l/Ce)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):X.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/Q)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/Q)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):X.directoryMaxFileCount,inlinePreviewMimes:Te(r.inlinePreviewMimes,32).length?Te(r.inlinePreviewMimes,32):[...X.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/Q)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):X.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/Z)),siteMaxTtlDays:Math.max(1,Math.round(p/Ce)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):X.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/Q)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):X.siteMaxFileCount}}function De(e){let t=e.defaultTtlHours*Z,n=e.maxTtlDays*Ce,r=e.siteDefaultTtlHours*Z,i=e.siteMaxTtlDays*Ce;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 Oe(e){let t=De(e);if(t)throw Error(t);await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*Z,maxTtlMs:e.maxTtlDays*Ce,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Q,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Q,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*Q,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*Z,maxTtlMs:e.siteMaxTtlDays*Ce,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Q,maxFileCount:e.siteMaxFileCount}}}})}),L()}var $=r();function ke(){return F(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H,`dark:border-edge`)}function Ae({hasToken:e}){let t=l(s(e=>e.language)).sharesSettings,{data:n,isLoading:r}=R(e),i=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(Ee(n.payload.config)),[n]),a=(0,Y.useRef)(!1),[o,c]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),g=o??i,_=i,v=(0,Y.useMemo)(()=>!g||!_?!1:JSON.stringify(g)!==JSON.stringify(_),[g,_]),y=(0,Y.useCallback)(e=>{a.current=!0,c(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),b=(0,Y.useCallback)(async()=>{if(!(!g||u)){d(!0),p(null),h(!1);try{await Oe(g),a.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:t.policySaveError)}finally{d(!1)}}},[g,u,t.policySaveError]),x=(0,Y.useCallback)(()=>{a.current=!1,c(null),p(null),h(!1)},[]);return!e||!g?r?(0,$.jsx)(J,{children:(0,$.jsx)(he,{rows:2})}):null:(0,$.jsxs)(J,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[m?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,$.jsx)(B,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>y(Se()),children:t.policyUseRecommended}),(0,$.jsx)(B,{type:`button`,variant:`secondary`,disabled:!v||u,onClick:x,children:t.policyDiscard}),(0,$.jsx)(B,{type:`button`,variant:`primary`,disabled:!v||u,onClick:()=>void b(),children:u?t.policySaving:t.policySave})]})]}),v?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,f?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,$.jsx)(je,{t,form:g,onChange:y})]})}function je(e){let t=(0,xe.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,$.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,$.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,$.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,$.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,$.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,$.jsx)(Me,{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,$.jsx)(Me,{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,$.jsx)(Me,{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,$.jsx)(Me,{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 C=!r.enabled,w;t[47]===i?w=t[48]:(w=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=w);let T;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==w?(T=(0,$.jsx)(Me,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:w}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=w,t[54]=T):T=t[54];let E=!r.enabled,D;t[55]===i?D=t[56]:(D=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=D);let O;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==E||t[61]!==D?(O=(0,$.jsx)(Me,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:E,onChange:D}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=E,t[61]=D,t[62]=O):O=t[62];let ee;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==T||t[67]!==O||t[68]!==p?(ee=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,T,O]}),t[63]=g,t[64]=y,t[65]=S,t[66]=T,t[67]=O,t[68]=p,t[69]=ee):ee=t[69];let k=!r.enabled,A;t[70]===i?A=t[71]:(A=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=A);let j;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==k||t[75]!==A?(j=(0,$.jsx)(Ne,{t:n,values:r.inlinePreviewMimes,disabled:k,onChange:A}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=k,t[75]=A,t[76]=j):j=t[76];let M;t[77]!==ee||t[78]!==j||t[79]!==s||t[80]!==u?(M=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[s,u,ee,j]}),t[77]=ee,t[78]=j,t[79]=s,t[80]=u,t[81]=M):M=t[81];let N;t[82]===n.policyNoteSection?N=t[83]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=N);let P;t[84]===n.policyNoteSectionHint?P=t[85]:(P=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=P);let F;t[86]!==N||t[87]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-4`,children:[N,P]}),t[86]=N,t[87]=P,t[88]=F):F=t[88];let I;t[89]===i?I=t[90]:(I=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=I);let te;t[91]!==r.noteEnabled||t[92]!==I?(te=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:I}),t[91]=r.noteEnabled,t[92]=I,t[93]=te):te=t[93];let L;t[94]!==n.policyNoteEnabled||t[95]!==te?(L=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[te,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=te,t[96]=L):L=t[96];let R=!r.enabled||!r.noteEnabled,z;t[97]===i?z=t[98]:(z=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=z);let B;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==R||t[103]!==z?(B=(0,$.jsx)(Me,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:R,onChange:z}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=R,t[103]=z,t[104]=B):B=t[104];let V=!r.enabled||!r.noteEnabled,H;t[105]===i?H=t[106]:(H=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=H);let U;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==V||t[111]!==H?(U=(0,$.jsx)(Me,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:V,onChange:H}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=V,t[111]=H,t[112]=U):U=t[112];let W;t[113]!==B||t[114]!==U?(W=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[B,U]}),t[113]=B,t[114]=U,t[115]=W):W=t[115];let G;t[116]!==F||t[117]!==L||t[118]!==W?(G=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[F,L,W]}),t[116]=F,t[117]=L,t[118]=W,t[119]=G):G=t[119];let K;t[120]===n.policySiteSection?K=t[121]:(K=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=K);let ne;t[122]===n.policySiteSectionHint?ne=t[123]:(ne=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=ne);let q;t[124]!==K||t[125]!==ne?(q=(0,$.jsxs)(`div`,{className:`mb-4`,children:[K,ne]}),t[124]=K,t[125]=ne,t[126]=q):q=t[126];let re;t[127]===i?re=t[128]:(re=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=re);let ie;t[129]!==r.siteEnabled||t[130]!==re?(ie=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:re}),t[129]=r.siteEnabled,t[130]=re,t[131]=ie):ie=t[131];let ae;t[132]!==n.policySiteEnabled||t[133]!==ie?(ae=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ie,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=ie,t[134]=ae):ae=t[134];let oe=!r.siteEnabled,se;t[135]===i?se=t[136]:(se=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=se);let ce;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==oe||t[141]!==se?(ce=(0,$.jsx)(Me,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:oe,onChange:se}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=oe,t[141]=se,t[142]=ce):ce=t[142];let le=!r.siteEnabled,ue;t[143]===i?ue=t[144]:(ue=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=ue);let de;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==le||t[149]!==ue?(de=(0,$.jsx)(Me,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:le,onChange:ue}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=le,t[149]=ue,t[150]=de):de=t[150];let fe=!r.siteEnabled,pe;t[151]===i?pe=t[152]:(pe=e=>i({maxActiveSites:e}),t[151]=i,t[152]=pe);let me;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==fe||t[157]!==pe?(me=(0,$.jsx)(Me,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:fe,onChange:pe}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=fe,t[157]=pe,t[158]=me):me=t[158];let he=!r.siteEnabled,ge;t[159]===i?ge=t[160]:(ge=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=ge);let _e;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==he||t[165]!==ge?(_e=(0,$.jsx)(Me,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:he,onChange:ge}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=he,t[165]=ge,t[166]=_e):_e=t[166];let ve=!r.siteEnabled,ye;t[167]===i?ye=t[168]:(ye=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=ye);let be;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==ve||t[173]!==ye?(be=(0,$.jsx)(Me,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:ve,onChange:ye}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=ve,t[173]=ye,t[174]=be):be=t[174];let J;t[175]!==ce||t[176]!==de||t[177]!==me||t[178]!==_e||t[179]!==be?(J=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,de,me,_e,be]}),t[175]=ce,t[176]=de,t[177]=me,t[178]=_e,t[179]=be,t[180]=J):J=t[180];let Y;t[181]!==q||t[182]!==ae||t[183]!==J?(Y=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[q,ae,J]}),t[181]=q,t[182]=ae,t[183]=J,t[184]=Y):Y=t[184];let X;return t[185]!==M||t[186]!==G||t[187]!==Y?(X=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[M,G,Y]}),t[185]=M,t[186]=G,t[187]=Y,t[188]=X):X=t[188],X}function Me(e){let t=(0,xe.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,$.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 d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=F(ke(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let f;t[4]!==s||t[5]!==o||t[6]!==l?(f=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]=f):f=t[7];let p;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==f||t[13]!==a?(p=(0,$.jsx)(_e,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:f}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=f,t[13]=a,t[14]=p):p=t[14];let m;t[15]===i?m=t[16]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=m);let h;return t[17]!==u||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{children:[u,p,m]}),t[17]=u,t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function Ne(e){let t=(0,xe.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,$.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,$.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,$.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,$.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 d;t[11]===u?d=t[12]:(d=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let f;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(f=F(ke(),`font-mono text-xs`),t[13]=f):f=t[13];let p=i||r.length>=32,m;t[14]===s?m=t[15]:(m=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=m);let h;t[16]!==n.policyMimePlaceholder||t[17]!==p||t[18]!==m?(h=(0,$.jsx)(`input`,{className:f,placeholder:n.policyMimePlaceholder,disabled:p,onKeyDown:m}),t[16]=n.policyMimePlaceholder,t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[c,l,d,h]}),t[20]=c,t[21]=l,t[22]=d,t[23]=h,t[24]=g):g=t[24],g}function Pe(e){let t=(0,xe.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,conversationId:g,agentId:_}=e,b=c===void 0?`any`:c,x=l(s(Le)),S=x.workspace,C=x.sharesSettings,T=me(Ie),{data:D}=te(o(Fe)?`picker-agents-list`:null,z),O;bb0:{let e;t[0]===_?e=t[1]:(e=_?.trim(),t[0]=_,t[1]=e);let n=e;if(n){O=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){O=i;break bb0}if(D?.defaultId){O=D.defaultId;break bb0}if(D?.agents?.[0]?.id){O=D.agents[0].id;break bb0}O=``}let k=O,[A,j]=(0,Y.useState)(k),M,N;t[4]===k?(M=t[5],N=t[6]):(M=()=>{j(k)},N=[k],t[4]=k,t[5]=M,t[6]=N),(0,Y.useEffect)(M,N);let{tree:I,loading:L,error:R,loadRoot:V,loadChildren:H,reset:U}=pe(A,g??null),G;t[7]===a?G=t[8]:(G=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=G);let[K,q]=(0,Y.useState)(G),re;t[9]!==a||t[10]!==V||t[11]!==n||t[12]!==U||t[13]!==q?(re=()=>{if(!n){U(),q(a?{path:a,isDirectory:!1}:null);return}V()},t[9]=a,t[10]=V,t[11]=n,t[12]=U,t[13]=q,t[14]=re):re=t[14];let ie;t[15]!==g||t[16]!==a||t[17]!==V||t[18]!==n||t[19]!==A||t[20]!==U?(ie=[n,A,g,V,U,a],t[15]=g,t[16]=a,t[17]=V,t[18]=n,t[19]=A,t[20]=U,t[21]=ie):ie=t[21],(0,Y.useEffect)(re,ie);let ae;t[22]===H?ae=t[23]:(ae=e=>{H(e)},t[22]=H,t[23]=ae);let oe=ae,se=K!==null&&(b===`any`||b===`file`&&!K.isDirectory||b===`directory`&&K.isDirectory),ce;bb1:{if(!K){ce=C.pickerHintNone;break bb1}if(b===`file`&&K.isDirectory){ce=C.pickerHintNeedsFile;break bb1}if(b===`directory`&&!K.isDirectory){ce=C.pickerHintNeedsDirectory;break bb1}ce=`${K.isDirectory?`📁`:`📄`} ${K.path}`}let le=ce,ue=D?.agents??[],de;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=de):de=t[24];let fe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(fe=F(`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]=fe):fe=t[25];let he;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(w,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=he):he=t[26];let ge=x.cron.refresh,_e=x.cron.refresh,ve;t[27]===V?ve=t[28]:(ve=()=>void V(),t[27]=V,t[28]=ve);let ye=L&&`animate-spin`,be;t[29]===ye?be=t[30]:(be=F(`size-4`,ye),t[29]=ye,t[30]=be);let J;t[31]===be?J=t[32]:(J=(0,$.jsx)(ee,{className:be,"aria-hidden":!0}),t[31]=be,t[32]=J);let X;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,$.jsx)(P,{className:`size-4`}),t[33]=X):X=t[33];let Se;t[34]!==R||t[35]!==S.loadError?(Se=R?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[S.loadError,`: `,R]}):null,t[34]=R,t[35]=S.loadError,t[36]=Se):Se=t[36];let Z;t[37]!==oe||t[38]!==L||t[39]!==K?.path||t[40]!==q||t[41]!==S.emptyDir||t[42]!==S.title||t[43]!==I?(Z=L&&I.length===0?(0,$.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(E,{className:`size-4 animate-spin`}),S.title,`…`]}):(0,$.jsx)(ne,{tree:I,selectedPath:K?.path??null,onSelectFile:e=>q({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>q({path:e,isDirectory:t}),onExpandDir:oe,onAction:void 0,emptyHint:S.emptyDir}),t[37]=oe,t[38]=L,t[39]=K?.path,t[40]=q,t[41]=S.emptyDir,t[42]=S.title,t[43]=I,t[44]=Z):Z=t[44];let Ce;t[45]!==Se||t[46]!==Z?(Ce=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[Se,Z]}),t[45]=Se,t[46]=Z,t[47]=Ce):Ce=t[47];let Q;t[48]===le?Q=t[49]:(Q=(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:le}),t[48]=le,t[49]=Q);let we;t[50]===r?we=t[51]:(we=()=>r(!1),t[50]=r,t[51]=we);let Te;t[52]!==C.cancel||t[53]!==we?(Te=(0,$.jsx)(B,{type:`button`,variant:`ghost`,onClick:we,children:C.cancel}),t[52]=C.cancel,t[53]=we,t[54]=Te):Te=t[54];let Ee=!se,De;t[55]!==i||t[56]!==r||t[57]!==A||t[58]!==K?(De=()=>{K&&(i({...K,agentId:A}),r(!1))},t[55]=i,t[56]=r,t[57]=A,t[58]=K,t[59]=De):De=t[59];let Oe;t[60]!==C.pickerConfirm||t[61]!==Ee||t[62]!==De?(Oe=(0,$.jsx)(B,{type:`button`,disabled:Ee,onClick:De,children:C.pickerConfirm}),t[60]=C.pickerConfirm,t[61]=Ee,t[62]=De,t[63]=Oe):Oe=t[63];let ke;t[64]!==Te||t[65]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Te,Oe]}),t[64]=Te,t[65]=Oe,t[66]=ke):ke=t[66];let Ae;return t[67]!==Q||t[68]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Q,ke]}),t[67]=Q,t[68]=ke,t[69]=Ae):Ae=t[69],(0,$.jsx)(h,{open:n,onOpenChange:r,children:(0,$.jsxs)(f,{children:[de,(0,$.jsxs)(p,{className:fe,children:[(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[he,(0,$.jsx)(m,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:C.pickerTitle}),(0,$.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:ge,"aria-label":_e,disabled:L,onClick:ve,children:J}),(0,$.jsx)(d,{asChild:!0,children:(0,$.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":S.close,children:X})})]}),ue.length>0?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,$.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:C.pickerAgentLabel}),(0,$.jsx)(v,{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:A,onChange:e=>{j(e.target.value),q(null)},children:ue.map(e=>(0,$.jsxs)(y,{value:e.id,children:[W(e,x.agentsSettings),e.id===D?.defaultId?` ★`:``]},e.id))})]}):null,Ce,Ae]})]})})}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,xe.c)(23),t=s(Ge),n=l(t).sharesSettings,r=!!o(We),[a,c]=i(),u;e[0]===a?u=e[1]:(u=ze(a.get(`tab`)),e[0]=a,e[1]=u);let d=u,f;e[2]===c?f=e[3]:(f=e=>{c(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=c,e[3]=f);let p=f;if(!r)return(0,$.jsx)(ve,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let m={shares:n.tabShares,policy:n.tabPolicy},h=Re.map(e=>({id:e,label:m[e]})),g;e[4]===n.title?g=e[5]:(g=(0,$.jsx)(ye,{title:n.title}),e[4]=n.title,e[5]=g);let _;e[6]!==d||e[7]!==p||e[8]!==n.tabsAria||e[9]!==h?(_=(0,$.jsx)(U,{items:h,activeTab:d,onChange:p,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[6]=d,e[7]=p,e[8]=n.tabsAria,e[9]=h,e[10]=_):_=e[10];let v;e[11]!==d||e[12]!==r||e[13]!==t||e[14]!==n?(v=d===`shares`?(0,$.jsx)(Ke,{t:n,language:t}):(0,$.jsx)(Ae,{hasToken:r}),e[11]=d,e[12]=r,e[13]=t,e[14]=n,e[15]=v):v=e[15];let y;e[16]!==d||e[17]!==v?(y=(0,$.jsx)(be,{id:d,activeTab:d,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[16]=d,e[17]=v,e[18]=y):y=e[18];let b;return e[19]!==g||e[20]!==_||e[21]!==y?(b=(0,$.jsxs)(ve,{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,xe.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}=te(`shares-list`,se,i),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:3e4},t[1]=l):l=t[1];let u=te(`hosted-publications-list`,oe,l),d;t[2]===a?.payload?.shares?d=t[3]:(d=a?.payload?.shares??[],t[2]=a?.payload?.shares,t[3]=d);let f=d,[p,m]=(0,Y.useState)(!1),h;bb0:{if(p){h=f;break bb0}let e;t[4]===f?e=t[5]:(e=f.filter(Ze),t[4]=f,t[5]=e),h=e}let g=h,_;t[6]===f?_=t[7]:(_=f.filter(Xe),t[6]=f,t[7]=_);let v=_.length,y;t[8]===f?y=t[9]:(y=f.filter(Ye),t[8]=f,t[9]=y);let b=y.length,x;t[10]===c?x=t[11]:(x=()=>void c(),t[10]=c,t[11]=x);let S;t[12]!==n||t[13]!==x?(S=(0,$.jsx)(rt,{t:n,onCreated:x}),t[12]=n,t[13]=x,t[14]=S):S=t[14];let C=u.data?.connected===!0,w=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]!==w||t[19]!==T||t[20]!==C?(E=(0,$.jsx)(Qe,{language:r,connected:C,publishingAllowed:w,onCreated:T}),t[17]=r,t[18]=w,t[19]=T,t[20]=C,t[21]=E):E=t[21];let D=p?n.allSharesTitle:n.listTitle,O;t[22]===v?O=t[23]:(O=v>0&&(0,$.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[22]=v,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[D,O]}),t[24]=D,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`,M;t[29]===j?M=t[30]:(M=F(`size-3.5`,j),t[29]=j,t[30]=M);let N;t[31]===M?N=t[32]:(N=(0,$.jsx)(ee,{className:M}),t[31]=M,t[32]=N);let P;t[33]!==s||t[34]!==A||t[35]!==N?(P=(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:A,disabled:s,children:N}),t[33]=s,t[34]=A,t[35]=N,t[36]=P):P=t[36];let I;t[37]!==b||t[38]!==p||t[39]!==n.hideExpired||t[40]!==n.showExpired?(I=b>0&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Je),children:p?n.hideExpired:n.showExpired}),t[37]=b,t[38]=p,t[39]=n.hideExpired,t[40]=n.showExpired,t[41]=I):I=t[41];let L;t[42]!==P||t[43]!==I?(L=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,I]}),t[42]=P,t[43]=I,t[44]=L):L=t[44];let R;t[45]!==k||t[46]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[k,L]}),t[45]=k,t[46]=L,t[47]=R):R=t[47];let z;t[48]!==a||t[49]!==o||t[50]!==g||t[51]!==s||t[52]!==r||t[53]!==c||t[54]!==n?(z=s&&!a?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(qe)}):o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:n.error}),(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):g.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,$.jsx)(at,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[48]=a,t[49]=o,t[50]=g,t[51]=s,t[52]=r,t[53]=c,t[54]=n,t[55]=z):z=t[55];let V;t[56]!==b||t[57]!==c||t[58]!==p||t[59]!==n?(V=b>0&&p&&(0,$.jsx)(ot,{t:n,onCleaned:()=>void c()}),t[56]=b,t[57]=c,t[58]=p,t[59]=n,t[60]=V):V=t[60];let H;t[61]!==R||t[62]!==z||t[63]!==V?(H=(0,$.jsxs)(J,{children:[R,z,V]}),t[61]=R,t[62]=z,t[63]=V,t[64]=H):H=t[64];let U;t[65]===u?U=t[66]:(U=()=>void u.mutate(),t[65]=u,t[66]=U);let W;t[67]!==u.data||t[68]!==u.error||t[69]!==u.isLoading||t[70]!==r||t[71]!==n||t[72]!==U?(W=(0,$.jsx)($e,{data:u.data,error:u.error,isLoading:u.isLoading,language:r,t:n,onChanged:U}),t[67]=u.data,t[68]=u.error,t[69]=u.isLoading,t[70]=r,t[71]=n,t[72]=U,t[73]=W):W=t[73];let G;return t[74]!==E||t[75]!==H||t[76]!==W||t[77]!==S?(G=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,E,H,W]}),t[74]=E,t[75]=H,t[76]=W,t[77]=S,t[78]=G):G=t[78],G}function qe(e,t){return(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(I,{className:`h-4 w-2/3`}),(0,$.jsx)(I,{className:`mt-2 h-3 w-1/2`})]}),(0,$.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,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(6048e5),[_,b]=(0,Y.useState)(!1),[S,T]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(null),ee=async()=>{if(a.trim()){b(!0),O(null);try{let e=await le({path:a.trim(),title:p.trim()||void 0,ttlMs:h,spaFallback:!0,...s?{agentId:s}:{}});T(e),r()}catch(e){O(e instanceof Error?e.message:String(e))}finally{b(!1)}}};return(0,$.jsxs)(J,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`发布静态网站`:`Publish static website`}),(0,$.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,$.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,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-[1fr_12rem]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{value:a,onChange:e=>{o(e.target.value),u(!1),T(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,$.jsxs)(B,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>f(!0),children:[a&&!l?(0,$.jsx)(C,{className:`size-4`}):(0,$.jsx)(w,{className:`size-4`}),a?i?`更换`:`Change`:i?`选择`:`Browse`]})]}),(0,$.jsxs)(v,{value:String(h),onChange:e=>g(Number(e.target.value)),children:[(0,$.jsx)(y,{value:`86400000`,children:i?`24 小时`:`24 hours`}),(0,$.jsx)(y,{value:`604800000`,children:i?`7 天`:`7 days`}),(0,$.jsx)(y,{value:`2592000000`,children:i?`30 天`:`30 days`})]}),(0,$.jsx)(`input`,{value:p,onChange:e=>m(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,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,$.jsxs)(B,{type:`button`,onClick:()=>void ee(),disabled:!a.trim()||_||!t||!n,children:[_?(0,$.jsx)(E,{className:`size-4 animate-spin`}):(0,$.jsx)(x,{className:`size-4`}),_?i?`发布中…`:`Publishing…`:i?`发布网站`:`Publish site`]}),S?(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 truncate text-xs text-accent hover:underline`,onClick:()=>void V(S.shareUrl),children:[S.shareUrl,` · `,S.fileCount,` `,i?`个文件`:`files`,` · `,Be(S.totalBytes)]}):null]}),D?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:D}):null]})]}),(0,$.jsx)(Pe,{open:d,onOpenChange:f,initialPath:a||void 0,agentId:s||void 0,selectKind:`any`,onConfirm:e=>{o(e.path),c(e.agentId),u(e.isDirectory),T(null),O(null)}})]})}function $e(e){let t=(0,xe.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,$.jsx)(x,{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,$.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,$.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,$.jsx)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:(0,$.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,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:2}).map(et)}):r?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o.error}):n?.connected?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n.publishingAllowed?null:(0,$.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,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedEmpty}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.publications.map(e=>(0,$.jsx)(tt,{publication:e,language:a,t:o,publishingAllowed:n.publishingAllowed,onChanged:s},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedDisconnected}),(0,$.jsx)(ge,{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,$.jsxs)(J,{children:[d,f]}),t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function et(e,t){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:[(0,$.jsx)(I,{className:`h-4 w-2/3`}),(0,$.jsx)(I,{className:`mt-2 h-3 w-1/2`})]},t)}function tt({publication:e,language:t,t:n,publishingAllowed:r,onChanged:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),h=Date.now()>=new Date(e.expiresAt).getTime(),_=e.status===`active`&&!h,v=e.status===`revoked`?n.statusRevoked:h?n.statusExpired:e.status===`staging`?t===`zh`?`准备中`:`Staging`:n.statusActive,y=e.kind===`note_document`?k:e.kind===`static_site`?x:D,b=e.kind===`note_document`?t===`zh`?`笔记文档`:`Note document`:e.kind===`static_site`?t===`zh`?`静态网站`:`Static website`:t===`zh`?`会话快照`:`Conversation snapshot`,C=(0,Y.useCallback)(async()=>{e.shareUrl&&await V(e.shareUrl)&&(u(!0),window.setTimeout(()=>u(!1),2e3))},[e.shareUrl]),w=(0,Y.useCallback)(async()=>{o(!1),c(!0);try{await de(e.id),i()}catch{}finally{c(!1)}},[e.id,i]),O=(0,Y.useCallback)(async()=>{if(!(!e.revision||e.revision<=1)){f(!0);try{let t=(await ie(e.id)).find(t=>t.revision<e.revision);if(!t)return;await fe(e.id,e.revision,t.revision),i()}catch{}finally{f(!1)}}},[e.id,e.revision,i]),j=(0,Y.useCallback)(async()=>{m(!0);try{await ae(e.id),i()}catch{}finally{m(!1)}},[e.id,i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:F(`text-xs font-medium`,_?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`),children:v})]}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[b,` · `,n.hostedRevision,` `,e.revision??`—`,` · `,e.managedFromThisDevice?n.hostedThisDevice:n.hostedOtherDevice]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{children:[t===`zh`?`浏览`:`Views`,`: `,e.viewCount,e.maxViews===null?``:` / ${e.maxViews}`]}),(0,$.jsx)(`span`,{children:h?n.statusExpired:Ve(e.expiresAt,t)}),e.description?(0,$.jsx)(`span`,{className:`italic`,children:e.description}):null]})]}),_?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.shareUrl?(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:!r,title:n.copyUrl,onClick:()=>void C(),children:l?(0,$.jsx)(g,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(S,{className:`size-3.5`})}):null,(e.revision??0)>1?(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:d||!r,onClick:()=>void O(),title:t===`zh`?`回滚上一版本`:`Roll back one revision`,children:d?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(T,{className:`size-3.5`})}):null,e.kind===`static_site`&&e.managedFromThisDevice?(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:p||!r,onClick:()=>void j(),title:t===`zh`?`发布工作区中的最新版本`:`Publish latest workspace version`,children:(0,$.jsx)(ee,{className:F(`size-3.5`,p&&`animate-spin`)})}):null,(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,disabled:s,onClick:()=>o(!0),children:s?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(A,{className:`size-3.5`})})]}):null]})}),(0,$.jsx)(K,{open:a,title:n.revokeConfirmTitle,description:n.revokeConfirmBody,confirmLabel:n.revokeConfirmLabel,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void w(),onCancel:()=>o(!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,Y.useReducer)(G,nt),{expanded:i,path:a,isDirectory:o,agentId:s,ttlMs:c,maxViews:l,description:u,directoryMode:d,creating:f,result:p,errorMsg:m,resultDialogOpen:h,pickerOpen:g}=n,_=(0,Y.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{let e=await q({path:a.trim(),ttlMs:c,maxViews:l,description:u.trim()||void 0,...s?{agentId:s}:{},...o?{kind:`directory`,directoryMode:d}:{}});r({type:`patch`,patch:{result:e.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,c,l,u,d,t]),b=(0,Y.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,$.jsxs)(J,{children:[(0,$.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:F(`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,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:o?`📁`:`📄`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,$.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,$.jsxs)(B,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,$.jsx)(C,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),o?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,$.jsxs)(v,{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:d,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,$.jsx)(y,{value:`browse`,children:e.directoryModeBrowse}),(0,$.jsx)(y,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,$.jsx)(v,{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:c,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:He.map(t=>(0,$.jsx)(y,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,$.jsxs)(v,{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??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,$.jsx)(y,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,$.jsx)(y,{value:`1`,children:`1`}),(0,$.jsx)(y,{value:`5`,children:`5`}),(0,$.jsx)(y,{value:`10`,children:`10`}),(0,$.jsx)(y,{value:`50`,children:`50`}),(0,$.jsx)(y,{value:`100`,children:`100`})]})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,$.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:u,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,$.jsxs)(B,{type:`button`,disabled:f||!a.trim(),onClick:()=>void _(),children:[f?(0,$.jsx)(E,{className:`size-4 animate-spin`}):(0,$.jsx)(O,{className:`size-4`}),f?e.creating:e.createButton]}),(0,$.jsx)(B,{type:`button`,variant:`ghost`,onClick:()=>{b(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),m&&(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m})]}),(0,$.jsx)(j,{open:h,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:p}),(0,$.jsx)(Pe,{open:g,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,$.jsxs)(B,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,$.jsx)(O,{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[a,o]=(0,Y.useReducer)(G,it),{revokeOpen:s,revoking:c,linksOpen:l,urlCopied:u,copyFailed:d,extending:f}=a,p=!e.expired&&!e.revoked,m=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,h=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,v=(0,Y.useCallback)(async()=>{o({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await re(e.id),r()}catch{}finally{o({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),y=(0,Y.useCallback)(async()=>{if(o({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await V(e.shareUrl)){o({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{copyFailed:!1}}),2500);return}o({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),x=(0,Y.useCallback)(async()=>{o({type:`patch`,patch:{extending:!0}});try{await ce(e.id,864e5),i()}catch{}finally{o({type:`patch`,patch:{extending:!1}})}},[e.id,i]),w=`share-links-${e.id}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:F(`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":l,"aria-controls":w,onClick:()=>o({type:`patch`,patch:{linksOpen:!l}}),children:[(0,$.jsx)(_,{className:F(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,l?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,$.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(D,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:F(`text-xs font-medium`,h),children:m})]}),(0,$.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,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:Be(e.fileSize)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(b,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Ve(e.expiresAt,n)]}),(0,$.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,$.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void y(),children:u?(0,$.jsx)(g,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(S,{className:`size-3.5`})}),(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void x(),disabled:f,title:t.extend,children:f?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(b,{className:`size-3.5`})}),(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>o({type:`patch`,patch:{revokeOpen:!0}}),disabled:c,children:c?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(A,{className:`size-3.5`})})]})})]}),p&&l?(0,$.jsxs)(`div`,{id:w,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,$.jsx)(M,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),d?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(N,{reachability:e.reachability})})]}):null]}),(0,$.jsx)(K,{open:s,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void v(),onCancel:()=>o({type:`patch`,patch:{revokeOpen:!1}})})]})}function ot({t:e,onCleaned:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1),o=(0,Y.useCallback)(async()=>{r(!1),a(!0);try{await ue(),t()}catch{}finally{a(!1)}},[t]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(B,{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,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(A,{className:`size-3.5`}),e.cleanExpired]})}),(0,$.jsx)(K,{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
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i}from"./chunk-KS7C4IRE-BPb7KheU.js";import{i as a,l as o,n as s,o as c}from"./locale-store-B4o4aDCg.js";import{t as l}from"./messages-hlOsXkQ7.js";import{a as u,n as d,o as f,r as p,s as m,t as h}from"./dist-CY7CS_D3.js";import{t as g}from"./check-DUBLcKHA.js";import{t as _}from"./chevron-down-ccbiQQz_.js";import{n as v,r as y}from"./popover-select-CLsphyzA.js";import{i as b}from"./file-tree-utils-DJs1faGv.js";import{t as x}from"./cloud-C4-yfnnk.js";import{t as S}from"./copy-Dv6d4Dvw.js";import{t as C}from"./file-text-D12HbeVy.js";import{t as w}from"./folder-open-CyzJ19I9.js";import{t as T}from"./history-DXH_9jsE.js";import{t as E}from"./loader-circle-CifKLtgG.js";import{t as D}from"./message-square-fVE7Ghj1.js";import{t as O}from"./plus-Q2yW6OE7.js";import{t as ee}from"./refresh-cw-BRlGaq2w.js";import{t as k}from"./sticky-note-fzP7NAJq.js";import{t as A}from"./trash-2-DusmjVPV.js";import{n as j,r as M,t as N}from"./share-link-dialog-3RNzFIH3.js";import{t as P}from"./x-B_N4OPjy.js";import{t as F}from"./cn-0WouolD0.js";import{t as I}from"./skeleton-DzdOeGYz.js";import{i as te}from"./vendor-swr-CdRzEUwF.js";import{n as L,r as R}from"./gateway-config-swr-2VOPSLSq.js";import{o as z}from"./agents-admin-api-_mp_Ew1u.js";import{t as B}from"./button-ChmVQg9O.js";import{t as V}from"./copy-to-clipboard-HOJ79TWv.js";import{s as H}from"./form-field-width-DJw_jULe.js";import{t as U}from"./page-tabs-DoYMKhVO.js";import{n as W}from"./agent-display-names-Bje7vfSn.js";import{r as G}from"./settings-form-draft-Dy10ldo8.js";import{t as K}from"./confirm-dialog-DkviAS5j.js";import{t as ne}from"./file-tree-CYUkQR1t.js";import{a as q,b as re,c as ie,g as ae,l as oe,m as se,o as ce,r as le,t as ue,v as de,x as fe}from"./shares-api-B532SLIU.js";import{t as pe}from"./use-workspace-tree-VwHdfiR8.js";import{t as me}from"./workspace-editor-agent-store-Bh4FYwVq.js";import{t as he}from"./settings-loading-skeleton-CAoOV17i.js";import{t as ge}from"./oauth-provider-connect-3QGibJMl.js";import{t as _e}from"./number-input-El7Szeln.js";import{n as ve,t as ye}from"./settings-page-header-DKgbD0Bc.js";import{t as be}from"./settings-page-layout-BE3vLWp_.js";import{t as J}from"./settings-form-section-num14vSv.js";var Y=e(t(),1),xe=n(),X={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 Se(){return structuredClone(X)}var Z=36e5,Ce=864e5,Q=1048576;function we(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Te(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 Ee(e){let t=we(e)?e:{},n=we(t.gateway)?t.gateway:{},r=we(n.share)?n.share:{},i=we(r.directory)?r.directory:{},a=we(r.note)?r.note:{},o=we(n.siteShare)?n.siteShare:{},s=we(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):X.defaultTtlHours*Z,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):X.maxTtlDays*Ce,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):X.maxFileSizeMb*Q,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):X.directoryMaxFolderSizeMb*Q,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):X.siteDefaultTtlHours*Z,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):X.siteMaxTtlDays*Ce,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):X.siteMaxRootDirSizeMb*Q,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):X.noteMaxTotalSizeMb*Q;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/Z)),maxTtlDays:Math.max(1,Math.round(l/Ce)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):X.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/Q)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/Q)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):X.directoryMaxFileCount,inlinePreviewMimes:Te(r.inlinePreviewMimes,32).length?Te(r.inlinePreviewMimes,32):[...X.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/Q)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):X.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/Z)),siteMaxTtlDays:Math.max(1,Math.round(p/Ce)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):X.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/Q)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):X.siteMaxFileCount}}function De(e){let t=e.defaultTtlHours*Z,n=e.maxTtlDays*Ce,r=e.siteDefaultTtlHours*Z,i=e.siteMaxTtlDays*Ce;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 Oe(e){let t=De(e);if(t)throw Error(t);await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*Z,maxTtlMs:e.maxTtlDays*Ce,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Q,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Q,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*Q,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*Z,maxTtlMs:e.siteMaxTtlDays*Ce,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Q,maxFileCount:e.siteMaxFileCount}}}})}),L()}var $=r();function ke(){return F(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H,`dark:border-edge`)}function Ae({hasToken:e}){let t=l(s(e=>e.language)).sharesSettings,{data:n,isLoading:r}=R(e),i=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(Ee(n.payload.config)),[n]),a=(0,Y.useRef)(!1),[o,c]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),g=o??i,_=i,v=(0,Y.useMemo)(()=>!g||!_?!1:JSON.stringify(g)!==JSON.stringify(_),[g,_]),y=(0,Y.useCallback)(e=>{a.current=!0,c(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),b=(0,Y.useCallback)(async()=>{if(!(!g||u)){d(!0),p(null),h(!1);try{await Oe(g),a.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2500)}catch(e){p(e instanceof Error?e.message:t.policySaveError)}finally{d(!1)}}},[g,u,t.policySaveError]),x=(0,Y.useCallback)(()=>{a.current=!1,c(null),p(null),h(!1)},[]);return!e||!g?r?(0,$.jsx)(J,{children:(0,$.jsx)(he,{rows:2})}):null:(0,$.jsxs)(J,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[m?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,$.jsx)(B,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>y(Se()),children:t.policyUseRecommended}),(0,$.jsx)(B,{type:`button`,variant:`secondary`,disabled:!v||u,onClick:x,children:t.policyDiscard}),(0,$.jsx)(B,{type:`button`,variant:`primary`,disabled:!v||u,onClick:()=>void b(),children:u?t.policySaving:t.policySave})]})]}),v?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,f?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,$.jsx)(je,{t,form:g,onChange:y})]})}function je(e){let t=(0,xe.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,$.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,$.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,$.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,$.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,$.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,$.jsx)(Me,{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,$.jsx)(Me,{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,$.jsx)(Me,{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,$.jsx)(Me,{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 C=!r.enabled,w;t[47]===i?w=t[48]:(w=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=w);let T;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==w?(T=(0,$.jsx)(Me,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:w}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=w,t[54]=T):T=t[54];let E=!r.enabled,D;t[55]===i?D=t[56]:(D=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=D);let O;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==E||t[61]!==D?(O=(0,$.jsx)(Me,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:E,onChange:D}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=E,t[61]=D,t[62]=O):O=t[62];let ee;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==T||t[67]!==O||t[68]!==p?(ee=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,T,O]}),t[63]=g,t[64]=y,t[65]=S,t[66]=T,t[67]=O,t[68]=p,t[69]=ee):ee=t[69];let k=!r.enabled,A;t[70]===i?A=t[71]:(A=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=A);let j;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==k||t[75]!==A?(j=(0,$.jsx)(Ne,{t:n,values:r.inlinePreviewMimes,disabled:k,onChange:A}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=k,t[75]=A,t[76]=j):j=t[76];let M;t[77]!==ee||t[78]!==j||t[79]!==s||t[80]!==u?(M=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[s,u,ee,j]}),t[77]=ee,t[78]=j,t[79]=s,t[80]=u,t[81]=M):M=t[81];let N;t[82]===n.policyNoteSection?N=t[83]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=N);let P;t[84]===n.policyNoteSectionHint?P=t[85]:(P=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=P);let F;t[86]!==N||t[87]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-4`,children:[N,P]}),t[86]=N,t[87]=P,t[88]=F):F=t[88];let I;t[89]===i?I=t[90]:(I=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=I);let te;t[91]!==r.noteEnabled||t[92]!==I?(te=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:I}),t[91]=r.noteEnabled,t[92]=I,t[93]=te):te=t[93];let L;t[94]!==n.policyNoteEnabled||t[95]!==te?(L=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[te,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=te,t[96]=L):L=t[96];let R=!r.enabled||!r.noteEnabled,z;t[97]===i?z=t[98]:(z=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=z);let B;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==R||t[103]!==z?(B=(0,$.jsx)(Me,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:R,onChange:z}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=R,t[103]=z,t[104]=B):B=t[104];let V=!r.enabled||!r.noteEnabled,H;t[105]===i?H=t[106]:(H=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=H);let U;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==V||t[111]!==H?(U=(0,$.jsx)(Me,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:V,onChange:H}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=V,t[111]=H,t[112]=U):U=t[112];let W;t[113]!==B||t[114]!==U?(W=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[B,U]}),t[113]=B,t[114]=U,t[115]=W):W=t[115];let G;t[116]!==F||t[117]!==L||t[118]!==W?(G=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[F,L,W]}),t[116]=F,t[117]=L,t[118]=W,t[119]=G):G=t[119];let K;t[120]===n.policySiteSection?K=t[121]:(K=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=K);let ne;t[122]===n.policySiteSectionHint?ne=t[123]:(ne=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=ne);let q;t[124]!==K||t[125]!==ne?(q=(0,$.jsxs)(`div`,{className:`mb-4`,children:[K,ne]}),t[124]=K,t[125]=ne,t[126]=q):q=t[126];let re;t[127]===i?re=t[128]:(re=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=re);let ie;t[129]!==r.siteEnabled||t[130]!==re?(ie=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:re}),t[129]=r.siteEnabled,t[130]=re,t[131]=ie):ie=t[131];let ae;t[132]!==n.policySiteEnabled||t[133]!==ie?(ae=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ie,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=ie,t[134]=ae):ae=t[134];let oe=!r.siteEnabled,se;t[135]===i?se=t[136]:(se=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=se);let ce;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==oe||t[141]!==se?(ce=(0,$.jsx)(Me,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:oe,onChange:se}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=oe,t[141]=se,t[142]=ce):ce=t[142];let le=!r.siteEnabled,ue;t[143]===i?ue=t[144]:(ue=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=ue);let de;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==le||t[149]!==ue?(de=(0,$.jsx)(Me,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:le,onChange:ue}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=le,t[149]=ue,t[150]=de):de=t[150];let fe=!r.siteEnabled,pe;t[151]===i?pe=t[152]:(pe=e=>i({maxActiveSites:e}),t[151]=i,t[152]=pe);let me;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==fe||t[157]!==pe?(me=(0,$.jsx)(Me,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:fe,onChange:pe}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=fe,t[157]=pe,t[158]=me):me=t[158];let he=!r.siteEnabled,ge;t[159]===i?ge=t[160]:(ge=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=ge);let _e;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==he||t[165]!==ge?(_e=(0,$.jsx)(Me,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:he,onChange:ge}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=he,t[165]=ge,t[166]=_e):_e=t[166];let ve=!r.siteEnabled,ye;t[167]===i?ye=t[168]:(ye=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=ye);let be;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==ve||t[173]!==ye?(be=(0,$.jsx)(Me,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:ve,onChange:ye}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=ve,t[173]=ye,t[174]=be):be=t[174];let J;t[175]!==ce||t[176]!==de||t[177]!==me||t[178]!==_e||t[179]!==be?(J=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,de,me,_e,be]}),t[175]=ce,t[176]=de,t[177]=me,t[178]=_e,t[179]=be,t[180]=J):J=t[180];let Y;t[181]!==q||t[182]!==ae||t[183]!==J?(Y=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[q,ae,J]}),t[181]=q,t[182]=ae,t[183]=J,t[184]=Y):Y=t[184];let X;return t[185]!==M||t[186]!==G||t[187]!==Y?(X=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[M,G,Y]}),t[185]=M,t[186]=G,t[187]=Y,t[188]=X):X=t[188],X}function Me(e){let t=(0,xe.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,$.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 d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=F(ke(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let f;t[4]!==s||t[5]!==o||t[6]!==l?(f=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]=f):f=t[7];let p;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==f||t[13]!==a?(p=(0,$.jsx)(_e,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:f}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=f,t[13]=a,t[14]=p):p=t[14];let m;t[15]===i?m=t[16]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=m);let h;return t[17]!==u||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{children:[u,p,m]}),t[17]=u,t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function Ne(e){let t=(0,xe.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,$.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,$.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,$.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,$.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 d;t[11]===u?d=t[12]:(d=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let f;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(f=F(ke(),`font-mono text-xs`),t[13]=f):f=t[13];let p=i||r.length>=32,m;t[14]===s?m=t[15]:(m=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=m);let h;t[16]!==n.policyMimePlaceholder||t[17]!==p||t[18]!==m?(h=(0,$.jsx)(`input`,{className:f,placeholder:n.policyMimePlaceholder,disabled:p,onKeyDown:m}),t[16]=n.policyMimePlaceholder,t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[c,l,d,h]}),t[20]=c,t[21]=l,t[22]=d,t[23]=h,t[24]=g):g=t[24],g}function Pe(e){let t=(0,xe.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,conversationId:g,agentId:_}=e,b=c===void 0?`any`:c,x=l(s(Le)),S=x.workspace,C=x.sharesSettings,T=me(Ie),{data:D}=te(o(Fe)?`picker-agents-list`:null,z),O;bb0:{let e;t[0]===_?e=t[1]:(e=_?.trim(),t[0]=_,t[1]=e);let n=e;if(n){O=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){O=i;break bb0}if(D?.defaultId){O=D.defaultId;break bb0}if(D?.agents?.[0]?.id){O=D.agents[0].id;break bb0}O=``}let k=O,[A,j]=(0,Y.useState)(k),M,N;t[4]===k?(M=t[5],N=t[6]):(M=()=>{j(k)},N=[k],t[4]=k,t[5]=M,t[6]=N),(0,Y.useEffect)(M,N);let{tree:I,loading:L,error:R,loadRoot:V,loadChildren:H,reset:U}=pe(A,g??null),G;t[7]===a?G=t[8]:(G=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=G);let[K,q]=(0,Y.useState)(G),re;t[9]!==a||t[10]!==V||t[11]!==n||t[12]!==U||t[13]!==q?(re=()=>{if(!n){U(),q(a?{path:a,isDirectory:!1}:null);return}V()},t[9]=a,t[10]=V,t[11]=n,t[12]=U,t[13]=q,t[14]=re):re=t[14];let ie;t[15]!==g||t[16]!==a||t[17]!==V||t[18]!==n||t[19]!==A||t[20]!==U?(ie=[n,A,g,V,U,a],t[15]=g,t[16]=a,t[17]=V,t[18]=n,t[19]=A,t[20]=U,t[21]=ie):ie=t[21],(0,Y.useEffect)(re,ie);let ae;t[22]===H?ae=t[23]:(ae=e=>{H(e)},t[22]=H,t[23]=ae);let oe=ae,se=K!==null&&(b===`any`||b===`file`&&!K.isDirectory||b===`directory`&&K.isDirectory),ce;bb1:{if(!K){ce=C.pickerHintNone;break bb1}if(b===`file`&&K.isDirectory){ce=C.pickerHintNeedsFile;break bb1}if(b===`directory`&&!K.isDirectory){ce=C.pickerHintNeedsDirectory;break bb1}ce=`${K.isDirectory?`📁`:`📄`} ${K.path}`}let le=ce,ue=D?.agents??[],de;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=de):de=t[24];let fe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(fe=F(`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]=fe):fe=t[25];let he;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(w,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=he):he=t[26];let ge=x.cron.refresh,_e=x.cron.refresh,ve;t[27]===V?ve=t[28]:(ve=()=>void V(),t[27]=V,t[28]=ve);let ye=L&&`animate-spin`,be;t[29]===ye?be=t[30]:(be=F(`size-4`,ye),t[29]=ye,t[30]=be);let J;t[31]===be?J=t[32]:(J=(0,$.jsx)(ee,{className:be,"aria-hidden":!0}),t[31]=be,t[32]=J);let X;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,$.jsx)(P,{className:`size-4`}),t[33]=X):X=t[33];let Se;t[34]!==R||t[35]!==S.loadError?(Se=R?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[S.loadError,`: `,R]}):null,t[34]=R,t[35]=S.loadError,t[36]=Se):Se=t[36];let Z;t[37]!==oe||t[38]!==L||t[39]!==K?.path||t[40]!==q||t[41]!==S.emptyDir||t[42]!==S.title||t[43]!==I?(Z=L&&I.length===0?(0,$.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(E,{className:`size-4 animate-spin`}),S.title,`…`]}):(0,$.jsx)(ne,{tree:I,selectedPath:K?.path??null,onSelectFile:e=>q({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>q({path:e,isDirectory:t}),onExpandDir:oe,onAction:void 0,emptyHint:S.emptyDir}),t[37]=oe,t[38]=L,t[39]=K?.path,t[40]=q,t[41]=S.emptyDir,t[42]=S.title,t[43]=I,t[44]=Z):Z=t[44];let Ce;t[45]!==Se||t[46]!==Z?(Ce=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[Se,Z]}),t[45]=Se,t[46]=Z,t[47]=Ce):Ce=t[47];let Q;t[48]===le?Q=t[49]:(Q=(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:le}),t[48]=le,t[49]=Q);let we;t[50]===r?we=t[51]:(we=()=>r(!1),t[50]=r,t[51]=we);let Te;t[52]!==C.cancel||t[53]!==we?(Te=(0,$.jsx)(B,{type:`button`,variant:`ghost`,onClick:we,children:C.cancel}),t[52]=C.cancel,t[53]=we,t[54]=Te):Te=t[54];let Ee=!se,De;t[55]!==i||t[56]!==r||t[57]!==A||t[58]!==K?(De=()=>{K&&(i({...K,agentId:A}),r(!1))},t[55]=i,t[56]=r,t[57]=A,t[58]=K,t[59]=De):De=t[59];let Oe;t[60]!==C.pickerConfirm||t[61]!==Ee||t[62]!==De?(Oe=(0,$.jsx)(B,{type:`button`,disabled:Ee,onClick:De,children:C.pickerConfirm}),t[60]=C.pickerConfirm,t[61]=Ee,t[62]=De,t[63]=Oe):Oe=t[63];let ke;t[64]!==Te||t[65]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Te,Oe]}),t[64]=Te,t[65]=Oe,t[66]=ke):ke=t[66];let Ae;return t[67]!==Q||t[68]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Q,ke]}),t[67]=Q,t[68]=ke,t[69]=Ae):Ae=t[69],(0,$.jsx)(h,{open:n,onOpenChange:r,children:(0,$.jsxs)(f,{children:[de,(0,$.jsxs)(p,{className:fe,children:[(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[he,(0,$.jsx)(m,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:C.pickerTitle}),(0,$.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:ge,"aria-label":_e,disabled:L,onClick:ve,children:J}),(0,$.jsx)(d,{asChild:!0,children:(0,$.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":S.close,children:X})})]}),ue.length>0?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,$.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:C.pickerAgentLabel}),(0,$.jsx)(v,{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:A,onChange:e=>{j(e.target.value),q(null)},children:ue.map(e=>(0,$.jsxs)(y,{value:e.id,children:[W(e,x.agentsSettings),e.id===D?.defaultId?` ★`:``]},e.id))})]}):null,Ce,Ae]})]})})}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,xe.c)(23),t=s(Ge),n=l(t).sharesSettings,r=!!o(We),[a,c]=i(),u;e[0]===a?u=e[1]:(u=ze(a.get(`tab`)),e[0]=a,e[1]=u);let d=u,f;e[2]===c?f=e[3]:(f=e=>{c(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=c,e[3]=f);let p=f;if(!r)return(0,$.jsx)(ve,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let m={shares:n.tabShares,policy:n.tabPolicy},h=Re.map(e=>({id:e,label:m[e]})),g;e[4]===n.title?g=e[5]:(g=(0,$.jsx)(ye,{title:n.title}),e[4]=n.title,e[5]=g);let _;e[6]!==d||e[7]!==p||e[8]!==n.tabsAria||e[9]!==h?(_=(0,$.jsx)(U,{items:h,activeTab:d,onChange:p,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[6]=d,e[7]=p,e[8]=n.tabsAria,e[9]=h,e[10]=_):_=e[10];let v;e[11]!==d||e[12]!==r||e[13]!==t||e[14]!==n?(v=d===`shares`?(0,$.jsx)(Ke,{t:n,language:t}):(0,$.jsx)(Ae,{hasToken:r}),e[11]=d,e[12]=r,e[13]=t,e[14]=n,e[15]=v):v=e[15];let y;e[16]!==d||e[17]!==v?(y=(0,$.jsx)(be,{id:d,activeTab:d,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[16]=d,e[17]=v,e[18]=y):y=e[18];let b;return e[19]!==g||e[20]!==_||e[21]!==y?(b=(0,$.jsxs)(ve,{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,xe.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}=te(`shares-list`,se,i),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:3e4},t[1]=l):l=t[1];let u=te(`hosted-publications-list`,oe,l),d;t[2]===a?.payload?.shares?d=t[3]:(d=a?.payload?.shares??[],t[2]=a?.payload?.shares,t[3]=d);let f=d,[p,m]=(0,Y.useState)(!1),h;bb0:{if(p){h=f;break bb0}let e;t[4]===f?e=t[5]:(e=f.filter(Ze),t[4]=f,t[5]=e),h=e}let g=h,_;t[6]===f?_=t[7]:(_=f.filter(Xe),t[6]=f,t[7]=_);let v=_.length,y;t[8]===f?y=t[9]:(y=f.filter(Ye),t[8]=f,t[9]=y);let b=y.length,x;t[10]===c?x=t[11]:(x=()=>void c(),t[10]=c,t[11]=x);let S;t[12]!==n||t[13]!==x?(S=(0,$.jsx)(rt,{t:n,onCreated:x}),t[12]=n,t[13]=x,t[14]=S):S=t[14];let C=u.data?.connected===!0,w=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]!==w||t[19]!==T||t[20]!==C?(E=(0,$.jsx)(Qe,{language:r,connected:C,publishingAllowed:w,onCreated:T}),t[17]=r,t[18]=w,t[19]=T,t[20]=C,t[21]=E):E=t[21];let D=p?n.allSharesTitle:n.listTitle,O;t[22]===v?O=t[23]:(O=v>0&&(0,$.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[22]=v,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[D,O]}),t[24]=D,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`,M;t[29]===j?M=t[30]:(M=F(`size-3.5`,j),t[29]=j,t[30]=M);let N;t[31]===M?N=t[32]:(N=(0,$.jsx)(ee,{className:M}),t[31]=M,t[32]=N);let P;t[33]!==s||t[34]!==A||t[35]!==N?(P=(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:A,disabled:s,children:N}),t[33]=s,t[34]=A,t[35]=N,t[36]=P):P=t[36];let I;t[37]!==b||t[38]!==p||t[39]!==n.hideExpired||t[40]!==n.showExpired?(I=b>0&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Je),children:p?n.hideExpired:n.showExpired}),t[37]=b,t[38]=p,t[39]=n.hideExpired,t[40]=n.showExpired,t[41]=I):I=t[41];let L;t[42]!==P||t[43]!==I?(L=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,I]}),t[42]=P,t[43]=I,t[44]=L):L=t[44];let R;t[45]!==k||t[46]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[k,L]}),t[45]=k,t[46]=L,t[47]=R):R=t[47];let z;t[48]!==a||t[49]!==o||t[50]!==g||t[51]!==s||t[52]!==r||t[53]!==c||t[54]!==n?(z=s&&!a?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(qe)}):o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:n.error}),(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):g.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,$.jsx)(at,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[48]=a,t[49]=o,t[50]=g,t[51]=s,t[52]=r,t[53]=c,t[54]=n,t[55]=z):z=t[55];let V;t[56]!==b||t[57]!==c||t[58]!==p||t[59]!==n?(V=b>0&&p&&(0,$.jsx)(ot,{t:n,onCleaned:()=>void c()}),t[56]=b,t[57]=c,t[58]=p,t[59]=n,t[60]=V):V=t[60];let H;t[61]!==R||t[62]!==z||t[63]!==V?(H=(0,$.jsxs)(J,{children:[R,z,V]}),t[61]=R,t[62]=z,t[63]=V,t[64]=H):H=t[64];let U;t[65]===u?U=t[66]:(U=()=>void u.mutate(),t[65]=u,t[66]=U);let W;t[67]!==u.data||t[68]!==u.error||t[69]!==u.isLoading||t[70]!==r||t[71]!==n||t[72]!==U?(W=(0,$.jsx)($e,{data:u.data,error:u.error,isLoading:u.isLoading,language:r,t:n,onChanged:U}),t[67]=u.data,t[68]=u.error,t[69]=u.isLoading,t[70]=r,t[71]=n,t[72]=U,t[73]=W):W=t[73];let G;return t[74]!==E||t[75]!==H||t[76]!==W||t[77]!==S?(G=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,E,H,W]}),t[74]=E,t[75]=H,t[76]=W,t[77]=S,t[78]=G):G=t[78],G}function qe(e,t){return(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(I,{className:`h-4 w-2/3`}),(0,$.jsx)(I,{className:`mt-2 h-3 w-1/2`})]}),(0,$.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,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(6048e5),[_,b]=(0,Y.useState)(!1),[S,T]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(null),ee=async()=>{if(a.trim()){b(!0),O(null);try{let e=await le({path:a.trim(),title:p.trim()||void 0,ttlMs:h,spaFallback:!0,...s?{agentId:s}:{}});T(e),r()}catch(e){O(e instanceof Error?e.message:String(e))}finally{b(!1)}}};return(0,$.jsxs)(J,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`发布静态网站`:`Publish static website`}),(0,$.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,$.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,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-[1fr_12rem]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{value:a,onChange:e=>{o(e.target.value),u(!1),T(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,$.jsxs)(B,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>f(!0),children:[a&&!l?(0,$.jsx)(C,{className:`size-4`}):(0,$.jsx)(w,{className:`size-4`}),a?i?`更换`:`Change`:i?`选择`:`Browse`]})]}),(0,$.jsxs)(v,{value:String(h),onChange:e=>g(Number(e.target.value)),children:[(0,$.jsx)(y,{value:`86400000`,children:i?`24 小时`:`24 hours`}),(0,$.jsx)(y,{value:`604800000`,children:i?`7 天`:`7 days`}),(0,$.jsx)(y,{value:`2592000000`,children:i?`30 天`:`30 days`})]}),(0,$.jsx)(`input`,{value:p,onChange:e=>m(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,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,$.jsxs)(B,{type:`button`,onClick:()=>void ee(),disabled:!a.trim()||_||!t||!n,children:[_?(0,$.jsx)(E,{className:`size-4 animate-spin`}):(0,$.jsx)(x,{className:`size-4`}),_?i?`发布中…`:`Publishing…`:i?`发布网站`:`Publish site`]}),S?(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 truncate text-xs text-accent hover:underline`,onClick:()=>void V(S.shareUrl),children:[S.shareUrl,` · `,S.fileCount,` `,i?`个文件`:`files`,` · `,Be(S.totalBytes)]}):null]}),D?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:D}):null]})]}),(0,$.jsx)(Pe,{open:d,onOpenChange:f,initialPath:a||void 0,agentId:s||void 0,selectKind:`any`,onConfirm:e=>{o(e.path),c(e.agentId),u(e.isDirectory),T(null),O(null)}})]})}function $e(e){let t=(0,xe.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,$.jsx)(x,{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,$.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,$.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,$.jsx)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:(0,$.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,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:2}).map(et)}):r?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o.error}):n?.connected?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n.publishingAllowed?null:(0,$.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,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedEmpty}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.publications.map(e=>(0,$.jsx)(tt,{publication:e,language:a,t:o,publishingAllowed:n.publishingAllowed,onChanged:s},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedDisconnected}),(0,$.jsx)(ge,{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,$.jsxs)(J,{children:[d,f]}),t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function et(e,t){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:[(0,$.jsx)(I,{className:`h-4 w-2/3`}),(0,$.jsx)(I,{className:`mt-2 h-3 w-1/2`})]},t)}function tt({publication:e,language:t,t:n,publishingAllowed:r,onChanged:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),h=Date.now()>=new Date(e.expiresAt).getTime(),_=e.status===`active`&&!h,v=e.status===`revoked`?n.statusRevoked:h?n.statusExpired:e.status===`staging`?t===`zh`?`准备中`:`Staging`:n.statusActive,y=e.kind===`note_document`?k:e.kind===`static_site`?x:D,b=e.kind===`note_document`?t===`zh`?`笔记文档`:`Note document`:e.kind===`static_site`?t===`zh`?`静态网站`:`Static website`:t===`zh`?`会话快照`:`Conversation snapshot`,C=(0,Y.useCallback)(async()=>{e.shareUrl&&await V(e.shareUrl)&&(u(!0),window.setTimeout(()=>u(!1),2e3))},[e.shareUrl]),w=(0,Y.useCallback)(async()=>{o(!1),c(!0);try{await de(e.id),i()}catch{}finally{c(!1)}},[e.id,i]),O=(0,Y.useCallback)(async()=>{if(!(!e.revision||e.revision<=1)){f(!0);try{let t=(await ie(e.id)).find(t=>t.revision<e.revision);if(!t)return;await fe(e.id,e.revision,t.revision),i()}catch{}finally{f(!1)}}},[e.id,e.revision,i]),j=(0,Y.useCallback)(async()=>{m(!0);try{await ae(e.id),i()}catch{}finally{m(!1)}},[e.id,i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:F(`text-xs font-medium`,_?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`),children:v})]}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[b,` · `,n.hostedRevision,` `,e.revision??`—`,` · `,e.managedFromThisDevice?n.hostedThisDevice:n.hostedOtherDevice]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{children:[t===`zh`?`浏览`:`Views`,`: `,e.viewCount,e.maxViews===null?``:` / ${e.maxViews}`]}),(0,$.jsx)(`span`,{children:h?n.statusExpired:Ve(e.expiresAt,t)}),e.description?(0,$.jsx)(`span`,{className:`italic`,children:e.description}):null]})]}),_?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.shareUrl?(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:!r,title:n.copyUrl,onClick:()=>void C(),children:l?(0,$.jsx)(g,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(S,{className:`size-3.5`})}):null,(e.revision??0)>1?(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:d||!r,onClick:()=>void O(),title:t===`zh`?`回滚上一版本`:`Roll back one revision`,children:d?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(T,{className:`size-3.5`})}):null,e.kind===`static_site`&&e.managedFromThisDevice?(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:p||!r,onClick:()=>void j(),title:t===`zh`?`发布工作区中的最新版本`:`Publish latest workspace version`,children:(0,$.jsx)(ee,{className:F(`size-3.5`,p&&`animate-spin`)})}):null,(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,disabled:s,onClick:()=>o(!0),children:s?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(A,{className:`size-3.5`})})]}):null]})}),(0,$.jsx)(K,{open:a,title:n.revokeConfirmTitle,description:n.revokeConfirmBody,confirmLabel:n.revokeConfirmLabel,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void w(),onCancel:()=>o(!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,Y.useReducer)(G,nt),{expanded:i,path:a,isDirectory:o,agentId:s,ttlMs:c,maxViews:l,description:u,directoryMode:d,creating:f,result:p,errorMsg:m,resultDialogOpen:h,pickerOpen:g}=n,_=(0,Y.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{let e=await q({path:a.trim(),ttlMs:c,maxViews:l,description:u.trim()||void 0,...s?{agentId:s}:{},...o?{kind:`directory`,directoryMode:d}:{}});r({type:`patch`,patch:{result:e.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,c,l,u,d,t]),b=(0,Y.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,$.jsxs)(J,{children:[(0,$.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:F(`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,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:o?`📁`:`📄`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,$.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,$.jsxs)(B,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,$.jsx)(C,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),o?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,$.jsxs)(v,{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:d,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,$.jsx)(y,{value:`browse`,children:e.directoryModeBrowse}),(0,$.jsx)(y,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,$.jsx)(v,{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:c,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:He.map(t=>(0,$.jsx)(y,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,$.jsxs)(v,{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??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,$.jsx)(y,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,$.jsx)(y,{value:`1`,children:`1`}),(0,$.jsx)(y,{value:`5`,children:`5`}),(0,$.jsx)(y,{value:`10`,children:`10`}),(0,$.jsx)(y,{value:`50`,children:`50`}),(0,$.jsx)(y,{value:`100`,children:`100`})]})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,$.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:u,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,$.jsxs)(B,{type:`button`,disabled:f||!a.trim(),onClick:()=>void _(),children:[f?(0,$.jsx)(E,{className:`size-4 animate-spin`}):(0,$.jsx)(O,{className:`size-4`}),f?e.creating:e.createButton]}),(0,$.jsx)(B,{type:`button`,variant:`ghost`,onClick:()=>{b(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),m&&(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m})]}),(0,$.jsx)(j,{open:h,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:p}),(0,$.jsx)(Pe,{open:g,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,$.jsxs)(B,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,$.jsx)(O,{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[a,o]=(0,Y.useReducer)(G,it),{revokeOpen:s,revoking:c,linksOpen:l,urlCopied:u,copyFailed:d,extending:f}=a,p=!e.expired&&!e.revoked,m=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,h=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,v=(0,Y.useCallback)(async()=>{o({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await re(e.id),r()}catch{}finally{o({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),y=(0,Y.useCallback)(async()=>{if(o({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await V(e.shareUrl)){o({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{copyFailed:!1}}),2500);return}o({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),x=(0,Y.useCallback)(async()=>{o({type:`patch`,patch:{extending:!0}});try{await ce(e.id,864e5),i()}catch{}finally{o({type:`patch`,patch:{extending:!1}})}},[e.id,i]),w=`share-links-${e.id}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:F(`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":l,"aria-controls":w,onClick:()=>o({type:`patch`,patch:{linksOpen:!l}}),children:[(0,$.jsx)(_,{className:F(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,l?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,$.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(D,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:F(`text-xs font-medium`,h),children:m})]}),(0,$.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,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:Be(e.fileSize)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(b,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Ve(e.expiresAt,n)]}),(0,$.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,$.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void y(),children:u?(0,$.jsx)(g,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(S,{className:`size-3.5`})}),(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void x(),disabled:f,title:t.extend,children:f?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(b,{className:`size-3.5`})}),(0,$.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>o({type:`patch`,patch:{revokeOpen:!0}}),disabled:c,children:c?(0,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(A,{className:`size-3.5`})})]})})]}),p&&l?(0,$.jsxs)(`div`,{id:w,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,$.jsx)(M,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),d?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(N,{reachability:e.reachability})})]}):null]}),(0,$.jsx)(K,{open:s,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void v(),onCancel:()=>o({type:`patch`,patch:{revokeOpen:!1}})})]})}function ot({t:e,onCleaned:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1),o=(0,Y.useCallback)(async()=>{r(!1),a(!0);try{await ue(),t()}catch{}finally{a(!1)}},[t]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(B,{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,$.jsx)(E,{className:`size-3.5 animate-spin`}):(0,$.jsx)(A,{className:`size-3.5`}),e.cleanExpired]})}),(0,$.jsx)(K,{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,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-DGZZ-M85.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/pdf-runtime-JnUAvfIa.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{d as o,f as s,h as c,t as l,u}from"./chunk-KS7C4IRE-BPb7KheU.js";import{i as d,n as f,o as p}from"./locale-store-B4o4aDCg.js";import{t as m}from"./archive-Dz0hferG.js";import{t as h}from"./arrow-down-to-line-C5D8Vt-L.js";import{t as g}from"./arrow-left-D880xG-P.js";import{n as _,r as v}from"./popover-select-CLsphyzA.js";import{t as y}from"./ellipsis-0k4rZLoy.js";import{t as b}from"./file-image-CDUPkZvG.js";import{t as x}from"./file-text-D12HbeVy.js";import{t as S}from"./file-CStvVK2S.js";import{n as C,t as w}from"./sheet-C2H8iR8Y.js";import{n as T,t as E}from"./star-BuMAkjC9.js";import{a as D,c as ee,f as O,g as k,h as A,l as j,m as M,p as N,r as te,s as P}from"./use-generated-media-CEJ5BBxX.js";import{t as ne}from"./pause-DuPxgSxk.js";import{t as re}from"./play-kxZvpBg8.js";import{t as F}from"./presentation-D-Ui_vVA.js";import{t as ie}from"./rotate-ccw-JM1TBLpp.js";import{t as ae}from"./search-DA7gz22f.js";import{i as oe,m as se,n as I,r as ce,t as L}from"./preview-runtime-BWkErYI2.js";import{t as R}from"./trash-2-DusmjVPV.js";import{t as le}from"./x-B_N4OPjy.js";import{t as z}from"./cn-0WouolD0.js";import{t as ue}from"./skeleton-DzdOeGYz.js";import{i as de,t as fe}from"./vendor-swr-CdRzEUwF.js";import"./constants-D5Z-mUto.js";import{a as pe,i as me,o as he,r as ge,s as _e}from"./dist-GJ8-1PAx.js";import{i as ve}from"./theme-store-C7t81hG7.js";import{t as B}from"./page-tabs-DoYMKhVO.js";import{t as ye}from"./page-header-store-D_2QZ6Ps.js";var be=e(n(),1),V=r(),H=e(t(),1),U=i();function xe({itemId:e,version:t,hit:n,download:r}){let i=f(e=>e.language),o=ve(e=>e.resolved),s=se(t.fileName,t.mimeType),c=s===`audio`||s===`video`,[l,u]=(0,H.useState)(null),d={id:`space:${t.id}`,context:`attachment`,source:{kind:`inline`},fileName:t.fileName,mimeType:t.mimeType,size:t.sizeBytes,type:s},p=ce(d),[m,h]=(0,H.useState)({loading:!0,textContent:null,binaryBuffer:null,loadError:null}),{plugin:g,controls:_}=p,{setPage:v,pageCount:y}=_,b=typeof n?.locator.page==`number`?n.locator.page:void 0,x=typeof n?.locator.slide==`number`?n.locator.slide:void 0,S=typeof n?.locator.line==`number`?n.locator.line:void 0,C=typeof n?.locator.sheet==`string`?n.locator.sheet:void 0,w=typeof n?.locator.paragraph==`number`?n.locator.paragraph:void 0;if((0,H.useEffect)(()=>{b&&y!==null&&v(b)},[b,y,v]),(0,H.useEffect)(()=>{let n=new AbortController,r;if(!c){if(g.readMode===`metadata`){h({loading:!1,textContent:null,binaryBuffer:null,loadError:null});return}if(g.maxBytes&&t.sizeBytes>g.maxBytes){h({loading:!1,textContent:null,binaryBuffer:null,loadError:i===`zh`?`文件过大,可下载查看`:`File too large to preview`});return}return O(e,t.id,n.signal).then(async e=>{let i=g.readMode===`text`?await e.text():null,o=g.readMode===`binary`?await e.arrayBuffer():null,c=s===`pptx`&&o?await a(()=>import(`./attachment-process-heavy-DGZZ-M85.js`).then(e=>e.processPptx(o,t.fileName)),__vite__mapDeps([0,1,2,3])):void 0;n.signal.aborted||(c&&u(c.extractedText),r=g.readMode===`url`?URL.createObjectURL(new Blob([e],{type:t.mimeType})):void 0,h({loading:!1,textContent:i,binaryBuffer:o,rawUrl:r,loadError:null}))}).catch(()=>{n.signal.aborted||h({loading:!1,textContent:null,binaryBuffer:null,loadError:i===`zh`?`资料暂不可读`:`Content unavailable`})}),()=>{n.abort(),r&&URL.revokeObjectURL(r)}}},[s,c,e,t.id,t.fileName,t.mimeType,t.sizeBytes,g,i]),c){let n=N(e,t.id);return(0,U.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 items-center justify-center overflow-hidden bg-surface-panel p-3`,children:s===`audio`?(0,U.jsx)(`audio`,{src:n,controls:!0,preload:`metadata`,className:`w-full`}):(0,U.jsx)(`video`,{src:n,controls:!0,playsInline:!0,preload:`metadata`,className:`max-h-full max-w-full rounded-lg`})})}return(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[g.capabilities.some(e=>[`zoom`,`pageNavigation`,`rotate`,`search`].includes(e))?(0,U.jsx)(`div`,{className:`border-b border-edge-subtle px-2 py-1`,children:(0,U.jsx)(L,{controller:p})}):null,(0,U.jsx)(I,{...m,descriptor:d,language:i,resolvedTheme:o,targetLine:S,targetSlide:x,targetSheet:C,targetParagraph:w,extractedText:l,controller:p,actions:{onDownload:r,canDownload:!0}})]})}var W=`grid h-9 w-11 shrink-0 place-items-center overflow-hidden rounded-md bg-surface-inset text-fg-muted`;function Se(e){let t=(0,V.c)(17),{kind:n,src:r}=e,i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),d,f;t[0]===n?(d=t[1],f=t[2]):(d=()=>{let e=i.current;if(n!==`video`||!e)return;let t=new IntersectionObserver(e=>{e.some(G)&&(o(!0),t.disconnect())});return t.observe(e),()=>t.disconnect()},f=[n],t[0]=n,t[1]=d,t[2]=f),(0,H.useEffect)(d,f);let p=n===`image`?b:C,m=!s&&`invisible`,h;t[3]===m?h=t[4]:(h=z(`absolute inset-0 size-full object-cover`,m),t[3]=m,t[4]=h);let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=z(W,`relative`),t[5]=_):_=t[5];let v;t[6]===p?v=t[7]:(v=(0,U.jsx)(p,{className:`size-4`}),t[6]=p,t[7]=v);let y;t[8]!==l||t[9]!==n||t[10]!==g||t[11]!==r||t[12]!==a?(y=!l&&(n===`image`?(0,U.jsx)(`img`,{src:r,width:44,height:36,loading:`lazy`,decoding:`async`,alt:``,className:g,onLoad:()=>c(!0),onError:()=>u(!0)}):a&&(0,U.jsx)(`video`,{src:`${r}#t=0.1`,muted:!0,playsInline:!0,preload:`metadata`,className:g,onLoadedData:()=>c(!0),onError:()=>u(!0)})),t[8]=l,t[9]=n,t[10]=g,t[11]=r,t[12]=a,t[13]=y):y=t[13];let x;return t[14]!==v||t[15]!==y?(x=(0,U.jsxs)(`span`,{ref:i,className:_,"aria-hidden":!0,children:[v,y]}),t[14]=v,t[15]=y,t[16]=x):x=t[16],x}function G(e){return e.isIntersecting}function Ce(e){let t=(0,V.c)(2),{icon:n}=e,r=n===void 0?S:n,i;return t[0]===r?i=t[1]:(i=(0,U.jsx)(`span`,{className:W,children:(0,U.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),t[0]=r,t[1]=i),i}function we(e){let t=(0,V.c)(25),{src:n,title:r,zh:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.active?.entry.source.src===n?e.active.entry.element:null,t[0]=n,t[1]=a);let o=P(a),{playing:s,starting:c,failed:l,toggle:u}=te(o),[d,f]=(0,H.useState)(!1),p=d||l,m=s||c,h=p?ie:m?ne:re,g=p?i?`重试播放`:`Retry playback`:m?i?`暂停`:`Pause`:i?`播放`:`Play`,_;t[2]!==o||t[3]!==n||t[4]!==r||t[5]!==u?(_=function(){f(!1),o?u():D({kind:`audio`,src:n,title:r}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||f(!0)})},t[2]=o,t[3]=n,t[4]=r,t[5]=u,t[6]=_):_=t[6];let v=_,y=`${g} ${r}`,b=m&&`bg-accent-soft text-accent-fg`,x;t[7]===b?x=t[8]:(x=z(W,`hover:bg-surface-active`,b),t[7]=b,t[8]=x);let S;t[9]===h?S=t[10]:(S=(0,U.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t[9]=h,t[10]=S);let C;t[11]!==x||t[12]!==S?(C=(0,U.jsx)(`span`,{className:x,children:S}),t[11]=x,t[12]=S,t[13]=C):C=t[13];let w;t[14]!==g||t[15]!==v||t[16]!==y||t[17]!==C?(w=(0,U.jsx)(`button`,{type:`button`,"aria-label":y,title:g,onClick:v,className:`absolute start-2 top-1/2 grid size-11 -translate-y-1/2 place-items-center rounded-md focus-visible:outline-2 focus-visible:outline-accent sm:start-3`,children:C}),t[14]=g,t[15]=v,t[16]=y,t[17]=C,t[18]=w):w=t[18];let T;t[19]!==d||t[20]!==i?(T=d?(0,U.jsx)(`span`,{role:`alert`,className:`sr-only`,children:i?`音频暂时无法播放,请重试。`:`Audio could not play. Try again.`}):null,t[19]=d,t[20]=i,t[21]=T):T=t[21];let E;return t[22]!==w||t[23]!==T?(E=(0,U.jsxs)(U.Fragment,{children:[w,T]}),t[22]=w,t[23]=T,t[24]=E):E=t[24],E}var Te={document:x,pdf:x,spreadsheet:w,presentation:F,audio:k,archive:m},K=`inline-flex size-9 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,q=`block w-full rounded-lg px-3 py-2 text-start text-sm hover:bg-surface-hover`,Ee=`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover disabled:opacity-50`,De=`grid grid-cols-[minmax(0,1fr)_5rem] items-center gap-3 px-2 sm:px-3 @xl/list:grid-cols-[minmax(0,1fr)_4.5rem_minmax(0,0.55fr)_6.5rem] @xl/list:gap-4`,J=38,Y=30,X=72,Z=`xopc.space.previewWidth`;function Oe(){try{let e=Number(window.localStorage.getItem(Z));if(e>=Y&&e<=X)return e}catch{}return J}function Q(e){try{window.localStorage.setItem(Z,String(e))}catch{}}function ke(e){let t=e.get(`view`);return t===`favorites`||t===`trash`?t:`all`}function Ae(e){let t=(0,V.c)(33),{zh:n,width:r,onResize:i}=e,a=(0,H.useRef)(null),[o,s]=(0,H.useState)(!1),c;t[0]===i?c=t[1]:(c=function(e){let t=Math.max(Y,Math.min(X,e));return i(t),t},t[0]=i,t[1]=c);let l=c,u=n?`调整资料预览宽度`:`Resize file preview`,d;t[2]===r?d=t[3]:(d=Math.round(r),t[2]=r,t[3]=d);let f=n?`左右拖动调整宽度,双击恢复默认`:`Drag to resize, double-click to reset`,p=o&&`bg-accent-soft/40`,m;t[4]===p?m=t[5]:(m=z(`group absolute inset-y-0 start-0 z-20 hidden w-3 -translate-x-1/2 cursor-col-resize touch-none select-none items-center justify-center rounded-sm focus-visible:outline-2 focus-visible:outline-accent @min-[58rem]/space:flex`,p),t[4]=p,t[5]=m);let h;t[6]===r?h=t[7]:(h=e=>{if(e.button!==0||a.current)return;let t=e.currentTarget,n=t.closest(`[data-space-preview-host]`)?.parentElement?.clientWidth;n&&(e.preventDefault(),t.setPointerCapture(e.pointerId),a.current={id:e.pointerId,startX:e.clientX,startWidth:r,availableWidth:n,currentWidth:r},s(!0))},t[6]=r,t[7]=h);let g;t[8]===l?g=t[9]:(g=e=>{let t=a.current;t?.id===e.pointerId&&(t.currentWidth=l(t.startWidth+(t.startX-e.clientX)*100/t.availableWidth))},t[8]=l,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{a.current?.id===e.pointerId&&(Q(a.current.currentWidth),a.current=null,s(!1))},t[10]=_):_=t[10];let v;t[11]===l?v=t[12]:(v=()=>Q(l(J)),t[11]=l,t[12]=v);let y;t[13]!==l||t[14]!==r?(y=e=>{let t={ArrowLeft:r+2,ArrowRight:r-2,Home:Y,End:X};Object.hasOwn(t,e.key)&&(e.preventDefault(),Q(l(t[e.key])))},t[13]=l,t[14]=r,t[15]=y):y=t[15];let b=o&&`bg-accent`,x;t[16]===b?x=t[17]:(x=z(`h-10 w-0.5 rounded-full bg-edge group-hover:bg-accent group-focus-visible:bg-accent`,b),t[16]=b,t[17]=x);let S;t[18]===x?S=t[19]:(S=(0,U.jsx)(`span`,{"aria-hidden":!0,className:x}),t[18]=x,t[19]=S);let C;t[20]===o?C=t[21]:(C=o?(0,U.jsx)(`span`,{"aria-hidden":!0,className:`fixed inset-0 z-50 cursor-col-resize`}):null,t[20]=o,t[21]=C);let w;return t[22]!==v||t[23]!==y||t[24]!==S||t[25]!==C||t[26]!==u||t[27]!==d||t[28]!==f||t[29]!==m||t[30]!==h||t[31]!==g?(w=(0,U.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":u,"aria-controls":`space-file-preview`,"aria-valuemin":Y,"aria-valuemax":X,"aria-valuenow":d,tabIndex:0,title:f,className:m,onPointerDown:h,onPointerMove:g,onLostPointerCapture:_,onDoubleClick:v,onKeyDown:y,children:[S,C]}),t[22]=v,t[23]=y,t[24]=S,t[25]=C,t[26]=u,t[27]=d,t[28]=f,t[29]=m,t[30]=h,t[31]=g,t[32]=w):w=t[32],w}function je(e){return e?.available?e.kind===`task`&&e.taskId?`/tasks/${encodeURIComponent(e.taskId)}`:e.kind===`automation`&&e.automationRunId?`/automations?view=execution&run=${encodeURIComponent(e.automationRunId)}`:`/chat/${encodeURIComponent(e.conversationId)}`:null}function Me(e){let t=(0,V.c)(20),{text:n,query:r}=e,i,a,o,s,c;if(t[0]!==r||t[1]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=r?n.toLowerCase().indexOf(r.toLowerCase()):-1;if(e<0){let e;t[7]===n?e=t[8]:(e=(0,U.jsx)(U.Fragment,{children:n}),t[7]=n,t[8]=e),c=e;break bb0}i=e+r.length,s=e>40?`…${n.slice(e-40,e)}`:n.slice(0,e),a=`rounded-sm bg-accent-soft text-accent-fg`,o=n.slice(e,i)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[9]!==a||t[10]!==o?(l=(0,U.jsx)(`mark`,{className:a,children:o}),t[9]=a,t[10]=o,t[11]=l):l=t[11];let u;t[12]!==i||t[13]!==n?(u=n.slice(i,i+100),t[12]=i,t[13]=n,t[14]=u):u=t[14];let d=i+100<n.length?`…`:``,f;return t[15]!==s||t[16]!==l||t[17]!==u||t[18]!==d?(f=(0,U.jsxs)(U.Fragment,{children:[s,l,u,d]}),t[15]=s,t[16]=l,t[17]=u,t[18]=d,t[19]=f):f=t[19],f}function Ne(e){let t=(0,V.c)(22),{zh:n}=e,[r,i]=c(),a=o(),s=(0,H.useRef)(null),l;t[0]===r?l=t[1]:(l=(r.get(`q`)??``).slice(0,160),t[0]=r,t[1]=l);let u=l,d=n?`搜索资料`:`Search files`,f,p;t[2]!==a||t[3]!==u?(f=()=>{let e=s.current;e&&(document.activeElement!==e||a===`POP`)&&(e.value=u)},p=[a,u],t[2]=a,t[3]=u,t[4]=f,t[5]=p):(f=t[4],p=t[5]),(0,H.useLayoutEffect)(f,p);let m;t[6]===i?m=t[7]:(m=function(e){i(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n},{replace:!0})},t[6]=i,t[7]=m);let h=m,g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,U.jsx)(ae,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[8]=g):g=t[8];let _;t[9]===h?_=t[10]:(_=e=>h(e.target.value),t[9]=h,t[10]=_);let v;t[11]!==d||t[12]!==u||t[13]!==_?(v=(0,U.jsx)(`input`,{ref:s,defaultValue:u,maxLength:160,onChange:_,"aria-label":d,placeholder:d,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none`}),t[11]=d,t[12]=u,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==h||t[16]!==u||t[17]!==n?(y=u?(0,U.jsx)(`button`,{type:`button`,className:z(K,`size-6`),onClick:()=>{h(``),s.current&&(s.current.value=``,s.current.focus())},"aria-label":n?`清除搜索`:`Clear search`,children:(0,U.jsx)(le,{className:`size-4`})}):null,t[15]=h,t[16]=u,t[17]=n,t[18]=y):y=t[18];let b;return t[19]!==v||t[20]!==y?(b=(0,U.jsxs)(`div`,{role:`search`,className:`flex h-9 min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge-subtle bg-surface-inset px-2.5 focus-within:ring-2 focus-within:ring-accent @min-[40rem]/space-list:w-[clamp(7rem,24cqw,18rem)]`,children:[g,v,y]}),t[19]=v,t[20]=y,t[21]=b):b=t[21],b}function Pe(e){let t=(0,V.c)(44),{zh:n}=e,[r,i]=c(),a=n?`文档`:`Documents`,o;t[0]===a?o=t[1]:(o=[`document`,a],t[0]=a,t[1]=o);let s=n?`表格`:`Spreadsheets`,l;t[2]===s?l=t[3]:(l=[`spreadsheet`,s],t[2]=s,t[3]=l);let u=n?`演示`:`Slides`,d;t[4]===u?d=t[5]:(d=[`presentation`,u],t[4]=u,t[5]=d);let f=n?`图片`:`Images`,p;t[6]===f?p=t[7]:(p=[`image`,f],t[6]=f,t[7]=p);let m=n?`音频`:`Audio`,h;t[8]===m?h=t[9]:(h=[`audio`,m],t[8]=m,t[9]=h);let g=n?`视频`:`Video`,y;t[10]===g?y=t[11]:(y=[`video`,g],t[10]=g,t[11]=y);let b=n?`压缩包`:`Archives`,x;t[12]===b?x=t[13]:(x=[`archive`,b],t[12]=b,t[13]=x);let S=n?`文件`:`Files`,C;t[14]===S?C=t[15]:(C=[`file`,S],t[14]=S,t[15]=C);let w;t[16]!==h||t[17]!==y||t[18]!==x||t[19]!==C||t[20]!==o||t[21]!==l||t[22]!==d||t[23]!==p?(w=[o,l,d,p,h,y,x,C],t[16]=h,t[17]=y,t[18]=x,t[19]=C,t[20]=o,t[21]=l,t[22]=d,t[23]=p,t[24]=w):w=t[24];let T=w,E;t[25]===n?E=t[26]:(E=(0,U.jsx)(Ne,{zh:n}),t[25]=n,t[26]=E);let D;t[27]===r?D=t[28]:(D=r.get(`kind`)??`all`,t[27]=r,t[28]=D);let ee=n?`资料类型`:`File type`,O;t[29]===i?O=t[30]:(O=e=>i(t=>{let n=new URLSearchParams(t);return e.target.value===`all`?n.delete(`kind`):n.set(`kind`,e.target.value),n}),t[29]=i,t[30]=O);let k=n?`全部类型`:`All types`,A;t[31]===k?A=t[32]:(A=(0,U.jsx)(v,{value:`all`,children:k}),t[31]=k,t[32]=A);let j;t[33]===T?j=t[34]:(j=T.map(Fe),t[33]=T,t[34]=j);let M;t[35]!==D||t[36]!==ee||t[37]!==O||t[38]!==A||t[39]!==j?(M=(0,U.jsxs)(_,{value:D,align:`end`,"aria-label":ee,triggerClassName:`h-9 shrink-0`,onChange:O,children:[A,j]}),t[35]=D,t[36]=ee,t[37]=O,t[38]=A,t[39]=j,t[40]=M):M=t[40];let N;return t[41]!==E||t[42]!==M?(N=(0,U.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2`,children:[E,M]}),t[41]=E,t[42]=M,t[43]=N):N=t[43],N}function Fe(e){let[t,n]=e;return(0,U.jsx)(v,{value:t,children:n},t)}function Ie(e){let t=(0,V.c)(25),{zh:n,onViewChange:r}=e,[i,a]=c(),o=n?`全部资料`:`All files`,s;t[0]===o?s=t[1]:(s={id:`all`,label:o,icon:T},t[0]=o,t[1]=s);let l=n?`收藏`:`Favorites`,u;t[2]===l?u=t[3]:(u={id:`favorites`,label:l,icon:E},t[2]=l,t[3]=u);let d=n?`回收站`:`Trash`,f;t[4]===d?f=t[5]:(f={id:`trash`,label:d,icon:R},t[4]=d,t[5]=f);let p;t[6]!==s||t[7]!==u||t[8]!==f?(p=[s,u,f],t[6]=s,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m=p,h;t[10]!==r||t[11]!==a?(h=function(e){r(),a(t=>{let n=new URLSearchParams(t);for(let e of[`view`,`item`,`version`,`q`,`kind`])n.delete(e);return e!==`all`&&n.set(`view`,e),n})},t[10]=r,t[11]=a,t[12]=h):h=t[12];let g=h,_=n?`资料库`:`Space`,v;t[13]===_?v=t[14]:(v=(0,U.jsx)(`h1`,{className:`sr-only`,children:_}),t[13]=_,t[14]=v);let y;t[15]===i?y=t[16]:(y=ke(i),t[15]=i,t[16]=y);let b=n?`资料范围`:`Library views`,x;t[17]!==g||t[18]!==m||t[19]!==y||t[20]!==b?(x=(0,U.jsx)(B,{items:m,activeTab:y,onChange:g,ariaLabel:b,tabIdPrefix:`space-tab`,panelIdPrefix:`space-list`,className:`pb-0 [scrollbar-width:none]`,buttonClassName:`h-9 py-1.5`,scrollActiveIntoView:!0}),t[17]=g,t[18]=m,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==v||t[23]!==x?(S=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[v,x]}),t[22]=v,t[23]=x,t[24]=S):S=t[24],S}function Le(){let e=f(e=>e.language)===`zh`,t=ye(e=>e.setPageHeader),n=ye(e=>e.clearPageHeader),r=u(),[i,a]=c(),o=s(),m=i.get(`version`),[b,x]=(0,H.useState)(Oe),[S,C]=(0,H.useState)(!1),[w,T]=(0,H.useState)(!1),[D,k]=(0,H.useState)(!1),[te,P]=(0,H.useState)(``),[ne,re]=(0,H.useState)(),F=(0,H.useRef)(new Map),ie=(0,H.useRef)(null),ae=(0,H.useRef)(null),se=(0,H.useRef)(null),I=ke(i),ce=(i.get(`q`)??``).slice(0,160),L=(0,H.useDeferredValue)(ce),R=i.get(`item`),ve=i.get(`kind`),B=i.get(`taskId`)?`taskId`:i.get(`projectId`)?`projectId`:void 0,V=(0,H.useCallback)(()=>{re(void 0),P(``),C(!1),T(!1)},[]);(0,H.useLayoutEffect)(()=>(t({startExtra:null,main:(0,U.jsx)(Ie,{zh:e,onViewChange:V}),end:(0,U.jsx)(Pe,{zh:e}),className:`@max-[40rem]/space-list:h-auto @max-[40rem]/space-list:min-h-14 @max-[40rem]/space-list:gap-y-2 @max-[40rem]/space-list:py-2 @max-[40rem]/space-list:[&>:last-child]:col-span-full`}),n),[n,V,t,e]),(0,H.useLayoutEffect)(()=>{se.current&&(se.current.scrollTop=0)},[I]);let W=fe((e,t)=>{if(e&&!t?.nextCursor)return null;let n=new URLSearchParams({view:I,q:L});return ve&&n.set(`kind`,ve),B&&n.set(B,i.get(B)),e&&t?.nextCursor&&n.set(`cursor`,t.nextCursor),`${A}?${n}`},j,{refreshInterval:4e3}),G=de(R?M(R):null,ee,{refreshInterval:4e3}),J=W.data?.flatMap(e=>e.items)??[],Y=G.data,X=Y?.versions.find(e=>e.id===m)??Y?.currentVersion,Z=X?.id===Y?.currentVersion.id?J.find(e=>e.id===R)?.hit:void 0,Q=Y?.origins.find(e=>e.versionId===X?.id&&e.available)??Y?.origins.find(e=>e.available)??Y?.origin,Ne=je(Q);function Fe(e){a(t=>{let n=new URLSearchParams(t);for(let[t,r]of Object.entries(e))r?n.set(t,r):n.delete(t);return n})}function Le(e){C(!1),T(!1),P(``),Fe({item:e,version:null})}function Re(){Le(null),R&&requestAnimationFrame(()=>F.current.get(R)?.focus())}(0,H.useLayoutEffect)(()=>{R&&ae.current&&getComputedStyle(ae.current).visibility===`hidden`&&ie.current?.focus({preventScroll:!0})},[o,R]),(0,H.useEffect)(()=>{if(!R)return;let e=e=>{if(!(e.key!==`Escape`||e.defaultPrevented)){if(S||w){C(!1),T(!1);return}a(e=>{let t=new URLSearchParams(e);return t.delete(`item`),t.delete(`version`),t}),requestAnimationFrame(()=>F.current.get(R)?.focus())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,S,R,a]);function ze(e,t){if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let n=J[t+(e.key===`ArrowDown`?1:-1)];n&&F.current.get(n.id)?.focus()}async function Be(t){if(!D){k(!0),P(``);try{await t()}catch{P(e?`操作未完成,请重试`:`Could not complete the action. Try again.`),G.mutate()}finally{k(!1)}}}function $(e,t,n){return Be(async()=>{await p(d(M(t.id)+(e===`restore`||e===`purge`?`/${e}`:``)),{method:e===`patch`?`PATCH`:e===`trash`?`DELETE`:`POST`,body:JSON.stringify({revision:t.revision,...n})}),e===`trash`&&re({id:t.id,revision:t.revision+1}),(e===`restore`||e===`purge`)&&re(void 0),e===`patch`?(C(!1),await G.mutate()):R===t.id&&Le(null),await W.mutate()})}async function Ve(){!Y||!X||await Be(async()=>{let e=await O(Y.id,X.id),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=X.fileName,n.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3)})}function He(){!Y||!X||Be(async()=>{let e=await O(Y.id,X.id);if(e.size>33554432)throw Error(`Attachment too large`);let t=new globalThis.File([e],X.fileName,{type:X.mimeType}),n=new URLSearchParams({attachmentHandoff:oe(t)});Q?.projectId&&Q.available&&n.set(`projectId`,Q.projectId),r({pathname:`/chat/new`,search:`?${n}`},{state:{forceNewChat:!0}})})}function Ue(e){if(e.preventDefault(),!Y)return;let t=String(new FormData(e.currentTarget).get(`title`)??``).trim();t&&$(`patch`,Y,{title:t})}let We=new Intl.DateTimeFormat(e?`zh-CN`:`en`,{month:`short`,day:`numeric`}),Ge=e=>We.format(e),Ke=t=>t.origin?.label??(t.origin?.kind===`task`?e?`任务`:`Task`:t.origin?.kind===`automation`?e?`定时任务`:`Automation`:e?`对话`:`Chat`),qe=te||ne?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge-subtle bg-surface-panel px-3 py-2 text-sm`,role:`status`,children:[(0,U.jsx)(`span`,{children:te||(e?`已移到回收站`:`Moved to Trash`)}),ne?(0,U.jsx)(`button`,{type:`button`,disabled:D,className:`rounded-lg p-1 text-accent-fg`,onClick:()=>void $(`restore`,ne),children:e?`撤销`:`Undo`}):null]}):null;return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-[74rem] min-h-0 flex-1 px-3 pt-3 sm:px-5 sm:pt-5 @min-[58rem]/space:px-6`,children:(0,U.jsxs)(`section`,{ref:ae,id:`space-list-${I}`,role:`tabpanel`,"aria-labelledby":`space-tab-${I}`,className:`@container/list flex min-w-0 flex-1 flex-col`,children:[B?(0,U.jsx)(`div`,{className:`mb-3 flex shrink-0 justify-end`,children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>Fe({[B]:null}),className:`inline-flex min-h-9 items-center gap-1 rounded-lg bg-surface-inset px-2 py-1 text-sm text-fg-muted hover:bg-surface-hover`,children:[B===`projectId`?e?`当前项目`:`Project`:e?`当前任务`:`Task`,(0,U.jsx)(le,{className:`size-3.5`})]})}):null,(0,U.jsxs)(`div`,{ref:se,className:`min-h-0 flex-1 overflow-y-auto pb-5`,children:[W.isLoading?(0,U.jsx)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:Array.from({length:5},(e,t)=>(0,U.jsx)(ue,{className:`h-14 w-full rounded-xl`},t))}):null,W.error?(0,U.jsx)(`button`,{className:`rounded-lg py-3 text-sm text-accent-fg`,onClick:()=>void W.mutate(),children:e?`加载失败,重试`:`Could not load. Retry`}):null,!W.isLoading&&!W.error&&J.length===0?(0,U.jsx)(`p`,{className:`py-10 text-center text-sm text-fg-muted`,children:ce?e?`没有匹配的资料`:`No matching results`:I===`favorites`?e?`暂无收藏`:`No favorites`:I===`trash`?e?`回收站为空`:`Trash is empty`:e?`暂无资料`:`No results yet`}):null,J.length>0?(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-edge-subtle`,children:[(0,U.jsxs)(`div`,{className:z(De,`min-h-10 border-b border-edge-subtle bg-surface-inset text-xs font-medium text-fg-muted`),children:[(0,U.jsx)(`span`,{children:e?`名称`:`Name`}),(0,U.jsx)(`span`,{className:`hidden @xl/list:block`,children:e?`格式`:`Format`}),(0,U.jsx)(`span`,{className:`hidden @xl/list:block`,children:e?`来源`:`Source`}),(0,U.jsx)(`span`,{className:`min-w-[5rem] text-end`,children:e?`更新日期`:`Updated`})]}),(0,U.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:J.map((t,n)=>{let r=Te[t.kind],i=t.currentVersion,a=/\.([a-z\d]{1,12})$/i.exec(i.fileName)?.[1]?.toUpperCase(),o=N(t.id,i.id),s=t.kind===`audio`&&I!==`trash`,c=t.origin?Ke(t):null;return(0,U.jsxs)(`li`,{className:`relative [contain-intrinsic-size:auto_55px] [content-visibility:auto]`,children:[(0,U.jsxs)(`button`,{type:`button`,title:t.title,ref:e=>{e?F.current.set(t.id,e):F.current.delete(t.id)},onKeyDown:e=>ze(e,n),"aria-pressed":R===t.id,onClick:()=>Le(t.id),className:z(De,`min-h-[54px] w-full py-1.5 text-start focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,R===t.id?`bg-accent-soft`:`hover:bg-surface-hover`),children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5 sm:gap-3`,children:[s?(0,U.jsx)(`span`,{className:`w-11 shrink-0`,"aria-hidden":!0}):t.kind===`image`||t.kind===`video`?(0,U.jsx)(Se,{kind:t.kind,src:o},i.id):(0,U.jsx)(Ce,{icon:r}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:(0,U.jsx)(Me,{text:t.title,query:L.trim()})}),a||c?(0,U.jsxs)(`span`,{className:`block truncate text-xs text-fg-muted @xl/list:hidden`,children:[a,a&&c?` · `:null,c]}):null,t.hit?(0,U.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:(0,U.jsx)(Me,{text:t.hit.text,query:L.trim()})}):null]})]}),(0,U.jsx)(`span`,{className:`hidden @xl/list:block`,children:a?(0,U.jsx)(`span`,{className:`inline-block max-w-full truncate rounded bg-surface-inset px-1.5 py-0.5 align-middle text-xs font-medium text-fg-muted`,children:a}):(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`—`})}),(0,U.jsx)(`span`,{className:`hidden truncate text-sm text-fg-muted @xl/list:block`,children:c??`—`}),(0,U.jsx)(`time`,{className:`min-w-[5rem] text-end text-xs whitespace-nowrap tabular-nums text-fg-muted`,children:Ge(t.updatedAt)})]}),s?(0,U.jsx)(we,{src:o,title:t.title,zh:e},i.id):null]},t.id)})})]}):null,W.data?.at(-1)?.nextCursor?(0,U.jsx)(`button`,{className:`mt-3 rounded-lg py-2 text-sm text-accent-fg`,onClick:()=>void W.setSize(W.size+1),children:e?`加载更多`:`Load more`}):null]})]})}),R&&o?(0,be.createPortal)((0,U.jsxs)(`section`,{id:`space-file-preview`,"aria-label":e?`资料预览`:`File preview`,style:{"--space-preview-width":`${b}%`},className:`file-preview-surface absolute inset-0 z-40 flex min-h-0 min-w-0 flex-col @min-[58rem]/space:relative @min-[58rem]/space:inset-auto @min-[58rem]/space:w-[var(--space-preview-width)] @min-[58rem]/space:shrink-0 @min-[58rem]/space:border-s @min-[58rem]/space:border-edge-subtle`,children:[(0,U.jsx)(Ae,{zh:e,width:b,onResize:x}),(0,U.jsxs)(`header`,{className:`flex min-h-14 shrink-0 items-center gap-1 border-b border-edge-subtle px-3 py-2`,children:[(0,U.jsx)(`button`,{type:`button`,className:z(K,`@min-[58rem]/space:hidden`),onClick:Re,"aria-label":e?`返回`:`Back`,children:(0,U.jsx)(g,{className:`size-4`})}),(0,U.jsx)(`h2`,{ref:ie,tabIndex:-1,className:`min-w-0 flex-1 py-2 text-sm leading-5 font-semibold wrap-anywhere text-fg`,children:Y?.title??(e?`预览`:`Preview`)}),Y&&!Y.trashedAt?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,className:z(K,Y.favorite&&`text-accent-fg`),"aria-pressed":Y.favorite,"aria-label":e?`收藏`:`Favorite`,disabled:D,onClick:()=>void $(`patch`,Y,{favorite:!Y.favorite}),children:(0,U.jsx)(E,{className:z(`size-4`,Y.favorite&&`fill-current`)})}),(0,U.jsx)(`button`,{type:`button`,className:K,disabled:D,"aria-label":e?`下载`:`Download`,onClick:()=>void Ve(),children:(0,U.jsx)(h,{className:`size-4`})}),(0,U.jsxs)(he,{children:[(0,U.jsx)(_e,{className:K,"aria-label":e?`更多操作`:`More actions`,children:(0,U.jsx)(y,{className:`size-4`})}),(0,U.jsx)(pe,{children:(0,U.jsxs)(me,{align:`end`,sideOffset:5,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,U.jsx)(ge,{className:q,onClick:()=>C(!0),children:e?`重命名`:`Rename`}),(0,U.jsx)(ge,{className:z(q,`text-red-600 dark:text-red-400`),disabled:D,onClick:()=>void $(`trash`,Y),children:e?`移到回收站`:`Move to Trash`})]})})]})]}):null,(0,U.jsx)(`button`,{type:`button`,className:z(K,`hidden @min-[58rem]/space:inline-flex`),onClick:Re,"aria-label":e?`关闭预览`:`Close preview`,children:(0,U.jsx)(le,{className:`size-4`})})]}),S&&Y?(0,U.jsxs)(`form`,{className:`flex shrink-0 flex-wrap items-center gap-2 px-3 py-2`,onSubmit:Ue,children:[(0,U.jsx)(`input`,{name:`title`,defaultValue:Y.title,required:!0,maxLength:240,autoFocus:!0,"aria-label":e?`资料名称`:`Result name`,className:`min-w-24 flex-1 rounded-lg border border-edge bg-surface-panel px-2 py-2 text-sm`}),(0,U.jsx)(`button`,{className:Ee,disabled:D,children:e?`保存`:`Save`}),(0,U.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-sm hover:bg-surface-hover`,onClick:()=>C(!1),children:e?`取消`:`Cancel`})]}):null,G.isLoading?(0,U.jsx)(ue,{className:`m-3 min-h-0 flex-1 rounded-xl`}):null,G.error?(0,U.jsx)(`p`,{className:`px-3 py-5 text-sm text-fg-muted`,children:e?`资料暂不可用`:`Result unavailable`}):null,Y&&X?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xe,{itemId:Y.id,version:X,hit:Z,download:Ve},X.id),(0,U.jsxs)(`div`,{className:`max-h-[45%] shrink-0 space-y-2 overflow-y-auto border-t border-edge-subtle px-3 py-2`,children:[Z?(0,U.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:(0,U.jsx)(Me,{text:Z.text,query:L.trim()})}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{children:Q?Ke(Y):null}),X.indexStatus===`pending`?(0,U.jsx)(`span`,{children:e?`正在索引`:`Indexing`}):null,Y.versions.length>1?(0,U.jsx)(_,{value:X.id,onChange:e=>Fe({version:e.target.value}),children:Y.versions.map((t,n)=>(0,U.jsxs)(v,{value:t.id,children:[t.id===Y.currentVersion.id?e?`最新版`:`Latest`:Ge(t.createdAt),` · v`,Y.versions.length-n]},t.id))}):null]}),(0,U.jsx)(`footer`,{className:`flex flex-wrap items-center justify-between gap-2`,children:Y.trashedAt?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,className:Ee,disabled:D,onClick:()=>void $(`restore`,Y),children:e?`恢复`:`Restore`}),(0,U.jsx)(`button`,{type:`button`,className:`rounded-lg px-2 py-2 text-sm text-red-600 hover:bg-surface-hover dark:text-red-400`,onClick:()=>T(!0),children:e?`永久删除`:`Delete permanently`})]}):(0,U.jsxs)(U.Fragment,{children:[Ne?(0,U.jsx)(l,{className:`rounded-lg px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover`,to:Ne,children:e?`查看来源`:`Open source`}):(0,U.jsx)(`span`,{}),(0,U.jsx)(`button`,{type:`button`,className:Ee,disabled:D||X.sizeBytes>33554432,title:X.sizeBytes>33554432?e?`超过对话附件大小上限`:`Exceeds the chat attachment size limit`:void 0,onClick:He,children:e?`在对话中使用`:`Use in chat`})]})}),w?(0,U.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-edge bg-surface-panel p-3 text-sm`,children:[(0,U.jsx)(`p`,{children:e?`永久删除「${Y.title}」?`:`Delete “${Y.title}” permanently?`}),(0,U.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,className:q,onClick:()=>T(!1),children:e?`取消`:`Cancel`}),(0,U.jsx)(`button`,{type:`button`,className:z(q,`text-red-600 dark:text-red-400`),disabled:D,onClick:()=>void $(`purge`,Y),children:e?`删除`:`Delete`})]})]}):null]})]}):null,qe]}),o):null,R&&o?null:qe]})}export{Le as SpacePage};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{d as o,f as s,h as c,t as l,u}from"./chunk-KS7C4IRE-BPb7KheU.js";import{i as d,n as f,o as p}from"./locale-store-B4o4aDCg.js";import{t as m}from"./archive-Dz0hferG.js";import{t as h}from"./arrow-down-to-line-C5D8Vt-L.js";import{t as g}from"./arrow-left-D880xG-P.js";import{n as _,r as v}from"./popover-select-CLsphyzA.js";import{t as y}from"./ellipsis-0k4rZLoy.js";import{t as b}from"./file-image-CDUPkZvG.js";import{t as x}from"./file-text-D12HbeVy.js";import{t as S}from"./file-CStvVK2S.js";import{n as C,t as w}from"./sheet-C2H8iR8Y.js";import{n as T,t as E}from"./star-BuMAkjC9.js";import{a as D,c as ee,f as O,g as k,h as A,l as j,m as M,p as N,r as te,s as P}from"./use-generated-media-CEJ5BBxX.js";import{t as ne}from"./pause-DuPxgSxk.js";import{t as re}from"./play-kxZvpBg8.js";import{t as F}from"./presentation-D-Ui_vVA.js";import{t as ie}from"./rotate-ccw-JM1TBLpp.js";import{t as ae}from"./search-DA7gz22f.js";import{i as oe,m as se,n as I,r as ce,t as L}from"./preview-runtime-MJUo7XlD.js";import{t as R}from"./trash-2-DusmjVPV.js";import{t as le}from"./x-B_N4OPjy.js";import{t as z}from"./cn-0WouolD0.js";import{t as ue}from"./skeleton-DzdOeGYz.js";import{i as de,t as fe}from"./vendor-swr-CdRzEUwF.js";import"./constants-D5Z-mUto.js";import{a as pe,i as me,o as he,r as ge,s as _e}from"./dist-GJ8-1PAx.js";import{i as ve}from"./theme-store-C7t81hG7.js";import{t as B}from"./page-tabs-DoYMKhVO.js";import{t as ye}from"./page-header-store-D_2QZ6Ps.js";var be=e(n(),1),V=r(),H=e(t(),1),U=i();function xe({itemId:e,version:t,hit:n,download:r}){let i=f(e=>e.language),o=ve(e=>e.resolved),s=se(t.fileName,t.mimeType),c=s===`audio`||s===`video`,[l,u]=(0,H.useState)(null),d={id:`space:${t.id}`,context:`attachment`,source:{kind:`inline`},fileName:t.fileName,mimeType:t.mimeType,size:t.sizeBytes,type:s},p=ce(d),[m,h]=(0,H.useState)({loading:!0,textContent:null,binaryBuffer:null,loadError:null}),{plugin:g,controls:_}=p,{setPage:v,pageCount:y}=_,b=typeof n?.locator.page==`number`?n.locator.page:void 0,x=typeof n?.locator.slide==`number`?n.locator.slide:void 0,S=typeof n?.locator.line==`number`?n.locator.line:void 0,C=typeof n?.locator.sheet==`string`?n.locator.sheet:void 0,w=typeof n?.locator.paragraph==`number`?n.locator.paragraph:void 0;if((0,H.useEffect)(()=>{b&&y!==null&&v(b)},[b,y,v]),(0,H.useEffect)(()=>{let n=new AbortController,r;if(!c){if(g.readMode===`metadata`){h({loading:!1,textContent:null,binaryBuffer:null,loadError:null});return}if(g.maxBytes&&t.sizeBytes>g.maxBytes){h({loading:!1,textContent:null,binaryBuffer:null,loadError:i===`zh`?`文件过大,可下载查看`:`File too large to preview`});return}return O(e,t.id,n.signal).then(async e=>{let i=g.readMode===`text`?await e.text():null,o=g.readMode===`binary`?await e.arrayBuffer():null,c=s===`pptx`&&o?await a(()=>import(`./attachment-process-heavy-DGZZ-M85.js`).then(e=>e.processPptx(o,t.fileName)),__vite__mapDeps([0,1,2,3])):void 0;n.signal.aborted||(c&&u(c.extractedText),r=g.readMode===`url`?URL.createObjectURL(new Blob([e],{type:t.mimeType})):void 0,h({loading:!1,textContent:i,binaryBuffer:o,rawUrl:r,loadError:null}))}).catch(()=>{n.signal.aborted||h({loading:!1,textContent:null,binaryBuffer:null,loadError:i===`zh`?`资料暂不可读`:`Content unavailable`})}),()=>{n.abort(),r&&URL.revokeObjectURL(r)}}},[s,c,e,t.id,t.fileName,t.mimeType,t.sizeBytes,g,i]),c){let n=N(e,t.id);return(0,U.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 items-center justify-center overflow-hidden bg-surface-panel p-3`,children:s===`audio`?(0,U.jsx)(`audio`,{src:n,controls:!0,preload:`metadata`,className:`w-full`}):(0,U.jsx)(`video`,{src:n,controls:!0,playsInline:!0,preload:`metadata`,className:`max-h-full max-w-full rounded-lg`})})}return(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[g.capabilities.some(e=>[`zoom`,`pageNavigation`,`rotate`,`search`].includes(e))?(0,U.jsx)(`div`,{className:`border-b border-edge-subtle px-2 py-1`,children:(0,U.jsx)(L,{controller:p})}):null,(0,U.jsx)(I,{...m,descriptor:d,language:i,resolvedTheme:o,targetLine:S,targetSlide:x,targetSheet:C,targetParagraph:w,extractedText:l,controller:p,actions:{onDownload:r,canDownload:!0}})]})}var W=`grid h-9 w-11 shrink-0 place-items-center overflow-hidden rounded-md bg-surface-inset text-fg-muted`;function Se(e){let t=(0,V.c)(17),{kind:n,src:r}=e,i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),d,f;t[0]===n?(d=t[1],f=t[2]):(d=()=>{let e=i.current;if(n!==`video`||!e)return;let t=new IntersectionObserver(e=>{e.some(G)&&(o(!0),t.disconnect())});return t.observe(e),()=>t.disconnect()},f=[n],t[0]=n,t[1]=d,t[2]=f),(0,H.useEffect)(d,f);let p=n===`image`?b:C,m=!s&&`invisible`,h;t[3]===m?h=t[4]:(h=z(`absolute inset-0 size-full object-cover`,m),t[3]=m,t[4]=h);let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=z(W,`relative`),t[5]=_):_=t[5];let v;t[6]===p?v=t[7]:(v=(0,U.jsx)(p,{className:`size-4`}),t[6]=p,t[7]=v);let y;t[8]!==l||t[9]!==n||t[10]!==g||t[11]!==r||t[12]!==a?(y=!l&&(n===`image`?(0,U.jsx)(`img`,{src:r,width:44,height:36,loading:`lazy`,decoding:`async`,alt:``,className:g,onLoad:()=>c(!0),onError:()=>u(!0)}):a&&(0,U.jsx)(`video`,{src:`${r}#t=0.1`,muted:!0,playsInline:!0,preload:`metadata`,className:g,onLoadedData:()=>c(!0),onError:()=>u(!0)})),t[8]=l,t[9]=n,t[10]=g,t[11]=r,t[12]=a,t[13]=y):y=t[13];let x;return t[14]!==v||t[15]!==y?(x=(0,U.jsxs)(`span`,{ref:i,className:_,"aria-hidden":!0,children:[v,y]}),t[14]=v,t[15]=y,t[16]=x):x=t[16],x}function G(e){return e.isIntersecting}function Ce(e){let t=(0,V.c)(2),{icon:n}=e,r=n===void 0?S:n,i;return t[0]===r?i=t[1]:(i=(0,U.jsx)(`span`,{className:W,children:(0,U.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),t[0]=r,t[1]=i),i}function we(e){let t=(0,V.c)(25),{src:n,title:r,zh:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.active?.entry.source.src===n?e.active.entry.element:null,t[0]=n,t[1]=a);let o=P(a),{playing:s,starting:c,failed:l,toggle:u}=te(o),[d,f]=(0,H.useState)(!1),p=d||l,m=s||c,h=p?ie:m?ne:re,g=p?i?`重试播放`:`Retry playback`:m?i?`暂停`:`Pause`:i?`播放`:`Play`,_;t[2]!==o||t[3]!==n||t[4]!==r||t[5]!==u?(_=function(){f(!1),o?u():D({kind:`audio`,src:n,title:r}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||f(!0)})},t[2]=o,t[3]=n,t[4]=r,t[5]=u,t[6]=_):_=t[6];let v=_,y=`${g} ${r}`,b=m&&`bg-accent-soft text-accent-fg`,x;t[7]===b?x=t[8]:(x=z(W,`hover:bg-surface-active`,b),t[7]=b,t[8]=x);let S;t[9]===h?S=t[10]:(S=(0,U.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t[9]=h,t[10]=S);let C;t[11]!==x||t[12]!==S?(C=(0,U.jsx)(`span`,{className:x,children:S}),t[11]=x,t[12]=S,t[13]=C):C=t[13];let w;t[14]!==g||t[15]!==v||t[16]!==y||t[17]!==C?(w=(0,U.jsx)(`button`,{type:`button`,"aria-label":y,title:g,onClick:v,className:`absolute start-2 top-1/2 grid size-11 -translate-y-1/2 place-items-center rounded-md focus-visible:outline-2 focus-visible:outline-accent sm:start-3`,children:C}),t[14]=g,t[15]=v,t[16]=y,t[17]=C,t[18]=w):w=t[18];let T;t[19]!==d||t[20]!==i?(T=d?(0,U.jsx)(`span`,{role:`alert`,className:`sr-only`,children:i?`音频暂时无法播放,请重试。`:`Audio could not play. Try again.`}):null,t[19]=d,t[20]=i,t[21]=T):T=t[21];let E;return t[22]!==w||t[23]!==T?(E=(0,U.jsxs)(U.Fragment,{children:[w,T]}),t[22]=w,t[23]=T,t[24]=E):E=t[24],E}var Te={document:x,pdf:x,spreadsheet:w,presentation:F,audio:k,archive:m},K=`inline-flex size-9 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,q=`block w-full rounded-lg px-3 py-2 text-start text-sm hover:bg-surface-hover`,Ee=`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover disabled:opacity-50`,De=`grid grid-cols-[minmax(0,1fr)_5rem] items-center gap-3 px-2 sm:px-3 @xl/list:grid-cols-[minmax(0,1fr)_4.5rem_minmax(0,0.55fr)_6.5rem] @xl/list:gap-4`,J=38,Y=30,X=72,Z=`xopc.space.previewWidth`;function Oe(){try{let e=Number(window.localStorage.getItem(Z));if(e>=Y&&e<=X)return e}catch{}return J}function Q(e){try{window.localStorage.setItem(Z,String(e))}catch{}}function ke(e){let t=e.get(`view`);return t===`favorites`||t===`trash`?t:`all`}function Ae(e){let t=(0,V.c)(33),{zh:n,width:r,onResize:i}=e,a=(0,H.useRef)(null),[o,s]=(0,H.useState)(!1),c;t[0]===i?c=t[1]:(c=function(e){let t=Math.max(Y,Math.min(X,e));return i(t),t},t[0]=i,t[1]=c);let l=c,u=n?`调整资料预览宽度`:`Resize file preview`,d;t[2]===r?d=t[3]:(d=Math.round(r),t[2]=r,t[3]=d);let f=n?`左右拖动调整宽度,双击恢复默认`:`Drag to resize, double-click to reset`,p=o&&`bg-accent-soft/40`,m;t[4]===p?m=t[5]:(m=z(`group absolute inset-y-0 start-0 z-20 hidden w-3 -translate-x-1/2 cursor-col-resize touch-none select-none items-center justify-center rounded-sm focus-visible:outline-2 focus-visible:outline-accent @min-[58rem]/space:flex`,p),t[4]=p,t[5]=m);let h;t[6]===r?h=t[7]:(h=e=>{if(e.button!==0||a.current)return;let t=e.currentTarget,n=t.closest(`[data-space-preview-host]`)?.parentElement?.clientWidth;n&&(e.preventDefault(),t.setPointerCapture(e.pointerId),a.current={id:e.pointerId,startX:e.clientX,startWidth:r,availableWidth:n,currentWidth:r},s(!0))},t[6]=r,t[7]=h);let g;t[8]===l?g=t[9]:(g=e=>{let t=a.current;t?.id===e.pointerId&&(t.currentWidth=l(t.startWidth+(t.startX-e.clientX)*100/t.availableWidth))},t[8]=l,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{a.current?.id===e.pointerId&&(Q(a.current.currentWidth),a.current=null,s(!1))},t[10]=_):_=t[10];let v;t[11]===l?v=t[12]:(v=()=>Q(l(J)),t[11]=l,t[12]=v);let y;t[13]!==l||t[14]!==r?(y=e=>{let t={ArrowLeft:r+2,ArrowRight:r-2,Home:Y,End:X};Object.hasOwn(t,e.key)&&(e.preventDefault(),Q(l(t[e.key])))},t[13]=l,t[14]=r,t[15]=y):y=t[15];let b=o&&`bg-accent`,x;t[16]===b?x=t[17]:(x=z(`h-10 w-0.5 rounded-full bg-edge group-hover:bg-accent group-focus-visible:bg-accent`,b),t[16]=b,t[17]=x);let S;t[18]===x?S=t[19]:(S=(0,U.jsx)(`span`,{"aria-hidden":!0,className:x}),t[18]=x,t[19]=S);let C;t[20]===o?C=t[21]:(C=o?(0,U.jsx)(`span`,{"aria-hidden":!0,className:`fixed inset-0 z-50 cursor-col-resize`}):null,t[20]=o,t[21]=C);let w;return t[22]!==v||t[23]!==y||t[24]!==S||t[25]!==C||t[26]!==u||t[27]!==d||t[28]!==f||t[29]!==m||t[30]!==h||t[31]!==g?(w=(0,U.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":u,"aria-controls":`space-file-preview`,"aria-valuemin":Y,"aria-valuemax":X,"aria-valuenow":d,tabIndex:0,title:f,className:m,onPointerDown:h,onPointerMove:g,onLostPointerCapture:_,onDoubleClick:v,onKeyDown:y,children:[S,C]}),t[22]=v,t[23]=y,t[24]=S,t[25]=C,t[26]=u,t[27]=d,t[28]=f,t[29]=m,t[30]=h,t[31]=g,t[32]=w):w=t[32],w}function je(e){return e?.available?e.kind===`task`&&e.taskId?`/tasks/${encodeURIComponent(e.taskId)}`:e.kind===`automation`&&e.automationRunId?`/automations?view=execution&run=${encodeURIComponent(e.automationRunId)}`:`/chat/${encodeURIComponent(e.conversationId)}`:null}function Me(e){let t=(0,V.c)(20),{text:n,query:r}=e,i,a,o,s,c;if(t[0]!==r||t[1]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=r?n.toLowerCase().indexOf(r.toLowerCase()):-1;if(e<0){let e;t[7]===n?e=t[8]:(e=(0,U.jsx)(U.Fragment,{children:n}),t[7]=n,t[8]=e),c=e;break bb0}i=e+r.length,s=e>40?`…${n.slice(e-40,e)}`:n.slice(0,e),a=`rounded-sm bg-accent-soft text-accent-fg`,o=n.slice(e,i)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[9]!==a||t[10]!==o?(l=(0,U.jsx)(`mark`,{className:a,children:o}),t[9]=a,t[10]=o,t[11]=l):l=t[11];let u;t[12]!==i||t[13]!==n?(u=n.slice(i,i+100),t[12]=i,t[13]=n,t[14]=u):u=t[14];let d=i+100<n.length?`…`:``,f;return t[15]!==s||t[16]!==l||t[17]!==u||t[18]!==d?(f=(0,U.jsxs)(U.Fragment,{children:[s,l,u,d]}),t[15]=s,t[16]=l,t[17]=u,t[18]=d,t[19]=f):f=t[19],f}function Ne(e){let t=(0,V.c)(22),{zh:n}=e,[r,i]=c(),a=o(),s=(0,H.useRef)(null),l;t[0]===r?l=t[1]:(l=(r.get(`q`)??``).slice(0,160),t[0]=r,t[1]=l);let u=l,d=n?`搜索资料`:`Search files`,f,p;t[2]!==a||t[3]!==u?(f=()=>{let e=s.current;e&&(document.activeElement!==e||a===`POP`)&&(e.value=u)},p=[a,u],t[2]=a,t[3]=u,t[4]=f,t[5]=p):(f=t[4],p=t[5]),(0,H.useLayoutEffect)(f,p);let m;t[6]===i?m=t[7]:(m=function(e){i(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n},{replace:!0})},t[6]=i,t[7]=m);let h=m,g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,U.jsx)(ae,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[8]=g):g=t[8];let _;t[9]===h?_=t[10]:(_=e=>h(e.target.value),t[9]=h,t[10]=_);let v;t[11]!==d||t[12]!==u||t[13]!==_?(v=(0,U.jsx)(`input`,{ref:s,defaultValue:u,maxLength:160,onChange:_,"aria-label":d,placeholder:d,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none`}),t[11]=d,t[12]=u,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==h||t[16]!==u||t[17]!==n?(y=u?(0,U.jsx)(`button`,{type:`button`,className:z(K,`size-6`),onClick:()=>{h(``),s.current&&(s.current.value=``,s.current.focus())},"aria-label":n?`清除搜索`:`Clear search`,children:(0,U.jsx)(le,{className:`size-4`})}):null,t[15]=h,t[16]=u,t[17]=n,t[18]=y):y=t[18];let b;return t[19]!==v||t[20]!==y?(b=(0,U.jsxs)(`div`,{role:`search`,className:`flex h-9 min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge-subtle bg-surface-inset px-2.5 focus-within:ring-2 focus-within:ring-accent @min-[40rem]/space-list:w-[clamp(7rem,24cqw,18rem)]`,children:[g,v,y]}),t[19]=v,t[20]=y,t[21]=b):b=t[21],b}function Pe(e){let t=(0,V.c)(44),{zh:n}=e,[r,i]=c(),a=n?`文档`:`Documents`,o;t[0]===a?o=t[1]:(o=[`document`,a],t[0]=a,t[1]=o);let s=n?`表格`:`Spreadsheets`,l;t[2]===s?l=t[3]:(l=[`spreadsheet`,s],t[2]=s,t[3]=l);let u=n?`演示`:`Slides`,d;t[4]===u?d=t[5]:(d=[`presentation`,u],t[4]=u,t[5]=d);let f=n?`图片`:`Images`,p;t[6]===f?p=t[7]:(p=[`image`,f],t[6]=f,t[7]=p);let m=n?`音频`:`Audio`,h;t[8]===m?h=t[9]:(h=[`audio`,m],t[8]=m,t[9]=h);let g=n?`视频`:`Video`,y;t[10]===g?y=t[11]:(y=[`video`,g],t[10]=g,t[11]=y);let b=n?`压缩包`:`Archives`,x;t[12]===b?x=t[13]:(x=[`archive`,b],t[12]=b,t[13]=x);let S=n?`文件`:`Files`,C;t[14]===S?C=t[15]:(C=[`file`,S],t[14]=S,t[15]=C);let w;t[16]!==h||t[17]!==y||t[18]!==x||t[19]!==C||t[20]!==o||t[21]!==l||t[22]!==d||t[23]!==p?(w=[o,l,d,p,h,y,x,C],t[16]=h,t[17]=y,t[18]=x,t[19]=C,t[20]=o,t[21]=l,t[22]=d,t[23]=p,t[24]=w):w=t[24];let T=w,E;t[25]===n?E=t[26]:(E=(0,U.jsx)(Ne,{zh:n}),t[25]=n,t[26]=E);let D;t[27]===r?D=t[28]:(D=r.get(`kind`)??`all`,t[27]=r,t[28]=D);let ee=n?`资料类型`:`File type`,O;t[29]===i?O=t[30]:(O=e=>i(t=>{let n=new URLSearchParams(t);return e.target.value===`all`?n.delete(`kind`):n.set(`kind`,e.target.value),n}),t[29]=i,t[30]=O);let k=n?`全部类型`:`All types`,A;t[31]===k?A=t[32]:(A=(0,U.jsx)(v,{value:`all`,children:k}),t[31]=k,t[32]=A);let j;t[33]===T?j=t[34]:(j=T.map(Fe),t[33]=T,t[34]=j);let M;t[35]!==D||t[36]!==ee||t[37]!==O||t[38]!==A||t[39]!==j?(M=(0,U.jsxs)(_,{value:D,align:`end`,"aria-label":ee,triggerClassName:`h-9 shrink-0`,onChange:O,children:[A,j]}),t[35]=D,t[36]=ee,t[37]=O,t[38]=A,t[39]=j,t[40]=M):M=t[40];let N;return t[41]!==E||t[42]!==M?(N=(0,U.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2`,children:[E,M]}),t[41]=E,t[42]=M,t[43]=N):N=t[43],N}function Fe(e){let[t,n]=e;return(0,U.jsx)(v,{value:t,children:n},t)}function Ie(e){let t=(0,V.c)(25),{zh:n,onViewChange:r}=e,[i,a]=c(),o=n?`全部资料`:`All files`,s;t[0]===o?s=t[1]:(s={id:`all`,label:o,icon:T},t[0]=o,t[1]=s);let l=n?`收藏`:`Favorites`,u;t[2]===l?u=t[3]:(u={id:`favorites`,label:l,icon:E},t[2]=l,t[3]=u);let d=n?`回收站`:`Trash`,f;t[4]===d?f=t[5]:(f={id:`trash`,label:d,icon:R},t[4]=d,t[5]=f);let p;t[6]!==s||t[7]!==u||t[8]!==f?(p=[s,u,f],t[6]=s,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m=p,h;t[10]!==r||t[11]!==a?(h=function(e){r(),a(t=>{let n=new URLSearchParams(t);for(let e of[`view`,`item`,`version`,`q`,`kind`])n.delete(e);return e!==`all`&&n.set(`view`,e),n})},t[10]=r,t[11]=a,t[12]=h):h=t[12];let g=h,_=n?`资料库`:`Space`,v;t[13]===_?v=t[14]:(v=(0,U.jsx)(`h1`,{className:`sr-only`,children:_}),t[13]=_,t[14]=v);let y;t[15]===i?y=t[16]:(y=ke(i),t[15]=i,t[16]=y);let b=n?`资料范围`:`Library views`,x;t[17]!==g||t[18]!==m||t[19]!==y||t[20]!==b?(x=(0,U.jsx)(B,{items:m,activeTab:y,onChange:g,ariaLabel:b,tabIdPrefix:`space-tab`,panelIdPrefix:`space-list`,className:`pb-0 [scrollbar-width:none]`,buttonClassName:`h-9 py-1.5`,scrollActiveIntoView:!0}),t[17]=g,t[18]=m,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==v||t[23]!==x?(S=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[v,x]}),t[22]=v,t[23]=x,t[24]=S):S=t[24],S}function Le(){let e=f(e=>e.language)===`zh`,t=ye(e=>e.setPageHeader),n=ye(e=>e.clearPageHeader),r=u(),[i,a]=c(),o=s(),m=i.get(`version`),[b,x]=(0,H.useState)(Oe),[S,C]=(0,H.useState)(!1),[w,T]=(0,H.useState)(!1),[D,k]=(0,H.useState)(!1),[te,P]=(0,H.useState)(``),[ne,re]=(0,H.useState)(),F=(0,H.useRef)(new Map),ie=(0,H.useRef)(null),ae=(0,H.useRef)(null),se=(0,H.useRef)(null),I=ke(i),ce=(i.get(`q`)??``).slice(0,160),L=(0,H.useDeferredValue)(ce),R=i.get(`item`),ve=i.get(`kind`),B=i.get(`taskId`)?`taskId`:i.get(`projectId`)?`projectId`:void 0,V=(0,H.useCallback)(()=>{re(void 0),P(``),C(!1),T(!1)},[]);(0,H.useLayoutEffect)(()=>(t({startExtra:null,main:(0,U.jsx)(Ie,{zh:e,onViewChange:V}),end:(0,U.jsx)(Pe,{zh:e}),className:`@max-[40rem]/space-list:h-auto @max-[40rem]/space-list:min-h-14 @max-[40rem]/space-list:gap-y-2 @max-[40rem]/space-list:py-2 @max-[40rem]/space-list:[&>:last-child]:col-span-full`}),n),[n,V,t,e]),(0,H.useLayoutEffect)(()=>{se.current&&(se.current.scrollTop=0)},[I]);let W=fe((e,t)=>{if(e&&!t?.nextCursor)return null;let n=new URLSearchParams({view:I,q:L});return ve&&n.set(`kind`,ve),B&&n.set(B,i.get(B)),e&&t?.nextCursor&&n.set(`cursor`,t.nextCursor),`${A}?${n}`},j,{refreshInterval:4e3}),G=de(R?M(R):null,ee,{refreshInterval:4e3}),J=W.data?.flatMap(e=>e.items)??[],Y=G.data,X=Y?.versions.find(e=>e.id===m)??Y?.currentVersion,Z=X?.id===Y?.currentVersion.id?J.find(e=>e.id===R)?.hit:void 0,Q=Y?.origins.find(e=>e.versionId===X?.id&&e.available)??Y?.origins.find(e=>e.available)??Y?.origin,Ne=je(Q);function Fe(e){a(t=>{let n=new URLSearchParams(t);for(let[t,r]of Object.entries(e))r?n.set(t,r):n.delete(t);return n})}function Le(e){C(!1),T(!1),P(``),Fe({item:e,version:null})}function Re(){Le(null),R&&requestAnimationFrame(()=>F.current.get(R)?.focus())}(0,H.useLayoutEffect)(()=>{R&&ae.current&&getComputedStyle(ae.current).visibility===`hidden`&&ie.current?.focus({preventScroll:!0})},[o,R]),(0,H.useEffect)(()=>{if(!R)return;let e=e=>{if(!(e.key!==`Escape`||e.defaultPrevented)){if(S||w){C(!1),T(!1);return}a(e=>{let t=new URLSearchParams(e);return t.delete(`item`),t.delete(`version`),t}),requestAnimationFrame(()=>F.current.get(R)?.focus())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,S,R,a]);function ze(e,t){if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let n=J[t+(e.key===`ArrowDown`?1:-1)];n&&F.current.get(n.id)?.focus()}async function Be(t){if(!D){k(!0),P(``);try{await t()}catch{P(e?`操作未完成,请重试`:`Could not complete the action. Try again.`),G.mutate()}finally{k(!1)}}}function $(e,t,n){return Be(async()=>{await p(d(M(t.id)+(e===`restore`||e===`purge`?`/${e}`:``)),{method:e===`patch`?`PATCH`:e===`trash`?`DELETE`:`POST`,body:JSON.stringify({revision:t.revision,...n})}),e===`trash`&&re({id:t.id,revision:t.revision+1}),(e===`restore`||e===`purge`)&&re(void 0),e===`patch`?(C(!1),await G.mutate()):R===t.id&&Le(null),await W.mutate()})}async function Ve(){!Y||!X||await Be(async()=>{let e=await O(Y.id,X.id),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=X.fileName,n.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3)})}function He(){!Y||!X||Be(async()=>{let e=await O(Y.id,X.id);if(e.size>33554432)throw Error(`Attachment too large`);let t=new globalThis.File([e],X.fileName,{type:X.mimeType}),n=new URLSearchParams({attachmentHandoff:oe(t)});Q?.projectId&&Q.available&&n.set(`projectId`,Q.projectId),r({pathname:`/chat/new`,search:`?${n}`},{state:{forceNewChat:!0}})})}function Ue(e){if(e.preventDefault(),!Y)return;let t=String(new FormData(e.currentTarget).get(`title`)??``).trim();t&&$(`patch`,Y,{title:t})}let We=new Intl.DateTimeFormat(e?`zh-CN`:`en`,{month:`short`,day:`numeric`}),Ge=e=>We.format(e),Ke=t=>t.origin?.label??(t.origin?.kind===`task`?e?`任务`:`Task`:t.origin?.kind===`automation`?e?`定时任务`:`Automation`:e?`对话`:`Chat`),qe=te||ne?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge-subtle bg-surface-panel px-3 py-2 text-sm`,role:`status`,children:[(0,U.jsx)(`span`,{children:te||(e?`已移到回收站`:`Moved to Trash`)}),ne?(0,U.jsx)(`button`,{type:`button`,disabled:D,className:`rounded-lg p-1 text-accent-fg`,onClick:()=>void $(`restore`,ne),children:e?`撤销`:`Undo`}):null]}):null;return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-[74rem] min-h-0 flex-1 px-3 pt-3 sm:px-5 sm:pt-5 @min-[58rem]/space:px-6`,children:(0,U.jsxs)(`section`,{ref:ae,id:`space-list-${I}`,role:`tabpanel`,"aria-labelledby":`space-tab-${I}`,className:`@container/list flex min-w-0 flex-1 flex-col`,children:[B?(0,U.jsx)(`div`,{className:`mb-3 flex shrink-0 justify-end`,children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>Fe({[B]:null}),className:`inline-flex min-h-9 items-center gap-1 rounded-lg bg-surface-inset px-2 py-1 text-sm text-fg-muted hover:bg-surface-hover`,children:[B===`projectId`?e?`当前项目`:`Project`:e?`当前任务`:`Task`,(0,U.jsx)(le,{className:`size-3.5`})]})}):null,(0,U.jsxs)(`div`,{ref:se,className:`min-h-0 flex-1 overflow-y-auto pb-5`,children:[W.isLoading?(0,U.jsx)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:Array.from({length:5},(e,t)=>(0,U.jsx)(ue,{className:`h-14 w-full rounded-xl`},t))}):null,W.error?(0,U.jsx)(`button`,{className:`rounded-lg py-3 text-sm text-accent-fg`,onClick:()=>void W.mutate(),children:e?`加载失败,重试`:`Could not load. Retry`}):null,!W.isLoading&&!W.error&&J.length===0?(0,U.jsx)(`p`,{className:`py-10 text-center text-sm text-fg-muted`,children:ce?e?`没有匹配的资料`:`No matching results`:I===`favorites`?e?`暂无收藏`:`No favorites`:I===`trash`?e?`回收站为空`:`Trash is empty`:e?`暂无资料`:`No results yet`}):null,J.length>0?(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-edge-subtle`,children:[(0,U.jsxs)(`div`,{className:z(De,`min-h-10 border-b border-edge-subtle bg-surface-inset text-xs font-medium text-fg-muted`),children:[(0,U.jsx)(`span`,{children:e?`名称`:`Name`}),(0,U.jsx)(`span`,{className:`hidden @xl/list:block`,children:e?`格式`:`Format`}),(0,U.jsx)(`span`,{className:`hidden @xl/list:block`,children:e?`来源`:`Source`}),(0,U.jsx)(`span`,{className:`min-w-[5rem] text-end`,children:e?`更新日期`:`Updated`})]}),(0,U.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:J.map((t,n)=>{let r=Te[t.kind],i=t.currentVersion,a=/\.([a-z\d]{1,12})$/i.exec(i.fileName)?.[1]?.toUpperCase(),o=N(t.id,i.id),s=t.kind===`audio`&&I!==`trash`,c=t.origin?Ke(t):null;return(0,U.jsxs)(`li`,{className:`relative [contain-intrinsic-size:auto_55px] [content-visibility:auto]`,children:[(0,U.jsxs)(`button`,{type:`button`,title:t.title,ref:e=>{e?F.current.set(t.id,e):F.current.delete(t.id)},onKeyDown:e=>ze(e,n),"aria-pressed":R===t.id,onClick:()=>Le(t.id),className:z(De,`min-h-[54px] w-full py-1.5 text-start focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,R===t.id?`bg-accent-soft`:`hover:bg-surface-hover`),children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5 sm:gap-3`,children:[s?(0,U.jsx)(`span`,{className:`w-11 shrink-0`,"aria-hidden":!0}):t.kind===`image`||t.kind===`video`?(0,U.jsx)(Se,{kind:t.kind,src:o},i.id):(0,U.jsx)(Ce,{icon:r}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:(0,U.jsx)(Me,{text:t.title,query:L.trim()})}),a||c?(0,U.jsxs)(`span`,{className:`block truncate text-xs text-fg-muted @xl/list:hidden`,children:[a,a&&c?` · `:null,c]}):null,t.hit?(0,U.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:(0,U.jsx)(Me,{text:t.hit.text,query:L.trim()})}):null]})]}),(0,U.jsx)(`span`,{className:`hidden @xl/list:block`,children:a?(0,U.jsx)(`span`,{className:`inline-block max-w-full truncate rounded bg-surface-inset px-1.5 py-0.5 align-middle text-xs font-medium text-fg-muted`,children:a}):(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`—`})}),(0,U.jsx)(`span`,{className:`hidden truncate text-sm text-fg-muted @xl/list:block`,children:c??`—`}),(0,U.jsx)(`time`,{className:`min-w-[5rem] text-end text-xs whitespace-nowrap tabular-nums text-fg-muted`,children:Ge(t.updatedAt)})]}),s?(0,U.jsx)(we,{src:o,title:t.title,zh:e},i.id):null]},t.id)})})]}):null,W.data?.at(-1)?.nextCursor?(0,U.jsx)(`button`,{className:`mt-3 rounded-lg py-2 text-sm text-accent-fg`,onClick:()=>void W.setSize(W.size+1),children:e?`加载更多`:`Load more`}):null]})]})}),R&&o?(0,be.createPortal)((0,U.jsxs)(`section`,{id:`space-file-preview`,"aria-label":e?`资料预览`:`File preview`,style:{"--space-preview-width":`${b}%`},className:`file-preview-surface absolute inset-0 z-40 flex min-h-0 min-w-0 flex-col @min-[58rem]/space:relative @min-[58rem]/space:inset-auto @min-[58rem]/space:w-[var(--space-preview-width)] @min-[58rem]/space:shrink-0 @min-[58rem]/space:border-s @min-[58rem]/space:border-edge-subtle`,children:[(0,U.jsx)(Ae,{zh:e,width:b,onResize:x}),(0,U.jsxs)(`header`,{className:`flex min-h-14 shrink-0 items-center gap-1 border-b border-edge-subtle px-3 py-2`,children:[(0,U.jsx)(`button`,{type:`button`,className:z(K,`@min-[58rem]/space:hidden`),onClick:Re,"aria-label":e?`返回`:`Back`,children:(0,U.jsx)(g,{className:`size-4`})}),(0,U.jsx)(`h2`,{ref:ie,tabIndex:-1,className:`min-w-0 flex-1 py-2 text-sm leading-5 font-semibold wrap-anywhere text-fg`,children:Y?.title??(e?`预览`:`Preview`)}),Y&&!Y.trashedAt?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,className:z(K,Y.favorite&&`text-accent-fg`),"aria-pressed":Y.favorite,"aria-label":e?`收藏`:`Favorite`,disabled:D,onClick:()=>void $(`patch`,Y,{favorite:!Y.favorite}),children:(0,U.jsx)(E,{className:z(`size-4`,Y.favorite&&`fill-current`)})}),(0,U.jsx)(`button`,{type:`button`,className:K,disabled:D,"aria-label":e?`下载`:`Download`,onClick:()=>void Ve(),children:(0,U.jsx)(h,{className:`size-4`})}),(0,U.jsxs)(he,{children:[(0,U.jsx)(_e,{className:K,"aria-label":e?`更多操作`:`More actions`,children:(0,U.jsx)(y,{className:`size-4`})}),(0,U.jsx)(pe,{children:(0,U.jsxs)(me,{align:`end`,sideOffset:5,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,U.jsx)(ge,{className:q,onClick:()=>C(!0),children:e?`重命名`:`Rename`}),(0,U.jsx)(ge,{className:z(q,`text-red-600 dark:text-red-400`),disabled:D,onClick:()=>void $(`trash`,Y),children:e?`移到回收站`:`Move to Trash`})]})})]})]}):null,(0,U.jsx)(`button`,{type:`button`,className:z(K,`hidden @min-[58rem]/space:inline-flex`),onClick:Re,"aria-label":e?`关闭预览`:`Close preview`,children:(0,U.jsx)(le,{className:`size-4`})})]}),S&&Y?(0,U.jsxs)(`form`,{className:`flex shrink-0 flex-wrap items-center gap-2 px-3 py-2`,onSubmit:Ue,children:[(0,U.jsx)(`input`,{name:`title`,defaultValue:Y.title,required:!0,maxLength:240,autoFocus:!0,"aria-label":e?`资料名称`:`Result name`,className:`min-w-24 flex-1 rounded-lg border border-edge bg-surface-panel px-2 py-2 text-sm`}),(0,U.jsx)(`button`,{className:Ee,disabled:D,children:e?`保存`:`Save`}),(0,U.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-sm hover:bg-surface-hover`,onClick:()=>C(!1),children:e?`取消`:`Cancel`})]}):null,G.isLoading?(0,U.jsx)(ue,{className:`m-3 min-h-0 flex-1 rounded-xl`}):null,G.error?(0,U.jsx)(`p`,{className:`px-3 py-5 text-sm text-fg-muted`,children:e?`资料暂不可用`:`Result unavailable`}):null,Y&&X?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xe,{itemId:Y.id,version:X,hit:Z,download:Ve},X.id),(0,U.jsxs)(`div`,{className:`max-h-[45%] shrink-0 space-y-2 overflow-y-auto border-t border-edge-subtle px-3 py-2`,children:[Z?(0,U.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:(0,U.jsx)(Me,{text:Z.text,query:L.trim()})}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{children:Q?Ke(Y):null}),X.indexStatus===`pending`?(0,U.jsx)(`span`,{children:e?`正在索引`:`Indexing`}):null,Y.versions.length>1?(0,U.jsx)(_,{value:X.id,onChange:e=>Fe({version:e.target.value}),children:Y.versions.map((t,n)=>(0,U.jsxs)(v,{value:t.id,children:[t.id===Y.currentVersion.id?e?`最新版`:`Latest`:Ge(t.createdAt),` · v`,Y.versions.length-n]},t.id))}):null]}),(0,U.jsx)(`footer`,{className:`flex flex-wrap items-center justify-between gap-2`,children:Y.trashedAt?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,className:Ee,disabled:D,onClick:()=>void $(`restore`,Y),children:e?`恢复`:`Restore`}),(0,U.jsx)(`button`,{type:`button`,className:`rounded-lg px-2 py-2 text-sm text-red-600 hover:bg-surface-hover dark:text-red-400`,onClick:()=>T(!0),children:e?`永久删除`:`Delete permanently`})]}):(0,U.jsxs)(U.Fragment,{children:[Ne?(0,U.jsx)(l,{className:`rounded-lg px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover`,to:Ne,children:e?`查看来源`:`Open source`}):(0,U.jsx)(`span`,{}),(0,U.jsx)(`button`,{type:`button`,className:Ee,disabled:D||X.sizeBytes>33554432,title:X.sizeBytes>33554432?e?`超过对话附件大小上限`:`Exceeds the chat attachment size limit`:void 0,onClick:He,children:e?`在对话中使用`:`Use in chat`})]})}),w?(0,U.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-edge bg-surface-panel p-3 text-sm`,children:[(0,U.jsx)(`p`,{children:e?`永久删除「${Y.title}」?`:`Delete “${Y.title}” permanently?`}),(0,U.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,className:q,onClick:()=>T(!1),children:e?`取消`:`Cancel`}),(0,U.jsx)(`button`,{type:`button`,className:z(q,`text-red-600 dark:text-red-400`),disabled:D,onClick:()=>void $(`purge`,Y),children:e?`删除`:`Delete`})]})]}):null]})]}):null,qe]}),o):null,R&&o?null:qe]})}export{Le as SpacePage};