nextclaw 0.46.0 → 0.47.0

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 (111) hide show
  1. package/dist/cli/app/index.js +1 -1
  2. package/dist/{nextclaw-cli-app-BVdP2e0w.js → nextclaw-cli-app-wU9aUEKj.js} +233 -1
  3. package/dist/nextclaw-cli-app-wU9aUEKj.js.map +1 -0
  4. package/package.json +14 -14
  5. package/resources/apps/nextclaw-github-issue-watcher/README.md +43 -0
  6. package/resources/apps/nextclaw-github-issue-watcher/guest/Cargo.lock +455 -0
  7. package/resources/apps/nextclaw-github-issue-watcher/guest/Cargo.toml +27 -0
  8. package/resources/apps/nextclaw-github-issue-watcher/guest/src/bindings.rs +11177 -0
  9. package/resources/apps/nextclaw-github-issue-watcher/guest/src/lib.rs +307 -0
  10. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/clocks@0.2.6/monotonic-clock.wit +50 -0
  11. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/clocks@0.2.6/timezone.wit +55 -0
  12. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/clocks@0.2.6/wall-clock.wit +46 -0
  13. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/clocks@0.2.6/world.wit +11 -0
  14. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/config@0.2.0-draft-2024-09-27/package.wit +1 -0
  15. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/config@0.2.0-draft-2024-09-27/store.wit +9 -0
  16. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/http@0.2.6/handler.wit +49 -0
  17. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/http@0.2.6/package.wit +1 -0
  18. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/http@0.2.6/types.wit +688 -0
  19. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/io@0.2.6/error.wit +34 -0
  20. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/io@0.2.6/poll.wit +47 -0
  21. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/io@0.2.6/streams.wit +290 -0
  22. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/io@0.2.6/world.wit +10 -0
  23. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/deps/keyvalue@0.2.0-draft2/store.wit +124 -0
  24. package/resources/apps/nextclaw-github-issue-watcher/guest/wit/portable-service.wit +56 -0
  25. package/resources/apps/nextclaw-github-issue-watcher/manifest.json +34 -0
  26. package/resources/apps/nextclaw-github-issue-watcher/marketplace.json +18 -0
  27. package/resources/apps/nextclaw-github-issue-watcher/panels/nextclaw-github-issue-watcher-panel.panel/assets/app.js +148 -0
  28. package/resources/apps/nextclaw-github-issue-watcher/panels/nextclaw-github-issue-watcher-panel.panel/index.html +190 -0
  29. package/resources/apps/nextclaw-github-issue-watcher/panels/nextclaw-github-issue-watcher-panel.panel/panel-app.json +11 -0
  30. package/resources/apps/nextclaw-github-issue-watcher/service-components/nextclaw-github-issue-watcher-service/service-app.json +36 -0
  31. package/resources/apps/nextclaw-github-issue-watcher/service-components/nextclaw-github-issue-watcher-service/service.wasm +0 -0
  32. package/resources/apps/nextclaw-github-issue-watcher/tests/public-github-runner-smoke.tools.mjs +150 -0
  33. package/resources/apps/nextclaw-github-issue-watcher/tests/service-smoke.json +12 -0
  34. package/resources/apps/nextclaw-portable-runtime-lab/README.md +5 -3
  35. package/resources/apps/nextclaw-portable-runtime-lab/manifest.json +14 -2
  36. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-contacts.panel/assets/app.js +21 -0
  37. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-contacts.panel/index.html +1 -0
  38. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-focus.panel/assets/app.js +21 -0
  39. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-focus.panel/index.html +1 -0
  40. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-notes.panel/assets/app.js +21 -0
  41. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-notes.panel/index.html +1 -0
  42. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-panel.panel/assets/app.js +201 -0
  43. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-panel.panel/assets/style.css +42 -0
  44. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-panel.panel/index.html +40 -19
  45. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-panel.panel/panel-app.json +2 -2
  46. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-todos.panel/assets/app.js +21 -0
  47. package/resources/apps/nextclaw-portable-runtime-lab/panels/nextclaw-portable-runtime-lab-todos.panel/index.html +1 -0
  48. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-capabilities/service-app.json +110 -3
  49. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-capabilities/service.wasm +0 -0
  50. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-composition/service-app.json +12 -3
  51. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-composition/service.wasm +0 -0
  52. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-provider/service-app.json +11 -0
  53. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-provider/service.wasm +0 -0
  54. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-resident/service.wasm +0 -0
  55. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-sqlite/service-app.json +37 -0
  56. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-sqlite/service.wasm +0 -0
  57. package/resources/apps/nextclaw-portable-runtime-lab/service-components/nextclaw-portable-runtime-lab-state/service.wasm +0 -0
  58. package/ui-dist/assets/{api-aEu9cEI8.js → api-n96IfCKb.js} +2 -2
  59. package/ui-dist/assets/{api-aEu9cEI8.js.gz → api-n96IfCKb.js.gz} +0 -0
  60. package/ui-dist/assets/{appearance-settings-page-z4DaHc_E.js → appearance-settings-page-C_AqxSF_.js} +1 -1
  61. package/ui-dist/assets/appearance-settings-page-C_AqxSF_.js.gz +0 -0
  62. package/ui-dist/assets/{channels-list-page-x07sGqsT.js → channels-list-page-uR-M4Ls8.js} +1 -1
  63. package/ui-dist/assets/channels-list-page-uR-M4Ls8.js.gz +0 -0
  64. package/ui-dist/assets/{confirm-dialog-BALTnP33.js → confirm-dialog-CHVBMpla.js} +1 -1
  65. package/ui-dist/assets/confirm-dialog-CHVBMpla.js.gz +0 -0
  66. package/ui-dist/assets/{desktop-capabilities-page-4-v3wKLV.js → desktop-capabilities-page-phMuNq1B.js} +1 -1
  67. package/ui-dist/assets/desktop-capabilities-page-phMuNq1B.js.gz +0 -0
  68. package/ui-dist/assets/{desktop-update-config-Cl-_XHqU.js → desktop-update-config-C77hkbor.js} +1 -1
  69. package/ui-dist/assets/desktop-update-config-C77hkbor.js.gz +0 -0
  70. package/ui-dist/assets/{extensions-DFQXmSwG.js → extensions-CQKXTqTI.js} +1 -1
  71. package/ui-dist/assets/extensions-CQKXTqTI.js.gz +0 -0
  72. package/ui-dist/assets/{index-zuqzAvNx.js → index-CLw9DuCJ.js} +4 -4
  73. package/ui-dist/assets/index-CLw9DuCJ.js.gz +0 -0
  74. package/ui-dist/assets/mcp-marketplace-page-CbWOamyW.js +1 -0
  75. package/ui-dist/assets/{mcp-marketplace-page-COUopIOc.js → mcp-marketplace-page-s9PTnSDT.js} +1 -1
  76. package/ui-dist/assets/mcp-marketplace-page-s9PTnSDT.js.gz +0 -0
  77. package/ui-dist/assets/{model-config-page-g9_-hZqZ.js → model-config-page-CxnCUWRW.js} +1 -1
  78. package/ui-dist/assets/model-config-page-CxnCUWRW.js.gz +0 -0
  79. package/ui-dist/assets/{privacy-settings-page-pNhQQT4r.js → privacy-settings-page-D8HZHHjL.js} +1 -1
  80. package/ui-dist/assets/privacy-settings-page-D8HZHHjL.js.gz +0 -0
  81. package/ui-dist/assets/{providers-config-page-DftW_6KU.js → providers-config-page-C0GIoGxm.js} +1 -1
  82. package/ui-dist/assets/providers-config-page-C0GIoGxm.js.gz +0 -0
  83. package/ui-dist/assets/remote-DvTCSAxQ.js +1 -0
  84. package/ui-dist/assets/{runtime-config-page-Cd9sOYvn.js → runtime-config-page-VNJZui5f.js} +1 -1
  85. package/ui-dist/assets/runtime-config-page-VNJZui5f.js.gz +0 -0
  86. package/ui-dist/assets/{search-config-page-BqoDbKpM.js → search-config-page-D3_qNXbB.js} +1 -1
  87. package/ui-dist/assets/search-config-page-D3_qNXbB.js.gz +0 -0
  88. package/ui-dist/assets/{secrets-config-page-GsahsEVw.js → secrets-config-page-Be4P1E8o.js} +1 -1
  89. package/ui-dist/assets/secrets-config-page-Be4P1E8o.js.gz +0 -0
  90. package/ui-dist/assets/security-config-BtcpKIhQ.js +1 -0
  91. package/ui-dist/assets/{tag-chip-ClBWeQ4p.js → tag-chip-Dc_NcCEe.js} +1 -1
  92. package/ui-dist/index.html +5 -5
  93. package/ui-dist/index.html.gz +0 -0
  94. package/dist/nextclaw-cli-app-BVdP2e0w.js.map +0 -1
  95. package/ui-dist/assets/appearance-settings-page-z4DaHc_E.js.gz +0 -0
  96. package/ui-dist/assets/channels-list-page-x07sGqsT.js.gz +0 -0
  97. package/ui-dist/assets/confirm-dialog-BALTnP33.js.gz +0 -0
  98. package/ui-dist/assets/desktop-capabilities-page-4-v3wKLV.js.gz +0 -0
  99. package/ui-dist/assets/desktop-update-config-Cl-_XHqU.js.gz +0 -0
  100. package/ui-dist/assets/extensions-DFQXmSwG.js.gz +0 -0
  101. package/ui-dist/assets/index-zuqzAvNx.js.gz +0 -0
  102. package/ui-dist/assets/mcp-marketplace-page-COUopIOc.js.gz +0 -0
  103. package/ui-dist/assets/mcp-marketplace-page-DxPPmYqh.js +0 -1
  104. package/ui-dist/assets/model-config-page-g9_-hZqZ.js.gz +0 -0
  105. package/ui-dist/assets/privacy-settings-page-pNhQQT4r.js.gz +0 -0
  106. package/ui-dist/assets/providers-config-page-DftW_6KU.js.gz +0 -0
  107. package/ui-dist/assets/remote-DS2TkMPm.js +0 -1
  108. package/ui-dist/assets/runtime-config-page-Cd9sOYvn.js.gz +0 -0
  109. package/ui-dist/assets/search-config-page-BqoDbKpM.js.gz +0 -0
  110. package/ui-dist/assets/secrets-config-page-GsahsEVw.js.gz +0 -0
  111. package/ui-dist/assets/security-config-BnHQyrtG.js +0 -1
@@ -0,0 +1,37 @@
1
+ {
2
+ "id": "nextclaw-portable-runtime-lab-sqlite",
3
+ "title": "Portable Spin SQLite Component",
4
+ "description": "通过标准 Spin SQLite interface 验证私有持久数据、隔离和权限拒绝。",
5
+ "protocol": "wasi-component",
6
+ "component": {
7
+ "entry": "service.wasm"
8
+ },
9
+ "actions": {
10
+ "sqlite_roundtrip": {
11
+ "risk": "write",
12
+ "title": "写入并查询标准 Spin SQLite",
13
+ "inputSchema": {
14
+ "type": "object",
15
+ "required": ["key", "value"],
16
+ "properties": {
17
+ "key": { "type": "string", "minLength": 1, "maxLength": 128 },
18
+ "value": { "type": "string", "minLength": 1, "maxLength": 4096 }
19
+ },
20
+ "additionalProperties": false
21
+ }
22
+ },
23
+ "sqlite_read": {
24
+ "risk": "read",
25
+ "title": "读取标准 Spin SQLite",
26
+ "inputSchema": {
27
+ "type": "object",
28
+ "required": ["key"],
29
+ "properties": {
30
+ "key": { "type": "string", "minLength": 1, "maxLength": 128 }
31
+ },
32
+ "additionalProperties": false
33
+ }
34
+ },
35
+ "sqlite_permission_denied": { "risk": "read", "title": "验证 SQLite 权限拒绝" }
36
+ }
37
+ }
@@ -4,10 +4,10 @@ import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,I as r,L as i,V as
4
4
  `,`
5
5
  `).split(`
6
6
 
7
- `),r=n.pop()??``;for(let e of n){let n=Wt(e);if(n?.event!==`ncp-event`)continue;let r=Gt(n.data);r&&t(r)}return r}},qt=class{constructor(e,t){this.requestService=e,this.baseUrl=t}list=async()=>(await this.requestService.get(`/api/agents`)).agents;create=async e=>await this.requestService.post(`/api/agents`,e);update=async(e,t)=>await this.requestService.put(`/api/agents/${encodeURIComponent(e)}`,t);delete=async e=>await this.requestService.delete(`/api/agents/${encodeURIComponent(e)}`);resolveAvatarUrl=e=>Bt(this.baseUrl,`/api/agents/${encodeURIComponent(e)}/avatar`)},Jt=class{constructor(e){this.requestService=e}fetchMeta=async()=>await this.requestService.get(`/api/app/meta`);fetchBootstrapStatus=async(e={})=>await this.requestService.get(`/api/runtime/bootstrap-status`,e)},Yt=class{constructor(e){this.requestService=e}list=async(e={})=>await this.requestService.get(e.includeStorageUsage===!1?`/api/app-packages?includeStorageUsage=false`:`/api/app-packages`);get=async e=>await this.requestService.get(`/api/app-packages/${encodeURIComponent(e)}`);listOperations=async()=>await this.requestService.get(`/api/app-package-operations`);startInstall=async e=>await this.requestService.post(`/api/app-package-operations/install`,e);startUpdate=async(e,t={})=>await this.requestService.post(`/api/app-package-operations/${encodeURIComponent(e)}/update`,t);startRollback=async(e,t)=>await this.requestService.post(`/api/app-package-operations/${encodeURIComponent(e)}/rollback`,{version:t});startUninstall=async(e,t=!1)=>await this.requestService.post(`/api/app-package-operations/${encodeURIComponent(e)}/uninstall`,{purgeData:t});install=async e=>await this.requestService.post(`/api/app-packages/install`,e);enable=async e=>await this.requestService.post(`/api/app-packages/${encodeURIComponent(e)}/enable`);disable=async e=>await this.requestService.post(`/api/app-packages/${encodeURIComponent(e)}/disable`);update=async(e,t={})=>await this.requestService.post(`/api/app-packages/${encodeURIComponent(e)}/update`,t);rollback=async(e,t)=>await this.requestService.post(`/api/app-packages/${encodeURIComponent(e)}/rollback`,{version:t});uninstall=async(e,t=!1)=>await this.requestService.request(`/api/app-packages/${encodeURIComponent(e)}`,{method:`DELETE`,body:{purgeData:t}})},Xt=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/app-data`);deleteRetained=async(e,t)=>await this.requestService.request(`/api/app-data/${encodeURIComponent(e)}`,{method:`DELETE`,body:{confirmAppId:t}})},Zt=class{constructor(e){this.requestService=e}fetchStatus=async(e={})=>await this.requestService.get(`/api/auth/status`,{...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}});setup=async e=>await this.requestService.post(`/api/auth/setup`,e);login=async e=>await this.requestService.post(`/api/auth/login`,e);logout=async()=>await this.requestService.post(`/api/auth/logout`,{});updatePassword=async e=>await this.requestService.put(`/api/auth/password`,e);updateEnabled=async e=>await this.requestService.put(`/api/auth/enabled`,e)},Qt=class{constructor(e){this.requestService=e}start=async(e,t={})=>await this.requestService.post(`/api/config/channels/${encodeURIComponent(e)}/auth/start`,t);poll=async(e,t)=>await this.requestService.post(`/api/config/channels/${encodeURIComponent(e)}/auth/poll`,t);connect=async(e,t)=>await this.requestService.post(`/api/config/channels/${encodeURIComponent(e)}/auth/connect`,t)},$t=class{constructor(e){this.requestService=e}listDesktopGrants=async()=>await this.requestService.get(`/api/capability-grants?resourceType=desktop.application`);grantDesktopAccess=async e=>await this.requestService.post(`/api/capability-grants`,e);revokeDesktopAccess=async e=>await this.requestService.request(`/api/capability-grants`,{method:`DELETE`,body:{subject:e.subject,resourceType:e.resource.type,target:e.resource.target,access:e.access}});getDesktopStatus=async()=>await this.requestService.get(`/api/desktop-host/status`);requestDesktopPermissions=async()=>await this.requestService.post(`/api/desktop-host/permissions/request`,{});openDesktopPermissionSettings=async()=>await this.requestService.post(`/api/desktop-host/permissions/open-settings`,{})},en=class{constructor(e){this.requestService=e}get=async()=>await this.requestService.get(`/api/feature-controls`)},tn=class{constructor(e){this.requestService=e}fetch=async()=>await this.requestService.get(`/api/config`);fetchMeta=async()=>await this.requestService.get(`/api/config/meta`);fetchSchema=async()=>await this.requestService.get(`/api/config/schema`);updateModel=async e=>await this.requestService.put(`/api/config/model`,e);updateSearch=async e=>await this.requestService.put(`/api/config/search`,e);updateChannel=async(e,t)=>await this.requestService.put(`/api/config/channels/${encodeURIComponent(e)}`,t);updateRuntime=async e=>await this.requestService.put(`/api/config/runtime`,e);updateSecrets=async e=>await this.requestService.put(`/api/config/secrets`,e);updateProductAnalytics=async e=>await this.requestService.put(`/api/config/product-analytics`,e);fetchProductAnalyticsStatus=async()=>await this.requestService.get(`/api/config/product-analytics/status`);executeAction=async(e,t={})=>await this.requestService.post(`/api/config/actions/${encodeURIComponent(e)}/execute`,t);fetchChatSessionTypes=async()=>await this.requestService.get(`/api/ncp/session-types`);fetchCronJobs=async(e={})=>await this.requestService.get(`/api/cron`,{query:{all:e.all?`1`:void 0,limit:e.limit,offset:e.offset,query:e.query,status:e.status}});deleteCronJob=async e=>await this.requestService.delete(`/api/cron/${encodeURIComponent(e)}`);setCronJobEnabled=async(e,t)=>await this.requestService.put(`/api/cron/${encodeURIComponent(e)}/enable`,t);runCronJob=async(e,t={})=>await this.requestService.post(`/api/cron/${encodeURIComponent(e)}/run`,t)},nn=class{constructor(e){this.requestService=e}fetchItems=async e=>await this.requestService.get(`${rn(e.type)}/items`,{query:an(e)});fetchItem=async(e,t)=>await this.requestService.get(`${rn(t)}/items/${encodeURIComponent(e)}`);fetchSkillContent=async e=>await this.requestService.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);fetchRecommendations=async(e,t={})=>await this.requestService.get(`${rn(e)}/recommendations`,{query:{...t.scene?.trim()?{scene:t.scene.trim()}:{},...typeof t.limit==`number`&&Number.isFinite(t.limit)?{limit:Math.max(1,Math.trunc(t.limit))}:{}}});fetchSkillScenes=async()=>await this.requestService.get(`/api/marketplace/skills/scenes`);install=async e=>await this.requestService.post(`${rn(on(e.type))}/install`,e);fetchInstalled=async e=>await this.requestService.get(`${rn(e)}/installed`);manage=async e=>await this.requestService.post(`${rn(on(e.type))}/manage`,e)};function rn(e){return e===`skill`?`/api/marketplace/skills`:`/api/marketplace/mcp`}function an(e){let{page:t,pageSize:n,q:r,scene:i,sort:a,tag:o}=e,s={};return r?.trim()&&(s.q=r.trim()),o?.trim()&&(s.tag=o.trim()),i?.trim()&&(s.scene=i.trim()),a&&(s.sort=a),typeof t==`number`&&Number.isFinite(t)&&(s.page=Math.max(1,Math.trunc(t))),typeof n==`number`&&Number.isFinite(n)&&(s.pageSize=Math.max(1,Math.trunc(n))),Object.keys(s).length>0?s:void 0}function on(e){if(!e)throw Error(`Marketplace request type is required.`);return e}var sn=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/inbox/deliveries`);get=async e=>await this.requestService.get(this.deliveryPath(e));updateState=async(e,t)=>await this.requestService.request(this.deliveryPath(e),{method:`PATCH`,body:{action:t}});delete=async e=>(await this.requestService.delete(this.deliveryPath(e))).deleted;deliveryPath=e=>`/api/inbox/deliveries/${encodeURIComponent(e)}`},cn=class{constructor(e){this.requestService=e}fetchItems=async(e={})=>await this.requestService.get(`/api/marketplace/mcp/items`,{query:ln(e)});fetchInstalled=async()=>await this.requestService.get(`/api/marketplace/mcp/installed`);fetchItem=async e=>await this.requestService.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}`);fetchContent=async e=>await this.requestService.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);fetchRecommendations=async(e={})=>await this.requestService.get(`/api/marketplace/mcp/recommendations`,{query:{...e.scene?.trim()?{scene:e.scene.trim()}:{},...typeof e.limit==`number`&&Number.isFinite(e.limit)?{limit:Math.max(1,Math.trunc(e.limit))}:{}}});install=async e=>await this.requestService.post(`/api/marketplace/mcp/install`,e);manage=async e=>await this.requestService.post(`/api/marketplace/mcp/manage`,e);doctor=async e=>await this.requestService.post(`/api/marketplace/mcp/doctor`,{name:e})};function ln(e){let{page:t,pageSize:n,q:r,sort:i,tag:a}=e,o={};return r?.trim()&&(o.q=r.trim()),a?.trim()&&(o.tag=a.trim()),i&&(o.sort=i),typeof t==`number`&&Number.isFinite(t)&&(o.page=Math.max(1,Math.trunc(t))),typeof n==`number`&&Number.isFinite(n)&&(o.pageSize=Math.max(1,Math.trunc(n))),Object.keys(o).length>0?o:void 0}var un=class{constructor(e){this.requestService=e}testConnection=async e=>await this.requestService.post(`/api/mcp/servers/test`,e);createConnection=async e=>await this.requestService.post(`/api/mcp/servers`,e)},dn=`x-nextclaw-panel-bridge-session`;function fn(e){return e?{[dn]:e}:void 0}var pn=class{constructor(e){this.requestService=e}listPanelApps=async()=>await this.requestService.get(`/api/panel-apps`);updatePanelAppPreferences=async(e,t)=>await this.requestService.request(`/api/panel-apps/${encodeURIComponent(e)}/preferences`,{method:`PATCH`,body:t});recordPanelAppOpened=async e=>await this.requestService.post(`/api/panel-apps/${encodeURIComponent(e)}/open`);deletePanelApp=async e=>await this.requestService.delete(`/api/panel-apps/${encodeURIComponent(e)}`);createBridgeSession=async e=>await this.requestService.post(`/api/panel-app-bridge-sessions`,e);deleteBridgeSession=async e=>await this.requestService.delete(`/api/panel-app-bridge-sessions/${encodeURIComponent(e)}`);grantClient=async e=>await this.requestService.post(`/api/panel-app-client-grants/${encodeURIComponent(e)}`,{});revokeClient=async e=>await this.requestService.delete(`/api/panel-app-client-grants/${encodeURIComponent(e)}`);sendAgentMessage=async(e,t={})=>await this.requestService.post(`/api/panel-app-agent/send`,e,{headers:fn(t.bridgeSessionToken)});generateAgentObject=async(e,t={})=>await this.requestService.post(`/api/panel-app-agent/generate-object`,e,{headers:fn(t.bridgeSessionToken)});grantAgentCapability=async(e,t={})=>await this.requestService.post(`/api/panel-app-agent-capabilities/${encodeURIComponent(e)}/grant`,{},{headers:fn(t.bridgeSessionToken)})},mn=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/providers`);listTemplates=async()=>await this.requestService.get(`/api/provider-templates`);listModelCatalog=async()=>await this.requestService.get(`/api/provider-model-catalog`);update=async(e,t)=>await this.requestService.put(`/api/providers/${encodeURIComponent(e)}`,t);create=async(e={})=>await this.requestService.post(`/api/providers`,e);delete=async e=>await this.requestService.delete(`/api/providers/${encodeURIComponent(e)}`);testConnection=async(e,t)=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/test`,t);discoverModels=async(e,t)=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/models/discover`,t);startAuth=async(e,t={})=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/auth/start`,t);pollAuth=async(e,t)=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/auth/poll`,t);importAuthFromCli=async e=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/auth/import-cli`,{})},hn=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/projects`);create=async e=>await this.requestService.post(`/api/projects`,e);addExisting=async e=>await this.requestService.post(`/api/projects/existing`,e)},gn=class{baseUrl;transport;webSocketFactory;constructor(e){this.options=e,this.baseUrl=e.baseUrl,this.transport=e.transport,this.webSocketFactory=e.webSocketFactory}subscribe=(e,t={})=>{if(this.transport?.subscribe){let t=this.transport.subscribe(e);return{close:()=>{t()}}}let n=null,r=null,i=!1,a=Math.max(200,t.reconnectDelayMs??1e3),o=()=>{r!==null&&(clearTimeout(r),r=null)},s=t=>{e(t)},c=()=>{try{n=this.createSocket(Ht(this.baseUrl,`/ws`))}catch(e){t.onError?.(e),i||(r=setTimeout(c,a));return}n.onopen=()=>{s({type:`connection.open`})},n.onmessage=e=>{let t=this.parseEvent(e.data);t&&s(t)},n.onerror=e=>{t.onError?.(e),s({type:`connection.error`,payload:{message:`WebSocket error`}})},n.onclose=()=>{s({type:`connection.close`}),n=null,i||(o(),r=setTimeout(c,a))}};return c(),{close:()=>{i=!0,o(),n?.close(),n=null}}};createSocket=e=>{if(this.webSocketFactory)return this.webSocketFactory(e);if(typeof globalThis.WebSocket!=`function`)throw Error(`WebSocket is unavailable. Provide webSocketFactory when creating the client.`);return new globalThis.WebSocket(e)};parseEvent=e=>{if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return t&&typeof t==`object`&&`type`in t?t:null}catch{return null}}},_n=class{constructor(e){this.requestService=e}fetchStatus=async()=>await this.requestService.get(`/api/remote/status`);fetchDoctor=async()=>await this.requestService.get(`/api/remote/doctor`);login=async e=>await this.requestService.post(`/api/remote/login`,e);startBrowserAuth=async(e={})=>await this.requestService.post(`/api/remote/auth/start`,e);pollBrowserAuth=async e=>await this.requestService.post(`/api/remote/auth/poll`,e);logout=async()=>await this.requestService.post(`/api/remote/logout`,{});updateAccountProfile=async e=>await this.requestService.put(`/api/remote/account/profile`,e);updateSettings=async e=>await this.requestService.put(`/api/remote/settings`,e);controlService=async e=>await this.requestService.post(`/api/remote/service/${e}`,{})},q=class extends Error{status;code;details;constructor(e){let{code:t,details:n,message:r,status:i}=e;super(r),this.name=`NextClawClientError`,this.status=i,this.code=t,this.details=n}};function vn(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function yn(e,t){return vn(e)?e[t]:void 0}var bn=class{baseUrl;fetchImpl;requestTimeoutMs;defaultHeaders;transport;constructor(e){this.options=e;let{baseUrl:t,fetchImpl:n,headers:r,requestTimeoutMs:i,token:a}=e;this.baseUrl=t,this.fetchImpl=Ut(n),this.requestTimeoutMs=Math.max(1e3,i??15e3),this.transport=e.transport,this.defaultHeaders={Accept:`application/json`,...r??{},...a?{Authorization:`Bearer ${a}`}:{}}}request=async(e,t={})=>{let{body:n,headers:r,method:i,query:a,signal:o,timeoutMs:s}=t;if(this.transport)return await this.requestWithTransport(e,t);let c=new AbortController,l=Math.max(1e3,s??this.requestTimeoutMs),u=this.bindAbortSignal(c,o),d=setTimeout(()=>c.abort(),l),f={...this.defaultHeaders,...r??{}},p=this.normalizeRequestBody(n,f);try{let t=await this.fetchImpl(Bt(this.baseUrl,Vt(e,this.serializeQuery(a))),{method:i??`GET`,headers:f,body:p,signal:c.signal}),n=await t.json();if(!t.ok){let e=this.extractApiError(n);throw new q({message:e.message,status:t.status,code:e.code,details:e.details})}if(!this.isApiResponse(n))throw new q({message:`Unexpected NextClaw API response shape.`,status:t.status});if(!n.ok)throw new q({message:n.error.message,status:t.status,code:n.error.code,details:n.error.details});return n.data}catch(e){throw e instanceof q?e:e instanceof Error&&e.name===`AbortError`?new q({message:`NextClaw API request timed out after ${l}ms.`}):new q({message:e instanceof Error?e.message:`NextClaw API request failed.`})}finally{o?.removeEventListener(`abort`,u),clearTimeout(d)}};bindAbortSignal=(e,t)=>{let n=()=>e.abort(t?.reason);return t?t.aborted?(e.abort(t.reason),n):(t.addEventListener(`abort`,n,{once:!0}),n):n};requestWithTransport=async(e,t)=>{let{body:n,headers:r,method:i,query:a,signal:o,timeoutMs:s}=t,{transport:c}=this;if(!c)throw new q({message:`NextClaw transport is not configured.`});try{return await c.request({method:i??`GET`,path:e,...n===void 0?{}:{body:n},...a?{query:a}:{},...r?{headers:r}:{},...o?{signal:o}:{},...s===void 0?{}:{timeoutMs:s}})}catch(e){if(e instanceof q)throw e;let t=yn(e,`code`),n=yn(e,`details`),r=yn(e,`status`);throw new q({message:e instanceof Error?e.message:`NextClaw API request failed.`,code:typeof t==`string`?t:void 0,details:vn(n)?n:void 0,status:typeof r==`number`?r:void 0})}};get=async(e,t={})=>await this.request(e,{...t,method:`GET`});post=async(e,t,n={})=>await this.request(e,{...n,method:`POST`,...t===void 0?{}:{body:t}});put=async(e,t,n={})=>await this.request(e,{...n,method:`PUT`,...t===void 0?{}:{body:t}});delete=async(e,t={})=>await this.request(e,{...t,method:`DELETE`});upload=async(e,t,n={})=>{let{headers:r,signal:i,timeoutMs:a}=n;if(this.transport?.upload)return await this.transport.upload({path:e,formData:t,...r?{headers:r}:{},...i?{signal:i}:{},...a===void 0?{}:{timeoutMs:a}});let o=new AbortController,s=Math.max(1e3,a??this.requestTimeoutMs),c=()=>o.abort(i?.reason);i&&(i.aborted?o.abort(i.reason):i.addEventListener(`abort`,c,{once:!0}));let l=setTimeout(()=>o.abort(),s);try{let n=await this.fetchImpl(Bt(this.baseUrl,e),{method:`POST`,headers:{Accept:`application/json`,...xn(this.options.token)??{},...this.options.headers??{},...r??{}},body:t,signal:o.signal}),i=await n.json();if(!n.ok){let e=this.extractApiError(i);throw new q({message:e.message,status:n.status,code:e.code,details:e.details})}if(!this.isApiResponse(i)||!i.ok)throw new q({message:`Unexpected NextClaw upload response shape.`,status:n.status});return i.data}catch(e){throw e instanceof q?e:e instanceof Error&&e.name===`AbortError`?new q({message:`NextClaw API upload timed out after ${s}ms.`}):new q({message:e instanceof Error?e.message:`NextClaw API upload failed.`})}finally{i?.removeEventListener(`abort`,c),clearTimeout(l)}};isApiResponse=e=>typeof e==`object`&&!!e&&`ok`in e;extractApiError=e=>{if(this.isApiResponse(e)&&!e.ok)return e.error;if(typeof e==`object`&&e&&`message`in e){let t=e;return{code:typeof t.code==`string`?t.code:`HTTP_ERROR`,message:typeof t.message==`string`?t.message:`NextClaw API request failed.`,details:t.details!==null&&typeof t.details==`object`?t.details:void 0}}return{code:`HTTP_ERROR`,message:`NextClaw API request failed.`}};normalizeRequestBody=(e,t)=>{if(e!==void 0)return e instanceof FormData||e instanceof URLSearchParams||e instanceof Blob||e instanceof ArrayBuffer?e:typeof e==`string`?(!(`Content-Type`in t)&&!(`content-type`in t)&&(t[`Content-Type`]=`application/json`),e):(!(`Content-Type`in t)&&!(`content-type`in t)&&(t[`Content-Type`]=`application/json`),JSON.stringify(e))};serializeQuery=e=>{if(!e)return;if(e instanceof URLSearchParams)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r:[r];for(let r of e)r!=null&&t.append(n,String(r))}return t}};function xn(e){return e?{Authorization:`Bearer ${e}`}:null}var Sn=class{constructor(e){this.requestService=e}fetch=async()=>await this.requestService.get(`/api/runtime/control`);startService=async()=>await this.requestService.post(`/api/runtime/control/start-service`,{});restartService=async()=>await this.requestService.post(`/api/runtime/control/restart-service`,{});stopService=async()=>await this.requestService.post(`/api/runtime/control/stop-service`,{})},Cn=class{constructor(e){this.requestService=e}fetch=async()=>await this.requestService.get(`/api/runtime/update`);check=async()=>await this.requestService.post(`/api/runtime/update/check`,{});download=async()=>await this.requestService.post(`/api/runtime/update/download`,{});apply=async()=>await this.requestService.post(`/api/runtime/update/apply`,{});updateChannel=async e=>await this.requestService.put(`/api/runtime/update/channel`,{channel:e})},wn=class{constructor(e){this.requestService=e}browse=async e=>{let{basePath:t,includeFiles:n,path:r}=e??{},i=typeof r==`string`?r.trim():``,a=typeof t==`string`?t.trim():``;return await this.requestService.get(`/api/server-paths/browse`,{query:{...i?{path:i}:{},...a?{basePath:a}:{},...n?{includeFiles:`1`}:{}}})};watch=async e=>await this.requestService.post(`/api/server-paths/watch`,e);unwatch=async e=>{await this.requestService.delete(`/api/server-paths/watch`,{query:{subscriptionId:e.trim()}})};createDirectory=async e=>await this.requestService.post(`/api/server-paths/directory`,e);createFile=async e=>await this.requestService.post(`/api/server-paths/file`,e);renameEntry=async e=>await this.requestService.request(`/api/server-paths/entry`,{method:`PATCH`,body:e});deleteEntry=async e=>await this.requestService.delete(`/api/server-paths/entry`,{query:{basePath:e.basePath.trim(),path:e.path.trim()}});uploadFiles=async e=>{let{basePath:t,files:n,overwrite:r,targetPath:i}=e,a=new FormData;return a.append(`basePath`,t.trim()),a.append(`targetPath`,i.trim()),a.append(`overwrite`,r?`true`:`false`),n.forEach(e=>a.append(`files`,e)),await this.requestService.upload(`/api/server-paths/files`,a,{timeoutMs:12e4})};read=async e=>{let{basePath:t,line:n,path:r}=e,i=r.trim(),a=typeof t==`string`?t.trim():``,o=Number.isSafeInteger(n)&&(n??0)>0?n:null;return await this.requestService.get(`/api/server-paths/read`,{query:{path:i,...a?{basePath:a}:{},...o?{line:String(o)}:{}}})};search=async e=>{let{basePath:t,limit:n,query:r}=e,i=t.trim(),a=r?.trim()??``,o=Number.isSafeInteger(n)&&(n??0)>0?n:null;return await this.requestService.get(`/api/server-paths/search`,{query:{basePath:i,...a?{query:a}:{},...o?{limit:String(o)}:{}}})}},Tn=`x-nextclaw-panel-bridge-session`;function En(e){return e?{[Tn]:e}:void 0}var Dn=class{constructor(e){this.requestService=e}listServiceApps=async()=>await this.requestService.get(`/api/service-apps`);getServiceApp=async e=>await this.requestService.get(`/api/service-apps/${encodeURIComponent(e)}`);restartServiceApp=async e=>await this.requestService.post(`/api/service-apps/${encodeURIComponent(e)}/restart`);deleteServiceApp=async(e,t=!1)=>await this.requestService.request(`/api/service-apps/${encodeURIComponent(e)}`,{method:`DELETE`,body:{purgeData:t}});listServiceActions=async(e={})=>{let t=e.appId?`?${new URLSearchParams({appId:e.appId}).toString()}`:``;return await this.requestService.get(`/api/service-actions${t}`,{headers:En(e.bridgeSessionToken)})};discoverServiceAppActions=async e=>await this.requestService.post(`/api/service-apps/${encodeURIComponent(e)}/actions/discover`,{});invokeServiceAction=async(e,t,n={})=>await this.requestService.post(`/api/service-actions/${encodeURIComponent(e)}/invoke`,{input:t??{}},{headers:En(n.bridgeSessionToken)});grantServiceAction=async(e,t={})=>await this.requestService.post(`/api/service-actions/${encodeURIComponent(e)}/grant`,{},{headers:En(t.bridgeSessionToken)});grantServiceActions=async(e,t={})=>await this.requestService.post(`/api/service-action-grants`,{actionIds:e},{headers:En(t.bridgeSessionToken)});grantAgentServiceActions=async(e,t)=>await this.requestService.post(`/api/agents/${encodeURIComponent(e)}/service-action-grants`,{actionIds:t});listServiceActionGrants=async()=>await this.requestService.get(`/api/service-action-grants`);revokeServiceAction=async(e,t={})=>await this.requestService.delete(`/api/service-actions/${encodeURIComponent(e)}/grant`,{headers:En(t.bridgeSessionToken)});revokeServiceActionGrant=async e=>{let{actionId:t,caller:n}=e,r=new URLSearchParams({surface:n.surface,callerId:n.surface===`panel-app`?n.appId:n.agentId});return await this.requestService.delete(`/api/service-action-grants/${encodeURIComponent(t)}?${r.toString()}`)}},On=class{constructor(e,t){this.requestService=e,this.eventBus=t}list=async e=>{let{limit:t,page:n,pageSize:r,query:i,peerId:a}=e??{},o=new URLSearchParams;typeof t==`number`&&Number.isFinite(t)&&o.set(`limit`,String(Math.max(1,Math.trunc(t)))),typeof n==`number`&&Number.isFinite(n)&&o.set(`page`,String(Math.max(1,Math.trunc(n)))),typeof r==`number`&&Number.isFinite(r)&&o.set(`pageSize`,String(Math.max(1,Math.trunc(r)))),i?.trim()&&o.set(`query`,i.trim());let s=a?.trim();return s&&o.set(`peerId`,s),await this.requestService.get(`/api/ncp/sessions`,{...o.size>0?{query:o}:{}})};get=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}`);listMessages=async(e,t={})=>{let n=typeof t==`number`?{limit:t}:t,r=new URLSearchParams;return typeof n.limit==`number`&&Number.isFinite(n.limit)&&r.set(`limit`,String(Math.max(1,Math.trunc(n.limit)))),n.cursor?.trim()&&r.set(`cursor`,n.cursor.trim()),n.toolPayload===`summary`&&r.set(`toolPayload`,`summary`),n.initialPayload===`compact`&&r.set(`initialPayload`,`compact`),await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/messages`,{...r.size>0?{query:r}:{},...n.signal?{signal:n.signal}:{}})};getUsage=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/usage`);listSkills=async(e,t)=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/skills`,{query:t?.projectRoot?.trim()?{projectRoot:t.projectRoot.trim()}:void 0});listQueuedInputs=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/queued-inputs`);deleteQueuedInput=async(e,t)=>await this.requestService.delete(`/api/ncp/sessions/${encodeURIComponent(e)}/queued-inputs/${encodeURIComponent(t)}`);listPendingInputs=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/pending-inputs`);steerQueuedInput=async(e,t)=>await this.requestService.post(`/api/ncp/sessions/${encodeURIComponent(e)}/queued-inputs/${encodeURIComponent(t)}/steer`);update=async(e,t)=>await this.requestService.put(`/api/ncp/sessions/${encodeURIComponent(e)}`,t);compactContext=async e=>await this.requestService.post(`/api/ncp/sessions/${encodeURIComponent(e)}/context/compact`);delete=async e=>await this.requestService.delete(`/api/ncp/sessions/${encodeURIComponent(e)}`);uploadAssets=async e=>{let t=new FormData;for(let n of e)t.append(`files`,n);return await this.requestService.upload(`/api/ncp/assets`,t)};subscribe=(e,t={})=>({close:this.eventBus.subscribeAll(t=>{e(t)})})},kn=class{constructor(e){this.requestService=e}list=async(e={})=>await this.requestService.get(`/api/system-object-references`,{query:e});resolve=async e=>await this.requestService.post(`/api/system-object-references/resolve`,{uri:e})},An=class{baseUrl;agentRuns;app;appPackages;appData;agents;auth;channelAuth;capabilityAccess;featureControls;config;eventBus;marketplace;inboxDeliveries;mcpMarketplace;mcp;panelApps;providers;projects;realtime;remote;runtimeControl;runtimeUpdate;serverPaths;serviceApps;sessions;systemObjectReferences;constructor(e){this.baseUrl=zt(e.baseUrl);let t={...e,baseUrl:this.baseUrl},n=new bn(t);this.realtime=new gn(t);let i=null;this.eventBus=new r({onFirstSubscriber:()=>{i??=this.realtime.subscribe(e=>{this.eventBus.emitEnvelope({type:e.type,payload:`payload`in e?e.payload:void 0,emittedAt:`emittedAt`in e?e.emittedAt:new Date().toISOString(),source:`source`in e?e.source:`realtime`})})},onNoSubscribers:()=>{i?.close(),i=null}}),this.agentRuns=new Kt(n,t),this.app=new Jt(n),this.appPackages=new Yt(n),this.appData=new Xt(n),this.agents=new qt(n,this.baseUrl),this.auth=new Zt(n),this.channelAuth=new Qt(n),this.capabilityAccess=new $t(n),this.featureControls=new en(n),this.config=new tn(n),this.marketplace=new nn(n),this.inboxDeliveries=new sn(n),this.mcpMarketplace=new cn(n),this.mcp=new un(n),this.panelApps=new pn(n),this.providers=new mn(n),this.projects=new hn(n),this.remote=new _n(n),this.runtimeControl=new Sn(n),this.runtimeUpdate=new Cn(n),this.serverPaths=new wn(n),this.serviceApps=new Dn(n),this.sessions=new On(n,this.eventBus),this.systemObjectReferences=new kn(n)}},jn=`http://127.0.0.1:55667`,Mn=(()=>{let e=(void 0)?.trim();return e?e.replace(/\/$/,``):typeof window<`u`&&window.location?.origin?window.location.origin:jn})(),Nn={"Use this page to manage the local NextClaw service. Closing the browser does not stop the service.":`runtimeControlManagedLocalMessage`,"This page is served by the running local service. Closing the browser does not stop it.":`runtimeControlManagedLocalHint`,"This page is served by the running local service.":`runtimeControlManagedLocalHintShort`,"This page is already hosted by the running local service.":`runtimeControlStartUnavailableHosted`,"App restart is only available in the desktop shell.":`runtimeControlRestartAppDesktopOnly`,"The local service is not running.":`runtimeControlServiceNotRunning`,"The local service is already stopped.":`runtimeControlServiceAlreadyStopped`,"Managed service started.":`runtimeControlManagedServiceStarted`,"Managed service start scheduled.":`runtimeControlManagedServiceStartScheduled`,"Restart scheduled. This page may disconnect for a few seconds.":`runtimeControlRestartScheduled`,"Stop scheduled. This page will disconnect shortly.":`runtimeControlStopScheduled`,"runtime healthy":`runtimeControlHealthy`};function Pn(e){return e.activeSystemAction?`service-transitioning`:e.lifecyclePhase}function Fn(e){return e===`ready`?`connected`:e===`startup-failed`||e===`stalled`?`disconnected`:`connecting`}function In(e){let t=Pn(e);return{...e,phase:t,connectionStatus:Fn(t)}}function Ln(e){return e===`start-service`?`starting-service`:e===`stop-service`?`stopping-service`:e===`restart-service`?`restarting-service`:`restarting-app`}function Rn(e){return e===`start-service`?`starting`:e===`stop-service`?`stopping`:e===`restart-service`?`restarting`:null}function J(e){if(!e)return null;let t=Nn[e.trim()];return t?o(t):e}function zn(e){let{action:t,message:n}=e;return{action:t,lifecycle:Ln(t),serviceState:Rn(t),message:n}}function Bn(e){if(e.runtimeControlError)return{tone:`inactive`,title:o(`runtimeControlLoadFailed`),description:e.runtimeControlError,reasonLines:[],actionLabel:null,isBusy:!1};if(!e.runtimeControlView)return{tone:`inactive`,title:o(`runtimeStatusLoadingTitle`),description:o(`runtimeStatusLoadingDescription`),reasonLines:[],actionLabel:null,isBusy:!!e.activeSystemAction};if(e.activeSystemAction)return{tone:`attention`,title:o(`runtimeControlTitle`),description:J(e.activeSystemAction.message)||J(e.runtimeControlView.message)||o(`runtimeControlDescription`),reasonLines:[],actionLabel:null,isBusy:!0};let t=e.runtimeControlView;return t.pendingRestart?{tone:`attention`,title:o(`runtimeStatusPendingRestartTitle`),description:o(`runtimeStatusPendingRestartDescription`),reasonLines:t.pendingRestart.changedPaths.length>0?t.pendingRestart.changedPaths.map(e=>o(`runtimeStatusPendingRestartReasonItem`).replace(`{path}`,e)):[t.pendingRestart.message],actionLabel:t.canRestartService.available?o(`runtimeStatusRestartAction`):null,isBusy:!1}:{tone:t.lifecycle===`healthy`?`healthy`:`inactive`,title:o(`runtimeStatusHealthyTitle`),description:o(`runtimeStatusHealthyDescription`),reasonLines:[],actionLabel:null,isBusy:!1}}function Vn(e){let t=e.activeSystemAction,n=e.runtimeControlView;return{controlView:n,visibleLifecycle:t?.lifecycle??n?.lifecycle??`healthy`,visibleServiceState:t?.serviceState??n?.serviceState??`unknown`,visibleMessage:J(t?.message)||J(e.lastSystemActionError)||J(n?.message)||o(`runtimeControlDescription`),busyAction:t?.action??null,busy:!!t,pendingRestart:n?.pendingRestart??null,errorMessage:J(e.lastSystemActionError)||J(e.runtimeControlError)||null}}var Hn={lifecyclePhase:`cold-starting`,hasReachedReady:!1,lastReadyAt:null,recoveryStartedAt:null,bootstrapStatus:null,lastError:null,lastTransportError:null,runtimeControlView:null,runtimeControlError:null,activeSystemAction:null,lastSystemActionError:null},Un=c(e=>({state:Hn,patchState:t=>e(e=>({state:{...e.state,...t}}))}));function Wn(e){if(e.length===0)throw Error(`AdaptiveCadence requires at least one stage.`);for(let t of e)if(t.delaysMs.length===0)throw Error(`AdaptiveCadence stage requires at least one delay.`)}var Gn=class{constructor(e){this.options=e,this.attempt=0,this.startedAt=null,this.lastFailureAt=null,this.lastSuccessAt=null,this.manualTriggerPending=!1,this.completed=!1,this.recordFailure=()=>{let e=this.clock();this.completed=!1,this.manualTriggerPending=!1,this.startedAt=this.startedAt??e,this.lastFailureAt=e,this.attempt+=1},this.recordSuccess=()=>{this.lastSuccessAt=this.clock(),this.attempt=0,this.startedAt=null,this.lastFailureAt=null,this.manualTriggerPending=!1,this.completed=!0},this.reset=()=>{this.attempt=0,this.startedAt=null,this.lastFailureAt=null,this.lastSuccessAt=null,this.manualTriggerPending=!1,this.completed=!1},this.requestManualTrigger=()=>{this.completed=!1,this.manualTriggerPending=!0},this.hasManualTrigger=()=>this.manualTriggerPending,this.getNextDelay=(e={})=>{if(this.manualTriggerPending)return e.consumeManualTrigger&&(this.manualTriggerPending=!1),this.options.manualTriggerDelayMs;if(this.completed)return this.options.successDelayMs;if(this.startedAt===null)return this.options.idleDelayMs;let t=this.resolveStage(this.clock()-this.startedAt);return t.delaysMs[Math.min(this.attempt-1,t.delaysMs.length-1)]},this.getSnapshot=()=>({attempt:this.attempt,startedAt:this.startedAt,lastFailureAt:this.lastFailureAt,lastSuccessAt:this.lastSuccessAt,manualTriggerPending:this.manualTriggerPending,completed:this.completed}),this.resolveStage=e=>this.options.stages.find(t=>t.untilElapsedMs===void 0||e<t.untilElapsedMs)??this.options.stages[this.options.stages.length-1],Wn(e.stages),this.clock=e.clock??(()=>Date.now())}},Kn=3e4,qn={idleDelayMs:1e3,manualTriggerDelayMs:0,successDelayMs:!1,stages:[{untilElapsedMs:3e4,delaysMs:[500,1e3,2e3,4e3,5e3]},{untilElapsedMs:5*6e4,delaysMs:[1e4,15e3,3e4]},{delaysMs:[6e4]}]};function Jn(e){return e instanceof Error?e.message:String(e??``)}function Yn(e){return e&&(e.ncpAgent.error?.trim()||e.lastError?.trim())||null}function Xn(e){return o(e===`start-service`?`runtimeControlStartingServiceHelp`:e===`restart-service`?`runtimeControlRestartingServiceHelp`:e===`stop-service`?`runtimeControlStoppingServiceHelp`:`runtimeControlRestartingAppHelp`)}var Y=new class{constructor(){this.recoveryTimeoutId=null,this.runtimeBootstrapProbeCadence=new Gn(qn),this.getRuntimeBootstrapPollInterval=e=>{let{lifecyclePhase:t,activeSystemAction:n}=this.getState(),r=t===`recovering`||t===`stalled`||n?.lifecycle===`recovering`;return this.runtimeBootstrapProbeCadence.hasManualTrigger()?this.runtimeBootstrapProbeCadence.getNextDelay({consumeManualTrigger:!0}):!r&&e?.ncpAgent.state===`ready`?!1:this.runtimeBootstrapProbeCadence.getNextDelay({consumeManualTrigger:!0})},this.getRuntimeControl=async()=>this.decorateForCurrentEnvironment(await eo()),this.reportBootstrapStatus=e=>{let t=this.getState(),n=Yn(e);if(e.ncpAgent.state===`ready`){this.transitionToReady(e);return}if(!t.hasReachedReady){if(e.ncpAgent.state===`error`||e.phase===`error`){this.transitionToStartupFailed(n,e);return}this.transitionToColdStarting(e);return}this.transitionToRecovering(n,e)},this.reportBootstrapQueryError=e=>{let t=Jn(e).trim();if(t&&!this.reportTransportFailure(t)){if(this.getState().hasReachedReady){this.transitionToRecovering(t);return}this.transitionToStartupFailed(t)}},this.reportTransportFailure=e=>{let t=Jn(e).trim();return ci(t)?this.getState().hasReachedReady?(this.transitionToRecovering(t),!0):(this.runtimeBootstrapProbeCadence.recordFailure(),this.patchState({lastTransportError:t}),!0):!1},this.handleConnectionInterrupted=e=>{let t=this.getState(),n=e?.trim()||null;if(!t.hasReachedReady){this.runtimeBootstrapProbeCadence.recordFailure(),n&&this.patchState({lastTransportError:n});return}this.transitionToRecovering(n)},this.handleConnectionRestored=()=>{let e=this.getState();e.bootstrapStatus?.ncpAgent.state===`ready`&&this.transitionToReady(e.bootstrapStatus)},this.reportRuntimeControlView=e=>{this.patchState({runtimeControlView:e,runtimeControlError:null})},this.reportRuntimeControlError=e=>{let t=Jn(e).trim();t&&this.patchState({runtimeControlError:t})},this.runRuntimeControlAction=async e=>{this.patchState({activeSystemAction:zn({action:e,message:Xn(e)}),lastSystemActionError:null});try{let t=await this.executeRuntimeControlAction(e);if(e===`restart-app`)return t;if(e===`stop-service`)return await this.refreshRuntimeControlView(),this.clearActiveSystemAction(),t;this.patchState({activeSystemAction:{action:e,lifecycle:`recovering`,serviceState:null,message:o(`runtimeControlRecoveringHelp`)}}),this.runtimeBootstrapProbeCadence.requestManualTrigger();let n=await this.waitForRecovery();return this.syncRuntimeControlQueryCache(n),this.reportRuntimeControlView(n),this.clearActiveSystemAction(),t}catch(t){let n=t instanceof Error?t.message:o(`runtimeControlActionFailed`);throw this.patchState({activeSystemAction:{action:e,lifecycle:`failed`,serviceState:e===`stop-service`?`running`:e===`restart-app`?null:`unknown`,message:n},lastSystemActionError:n}),t}},this.getStatusView=()=>In(this.getState()),this.requestRuntimeBootstrapProbeNow=()=>{this.runtimeBootstrapProbeCadence.requestManualTrigger(),Et.refetchQueries({queryKey:[`runtime-bootstrap-status`]})},this.resetForTests=()=>{this.clearRecoveryTimeout(),this.runtimeBootstrapProbeCadence.reset(),Un.setState({state:Hn})},this.getState=()=>Un.getState().state,this.patchState=e=>{Un.getState().patchState(e)},this.transitionToColdStarting=e=>{this.runtimeBootstrapProbeCadence.recordFailure(),this.clearRecoveryTimeout(),this.patchState({lifecyclePhase:`cold-starting`,recoveryStartedAt:null,bootstrapStatus:e,lastError:null})},this.transitionToStartupFailed=(e,t)=>{this.runtimeBootstrapProbeCadence.recordFailure(),this.clearRecoveryTimeout(),this.patchState({lifecyclePhase:`startup-failed`,recoveryStartedAt:null,bootstrapStatus:t??this.getState().bootstrapStatus,lastError:e})},this.transitionToRecovering=(e,t)=>{this.runtimeBootstrapProbeCadence.recordFailure();let n=this.getState();if(!n.hasReachedReady){this.patchState({lastTransportError:e?.trim()||n.lastTransportError});return}n.lifecyclePhase!==`recovering`&&n.lifecyclePhase!==`stalled`&&(this.clearRecoveryTimeout(),this.recoveryTimeoutId=window.setTimeout(()=>{this.recoveryTimeoutId=null,this.getState().lifecyclePhase===`recovering`&&this.patchState({lifecyclePhase:`stalled`})},Kn)),this.patchState({lifecyclePhase:n.lifecyclePhase===`stalled`?`stalled`:`recovering`,recoveryStartedAt:n.recoveryStartedAt??Date.now(),bootstrapStatus:t??n.bootstrapStatus,lastError:e?.trim()||n.lastError,lastTransportError:e?.trim()||n.lastTransportError})},this.transitionToReady=e=>{this.runtimeBootstrapProbeCadence.recordSuccess();let t=this.getState(),n=t.lifecyclePhase===`recovering`||t.lifecyclePhase===`stalled`;this.clearRecoveryTimeout(),this.patchState({lifecyclePhase:`ready`,hasReachedReady:!0,lastReadyAt:Date.now(),recoveryStartedAt:null,bootstrapStatus:e,lastError:null,lastTransportError:null}),n&&Et.refetchQueries({type:`active`})},this.executeRuntimeControlAction=async e=>{let t=this.getDesktopBridge();if(e===`restart-service`&&t&&typeof t.restartService==`function`){let e=await t.restartService();return{accepted:e.accepted,action:`restart-service`,lifecycle:e.lifecycle,message:e.message}}if(e===`start-service`)return await to();if(e===`stop-service`)return await ro();if(e===`restart-app`){if(!t||typeof t.restartApp!=`function`)throw Error(o(`runtimeRestartAppUnavailable`));let e=await t.restartApp();return{accepted:e.accepted,action:`restart-app`,lifecycle:e.lifecycle,message:e.message}}return await no()},this.waitForRecovery=async()=>{let e=Date.now()+25e3,t=null;for(;Date.now()<e;)try{return await this.getRuntimeControl()}catch(e){t=e,await new Promise(e=>{window.setTimeout(e,1500)})}throw t instanceof Error?t:Error(o(`runtimeRecoveryTimedOut`))},this.refreshRuntimeControlView=async()=>{try{let e=await this.getRuntimeControl();this.syncRuntimeControlQueryCache(e),this.reportRuntimeControlView(e)}catch(e){this.reportRuntimeControlError(e)}},this.syncRuntimeControlQueryCache=e=>{Et.setQueryData([`runtime-control`],e)},this.clearActiveSystemAction=()=>{this.patchState({activeSystemAction:null,lastSystemActionError:null})},this.clearRecoveryTimeout=()=>{this.recoveryTimeoutId!==null&&(window.clearTimeout(this.recoveryTimeoutId),this.recoveryTimeoutId=null)},this.decorateForCurrentEnvironment=e=>{let t=this.getDesktopBridge();return!t||typeof t.restartApp!=`function`?e:{...e,environment:`desktop-embedded`,serviceState:`running`,canStartService:{available:!1,requiresConfirmation:!1,impact:`none`},canStopService:{available:!1,requiresConfirmation:!0,impact:`brief-ui-disconnect`},canRestartApp:{available:!0,requiresConfirmation:!0,impact:`full-app-relaunch`},ownerLabel:o(`runtimeControlEnvironmentDesktop`),managementHint:o(`runtimeControlDesktopServiceHint`)}},this.getDesktopBridge=()=>typeof window>`u`?null:window.nextclawDesktop??null}};function Zn(){let e=Xe({queryKey:[`runtime-bootstrap-status`],queryFn:()=>Di({timeoutMs:5e3}),refetchInterval:e=>Y.getRuntimeBootstrapPollInterval(e.state.data),retry:!1}),t=Xe({queryKey:[`runtime-control`],queryFn:async()=>await Y.getRuntimeControl(),staleTime:5e3});(0,z.useEffect)(()=>{e.data&&Y.reportBootstrapStatus(e.data)},[e.data]),(0,z.useEffect)(()=>{e.error&&Y.reportBootstrapQueryError(e.error)},[e.error]),(0,z.useEffect)(()=>{t.data&&Y.reportRuntimeControlView(t.data)},[t.data]),(0,z.useEffect)(()=>{t.error&&Y.reportRuntimeControlError(t.error)},[t.error])}function Qn(){return In(Un(e=>e.state))}function $n(){return Bn(Un(e=>e.state))}function er(){return Vn(Un(e=>e.state))}var X=c(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),tr=class{constructor(e){this.desktopApi=e,this.kind=`desktop-bridge`,this.subscribe=e=>this.desktopApi.onUpdateStateChanged(e),this.getState=async()=>await this.desktopApi.getUpdateState(),this.checkForUpdates=async()=>await this.desktopApi.checkForUpdates(),this.downloadUpdate=async()=>await this.desktopApi.downloadUpdate(),this.applyDownloadedUpdate=async()=>await this.desktopApi.applyDownloadedUpdate(),this.updateChannel=async e=>await this.desktopApi.updateChannel(e)}},nr=class{constructor(){this.kind=`runtime-host`,this.getState=async()=>await ao(),this.checkForUpdates=async()=>await oo(),this.downloadUpdate=async()=>await so(),this.applyDownloadedUpdate=async()=>await co(),this.updateChannel=async e=>await lo(e)}},rr=new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.source=null,this.start=async()=>{this.subscriptionCount+=1;let e=this.resolveSource();if(this.source=e,!e){X.setState({supported:!1,initialized:!0,snapshot:null});return}e.kind===`desktop-bridge`&&!this.unsubscribe&&(this.unsubscribe=e.subscribe(e=>{X.setState({supported:!0,initialized:!0,snapshot:e})})),X.setState({supported:!0,initialized:!1});try{let t=await e.getState();X.setState({supported:!0,initialized:!0,snapshot:t})}catch(t){if(e.kind===`runtime-host`&&this.isUnsupportedError(t)){X.setState({supported:!1,initialized:!0,snapshot:null});return}X.setState({supported:!0,initialized:!0}),U.error(`${o(`runtimeUpdatesLoadFailed`)}: ${this.getErrorMessage(t)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null,this.source=null)},this.reportSnapshot=e=>{this.source?.kind!==`desktop-bridge`&&X.setState({supported:!0,initialized:!0,snapshot:e})},this.refreshAfterRealtimeReconnect=async()=>{this.source?.kind===`runtime-host`&&await this.refreshSnapshot()},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,o(`runtimeUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){U.success(o(`runtimeUpdatesAlreadyLatest`));return}if(e.status===`update-available`){U.success(o(`runtimeUpdatesAvailable`).replace(`{version}`,e.availableVersion??o(`runtimeUpdatesUnknownVersion`)));return}e.status===`downloaded`&&U.success(o(`runtimeUpdatesReadyToApply`))},this.downloadUpdate=async()=>{try{await this.runSnapshotCommand(`downloading`,o(`runtimeUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,o(`runtimeUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updateNow=async()=>{let e=X.getState().snapshot;if(!(e?.status!==`update-available`&&e?.status!==`downloaded`))try{await this.runSnapshotCommand(`updating`,o(`runtimeUpdatesUpdateFailed`),async t=>{let n=e.status===`downloaded`?e:await t.downloadUpdate();return X.setState({snapshot:n}),n.status===`downloaded`?await t.applyDownloadedUpdate():n})}catch{return}},this.updateChannel=async e=>{if(X.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,o(`runtimeUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){U.success(o(`runtimeUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}U.success(o(`runtimeUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.refreshSnapshot=async()=>{if(!(!this.source||this.source.kind!==`runtime-host`))try{let e=await this.source.getState();X.setState({supported:!0,initialized:!0,snapshot:e})}catch{}},this.runSnapshotCommand=async(e,t,n)=>{let r=this.source??this.resolveSource();if(!r)throw Error(o(`runtimeUpdatesUnavailableDescription`));this.source=r,X.setState({busyAction:e});try{let e=await n(r);return X.setState({snapshot:e}),e}catch(e){throw U.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{X.setState({busyAction:null})}},this.resolveSource=()=>{let e=this.getDesktopApi();return e?new tr(e):new nr},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.isUnsupportedError=e=>{let t=this.getErrorMessage(e).toLowerCase();return t.includes(`404`)||t.includes(`not found`)||t.includes(`endpoint not found`)},this.getErrorMessage=e=>e instanceof Error?e.message:o(`error`),this.getChannelLabel=e=>o(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}},ir=`https://docs.nextclaw.io/`;function ar(e,t){let n=t===`zh-CN`?`en-US`:`zh-CN`;return e?.[t]?.trim()||e?.[n]?.trim()||null}function or(e){let t=e.releaseNotesUrl?.trim(),n=(e.availableVersion??e.downloadedVersion)?.trim();return t?sr(n,t):null}function sr(e,t=ir){let n=e?.trim();if(!n||!/^[0-9A-Za-z.-]+$/.test(n))return null;try{return new URL(`/release-notes/nextclaw-v${n}.json`,t).toString()}catch{return null}}function cr(e,t){return ar(e?.links?.html,t)}function lr(e){let t=e.releaseNotesUrl?.trim(),n=(e.downloadedVersion??e.availableVersion)?.trim();return!t||!n?null:{url:t,versionLabel:`v${n}`}}function ur(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Z(e){return ur(e)?typeof e[`zh-CN`]==`string`||typeof e[`en-US`]==`string`:!1}function dr(e){return!ur(e)||!Z(e.title)?!1:e.body===void 0||Z(e.body)}function fr(e){return ur(e)&&typeof e.kind==`string`&&Array.isArray(e.items)&&e.items.every(dr)&&(e.title===void 0||Z(e.title))}function pr(e){return ur(e)&&(e.html===void 0||Z(e.html))}function mr(e){return ur(e)&&Array.isArray(e.sections)&&e.sections.every(fr)&&(e.title===void 0||Z(e.title))&&(e.summary===void 0||Z(e.summary))&&(e.links===void 0||pr(e.links))}async function hr(e){let t=await fetch(e,{cache:`no-store`,headers:{accept:`application/json`}});if(!t.ok)throw Error(`Release notes request failed with HTTP ${t.status}.`);let n=await t.json();if(!mr(n))throw Error(`Release notes payload has an unsupported shape.`);return n}function gr(){return s()===`zh`?`zh-CN`:`en-US`}function _r(e){let t=sr(e),n=gr(),r=cr(Xe({queryKey:[`current-release-notes`,t],queryFn:async()=>await hr(t??``),enabled:!!t,retry:!1,staleTime:300*1e3}).data,n),i=e?.trim();return r&&i?{url:r,versionLabel:`v${i}`}:null}var vr=z.forwardRef(({className:e,checked:t=!1,onCheckedChange:n,thumbClassName:r,...a},o)=>(0,B.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,ref:o,className:i(`switch-track peer inline-flex h-[22px] w-10 shrink-0 cursor-pointer items-center rounded-full border-2 transition-colors duration-fast focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:cursor-not-allowed disabled:opacity-50`,t?`border-primary/70 bg-primary`:`border-border/60 bg-muted hover:bg-[var(--interaction-hover)]`,e),onClick:()=>n?.(!t),...a,children:(0,B.jsx)(`span`,{"data-state":t?`checked`:`unchecked`,className:i(`switch-thumb pointer-events-none block h-5 w-5 rounded-full bg-card shadow-md ring-1 ring-border/50 transition-transform duration-fast`,t?`translate-x-5`:`translate-x-0`,r)})}));vr.displayName=`Switch`;var yr={maxRetries:8,startupTimeoutMs:2e3,settledTimeoutMs:5e3,retryBaseDelayMs:500,retryMaxDelayMs:3e3};function br(e){return e instanceof Error?ci(e.message):!1}function xr(e,t){return e>=yr.maxRetries?!1:br(t)}function Sr(e){return Math.min(yr.retryMaxDelayMs,yr.retryBaseDelayMs*2**Math.max(0,e-1))}function Cr(){let[e,t]=(0,z.useState)(!1),n=Xe({queryKey:[`auth-status`],queryFn:()=>bi({timeoutMs:e?yr.settledTimeoutMs:yr.startupTimeoutMs}),staleTime:5e3,retry:xr,retryDelay:Sr});return(0,z.useEffect)(()=>{n.isSuccess&&!e&&t(!0)},[e,n.isSuccess]),n}function wr(e){return Promise.all([e.invalidateQueries({queryKey:[`auth-status`]}),e.invalidateQueries({queryKey:[`app-meta`]}),e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),e.invalidateQueries({queryKey:[`config-schema`]}),e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`session-history`]}),e.invalidateQueries({queryKey:[`chat-runs`]}),e.invalidateQueries({queryKey:[`cron-jobs`]})])}function Tr(){let e=V();return Ze({mutationFn:xi,onSuccess:async()=>{await wr(e),U.success(o(`authSetupSuccess`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}function Er(){let e=V();return Ze({mutationFn:Si,onSuccess:async()=>{await wr(e),U.success(o(`authLoginSuccess`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}function Dr(){let e=V();return Ze({mutationFn:Ci,onSuccess:async()=>{await wr(e),U.success(o(`authLogoutSuccess`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}function Or(){let e=V();return Ze({mutationFn:wi,onSuccess:async()=>{await wr(e),U.success(o(`authPasswordUpdated`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}function kr(){let e=V();return Ze({mutationFn:Ti,onSuccess:async(t,n)=>{await wr(e),U.success(n.enabled?o(`authEnabledSuccess`):o(`authDisabledSuccess`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}var Ar=8;function jr(e){return e.trim().length>=Ar}function Mr(e,t){return e===t?!0:(U.error(o(`authPasswordMismatch`)),!1)}function Nr({children:e,contentClassName:t=`space-y-6`}){return(0,B.jsx)(Lt,{children:(0,B.jsx)(`div`,{className:`${t} p-4`,children:e})})}function Pr({canSubmitSetup:e,isPending:t,onSubmit:n,setSetupConfirmPassword:r,setSetupPassword:i,setSetupUsername:a,setupConfirmPassword:s,setupPassword:c,setupUsername:l}){return(0,B.jsxs)(Nr,{contentClassName:`space-y-5`,children:[(0,B.jsxs)(`div`,{className:`rounded-xl bg-background/65 p-4`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o(`authSetupTitle`)}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:o(`authSetupDescription`)})]}),(0,B.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-setup-username`,children:o(`authUsername`)}),(0,B.jsx)(G,{id:`auth-setup-username`,value:l,onChange:e=>a(e.target.value),placeholder:o(`authUsernamePlaceholder`)})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-setup-password`,children:o(`authPassword`)}),(0,B.jsx)(G,{id:`auth-setup-password`,type:`password`,value:c,onChange:e=>i(e.target.value),placeholder:o(`authPasswordPlaceholder`)})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-setup-confirm`,children:o(`authConfirmPassword`)}),(0,B.jsx)(G,{id:`auth-setup-confirm`,type:`password`,value:s,onChange:e=>r(e.target.value),placeholder:o(`authConfirmPasswordPlaceholder`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`authPasswordMinLengthHint`)})]}),(0,B.jsx)(jt,{type:`button`,disabled:!e,onClick:()=>void n(),children:o(t?`authSettingUp`:`authSetupAction`)})]})}function Fr({authenticated:e,canUpdatePassword:t,enabled:n,isLoggingOut:r,isUpdatingEnabled:i,isUpdatingPassword:a,nextConfirmPassword:s,nextPassword:c,onEnabledChange:l,onLogout:u,onPasswordUpdate:d,setNextConfirmPassword:f,setNextPassword:p,username:m}){return(0,B.jsxs)(Nr,{children:[(0,B.jsxs)(`div`,{className:`rounded-xl bg-background/65 p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-start md:justify-between`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o(`authStatusLabel`)}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`authStatusConfiguredUser`).replace(`{username}`,m??``)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`authUsernameFixedHelp`)})]}),(0,B.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-muted px-3 py-1 text-xs font-medium text-foreground`,children:o(n?`enabled`:`disabled`)})]}),(0,B.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4 border-t border-border/55 pt-4 md:flex-row md:items-center md:justify-between`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o(`authEnableLabel`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(n?`authEnableOnHelp`:`authEnableOffHelp`)})]}),(0,B.jsx)(vr,{checked:n,disabled:i,onCheckedChange:e=>{l(e)}})]})]}),(0,B.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-background/65 p-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o(`authPasswordSectionTitle`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`authPasswordSectionDescription`)})]}),(0,B.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-password-next`,children:o(`authPassword`)}),(0,B.jsx)(G,{id:`auth-password-next`,type:`password`,value:c,onChange:e=>p(e.target.value),placeholder:o(`authPasswordPlaceholder`)})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-password-confirm`,children:o(`authConfirmPassword`)}),(0,B.jsx)(G,{id:`auth-password-confirm`,type:`password`,value:s,onChange:e=>f(e.target.value),placeholder:o(`authConfirmPasswordPlaceholder`)})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(jt,{type:`button`,disabled:!t,onClick:()=>void d(),children:o(a?`authPasswordUpdating`:`authPasswordAction`)}),n&&e?(0,B.jsx)(jt,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void u(),children:o(r?`authLoggingOut`:`authLogoutAction`)}):null]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`authSessionMemoryNotice`)})]})]})}function Ir(){let e=Cr(),t=Tr(),n=kr(),r=Or(),i=Dr(),[a,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(``),[m,h]=(0,z.useState)(``),g=e.data,_=a.trim().length>0&&jr(c)&&c===u&&!t.isPending,v=jr(f)&&f===m&&!r.isPending;return e.isLoading&&!g?(0,B.jsx)(Nr,{contentClassName:`text-sm text-gray-500`,children:o(`loading`)}):e.isError||!g?(0,B.jsxs)(Nr,{contentClassName:`space-y-4`,children:[(0,B.jsx)(`p`,{className:`text-sm text-gray-500`,children:o(`authStatusLoadFailed`)}),(0,B.jsx)(jt,{variant:`outline`,onClick:()=>void e.refetch(),children:o(`authRetryStatus`)})]}):g.configured?(0,B.jsx)(Fr,{authenticated:g.authenticated,enabled:g.enabled,username:g.username,nextPassword:f,setNextPassword:p,nextConfirmPassword:m,setNextConfirmPassword:h,canUpdatePassword:v,isUpdatingEnabled:n.isPending,isUpdatingPassword:r.isPending,isLoggingOut:i.isPending,onEnabledChange:async e=>{try{await n.mutateAsync({enabled:e})}catch{}},onPasswordUpdate:async()=>{if(Mr(f,m))try{await r.mutateAsync({password:f}),p(``),h(``)}catch{}},onLogout:async()=>{try{await i.mutateAsync()}catch{}}}):(0,B.jsx)(Pr,{setupUsername:a,setSetupUsername:s,setupPassword:c,setSetupPassword:l,setupConfirmPassword:u,setSetupConfirmPassword:d,canSubmitSetup:_,isPending:t.isPending,onSubmit:async()=>{if(Mr(c,u))try{await t.mutateAsync({username:a.trim(),password:c}),l(``),d(``)}catch{}}})}function Lr(){return(0,B.jsx)(Pt,{title:o(`authSecurityTitle`),description:o(`authSecurityDescription`),children:(0,B.jsx)(Ir,{})})}function Rr(e){return e.replace(/\s+/g,` `).trim().slice(0,200)}function zr(e,t){if(t===404&&e.startsWith(`/api/providers/`)&&e.endsWith(`/test`))return`Provider test endpoint is missing. This usually means nextclaw runtime version is outdated.`;if(t===401||t===403)return`Authentication failed. Check apiKey and custom headers.`;if(t===429)return`Rate limited by upstream provider. Retry later or switch model/provider.`;if(t>=500)return`Upstream service error. Retry later and inspect server logs if it persists.`}function Br(e){if(e instanceof Error){let t=e.name?.trim()||`Error`,n=e.message?.trim()||`Unknown error`;return{summary:`${t}: ${n}`,details:{errorName:t,errorMessage:n,...e.stack?.trim()?{errorStack:e.stack.trim()}:{}}}}return{summary:String(e??`Unknown error`),details:{errorName:`NonError`,errorMessage:String(e??`Unknown error`)}}}async function Vr(e,t,n={}){let r=`${e}${t}`,i=(n.method||`GET`).toUpperCase(),a;try{let e=new Headers(n.headers);!(n.body instanceof FormData)&&!e.has(`Content-Type`)&&e.set(`Content-Type`,`application/json`),a=await fetch(r,{credentials:`include`,headers:e,...n})}catch(e){let n=Br(e);return Y.reportTransportFailure(n.summary),{ok:!1,error:{code:`NETWORK_ERROR`,message:`Fetch failed on ${i} ${t} | ${n.summary}`,details:{method:i,endpoint:t,url:r,...n.details}}}}let o=await a.text(),s=null;if(o)try{s=JSON.parse(o)}catch{}if(!s){let e=o?Rr(o):``,n=zr(t,a.status),s=[`Non-JSON response (${a.status} ${a.statusText}) on ${i} ${t}`];return e&&s.push(`body=${e}`),n&&s.push(`hint=${n}`),{ok:!1,error:{code:`INVALID_RESPONSE`,message:s.join(` | `),details:{status:a.status,statusText:a.statusText,method:i,endpoint:t,url:r,bodySnippet:e||void 0,hint:n}}}}return a.ok,s}function Hr(e){let t=e.split(`
7
+ `),r=n.pop()??``;for(let e of n){let n=Wt(e);if(n?.event!==`ncp-event`)continue;let r=Gt(n.data);r&&t(r)}return r}},qt=class{constructor(e,t){this.requestService=e,this.baseUrl=t}list=async()=>(await this.requestService.get(`/api/agents`)).agents;create=async e=>await this.requestService.post(`/api/agents`,e);update=async(e,t)=>await this.requestService.put(`/api/agents/${encodeURIComponent(e)}`,t);delete=async e=>await this.requestService.delete(`/api/agents/${encodeURIComponent(e)}`);resolveAvatarUrl=e=>Bt(this.baseUrl,`/api/agents/${encodeURIComponent(e)}/avatar`)},Jt=class{constructor(e){this.requestService=e}fetchMeta=async()=>await this.requestService.get(`/api/app/meta`);fetchBootstrapStatus=async(e={})=>await this.requestService.get(`/api/runtime/bootstrap-status`,e)},Yt=class{constructor(e){this.requestService=e}list=async(e={})=>await this.requestService.get(e.includeStorageUsage===!1?`/api/app-packages?includeStorageUsage=false`:`/api/app-packages`);get=async e=>await this.requestService.get(`/api/app-packages/${encodeURIComponent(e)}`);listOperations=async()=>await this.requestService.get(`/api/app-package-operations`);startInstall=async e=>await this.requestService.post(`/api/app-package-operations/install`,e);startUpdate=async(e,t={})=>await this.requestService.post(`/api/app-package-operations/${encodeURIComponent(e)}/update`,t);startRollback=async(e,t)=>await this.requestService.post(`/api/app-package-operations/${encodeURIComponent(e)}/rollback`,{version:t});startUninstall=async(e,t=!1)=>await this.requestService.post(`/api/app-package-operations/${encodeURIComponent(e)}/uninstall`,{purgeData:t});install=async e=>await this.requestService.post(`/api/app-packages/install`,e);enable=async e=>await this.requestService.post(`/api/app-packages/${encodeURIComponent(e)}/enable`);disable=async e=>await this.requestService.post(`/api/app-packages/${encodeURIComponent(e)}/disable`);update=async(e,t={})=>await this.requestService.post(`/api/app-packages/${encodeURIComponent(e)}/update`,t);rollback=async(e,t)=>await this.requestService.post(`/api/app-packages/${encodeURIComponent(e)}/rollback`,{version:t});uninstall=async(e,t=!1)=>await this.requestService.request(`/api/app-packages/${encodeURIComponent(e)}`,{method:`DELETE`,body:{purgeData:t}})},Xt=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/app-data`);deleteRetained=async(e,t)=>await this.requestService.request(`/api/app-data/${encodeURIComponent(e)}`,{method:`DELETE`,body:{confirmAppId:t}})},Zt=class{constructor(e){this.requestService=e}fetchStatus=async(e={})=>await this.requestService.get(`/api/auth/status`,{...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}});setup=async e=>await this.requestService.post(`/api/auth/setup`,e);login=async e=>await this.requestService.post(`/api/auth/login`,e);logout=async()=>await this.requestService.post(`/api/auth/logout`,{});updatePassword=async e=>await this.requestService.put(`/api/auth/password`,e);updateEnabled=async e=>await this.requestService.put(`/api/auth/enabled`,e)},Qt=class{constructor(e){this.requestService=e}start=async(e,t={})=>await this.requestService.post(`/api/config/channels/${encodeURIComponent(e)}/auth/start`,t);poll=async(e,t)=>await this.requestService.post(`/api/config/channels/${encodeURIComponent(e)}/auth/poll`,t);connect=async(e,t)=>await this.requestService.post(`/api/config/channels/${encodeURIComponent(e)}/auth/connect`,t)},$t=class{constructor(e){this.requestService=e}listDesktopGrants=async()=>await this.requestService.get(`/api/capability-grants?resourceType=desktop.application`);grantDesktopAccess=async e=>await this.requestService.post(`/api/capability-grants`,e);revokeDesktopAccess=async e=>await this.requestService.request(`/api/capability-grants`,{method:`DELETE`,body:{subject:e.subject,resourceType:e.resource.type,target:e.resource.target,access:e.access}});getDesktopStatus=async()=>await this.requestService.get(`/api/desktop-host/status`);requestDesktopPermissions=async()=>await this.requestService.post(`/api/desktop-host/permissions/request`,{});openDesktopPermissionSettings=async()=>await this.requestService.post(`/api/desktop-host/permissions/open-settings`,{})},en=class{constructor(e){this.requestService=e}get=async()=>await this.requestService.get(`/api/feature-controls`)},tn=class{constructor(e){this.requestService=e}fetch=async()=>await this.requestService.get(`/api/config`);fetchMeta=async()=>await this.requestService.get(`/api/config/meta`);fetchSchema=async()=>await this.requestService.get(`/api/config/schema`);updateModel=async e=>await this.requestService.put(`/api/config/model`,e);updateSearch=async e=>await this.requestService.put(`/api/config/search`,e);updateChannel=async(e,t)=>await this.requestService.put(`/api/config/channels/${encodeURIComponent(e)}`,t);updateRuntime=async e=>await this.requestService.put(`/api/config/runtime`,e);updateSecrets=async e=>await this.requestService.put(`/api/config/secrets`,e);updateProductAnalytics=async e=>await this.requestService.put(`/api/config/product-analytics`,e);fetchProductAnalyticsStatus=async()=>await this.requestService.get(`/api/config/product-analytics/status`);executeAction=async(e,t={})=>await this.requestService.post(`/api/config/actions/${encodeURIComponent(e)}/execute`,t);fetchChatSessionTypes=async()=>await this.requestService.get(`/api/ncp/session-types`);fetchCronJobs=async(e={})=>await this.requestService.get(`/api/cron`,{query:{all:e.all?`1`:void 0,limit:e.limit,offset:e.offset,query:e.query,status:e.status}});deleteCronJob=async e=>await this.requestService.delete(`/api/cron/${encodeURIComponent(e)}`);setCronJobEnabled=async(e,t)=>await this.requestService.put(`/api/cron/${encodeURIComponent(e)}/enable`,t);runCronJob=async(e,t={})=>await this.requestService.post(`/api/cron/${encodeURIComponent(e)}/run`,t)},nn=class{constructor(e){this.requestService=e}fetchItems=async e=>await this.requestService.get(`${rn(e.type)}/items`,{query:an(e)});fetchItem=async(e,t)=>await this.requestService.get(`${rn(t)}/items/${encodeURIComponent(e)}`);fetchSkillContent=async e=>await this.requestService.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);fetchRecommendations=async(e,t={})=>await this.requestService.get(`${rn(e)}/recommendations`,{query:{...t.scene?.trim()?{scene:t.scene.trim()}:{},...typeof t.limit==`number`&&Number.isFinite(t.limit)?{limit:Math.max(1,Math.trunc(t.limit))}:{}}});fetchSkillScenes=async()=>await this.requestService.get(`/api/marketplace/skills/scenes`);install=async e=>await this.requestService.post(`${rn(on(e.type))}/install`,e);fetchInstalled=async e=>await this.requestService.get(`${rn(e)}/installed`);manage=async e=>await this.requestService.post(`${rn(on(e.type))}/manage`,e)};function rn(e){return e===`skill`?`/api/marketplace/skills`:`/api/marketplace/mcp`}function an(e){let{page:t,pageSize:n,q:r,scene:i,sort:a,tag:o}=e,s={};return r?.trim()&&(s.q=r.trim()),o?.trim()&&(s.tag=o.trim()),i?.trim()&&(s.scene=i.trim()),a&&(s.sort=a),typeof t==`number`&&Number.isFinite(t)&&(s.page=Math.max(1,Math.trunc(t))),typeof n==`number`&&Number.isFinite(n)&&(s.pageSize=Math.max(1,Math.trunc(n))),Object.keys(s).length>0?s:void 0}function on(e){if(!e)throw Error(`Marketplace request type is required.`);return e}var sn=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/inbox/deliveries`);get=async e=>await this.requestService.get(this.deliveryPath(e));updateState=async(e,t)=>await this.requestService.request(this.deliveryPath(e),{method:`PATCH`,body:{action:t}});delete=async e=>(await this.requestService.delete(this.deliveryPath(e))).deleted;deliveryPath=e=>`/api/inbox/deliveries/${encodeURIComponent(e)}`},cn=class{constructor(e){this.requestService=e}fetchItems=async(e={})=>await this.requestService.get(`/api/marketplace/mcp/items`,{query:ln(e)});fetchInstalled=async()=>await this.requestService.get(`/api/marketplace/mcp/installed`);fetchItem=async e=>await this.requestService.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}`);fetchContent=async e=>await this.requestService.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);fetchRecommendations=async(e={})=>await this.requestService.get(`/api/marketplace/mcp/recommendations`,{query:{...e.scene?.trim()?{scene:e.scene.trim()}:{},...typeof e.limit==`number`&&Number.isFinite(e.limit)?{limit:Math.max(1,Math.trunc(e.limit))}:{}}});install=async e=>await this.requestService.post(`/api/marketplace/mcp/install`,e);manage=async e=>await this.requestService.post(`/api/marketplace/mcp/manage`,e);doctor=async e=>await this.requestService.post(`/api/marketplace/mcp/doctor`,{name:e})};function ln(e){let{page:t,pageSize:n,q:r,sort:i,tag:a}=e,o={};return r?.trim()&&(o.q=r.trim()),a?.trim()&&(o.tag=a.trim()),i&&(o.sort=i),typeof t==`number`&&Number.isFinite(t)&&(o.page=Math.max(1,Math.trunc(t))),typeof n==`number`&&Number.isFinite(n)&&(o.pageSize=Math.max(1,Math.trunc(n))),Object.keys(o).length>0?o:void 0}var un=class{constructor(e){this.requestService=e}testConnection=async e=>await this.requestService.post(`/api/mcp/servers/test`,e);createConnection=async e=>await this.requestService.post(`/api/mcp/servers`,e)},dn=`x-nextclaw-panel-bridge-session`;function fn(e){return e?{[dn]:e}:void 0}var pn=class{constructor(e){this.requestService=e}listPanelApps=async()=>await this.requestService.get(`/api/panel-apps`);updatePanelAppPreferences=async(e,t)=>await this.requestService.request(`/api/panel-apps/${encodeURIComponent(e)}/preferences`,{method:`PATCH`,body:t});recordPanelAppOpened=async e=>await this.requestService.post(`/api/panel-apps/${encodeURIComponent(e)}/open`);deletePanelApp=async e=>await this.requestService.delete(`/api/panel-apps/${encodeURIComponent(e)}`);createBridgeSession=async e=>await this.requestService.post(`/api/panel-app-bridge-sessions`,e);deleteBridgeSession=async e=>await this.requestService.delete(`/api/panel-app-bridge-sessions/${encodeURIComponent(e)}`);grantClient=async e=>await this.requestService.post(`/api/panel-app-client-grants/${encodeURIComponent(e)}`,{});revokeClient=async e=>await this.requestService.delete(`/api/panel-app-client-grants/${encodeURIComponent(e)}`);sendAgentMessage=async(e,t={})=>await this.requestService.post(`/api/panel-app-agent/send`,e,{headers:fn(t.bridgeSessionToken)});generateAgentObject=async(e,t={})=>await this.requestService.post(`/api/panel-app-agent/generate-object`,e,{headers:fn(t.bridgeSessionToken)});grantAgentCapability=async(e,t={})=>await this.requestService.post(`/api/panel-app-agent-capabilities/${encodeURIComponent(e)}/grant`,{},{headers:fn(t.bridgeSessionToken)})},mn=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/providers`);listTemplates=async()=>await this.requestService.get(`/api/provider-templates`);listModelCatalog=async()=>await this.requestService.get(`/api/provider-model-catalog`);update=async(e,t)=>await this.requestService.put(`/api/providers/${encodeURIComponent(e)}`,t);create=async(e={})=>await this.requestService.post(`/api/providers`,e);delete=async e=>await this.requestService.delete(`/api/providers/${encodeURIComponent(e)}`);testConnection=async(e,t)=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/test`,t);discoverModels=async(e,t)=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/models/discover`,t);startAuth=async(e,t={})=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/auth/start`,t);pollAuth=async(e,t)=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/auth/poll`,t);importAuthFromCli=async e=>await this.requestService.post(`/api/providers/${encodeURIComponent(e)}/auth/import-cli`,{})},hn=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/projects`);create=async e=>await this.requestService.post(`/api/projects`,e);addExisting=async e=>await this.requestService.post(`/api/projects/existing`,e)},gn=class{baseUrl;transport;webSocketFactory;constructor(e){this.options=e,this.baseUrl=e.baseUrl,this.transport=e.transport,this.webSocketFactory=e.webSocketFactory}subscribe=(e,t={})=>{if(this.transport?.subscribe){let t=this.transport.subscribe(e);return{close:()=>{t()}}}let n=null,r=null,i=!1,a=Math.max(200,t.reconnectDelayMs??1e3),o=()=>{r!==null&&(clearTimeout(r),r=null)},s=t=>{e(t)},c=()=>{try{n=this.createSocket(Ht(this.baseUrl,`/ws`))}catch(e){t.onError?.(e),i||(r=setTimeout(c,a));return}n.onopen=()=>{s({type:`connection.open`})},n.onmessage=e=>{let t=this.parseEvent(e.data);t&&s(t)},n.onerror=e=>{t.onError?.(e),s({type:`connection.error`,payload:{message:`WebSocket error`}})},n.onclose=()=>{s({type:`connection.close`}),n=null,i||(o(),r=setTimeout(c,a))}};return c(),{close:()=>{i=!0,o(),n?.close(),n=null}}};createSocket=e=>{if(this.webSocketFactory)return this.webSocketFactory(e);if(typeof globalThis.WebSocket!=`function`)throw Error(`WebSocket is unavailable. Provide webSocketFactory when creating the client.`);return new globalThis.WebSocket(e)};parseEvent=e=>{if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return t&&typeof t==`object`&&`type`in t?t:null}catch{return null}}},_n=class{constructor(e){this.requestService=e}fetchStatus=async()=>await this.requestService.get(`/api/remote/status`);fetchDoctor=async()=>await this.requestService.get(`/api/remote/doctor`);login=async e=>await this.requestService.post(`/api/remote/login`,e);startBrowserAuth=async(e={})=>await this.requestService.post(`/api/remote/auth/start`,e);pollBrowserAuth=async e=>await this.requestService.post(`/api/remote/auth/poll`,e);logout=async()=>await this.requestService.post(`/api/remote/logout`,{});updateAccountProfile=async e=>await this.requestService.put(`/api/remote/account/profile`,e);updateSettings=async e=>await this.requestService.put(`/api/remote/settings`,e);controlService=async e=>await this.requestService.post(`/api/remote/service/${e}`,{})},q=class extends Error{status;code;details;constructor(e){let{code:t,details:n,message:r,status:i}=e;super(r),this.name=`NextClawClientError`,this.status=i,this.code=t,this.details=n}};function vn(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function yn(e,t){return vn(e)?e[t]:void 0}var bn=class{baseUrl;fetchImpl;requestTimeoutMs;defaultHeaders;transport;constructor(e){this.options=e;let{baseUrl:t,fetchImpl:n,headers:r,requestTimeoutMs:i,token:a}=e;this.baseUrl=t,this.fetchImpl=Ut(n),this.requestTimeoutMs=Math.max(1e3,i??15e3),this.transport=e.transport,this.defaultHeaders={Accept:`application/json`,...r??{},...a?{Authorization:`Bearer ${a}`}:{}}}request=async(e,t={})=>{let{body:n,headers:r,method:i,query:a,signal:o,timeoutMs:s}=t;if(this.transport)return await this.requestWithTransport(e,t);let c=new AbortController,l=Math.max(1e3,s??this.requestTimeoutMs),u=this.bindAbortSignal(c,o),d=setTimeout(()=>c.abort(),l),f={...this.defaultHeaders,...r??{}},p=this.normalizeRequestBody(n,f);try{let t=await this.fetchImpl(Bt(this.baseUrl,Vt(e,this.serializeQuery(a))),{method:i??`GET`,headers:f,body:p,signal:c.signal}),n=await t.json();if(!t.ok){let e=this.extractApiError(n);throw new q({message:e.message,status:t.status,code:e.code,details:e.details})}if(!this.isApiResponse(n))throw new q({message:`Unexpected NextClaw API response shape.`,status:t.status});if(!n.ok)throw new q({message:n.error.message,status:t.status,code:n.error.code,details:n.error.details});return n.data}catch(e){throw e instanceof q?e:e instanceof Error&&e.name===`AbortError`?new q({message:`NextClaw API request timed out after ${l}ms.`}):new q({message:e instanceof Error?e.message:`NextClaw API request failed.`})}finally{o?.removeEventListener(`abort`,u),clearTimeout(d)}};bindAbortSignal=(e,t)=>{let n=()=>e.abort(t?.reason);return t?t.aborted?(e.abort(t.reason),n):(t.addEventListener(`abort`,n,{once:!0}),n):n};requestWithTransport=async(e,t)=>{let{body:n,headers:r,method:i,query:a,signal:o,timeoutMs:s}=t,{transport:c}=this;if(!c)throw new q({message:`NextClaw transport is not configured.`});try{return await c.request({method:i??`GET`,path:e,...n===void 0?{}:{body:n},...a?{query:a}:{},...r?{headers:r}:{},...o?{signal:o}:{},...s===void 0?{}:{timeoutMs:s}})}catch(e){if(e instanceof q)throw e;let t=yn(e,`code`),n=yn(e,`details`),r=yn(e,`status`);throw new q({message:e instanceof Error?e.message:`NextClaw API request failed.`,code:typeof t==`string`?t:void 0,details:vn(n)?n:void 0,status:typeof r==`number`?r:void 0})}};get=async(e,t={})=>await this.request(e,{...t,method:`GET`});post=async(e,t,n={})=>await this.request(e,{...n,method:`POST`,...t===void 0?{}:{body:t}});put=async(e,t,n={})=>await this.request(e,{...n,method:`PUT`,...t===void 0?{}:{body:t}});delete=async(e,t={})=>await this.request(e,{...t,method:`DELETE`});upload=async(e,t,n={})=>{let{headers:r,signal:i,timeoutMs:a}=n;if(this.transport?.upload)return await this.transport.upload({path:e,formData:t,...r?{headers:r}:{},...i?{signal:i}:{},...a===void 0?{}:{timeoutMs:a}});let o=new AbortController,s=Math.max(1e3,a??this.requestTimeoutMs),c=()=>o.abort(i?.reason);i&&(i.aborted?o.abort(i.reason):i.addEventListener(`abort`,c,{once:!0}));let l=setTimeout(()=>o.abort(),s);try{let n=await this.fetchImpl(Bt(this.baseUrl,e),{method:`POST`,headers:{Accept:`application/json`,...xn(this.options.token)??{},...this.options.headers??{},...r??{}},body:t,signal:o.signal}),i=await n.json();if(!n.ok){let e=this.extractApiError(i);throw new q({message:e.message,status:n.status,code:e.code,details:e.details})}if(!this.isApiResponse(i)||!i.ok)throw new q({message:`Unexpected NextClaw upload response shape.`,status:n.status});return i.data}catch(e){throw e instanceof q?e:e instanceof Error&&e.name===`AbortError`?new q({message:`NextClaw API upload timed out after ${s}ms.`}):new q({message:e instanceof Error?e.message:`NextClaw API upload failed.`})}finally{i?.removeEventListener(`abort`,c),clearTimeout(l)}};isApiResponse=e=>typeof e==`object`&&!!e&&`ok`in e;extractApiError=e=>{if(this.isApiResponse(e)&&!e.ok)return e.error;if(typeof e==`object`&&e&&`message`in e){let t=e;return{code:typeof t.code==`string`?t.code:`HTTP_ERROR`,message:typeof t.message==`string`?t.message:`NextClaw API request failed.`,details:t.details!==null&&typeof t.details==`object`?t.details:void 0}}return{code:`HTTP_ERROR`,message:`NextClaw API request failed.`}};normalizeRequestBody=(e,t)=>{if(e!==void 0)return e instanceof FormData||e instanceof URLSearchParams||e instanceof Blob||e instanceof ArrayBuffer?e:typeof e==`string`?(!(`Content-Type`in t)&&!(`content-type`in t)&&(t[`Content-Type`]=`application/json`),e):(!(`Content-Type`in t)&&!(`content-type`in t)&&(t[`Content-Type`]=`application/json`),JSON.stringify(e))};serializeQuery=e=>{if(!e)return;if(e instanceof URLSearchParams)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r:[r];for(let r of e)r!=null&&t.append(n,String(r))}return t}};function xn(e){return e?{Authorization:`Bearer ${e}`}:null}var Sn=class{constructor(e){this.requestService=e}fetch=async()=>await this.requestService.get(`/api/runtime/control`);startService=async()=>await this.requestService.post(`/api/runtime/control/start-service`,{});restartService=async()=>await this.requestService.post(`/api/runtime/control/restart-service`,{});stopService=async()=>await this.requestService.post(`/api/runtime/control/stop-service`,{})},Cn=class{constructor(e){this.requestService=e}fetch=async()=>await this.requestService.get(`/api/runtime/update`);check=async()=>await this.requestService.post(`/api/runtime/update/check`,{});download=async()=>await this.requestService.post(`/api/runtime/update/download`,{});apply=async()=>await this.requestService.post(`/api/runtime/update/apply`,{});updateChannel=async e=>await this.requestService.put(`/api/runtime/update/channel`,{channel:e})},wn=class{constructor(e){this.requestService=e}browse=async e=>{let{basePath:t,includeFiles:n,path:r}=e??{},i=typeof r==`string`?r.trim():``,a=typeof t==`string`?t.trim():``;return await this.requestService.get(`/api/server-paths/browse`,{query:{...i?{path:i}:{},...a?{basePath:a}:{},...n?{includeFiles:`1`}:{}}})};watch=async e=>await this.requestService.post(`/api/server-paths/watch`,e);unwatch=async e=>{await this.requestService.delete(`/api/server-paths/watch`,{query:{subscriptionId:e.trim()}})};createDirectory=async e=>await this.requestService.post(`/api/server-paths/directory`,e);createFile=async e=>await this.requestService.post(`/api/server-paths/file`,e);renameEntry=async e=>await this.requestService.request(`/api/server-paths/entry`,{method:`PATCH`,body:e});deleteEntry=async e=>await this.requestService.delete(`/api/server-paths/entry`,{query:{basePath:e.basePath.trim(),path:e.path.trim()}});uploadFiles=async e=>{let{basePath:t,files:n,overwrite:r,targetPath:i}=e,a=new FormData;return a.append(`basePath`,t.trim()),a.append(`targetPath`,i.trim()),a.append(`overwrite`,r?`true`:`false`),n.forEach(e=>a.append(`files`,e)),await this.requestService.upload(`/api/server-paths/files`,a,{timeoutMs:12e4})};read=async e=>{let{basePath:t,line:n,path:r}=e,i=r.trim(),a=typeof t==`string`?t.trim():``,o=Number.isSafeInteger(n)&&(n??0)>0?n:null;return await this.requestService.get(`/api/server-paths/read`,{query:{path:i,...a?{basePath:a}:{},...o?{line:String(o)}:{}}})};search=async e=>{let{basePath:t,limit:n,query:r}=e,i=t.trim(),a=r?.trim()??``,o=Number.isSafeInteger(n)&&(n??0)>0?n:null;return await this.requestService.get(`/api/server-paths/search`,{query:{basePath:i,...a?{query:a}:{},...o?{limit:String(o)}:{}}})}},Tn=`x-nextclaw-panel-bridge-session`;function J(e){return e?{[Tn]:e}:void 0}var En=class{constructor(e){this.requestService=e}listServiceApps=async()=>await this.requestService.get(`/api/service-apps`);getServiceApp=async e=>await this.requestService.get(`/api/service-apps/${encodeURIComponent(e)}`);restartServiceApp=async e=>await this.requestService.post(`/api/service-apps/${encodeURIComponent(e)}/restart`);deleteServiceApp=async(e,t=!1)=>await this.requestService.request(`/api/service-apps/${encodeURIComponent(e)}`,{method:`DELETE`,body:{purgeData:t}});listServiceActions=async(e={})=>{let t=e.appId?`?${new URLSearchParams({appId:e.appId}).toString()}`:``;return await this.requestService.get(`/api/service-actions${t}`,{headers:J(e.bridgeSessionToken)})};listVerificationRecords=async(e={})=>{let t=new URLSearchParams;e.acceptanceId&&t.set(`acceptanceId`,e.acceptanceId),e.appId&&t.set(`appId`,e.appId),e.limit!==void 0&&t.set(`limit`,String(e.limit));let n=t.size>0?`?${t.toString()}`:``;return await this.requestService.get(`/api/runtime-verification-records${n}`,{headers:J(e.bridgeSessionToken)})};getPortableRuntimeAcceptanceContract=async(e={})=>{let t=e.locale?`?${new URLSearchParams({locale:e.locale})}`:``;return await this.requestService.get(`/api/portable-runtime/acceptance/contract${t}`,{headers:J(e.bridgeSessionToken)})};getPortableRuntimeAcceptanceStatus=async(e={})=>{let t=new URLSearchParams;e.appId&&t.set(`appId`,e.appId),e.locale&&t.set(`locale`,e.locale);let n=t.size>0?`?${t.toString()}`:``;return await this.requestService.get(`/api/portable-runtime/acceptance/status${n}`,{headers:J(e.bridgeSessionToken)})};exportPortableRuntimeAcceptance=async(e={})=>{let t=new URLSearchParams;e.appId&&t.set(`appId`,e.appId),e.locale&&t.set(`locale`,e.locale);let n=t.size>0?`?${t.toString()}`:``;return await this.requestService.get(`/api/portable-runtime/acceptance/export${n}`,{headers:J(e.bridgeSessionToken)})};discoverServiceAppActions=async e=>await this.requestService.post(`/api/service-apps/${encodeURIComponent(e)}/actions/discover`,{});invokeServiceAction=async(e,t,n={})=>await this.requestService.post(`/api/service-actions/${encodeURIComponent(e)}/invoke`,{input:t??{}},{headers:J(n.bridgeSessionToken)});grantServiceAction=async(e,t={})=>await this.requestService.post(`/api/service-actions/${encodeURIComponent(e)}/grant`,{},{headers:J(t.bridgeSessionToken)});grantServiceActions=async(e,t={})=>await this.requestService.post(`/api/service-action-grants`,{actionIds:e},{headers:J(t.bridgeSessionToken)});grantAgentServiceActions=async(e,t)=>await this.requestService.post(`/api/agents/${encodeURIComponent(e)}/service-action-grants`,{actionIds:t});listServiceActionGrants=async()=>await this.requestService.get(`/api/service-action-grants`);revokeServiceAction=async(e,t={})=>await this.requestService.delete(`/api/service-actions/${encodeURIComponent(e)}/grant`,{headers:J(t.bridgeSessionToken)});revokeServiceActionGrant=async e=>{let{actionId:t,caller:n}=e,r=new URLSearchParams({surface:n.surface,callerId:n.surface===`panel-app`?n.appId:n.agentId});return await this.requestService.delete(`/api/service-action-grants/${encodeURIComponent(t)}?${r.toString()}`)}},Dn=class{constructor(e,t){this.requestService=e,this.eventBus=t}list=async e=>{let{limit:t,page:n,pageSize:r,query:i,peerId:a}=e??{},o=new URLSearchParams;typeof t==`number`&&Number.isFinite(t)&&o.set(`limit`,String(Math.max(1,Math.trunc(t)))),typeof n==`number`&&Number.isFinite(n)&&o.set(`page`,String(Math.max(1,Math.trunc(n)))),typeof r==`number`&&Number.isFinite(r)&&o.set(`pageSize`,String(Math.max(1,Math.trunc(r)))),i?.trim()&&o.set(`query`,i.trim());let s=a?.trim();return s&&o.set(`peerId`,s),await this.requestService.get(`/api/ncp/sessions`,{...o.size>0?{query:o}:{}})};get=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}`);listMessages=async(e,t={})=>{let n=typeof t==`number`?{limit:t}:t,r=new URLSearchParams;return typeof n.limit==`number`&&Number.isFinite(n.limit)&&r.set(`limit`,String(Math.max(1,Math.trunc(n.limit)))),n.cursor?.trim()&&r.set(`cursor`,n.cursor.trim()),n.toolPayload===`summary`&&r.set(`toolPayload`,`summary`),n.initialPayload===`compact`&&r.set(`initialPayload`,`compact`),await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/messages`,{...r.size>0?{query:r}:{},...n.signal?{signal:n.signal}:{}})};getUsage=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/usage`);listSkills=async(e,t)=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/skills`,{query:t?.projectRoot?.trim()?{projectRoot:t.projectRoot.trim()}:void 0});listQueuedInputs=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/queued-inputs`);deleteQueuedInput=async(e,t)=>await this.requestService.delete(`/api/ncp/sessions/${encodeURIComponent(e)}/queued-inputs/${encodeURIComponent(t)}`);listPendingInputs=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/pending-inputs`);steerQueuedInput=async(e,t)=>await this.requestService.post(`/api/ncp/sessions/${encodeURIComponent(e)}/queued-inputs/${encodeURIComponent(t)}/steer`);update=async(e,t)=>await this.requestService.put(`/api/ncp/sessions/${encodeURIComponent(e)}`,t);compactContext=async e=>await this.requestService.post(`/api/ncp/sessions/${encodeURIComponent(e)}/context/compact`);delete=async e=>await this.requestService.delete(`/api/ncp/sessions/${encodeURIComponent(e)}`);uploadAssets=async e=>{let t=new FormData;for(let n of e)t.append(`files`,n);return await this.requestService.upload(`/api/ncp/assets`,t)};subscribe=(e,t={})=>({close:this.eventBus.subscribeAll(t=>{e(t)})})},On=class{constructor(e){this.requestService=e}list=async(e={})=>await this.requestService.get(`/api/system-object-references`,{query:e});resolve=async e=>await this.requestService.post(`/api/system-object-references/resolve`,{uri:e})},kn=class{baseUrl;agentRuns;app;appPackages;appData;agents;auth;channelAuth;capabilityAccess;featureControls;config;eventBus;marketplace;inboxDeliveries;mcpMarketplace;mcp;panelApps;providers;projects;realtime;remote;runtimeControl;runtimeUpdate;serverPaths;serviceApps;sessions;systemObjectReferences;constructor(e){this.baseUrl=zt(e.baseUrl);let t={...e,baseUrl:this.baseUrl},n=new bn(t);this.realtime=new gn(t);let i=null;this.eventBus=new r({onFirstSubscriber:()=>{i??=this.realtime.subscribe(e=>{this.eventBus.emitEnvelope({type:e.type,payload:`payload`in e?e.payload:void 0,emittedAt:`emittedAt`in e?e.emittedAt:new Date().toISOString(),source:`source`in e?e.source:`realtime`})})},onNoSubscribers:()=>{i?.close(),i=null}}),this.agentRuns=new Kt(n,t),this.app=new Jt(n),this.appPackages=new Yt(n),this.appData=new Xt(n),this.agents=new qt(n,this.baseUrl),this.auth=new Zt(n),this.channelAuth=new Qt(n),this.capabilityAccess=new $t(n),this.featureControls=new en(n),this.config=new tn(n),this.marketplace=new nn(n),this.inboxDeliveries=new sn(n),this.mcpMarketplace=new cn(n),this.mcp=new un(n),this.panelApps=new pn(n),this.providers=new mn(n),this.projects=new hn(n),this.remote=new _n(n),this.runtimeControl=new Sn(n),this.runtimeUpdate=new Cn(n),this.serverPaths=new wn(n),this.serviceApps=new En(n),this.sessions=new Dn(n,this.eventBus),this.systemObjectReferences=new On(n)}},An=`http://127.0.0.1:55667`,jn=(()=>{let e=(void 0)?.trim();return e?e.replace(/\/$/,``):typeof window<`u`&&window.location?.origin?window.location.origin:An})(),Mn={"Use this page to manage the local NextClaw service. Closing the browser does not stop the service.":`runtimeControlManagedLocalMessage`,"This page is served by the running local service. Closing the browser does not stop it.":`runtimeControlManagedLocalHint`,"This page is served by the running local service.":`runtimeControlManagedLocalHintShort`,"This page is already hosted by the running local service.":`runtimeControlStartUnavailableHosted`,"App restart is only available in the desktop shell.":`runtimeControlRestartAppDesktopOnly`,"The local service is not running.":`runtimeControlServiceNotRunning`,"The local service is already stopped.":`runtimeControlServiceAlreadyStopped`,"Managed service started.":`runtimeControlManagedServiceStarted`,"Managed service start scheduled.":`runtimeControlManagedServiceStartScheduled`,"Restart scheduled. This page may disconnect for a few seconds.":`runtimeControlRestartScheduled`,"Stop scheduled. This page will disconnect shortly.":`runtimeControlStopScheduled`,"runtime healthy":`runtimeControlHealthy`};function Nn(e){return e.activeSystemAction?`service-transitioning`:e.lifecyclePhase}function Pn(e){return e===`ready`?`connected`:e===`startup-failed`||e===`stalled`?`disconnected`:`connecting`}function Fn(e){let t=Nn(e);return{...e,phase:t,connectionStatus:Pn(t)}}function In(e){return e===`start-service`?`starting-service`:e===`stop-service`?`stopping-service`:e===`restart-service`?`restarting-service`:`restarting-app`}function Ln(e){return e===`start-service`?`starting`:e===`stop-service`?`stopping`:e===`restart-service`?`restarting`:null}function Y(e){if(!e)return null;let t=Mn[e.trim()];return t?o(t):e}function Rn(e){let{action:t,message:n}=e;return{action:t,lifecycle:In(t),serviceState:Ln(t),message:n}}function zn(e){if(e.runtimeControlError)return{tone:`inactive`,title:o(`runtimeControlLoadFailed`),description:e.runtimeControlError,reasonLines:[],actionLabel:null,isBusy:!1};if(!e.runtimeControlView)return{tone:`inactive`,title:o(`runtimeStatusLoadingTitle`),description:o(`runtimeStatusLoadingDescription`),reasonLines:[],actionLabel:null,isBusy:!!e.activeSystemAction};if(e.activeSystemAction)return{tone:`attention`,title:o(`runtimeControlTitle`),description:Y(e.activeSystemAction.message)||Y(e.runtimeControlView.message)||o(`runtimeControlDescription`),reasonLines:[],actionLabel:null,isBusy:!0};let t=e.runtimeControlView;return t.pendingRestart?{tone:`attention`,title:o(`runtimeStatusPendingRestartTitle`),description:o(`runtimeStatusPendingRestartDescription`),reasonLines:t.pendingRestart.changedPaths.length>0?t.pendingRestart.changedPaths.map(e=>o(`runtimeStatusPendingRestartReasonItem`).replace(`{path}`,e)):[t.pendingRestart.message],actionLabel:t.canRestartService.available?o(`runtimeStatusRestartAction`):null,isBusy:!1}:{tone:t.lifecycle===`healthy`?`healthy`:`inactive`,title:o(`runtimeStatusHealthyTitle`),description:o(`runtimeStatusHealthyDescription`),reasonLines:[],actionLabel:null,isBusy:!1}}function Bn(e){let t=e.activeSystemAction,n=e.runtimeControlView;return{controlView:n,visibleLifecycle:t?.lifecycle??n?.lifecycle??`healthy`,visibleServiceState:t?.serviceState??n?.serviceState??`unknown`,visibleMessage:Y(t?.message)||Y(e.lastSystemActionError)||Y(n?.message)||o(`runtimeControlDescription`),busyAction:t?.action??null,busy:!!t,pendingRestart:n?.pendingRestart??null,errorMessage:Y(e.lastSystemActionError)||Y(e.runtimeControlError)||null}}var Vn={lifecyclePhase:`cold-starting`,hasReachedReady:!1,lastReadyAt:null,recoveryStartedAt:null,bootstrapStatus:null,lastError:null,lastTransportError:null,runtimeControlView:null,runtimeControlError:null,activeSystemAction:null,lastSystemActionError:null},Hn=c(e=>({state:Vn,patchState:t=>e(e=>({state:{...e.state,...t}}))}));function Un(e){if(e.length===0)throw Error(`AdaptiveCadence requires at least one stage.`);for(let t of e)if(t.delaysMs.length===0)throw Error(`AdaptiveCadence stage requires at least one delay.`)}var Wn=class{constructor(e){this.options=e,this.attempt=0,this.startedAt=null,this.lastFailureAt=null,this.lastSuccessAt=null,this.manualTriggerPending=!1,this.completed=!1,this.recordFailure=()=>{let e=this.clock();this.completed=!1,this.manualTriggerPending=!1,this.startedAt=this.startedAt??e,this.lastFailureAt=e,this.attempt+=1},this.recordSuccess=()=>{this.lastSuccessAt=this.clock(),this.attempt=0,this.startedAt=null,this.lastFailureAt=null,this.manualTriggerPending=!1,this.completed=!0},this.reset=()=>{this.attempt=0,this.startedAt=null,this.lastFailureAt=null,this.lastSuccessAt=null,this.manualTriggerPending=!1,this.completed=!1},this.requestManualTrigger=()=>{this.completed=!1,this.manualTriggerPending=!0},this.hasManualTrigger=()=>this.manualTriggerPending,this.getNextDelay=(e={})=>{if(this.manualTriggerPending)return e.consumeManualTrigger&&(this.manualTriggerPending=!1),this.options.manualTriggerDelayMs;if(this.completed)return this.options.successDelayMs;if(this.startedAt===null)return this.options.idleDelayMs;let t=this.resolveStage(this.clock()-this.startedAt);return t.delaysMs[Math.min(this.attempt-1,t.delaysMs.length-1)]},this.getSnapshot=()=>({attempt:this.attempt,startedAt:this.startedAt,lastFailureAt:this.lastFailureAt,lastSuccessAt:this.lastSuccessAt,manualTriggerPending:this.manualTriggerPending,completed:this.completed}),this.resolveStage=e=>this.options.stages.find(t=>t.untilElapsedMs===void 0||e<t.untilElapsedMs)??this.options.stages[this.options.stages.length-1],Un(e.stages),this.clock=e.clock??(()=>Date.now())}},Gn=3e4,Kn={idleDelayMs:1e3,manualTriggerDelayMs:0,successDelayMs:!1,stages:[{untilElapsedMs:3e4,delaysMs:[500,1e3,2e3,4e3,5e3]},{untilElapsedMs:5*6e4,delaysMs:[1e4,15e3,3e4]},{delaysMs:[6e4]}]};function qn(e){return e instanceof Error?e.message:String(e??``)}function Jn(e){return e&&(e.ncpAgent.error?.trim()||e.lastError?.trim())||null}function Yn(e){return o(e===`start-service`?`runtimeControlStartingServiceHelp`:e===`restart-service`?`runtimeControlRestartingServiceHelp`:e===`stop-service`?`runtimeControlStoppingServiceHelp`:`runtimeControlRestartingAppHelp`)}var X=new class{constructor(){this.recoveryTimeoutId=null,this.runtimeBootstrapProbeCadence=new Wn(Kn),this.getRuntimeBootstrapPollInterval=e=>{let{lifecyclePhase:t,activeSystemAction:n}=this.getState(),r=t===`recovering`||t===`stalled`||n?.lifecycle===`recovering`;return this.runtimeBootstrapProbeCadence.hasManualTrigger()?this.runtimeBootstrapProbeCadence.getNextDelay({consumeManualTrigger:!0}):!r&&e?.ncpAgent.state===`ready`?!1:this.runtimeBootstrapProbeCadence.getNextDelay({consumeManualTrigger:!0})},this.getRuntimeControl=async()=>this.decorateForCurrentEnvironment(await eo()),this.reportBootstrapStatus=e=>{let t=this.getState(),n=Jn(e);if(e.ncpAgent.state===`ready`){this.transitionToReady(e);return}if(!t.hasReachedReady){if(e.ncpAgent.state===`error`||e.phase===`error`){this.transitionToStartupFailed(n,e);return}this.transitionToColdStarting(e);return}this.transitionToRecovering(n,e)},this.reportBootstrapQueryError=e=>{let t=qn(e).trim();if(t&&!this.reportTransportFailure(t)){if(this.getState().hasReachedReady){this.transitionToRecovering(t);return}this.transitionToStartupFailed(t)}},this.reportTransportFailure=e=>{let t=qn(e).trim();return ci(t)?this.getState().hasReachedReady?(this.transitionToRecovering(t),!0):(this.runtimeBootstrapProbeCadence.recordFailure(),this.patchState({lastTransportError:t}),!0):!1},this.handleConnectionInterrupted=e=>{let t=this.getState(),n=e?.trim()||null;if(!t.hasReachedReady){this.runtimeBootstrapProbeCadence.recordFailure(),n&&this.patchState({lastTransportError:n});return}this.transitionToRecovering(n)},this.handleConnectionRestored=()=>{let e=this.getState();e.bootstrapStatus?.ncpAgent.state===`ready`&&this.transitionToReady(e.bootstrapStatus)},this.reportRuntimeControlView=e=>{this.patchState({runtimeControlView:e,runtimeControlError:null})},this.reportRuntimeControlError=e=>{let t=qn(e).trim();t&&this.patchState({runtimeControlError:t})},this.runRuntimeControlAction=async e=>{this.patchState({activeSystemAction:Rn({action:e,message:Yn(e)}),lastSystemActionError:null});try{let t=await this.executeRuntimeControlAction(e);if(e===`restart-app`)return t;if(e===`stop-service`)return await this.refreshRuntimeControlView(),this.clearActiveSystemAction(),t;this.patchState({activeSystemAction:{action:e,lifecycle:`recovering`,serviceState:null,message:o(`runtimeControlRecoveringHelp`)}}),this.runtimeBootstrapProbeCadence.requestManualTrigger();let n=await this.waitForRecovery();return this.syncRuntimeControlQueryCache(n),this.reportRuntimeControlView(n),this.clearActiveSystemAction(),t}catch(t){let n=t instanceof Error?t.message:o(`runtimeControlActionFailed`);throw this.patchState({activeSystemAction:{action:e,lifecycle:`failed`,serviceState:e===`stop-service`?`running`:e===`restart-app`?null:`unknown`,message:n},lastSystemActionError:n}),t}},this.getStatusView=()=>Fn(this.getState()),this.requestRuntimeBootstrapProbeNow=()=>{this.runtimeBootstrapProbeCadence.requestManualTrigger(),Et.refetchQueries({queryKey:[`runtime-bootstrap-status`]})},this.resetForTests=()=>{this.clearRecoveryTimeout(),this.runtimeBootstrapProbeCadence.reset(),Hn.setState({state:Vn})},this.getState=()=>Hn.getState().state,this.patchState=e=>{Hn.getState().patchState(e)},this.transitionToColdStarting=e=>{this.runtimeBootstrapProbeCadence.recordFailure(),this.clearRecoveryTimeout(),this.patchState({lifecyclePhase:`cold-starting`,recoveryStartedAt:null,bootstrapStatus:e,lastError:null})},this.transitionToStartupFailed=(e,t)=>{this.runtimeBootstrapProbeCadence.recordFailure(),this.clearRecoveryTimeout(),this.patchState({lifecyclePhase:`startup-failed`,recoveryStartedAt:null,bootstrapStatus:t??this.getState().bootstrapStatus,lastError:e})},this.transitionToRecovering=(e,t)=>{this.runtimeBootstrapProbeCadence.recordFailure();let n=this.getState();if(!n.hasReachedReady){this.patchState({lastTransportError:e?.trim()||n.lastTransportError});return}n.lifecyclePhase!==`recovering`&&n.lifecyclePhase!==`stalled`&&(this.clearRecoveryTimeout(),this.recoveryTimeoutId=window.setTimeout(()=>{this.recoveryTimeoutId=null,this.getState().lifecyclePhase===`recovering`&&this.patchState({lifecyclePhase:`stalled`})},Gn)),this.patchState({lifecyclePhase:n.lifecyclePhase===`stalled`?`stalled`:`recovering`,recoveryStartedAt:n.recoveryStartedAt??Date.now(),bootstrapStatus:t??n.bootstrapStatus,lastError:e?.trim()||n.lastError,lastTransportError:e?.trim()||n.lastTransportError})},this.transitionToReady=e=>{this.runtimeBootstrapProbeCadence.recordSuccess();let t=this.getState(),n=t.lifecyclePhase===`recovering`||t.lifecyclePhase===`stalled`;this.clearRecoveryTimeout(),this.patchState({lifecyclePhase:`ready`,hasReachedReady:!0,lastReadyAt:Date.now(),recoveryStartedAt:null,bootstrapStatus:e,lastError:null,lastTransportError:null}),n&&Et.refetchQueries({type:`active`})},this.executeRuntimeControlAction=async e=>{let t=this.getDesktopBridge();if(e===`restart-service`&&t&&typeof t.restartService==`function`){let e=await t.restartService();return{accepted:e.accepted,action:`restart-service`,lifecycle:e.lifecycle,message:e.message}}if(e===`start-service`)return await to();if(e===`stop-service`)return await ro();if(e===`restart-app`){if(!t||typeof t.restartApp!=`function`)throw Error(o(`runtimeRestartAppUnavailable`));let e=await t.restartApp();return{accepted:e.accepted,action:`restart-app`,lifecycle:e.lifecycle,message:e.message}}return await no()},this.waitForRecovery=async()=>{let e=Date.now()+25e3,t=null;for(;Date.now()<e;)try{return await this.getRuntimeControl()}catch(e){t=e,await new Promise(e=>{window.setTimeout(e,1500)})}throw t instanceof Error?t:Error(o(`runtimeRecoveryTimedOut`))},this.refreshRuntimeControlView=async()=>{try{let e=await this.getRuntimeControl();this.syncRuntimeControlQueryCache(e),this.reportRuntimeControlView(e)}catch(e){this.reportRuntimeControlError(e)}},this.syncRuntimeControlQueryCache=e=>{Et.setQueryData([`runtime-control`],e)},this.clearActiveSystemAction=()=>{this.patchState({activeSystemAction:null,lastSystemActionError:null})},this.clearRecoveryTimeout=()=>{this.recoveryTimeoutId!==null&&(window.clearTimeout(this.recoveryTimeoutId),this.recoveryTimeoutId=null)},this.decorateForCurrentEnvironment=e=>{let t=this.getDesktopBridge();return!t||typeof t.restartApp!=`function`?e:{...e,environment:`desktop-embedded`,serviceState:`running`,canStartService:{available:!1,requiresConfirmation:!1,impact:`none`},canStopService:{available:!1,requiresConfirmation:!0,impact:`brief-ui-disconnect`},canRestartApp:{available:!0,requiresConfirmation:!0,impact:`full-app-relaunch`},ownerLabel:o(`runtimeControlEnvironmentDesktop`),managementHint:o(`runtimeControlDesktopServiceHint`)}},this.getDesktopBridge=()=>typeof window>`u`?null:window.nextclawDesktop??null}};function Xn(){let e=Xe({queryKey:[`runtime-bootstrap-status`],queryFn:()=>Di({timeoutMs:5e3}),refetchInterval:e=>X.getRuntimeBootstrapPollInterval(e.state.data),retry:!1}),t=Xe({queryKey:[`runtime-control`],queryFn:async()=>await X.getRuntimeControl(),staleTime:5e3});(0,z.useEffect)(()=>{e.data&&X.reportBootstrapStatus(e.data)},[e.data]),(0,z.useEffect)(()=>{e.error&&X.reportBootstrapQueryError(e.error)},[e.error]),(0,z.useEffect)(()=>{t.data&&X.reportRuntimeControlView(t.data)},[t.data]),(0,z.useEffect)(()=>{t.error&&X.reportRuntimeControlError(t.error)},[t.error])}function Zn(){return Fn(Hn(e=>e.state))}function Qn(){return zn(Hn(e=>e.state))}function $n(){return Bn(Hn(e=>e.state))}var Z=c(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),er=class{constructor(e){this.desktopApi=e,this.kind=`desktop-bridge`,this.subscribe=e=>this.desktopApi.onUpdateStateChanged(e),this.getState=async()=>await this.desktopApi.getUpdateState(),this.checkForUpdates=async()=>await this.desktopApi.checkForUpdates(),this.downloadUpdate=async()=>await this.desktopApi.downloadUpdate(),this.applyDownloadedUpdate=async()=>await this.desktopApi.applyDownloadedUpdate(),this.updateChannel=async e=>await this.desktopApi.updateChannel(e)}},tr=class{constructor(){this.kind=`runtime-host`,this.getState=async()=>await ao(),this.checkForUpdates=async()=>await oo(),this.downloadUpdate=async()=>await so(),this.applyDownloadedUpdate=async()=>await co(),this.updateChannel=async e=>await lo(e)}},nr=new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.source=null,this.start=async()=>{this.subscriptionCount+=1;let e=this.resolveSource();if(this.source=e,!e){Z.setState({supported:!1,initialized:!0,snapshot:null});return}e.kind===`desktop-bridge`&&!this.unsubscribe&&(this.unsubscribe=e.subscribe(e=>{Z.setState({supported:!0,initialized:!0,snapshot:e})})),Z.setState({supported:!0,initialized:!1});try{let t=await e.getState();Z.setState({supported:!0,initialized:!0,snapshot:t})}catch(t){if(e.kind===`runtime-host`&&this.isUnsupportedError(t)){Z.setState({supported:!1,initialized:!0,snapshot:null});return}Z.setState({supported:!0,initialized:!0}),U.error(`${o(`runtimeUpdatesLoadFailed`)}: ${this.getErrorMessage(t)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null,this.source=null)},this.reportSnapshot=e=>{this.source?.kind!==`desktop-bridge`&&Z.setState({supported:!0,initialized:!0,snapshot:e})},this.refreshAfterRealtimeReconnect=async()=>{this.source?.kind===`runtime-host`&&await this.refreshSnapshot()},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,o(`runtimeUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){U.success(o(`runtimeUpdatesAlreadyLatest`));return}if(e.status===`update-available`){U.success(o(`runtimeUpdatesAvailable`).replace(`{version}`,e.availableVersion??o(`runtimeUpdatesUnknownVersion`)));return}e.status===`downloaded`&&U.success(o(`runtimeUpdatesReadyToApply`))},this.downloadUpdate=async()=>{try{await this.runSnapshotCommand(`downloading`,o(`runtimeUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,o(`runtimeUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updateNow=async()=>{let e=Z.getState().snapshot;if(!(e?.status!==`update-available`&&e?.status!==`downloaded`))try{await this.runSnapshotCommand(`updating`,o(`runtimeUpdatesUpdateFailed`),async t=>{let n=e.status===`downloaded`?e:await t.downloadUpdate();return Z.setState({snapshot:n}),n.status===`downloaded`?await t.applyDownloadedUpdate():n})}catch{return}},this.updateChannel=async e=>{if(Z.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,o(`runtimeUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){U.success(o(`runtimeUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}U.success(o(`runtimeUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.refreshSnapshot=async()=>{if(!(!this.source||this.source.kind!==`runtime-host`))try{let e=await this.source.getState();Z.setState({supported:!0,initialized:!0,snapshot:e})}catch{}},this.runSnapshotCommand=async(e,t,n)=>{let r=this.source??this.resolveSource();if(!r)throw Error(o(`runtimeUpdatesUnavailableDescription`));this.source=r,Z.setState({busyAction:e});try{let e=await n(r);return Z.setState({snapshot:e}),e}catch(e){throw U.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{Z.setState({busyAction:null})}},this.resolveSource=()=>{let e=this.getDesktopApi();return e?new er(e):new tr},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.isUnsupportedError=e=>{let t=this.getErrorMessage(e).toLowerCase();return t.includes(`404`)||t.includes(`not found`)||t.includes(`endpoint not found`)},this.getErrorMessage=e=>e instanceof Error?e.message:o(`error`),this.getChannelLabel=e=>o(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}},rr=`https://docs.nextclaw.io/`;function ir(e,t){let n=t===`zh-CN`?`en-US`:`zh-CN`;return e?.[t]?.trim()||e?.[n]?.trim()||null}function ar(e){let t=e.releaseNotesUrl?.trim(),n=(e.availableVersion??e.downloadedVersion)?.trim();return t?or(n,t):null}function or(e,t=rr){let n=e?.trim();if(!n||!/^[0-9A-Za-z.-]+$/.test(n))return null;try{return new URL(`/release-notes/nextclaw-v${n}.json`,t).toString()}catch{return null}}function sr(e,t){return ir(e?.links?.html,t)}function cr(e){let t=e.releaseNotesUrl?.trim(),n=(e.downloadedVersion??e.availableVersion)?.trim();return!t||!n?null:{url:t,versionLabel:`v${n}`}}function lr(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ur(e){return lr(e)?typeof e[`zh-CN`]==`string`||typeof e[`en-US`]==`string`:!1}function dr(e){return!lr(e)||!ur(e.title)?!1:e.body===void 0||ur(e.body)}function fr(e){return lr(e)&&typeof e.kind==`string`&&Array.isArray(e.items)&&e.items.every(dr)&&(e.title===void 0||ur(e.title))}function pr(e){return lr(e)&&(e.html===void 0||ur(e.html))}function mr(e){return lr(e)&&Array.isArray(e.sections)&&e.sections.every(fr)&&(e.title===void 0||ur(e.title))&&(e.summary===void 0||ur(e.summary))&&(e.links===void 0||pr(e.links))}async function hr(e){let t=await fetch(e,{cache:`no-store`,headers:{accept:`application/json`}});if(!t.ok)throw Error(`Release notes request failed with HTTP ${t.status}.`);let n=await t.json();if(!mr(n))throw Error(`Release notes payload has an unsupported shape.`);return n}function gr(){return s()===`zh`?`zh-CN`:`en-US`}function _r(e){let t=or(e),n=gr(),r=sr(Xe({queryKey:[`current-release-notes`,t],queryFn:async()=>await hr(t??``),enabled:!!t,retry:!1,staleTime:300*1e3}).data,n),i=e?.trim();return r&&i?{url:r,versionLabel:`v${i}`}:null}var vr=z.forwardRef(({className:e,checked:t=!1,onCheckedChange:n,thumbClassName:r,...a},o)=>(0,B.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,ref:o,className:i(`switch-track peer inline-flex h-[22px] w-10 shrink-0 cursor-pointer items-center rounded-full border-2 transition-colors duration-fast focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:cursor-not-allowed disabled:opacity-50`,t?`border-primary/70 bg-primary`:`border-border/60 bg-muted hover:bg-[var(--interaction-hover)]`,e),onClick:()=>n?.(!t),...a,children:(0,B.jsx)(`span`,{"data-state":t?`checked`:`unchecked`,className:i(`switch-thumb pointer-events-none block h-5 w-5 rounded-full bg-card shadow-md ring-1 ring-border/50 transition-transform duration-fast`,t?`translate-x-5`:`translate-x-0`,r)})}));vr.displayName=`Switch`;var yr={maxRetries:8,startupTimeoutMs:2e3,settledTimeoutMs:5e3,retryBaseDelayMs:500,retryMaxDelayMs:3e3};function br(e){return e instanceof Error?ci(e.message):!1}function xr(e,t){return e>=yr.maxRetries?!1:br(t)}function Sr(e){return Math.min(yr.retryMaxDelayMs,yr.retryBaseDelayMs*2**Math.max(0,e-1))}function Cr(){let[e,t]=(0,z.useState)(!1),n=Xe({queryKey:[`auth-status`],queryFn:()=>bi({timeoutMs:e?yr.settledTimeoutMs:yr.startupTimeoutMs}),staleTime:5e3,retry:xr,retryDelay:Sr});return(0,z.useEffect)(()=>{n.isSuccess&&!e&&t(!0)},[e,n.isSuccess]),n}function wr(e){return Promise.all([e.invalidateQueries({queryKey:[`auth-status`]}),e.invalidateQueries({queryKey:[`app-meta`]}),e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),e.invalidateQueries({queryKey:[`config-schema`]}),e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`session-history`]}),e.invalidateQueries({queryKey:[`chat-runs`]}),e.invalidateQueries({queryKey:[`cron-jobs`]})])}function Tr(){let e=V();return Ze({mutationFn:xi,onSuccess:async()=>{await wr(e),U.success(o(`authSetupSuccess`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}function Er(){let e=V();return Ze({mutationFn:Si,onSuccess:async()=>{await wr(e),U.success(o(`authLoginSuccess`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}function Dr(){let e=V();return Ze({mutationFn:Ci,onSuccess:async()=>{await wr(e),U.success(o(`authLogoutSuccess`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}function Or(){let e=V();return Ze({mutationFn:wi,onSuccess:async()=>{await wr(e),U.success(o(`authPasswordUpdated`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}function kr(){let e=V();return Ze({mutationFn:Ti,onSuccess:async(t,n)=>{await wr(e),U.success(n.enabled?o(`authEnabledSuccess`):o(`authDisabledSuccess`))},onError:e=>{U.error(`${o(`authActionFailed`)}: ${e.message}`)}})}var Ar=8;function jr(e){return e.trim().length>=Ar}function Mr(e,t){return e===t?!0:(U.error(o(`authPasswordMismatch`)),!1)}function Nr({children:e,contentClassName:t=`space-y-6`}){return(0,B.jsx)(Lt,{children:(0,B.jsx)(`div`,{className:`${t} p-4`,children:e})})}function Pr({canSubmitSetup:e,isPending:t,onSubmit:n,setSetupConfirmPassword:r,setSetupPassword:i,setSetupUsername:a,setupConfirmPassword:s,setupPassword:c,setupUsername:l}){return(0,B.jsxs)(Nr,{contentClassName:`space-y-5`,children:[(0,B.jsxs)(`div`,{className:`rounded-xl bg-background/65 p-4`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o(`authSetupTitle`)}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:o(`authSetupDescription`)})]}),(0,B.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-setup-username`,children:o(`authUsername`)}),(0,B.jsx)(G,{id:`auth-setup-username`,value:l,onChange:e=>a(e.target.value),placeholder:o(`authUsernamePlaceholder`)})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-setup-password`,children:o(`authPassword`)}),(0,B.jsx)(G,{id:`auth-setup-password`,type:`password`,value:c,onChange:e=>i(e.target.value),placeholder:o(`authPasswordPlaceholder`)})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-setup-confirm`,children:o(`authConfirmPassword`)}),(0,B.jsx)(G,{id:`auth-setup-confirm`,type:`password`,value:s,onChange:e=>r(e.target.value),placeholder:o(`authConfirmPasswordPlaceholder`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`authPasswordMinLengthHint`)})]}),(0,B.jsx)(jt,{type:`button`,disabled:!e,onClick:()=>void n(),children:o(t?`authSettingUp`:`authSetupAction`)})]})}function Fr({authenticated:e,canUpdatePassword:t,enabled:n,isLoggingOut:r,isUpdatingEnabled:i,isUpdatingPassword:a,nextConfirmPassword:s,nextPassword:c,onEnabledChange:l,onLogout:u,onPasswordUpdate:d,setNextConfirmPassword:f,setNextPassword:p,username:m}){return(0,B.jsxs)(Nr,{children:[(0,B.jsxs)(`div`,{className:`rounded-xl bg-background/65 p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-start md:justify-between`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o(`authStatusLabel`)}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`authStatusConfiguredUser`).replace(`{username}`,m??``)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`authUsernameFixedHelp`)})]}),(0,B.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-muted px-3 py-1 text-xs font-medium text-foreground`,children:o(n?`enabled`:`disabled`)})]}),(0,B.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4 border-t border-border/55 pt-4 md:flex-row md:items-center md:justify-between`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o(`authEnableLabel`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(n?`authEnableOnHelp`:`authEnableOffHelp`)})]}),(0,B.jsx)(vr,{checked:n,disabled:i,onCheckedChange:e=>{l(e)}})]})]}),(0,B.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-background/65 p-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o(`authPasswordSectionTitle`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`authPasswordSectionDescription`)})]}),(0,B.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-password-next`,children:o(`authPassword`)}),(0,B.jsx)(G,{id:`auth-password-next`,type:`password`,value:c,onChange:e=>p(e.target.value),placeholder:o(`authPasswordPlaceholder`)})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(K,{htmlFor:`auth-password-confirm`,children:o(`authConfirmPassword`)}),(0,B.jsx)(G,{id:`auth-password-confirm`,type:`password`,value:s,onChange:e=>f(e.target.value),placeholder:o(`authConfirmPasswordPlaceholder`)})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(jt,{type:`button`,disabled:!t,onClick:()=>void d(),children:o(a?`authPasswordUpdating`:`authPasswordAction`)}),n&&e?(0,B.jsx)(jt,{type:`button`,variant:`outline`,disabled:r,onClick:()=>void u(),children:o(r?`authLoggingOut`:`authLogoutAction`)}):null]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`authSessionMemoryNotice`)})]})]})}function Ir(){let e=Cr(),t=Tr(),n=kr(),r=Or(),i=Dr(),[a,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)(``),[m,h]=(0,z.useState)(``),g=e.data,_=a.trim().length>0&&jr(c)&&c===u&&!t.isPending,v=jr(f)&&f===m&&!r.isPending;return e.isLoading&&!g?(0,B.jsx)(Nr,{contentClassName:`text-sm text-gray-500`,children:o(`loading`)}):e.isError||!g?(0,B.jsxs)(Nr,{contentClassName:`space-y-4`,children:[(0,B.jsx)(`p`,{className:`text-sm text-gray-500`,children:o(`authStatusLoadFailed`)}),(0,B.jsx)(jt,{variant:`outline`,onClick:()=>void e.refetch(),children:o(`authRetryStatus`)})]}):g.configured?(0,B.jsx)(Fr,{authenticated:g.authenticated,enabled:g.enabled,username:g.username,nextPassword:f,setNextPassword:p,nextConfirmPassword:m,setNextConfirmPassword:h,canUpdatePassword:v,isUpdatingEnabled:n.isPending,isUpdatingPassword:r.isPending,isLoggingOut:i.isPending,onEnabledChange:async e=>{try{await n.mutateAsync({enabled:e})}catch{}},onPasswordUpdate:async()=>{if(Mr(f,m))try{await r.mutateAsync({password:f}),p(``),h(``)}catch{}},onLogout:async()=>{try{await i.mutateAsync()}catch{}}}):(0,B.jsx)(Pr,{setupUsername:a,setSetupUsername:s,setupPassword:c,setSetupPassword:l,setupConfirmPassword:u,setSetupConfirmPassword:d,canSubmitSetup:_,isPending:t.isPending,onSubmit:async()=>{if(Mr(c,u))try{await t.mutateAsync({username:a.trim(),password:c}),l(``),d(``)}catch{}}})}function Lr(){return(0,B.jsx)(Pt,{title:o(`authSecurityTitle`),description:o(`authSecurityDescription`),children:(0,B.jsx)(Ir,{})})}function Rr(e){return e.replace(/\s+/g,` `).trim().slice(0,200)}function zr(e,t){if(t===404&&e.startsWith(`/api/providers/`)&&e.endsWith(`/test`))return`Provider test endpoint is missing. This usually means nextclaw runtime version is outdated.`;if(t===401||t===403)return`Authentication failed. Check apiKey and custom headers.`;if(t===429)return`Rate limited by upstream provider. Retry later or switch model/provider.`;if(t>=500)return`Upstream service error. Retry later and inspect server logs if it persists.`}function Br(e){if(e instanceof Error){let t=e.name?.trim()||`Error`,n=e.message?.trim()||`Unknown error`;return{summary:`${t}: ${n}`,details:{errorName:t,errorMessage:n,...e.stack?.trim()?{errorStack:e.stack.trim()}:{}}}}return{summary:String(e??`Unknown error`),details:{errorName:`NonError`,errorMessage:String(e??`Unknown error`)}}}async function Vr(e,t,n={}){let r=`${e}${t}`,i=(n.method||`GET`).toUpperCase(),a;try{let e=new Headers(n.headers);!(n.body instanceof FormData)&&!e.has(`Content-Type`)&&e.set(`Content-Type`,`application/json`),a=await fetch(r,{credentials:`include`,headers:e,...n})}catch(e){let n=Br(e);return X.reportTransportFailure(n.summary),{ok:!1,error:{code:`NETWORK_ERROR`,message:`Fetch failed on ${i} ${t} | ${n.summary}`,details:{method:i,endpoint:t,url:r,...n.details}}}}let o=await a.text(),s=null;if(o)try{s=JSON.parse(o)}catch{}if(!s){let e=o?Rr(o):``,n=zr(t,a.status),s=[`Non-JSON response (${a.status} ${a.statusText}) on ${i} ${t}`];return e&&s.push(`body=${e}`),n&&s.push(`hint=${n}`),{ok:!1,error:{code:`INVALID_RESPONSE`,message:s.join(` | `),details:{status:a.status,statusText:a.statusText,method:i,endpoint:t,url:r,bodySnippet:e||void 0,hint:n}}}}return a.ok,s}function Hr(e){let t=e.split(`
8
8
  `),n=``,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim();continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}if(!n)return null;let i,a=r.join(`
9
9
  `);if(a)try{i=JSON.parse(a)}catch{i=a}return{name:n,payload:i}}function Ur(e,t,n){let r=Hr(e);r&&(r.name===`final`&&n(r.payload),t(r))}function Wr(e,t,n){let r=e,i=r.indexOf(`
10
10
 
11
11
  `);for(;i!==-1;)Ur(r.slice(0,i),t,n),r=r.slice(i+2),i=r.indexOf(`
12
12
 
13
- `);return r}async function Gr(e,t){let n=e.body?.getReader();if(!n)throw Error(`SSE response body unavailable`);let r=new TextDecoder,i=``,a;try{for(;;){let{value:e,done:o}=await n.read();if(o)break;i+=r.decode(e,{stream:!0}),i=Wr(i,t,e=>{a=e})}i.trim()&&Ur(i,t,e=>{a=e})}finally{n.releaseLock()}return a}function Kr(e,t){let n=e.replace(/\/$/,``);try{let e=new URL(n,window.location.origin);return`${e.protocol===`https:`?`wss:`:e.protocol===`http:`?`ws:`:e.protocol}//${e.host}${t}`}catch{return n.startsWith(`wss://`)||n.startsWith(`ws://`)?`${n}${t}`:n.startsWith(`https://`)?`${n.replace(/^https:/,`wss:`)}${t}`:n.startsWith(`http://`)?`${n.replace(/^http:/,`ws:`)}${t}`:`${n}${t}`}}function qr(e,t){if(!e.ok){let n=Error(e.error?.message||t);return n.code=e.error?.code,n.details=e.error?.details,n}return Error(t)}function Jr(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown error`}return String(e??`Unknown error`)}function Yr(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}var Xr=class{constructor(e){this.wsUrl=e,this.socket=null,this.reconnectTimer=null,this.manualClose=!1,this.subscribers=new Set,this.subscribe=e=>(this.subscribers.add(e),this.subscribers.size===1?this.connect():this.socket?.readyState===WebSocket.OPEN&&e({type:`connection.open`,payload:{}}),()=>{this.subscribers.delete(e),this.subscribers.size===0&&this.disconnect()}),this.emit=e=>{for(let t of this.subscribers)t(e)},this.connect=()=>{if(this.socket&&(this.socket.readyState===WebSocket.CONNECTING||this.socket.readyState===WebSocket.OPEN))return;this.manualClose=!1;let e=new WebSocket(this.wsUrl);this.socket=e,e.onopen=()=>{this.emit({type:`connection.open`,payload:{}})},e.onmessage=e=>{try{let t=JSON.parse(String(e.data??``));this.emit(t)}catch(e){console.error(`Failed to parse websocket message:`,e)}},e.onerror=()=>{this.emit({type:`connection.error`,payload:{message:`websocket error`}})},e.onclose=()=>{this.emit({type:`connection.close`,payload:{}}),this.socket=null,!this.manualClose&&this.subscribers.size>0&&this.scheduleReconnect()}},this.scheduleReconnect=()=>{this.reconnectTimer===null&&(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},3e3))},this.disconnect=()=>{this.manualClose=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.socket?.close(),this.socket=null}}},Zr=class{constructor(e={}){this.options=e,this.request=async e=>{let t=Number.isFinite(e.timeoutMs)&&(e.timeoutMs??0)>0?Math.trunc(e.timeoutMs):null,n=t?new AbortController:null,r=t?window.setTimeout(()=>n?.abort(`Request timed out after ${t}ms: ${e.method} ${e.path}`),t):null,i=Qr(e.body);try{let t=await Vr(this.apiBase,e.path,{method:e.method,...i===void 0?{}:{body:i},...e.headers?{headers:e.headers}:{},signal:n?.signal??e.signal});if(!t.ok)throw qr(t,`Request failed for ${e.method} ${e.path}`);return t.data}catch(t){if(n?.signal.aborted){let{reason:t}=n.signal;throw Error(typeof t==`string`&&t.trim()?t:`Request timed out: ${e.method} ${e.path}`)}throw t instanceof Error?t:Yr(`Request failed for ${e.method} ${e.path} | ${Jr(t)}`,t)}finally{r!==null&&window.clearTimeout(r)}},this.openStream=e=>{let t=new AbortController,n=()=>t.abort();return e.signal&&(e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0})),{finished:(async()=>{let r;try{r=await fetch(`${this.apiBase}${e.path}`,{method:e.method,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`},...e.body===void 0?{}:{body:JSON.stringify(e.body)},signal:t.signal})}catch(t){throw Y.reportTransportFailure(Jr(t)),Yr(`Stream request failed for ${e.method} ${e.path} | ${Jr(t)}`,t)}if(!r.ok){let t=(await r.text()).trim();throw Error(t?`Stream request failed for ${e.method} ${e.path} | HTTP ${r.status} | ${t}`:`Stream request failed for ${e.method} ${e.path} | HTTP ${r.status}`)}try{return await Gr(r,e.onEvent)}finally{e.signal?.removeEventListener(`abort`,n)}})(),cancel:()=>t.abort()}},this.subscribe=e=>this.realtimeGateway.subscribe(e),this.apiBase=e.apiBase??((void 0)?.trim().replace(/\/$/,``)||(typeof window<`u`?window.location.origin:`http://127.0.0.1:55667`)),this.realtimeGateway=new Xr(Kr(this.apiBase,e.wsPath??`/ws`))}};function Qr(e){if(e!==void 0)return e instanceof FormData||e instanceof URLSearchParams||e instanceof Blob||e instanceof ArrayBuffer||typeof e==`string`?e:JSON.stringify(e)}function $r(e,t,n){if(typeof e==`object`&&e&&`ok`in e){let r=e;if(r.ok===!1&&r.error?.message){let e=Error(r.error.message);return e.code=r.error.code,e.details=r.error.details,e.status=t,e}if(r.ok===!0)return Error(n)}return typeof e==`string`&&e.trim()?Error(e.trim()):Error(`${n} (${t})`)}function ei(e){if(typeof e==`object`&&e&&`ok`in e){let t=e;if(t.ok===!1){let e=Error(t.error?.message??`Remote request failed.`);throw e.code=t.error?.code,e.details=t.error?.details,e}if(t.ok===!0)return t.data}return e}function ti(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var ni=15e3,ri=class{constructor(e,t=(void 0)?.trim().replace(/\/$/,``)||(typeof window<`u`?window.location.origin:`http://127.0.0.1:55667`)){this.runtime=e,this.apiBase=t,this.socket=null,this.connectPromise=null,this.connectTimeoutId=null,this.reconnectTimer=null,this.manualClose=!1,this.subscribers=new Set,this.pendingRequests=new Map,this.pendingStreams=new Map,this.request=async e=>{await this.ensureSocket();let t=ti(`req`),n=Number.isFinite(e.timeoutMs)&&(e.timeoutMs??0)>0?Math.trunc(e.timeoutMs):ni;return await new Promise((r,i)=>{let a=window.setTimeout(()=>{this.pendingRequests.delete(t),i(Error(`Timed out waiting for remote request response after ${n}ms: ${e.method} ${e.path}`))},n);this.pendingRequests.set(t,{resolve:e=>r(e),reject:i,timeoutId:a}),this.send({type:`request`,id:t,target:{method:e.method,path:e.path,...e.headers?{headers:e.headers}:{},...e.body===void 0?{}:{body:e.body}}})})},this.openStream=e=>{let t=ti(`stream`),n=!1,r=e=>{n||(n=!0,a(e))},i,a,o=new Promise((e,t)=>{i=e,a=t}),s=()=>{this.pendingStreams.delete(t),!n&&(n=!0,this.send({type:`stream.cancel`,streamId:t}),a(Error(`stream cancelled`)))};this.pendingStreams.set(t,{onEvent:e.onEvent,finalResult:void 0,resolve:e=>{n||(n=!0,i(e))},reject:e=>{n||(n=!0,a(e))}});let c=()=>s();return e.signal&&(e.signal.aborted?s():e.signal.addEventListener(`abort`,c,{once:!0})),this.ensureSocket().then(()=>{n||this.send({type:`stream.open`,streamId:t,target:{method:e.method,path:e.path,...e.body===void 0?{}:{body:e.body}}})}).catch(e=>{this.pendingStreams.delete(t),r(e instanceof Error?e:Error(String(e)))}),{finished:o.finally(()=>{e.signal?.removeEventListener(`abort`,c),this.pendingStreams.delete(t)}),cancel:s}},this.subscribe=e=>(this.subscribers.add(e),this.ensureSocket().catch(t=>{e({type:`connection.error`,payload:{message:t instanceof Error?t.message:String(t)}})}),()=>{this.subscribers.delete(e)}),this.emit=e=>{for(let t of this.subscribers)t(e)},this.send=e=>{if(!this.socket||this.socket.readyState!==WebSocket.OPEN)throw Error(`Remote transport websocket is not connected.`);this.socket.send(JSON.stringify(e))},this.ensureSocket=async()=>{if(this.socket?.readyState===WebSocket.OPEN&&this.connectPromise===null)return;if(this.connectPromise)return await this.connectPromise;let e=Kr(this.apiBase,this.runtime.wsPath);this.manualClose=!1,this.connectPromise=new Promise((t,n)=>{let r=new WebSocket(e);this.socket=r;let i=!1,a=()=>{this.connectTimeoutId!==null&&(window.clearTimeout(this.connectTimeoutId),this.connectTimeoutId=null)};this.connectTimeoutId=window.setTimeout(()=>{this.connectTimeoutId=null,n(Error(`Timed out waiting for remote transport websocket.`)),r.close()},8e3),r.onopen=()=>{i=!0,a(),this.connectPromise=null,t(),this.emit({type:`connection.open`,payload:{}})},r.onmessage=e=>{try{let t=JSON.parse(String(e.data??``));if(t.type===`connection.ready`)return;this.handleFrame(t)}catch(e){console.error(`Failed to parse remote websocket frame:`,e)}},r.onerror=()=>{this.emit({type:`connection.error`,payload:{message:`remote websocket error`}})},r.onclose=()=>{a();let e=this.connectPromise!==null;this.socket=null,this.connectPromise=null,this.failPendingWork(Error(`Remote transport connection closed.`)),this.emit({type:`connection.close`,payload:{}}),e&&!i&&n(Error(`Remote transport connection closed before ready.`)),!this.manualClose&&this.subscribers.size>0&&this.scheduleReconnect()}});let{connectPromise:t}=this;return await t},this.scheduleReconnect=()=>{this.reconnectTimer===null&&(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.ensureSocket().catch(()=>void 0)},3e3))},this.failPendingWork=e=>{for(let t of this.pendingRequests.values())window.clearTimeout(t.timeoutId),t.reject(e);this.pendingRequests.clear();for(let t of this.pendingStreams.values())t.reject(e);this.pendingStreams.clear()},this.handleFrame=e=>{if(e.type===`response`||e.type===`request.error`){this.handleRequestFrame(e);return}if(e.type===`stream.event`||e.type===`stream.end`||e.type===`stream.error`){this.handleStreamFrame(e);return}if(e.type===`event`){this.emit(e.event);return}e.type===`connection.error`&&this.emit({type:`connection.error`,payload:{message:e.message}})},this.handleRequestFrame=e=>{let t=this.pendingRequests.get(e.id);if(t){if(this.pendingRequests.delete(e.id),window.clearTimeout(t.timeoutId),e.type===`request.error`){t.reject(Error(e.message));return}if(e.status>=400){t.reject($r(e.body,e.status,`Remote request failed.`));return}try{t.resolve(ei(e.body))}catch(e){t.reject(e instanceof Error?e:Error(String(e)))}}},this.handleStreamFrame=e=>{let t=this.pendingStreams.get(e.streamId);if(t){if(e.type===`stream.event`){try{e.event===`final`&&(t.finalResult=e.payload),t.onEvent({name:e.event,payload:e.payload})}catch(n){this.pendingStreams.delete(e.streamId),t.reject(n instanceof Error?n:Error(String(n)))}return}if(this.pendingStreams.delete(e.streamId),e.type===`stream.end`){t.resolve(t.finalResult);return}t.reject(Error(e.message))}}}},ii=`/_remote/runtime`,ai={mode:`remote`,protocolVersion:1,wsPath:`/_remote/ws`};async function oi(e){let t=`${e.replace(/\/$/,``)}${ii}`,n;try{n=await fetch(t,{method:`GET`,credentials:`include`,cache:`no-store`})}catch{return new Zr({apiBase:e})}if(n.status===404)return new Zr({apiBase:e});if(!(n.headers.get(`content-type`)?.toLowerCase()??``).includes(`application/json`))return n.status>=400?new ri(ai,e):new Zr({apiBase:e});let r=null;try{r=await n.json()}catch{return n.status>=400?new ri(ai,e):new Zr({apiBase:e})}return n.ok&&r.ok&&r.data?.mode===`remote`?new ri(r.data,e):n.status>=400?new ri(ai,e):new Zr({apiBase:e})}var si=new class{constructor(e=(void 0)?.trim().replace(/\/$/,``)||(typeof window<`u`?window.location.origin:`http://127.0.0.1:55667`)){this.apiBase=e,this.transportPromise=null,this.getTransport=async()=>(this.transportPromise||=oi(this.apiBase),await this.transportPromise),this.request=async e=>await(await this.getTransport()).request(e),this.openStream=e=>{let t=null,n,r,i=new Promise((e,t)=>{n=e,r=t});return this.getTransport().then(i=>{t=i.openStream(e),t.finished.then(n).catch(e=>{r(e instanceof Error?e:Error(String(e)))})}).catch(e=>{r(e instanceof Error?e:Error(String(e)))}),{finished:i,cancel:()=>t?.cancel()}},this.subscribe=e=>{let t=()=>{},n=!0;return this.getTransport().then(r=>{n&&(t=r.subscribe(e))}).catch(t=>{e({type:`connection.error`,payload:{message:t instanceof Error?t.message:String(t)}})}),()=>{n=!1,t()}}}};function ci(e){let t=e.trim().toLowerCase();return t?[`failed to fetch`,`networkerror`,`network request failed`,`load failed`,`request timed out`,`timed out waiting for remote request response`,`remote transport connection closed`,`websocket error`,`fetch failed on `,`stream request failed for `,`ncp fetch failed for `].some(e=>t.includes(e)):!1}var Q=new An({baseUrl:Mn,transport:{request:async({body:e,headers:t,method:n,path:r,query:i,signal:a,timeoutMs:o})=>await si.request({method:n,path:fi(r,di(i)),...e===void 0?{}:{body:e},...t?{headers:t}:{},...a?{signal:a}:{},...o===void 0?{}:{timeoutMs:o}}),upload:async({formData:e,headers:t,path:n,signal:r})=>{let i=await fetch(`${Mn}${n}`,{method:`POST`,body:e,credentials:`include`,...t?{headers:t}:{},...r?{signal:r}:{}}),a=await i.json();if(!i.ok||!a.ok)throw new q({message:pi(a,`Upload failed for ${n}`),status:i.status,code:a.ok?void 0:a.error.code,details:a.ok?void 0:a.error.details});return a.data},subscribe:e=>si.subscribe(e)}});async function $(e,t={}){let n=(t.method||`GET`).toUpperCase();try{return{ok:!0,data:await si.request({method:n,path:e,...t.timeoutMs===void 0?{}:{timeoutMs:t.timeoutMs},...t.body===void 0?{}:{body:ui(t.body)}})}}catch(t){return{ok:!1,error:{code:`REQUEST_FAILED`,message:t instanceof Error?t.message:String(t),details:{method:n,endpoint:e}}}}}var li={get:(e,t={})=>$(e,{...t,method:`GET`}),put:(e,t)=>$(e,{method:`PUT`,body:JSON.stringify(t)}),post:(e,t)=>$(e,{method:`POST`,body:JSON.stringify(t)}),delete:e=>$(e,{method:`DELETE`})};function ui(e){if(e!=null){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}}function di(e){if(!e)return;if(e instanceof URLSearchParams)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r:[r];for(let r of e)r!=null&&t.append(n,String(r))}return t}function fi(e,t){let n=t?.toString();return n?`${e}${e.includes(`?`)?`&`:`?`}${n}`:e}function pi(e,t){return e.ok?t:e.error.message}async function mi(){return{agents:await Q.agents.list()}}async function hi(e,t){return await Q.agents.update(e,t)}async function gi(e){return await Q.agents.delete(e)}async function _i(e,t={}){return await Q.channelAuth.start(e,t)}async function vi(e,t){return await Q.channelAuth.poll(e,t)}async function yi(e,t){return await Q.channelAuth.connect(e,t)}async function bi(e={}){return await Q.auth.fetchStatus({timeoutMs:e.timeoutMs??5e3})}async function xi(e){return await Q.auth.setup(e)}async function Si(e){return await Q.auth.login(e)}async function Ci(){return await Q.auth.logout()}async function wi(e){return await Q.auth.updatePassword(e)}async function Ti(e){return await Q.auth.updateEnabled(e)}async function Ei(){return await Q.app.fetchMeta()}async function Di(e={}){return await Q.app.fetchBootstrapStatus(e)}async function Oi(){return await Q.config.fetch()}async function ki(){return await Q.config.fetchMeta()}async function Ai(){return await Q.providers.list()}async function ji(){return await Q.providers.listTemplates()}async function Mi(){return await Q.providers.listModelCatalog()}async function Ni(){return await Q.config.fetchSchema()}async function Pi(e){return await Q.config.updateModel(e)}async function Fi(e){return await Q.config.updateSearch(e)}async function Ii(e,t){return await Q.providers.update(e,t)}async function Li(e={}){return await Q.providers.create(e)}async function Ri(e){return await Q.providers.delete(e)}async function zi(e,t){return await Q.providers.testConnection(e,t)}async function Bi(e,t){return await Q.providers.discoverModels(e,t)}async function Vi(e,t={}){return await Q.providers.startAuth(e,t)}async function Hi(e,t){return await Q.providers.pollAuth(e,t)}async function Ui(e){return await Q.providers.importAuthFromCli(e)}async function Wi(e,t){return await Q.config.updateChannel(e,t)}async function Gi(e){return await Q.config.updateRuntime(e)}async function Ki(e){return await Q.config.updateSecrets(e)}async function qi(e){return await Q.config.updateProductAnalytics(e)}async function Ji(){return await Q.config.fetchProductAnalyticsStatus()}async function Yi(e,t){return await Q.config.executeAction(e,t)}async function Xi(){return await Q.config.fetchChatSessionTypes()}async function Zi(e){return await Q.config.fetchCronJobs(e)}async function Qi(e){return await Q.config.deleteCronJob(e)}async function $i(e,t){return await Q.config.setCronJobEnabled(e,t)}async function ea(e,t){return await Q.config.runCronJob(e,t)}async function ta(e){return await Q.marketplace.fetchItems(e)}async function na(e){return await Q.marketplace.fetchSkillContent(e)}async function ra(){return await Q.marketplace.fetchSkillScenes()}async function ia(e){return await Q.marketplace.install(e)}async function aa(e){return await Q.marketplace.fetchInstalled(e)}async function oa(e){return await Q.marketplace.manage(e)}async function sa(e){return await Q.mcpMarketplace.fetchItems(e)}async function ca(){return await Q.mcpMarketplace.fetchInstalled()}async function la(e){return await Q.mcpMarketplace.fetchContent(e)}async function ua(e){return await Q.mcpMarketplace.install({type:`mcp`,...e})}async function da(e){return await Q.mcpMarketplace.manage({type:`mcp`,...e})}async function fa(e){return await Q.mcpMarketplace.doctor(e)}async function pa(e){return await Q.mcp.testConnection(e)}async function ma(e){return await Q.mcp.createConnection(e)}function ha(e){return`${Mn}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}async function ga(e){return(await Q.sessions.uploadAssets(e)).assets.map(e=>({id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,assetUri:e.assetUri,url:e.url}))}async function _a(e){return await Q.sessions.list(e)}async function va(e,t={}){return await Q.sessions.listMessages(e,t)}async function ya(e,t,n,r){let i=(await va(e,{cursor:n,limit:1,...r?{signal:r}:{}})).messages[0];if(!i||i.id!==t)throw Error(`Session message detail no longer matches ${t}.`);return i}async function ba(e){return await Q.sessions.getUsage(e)}async function xa(e){let t=await $(`/api/ncp/sessions/${encodeURIComponent(e)}/observations`);if(!t.ok)throw Error(t.error.message);return t.data}async function Sa(e,t){let n=await $(`/api/ncp/sessions/${encodeURIComponent(e)}/observations/${t.kind}/${encodeURIComponent(t.id)}`,{method:`PATCH`,body:JSON.stringify({action:t.action})});if(!n.ok)throw Error(n.error.message);return n.data}async function Ca(e,t){return await Q.sessions.listSkills(e,t)}async function wa(e,t){return await Q.sessions.update(e,t)}async function Ta(e){return await Q.sessions.compactContext(e)}async function Ea(e){return await Q.sessions.delete(e)}async function Da(){return await Q.projects.list()}async function Oa(e){return await Q.projects.create(e)}async function ka(e){return await Q.projects.addExisting(e)}function Aa(e){return encodeURIComponent(e)}async function ja(e){let t=await li.get(`/api/preferences/${Aa(e)}`);if(!t.ok)throw Error(t.error.message);return t.data}async function Ma(e,t){let n=await li.put(`/api/preferences/${Aa(e)}`,{value:t});if(!n.ok)throw Error(n.error.message);return n.data}var Na={chat:{modelFavorites:`chat.modelFavorites`,newSessionType:`chat.newSession.sessionType`}};function Pa(e){return e.lastMessageAt??e.createdAt??e.updatedAt}function Fa(e){return e.metadata?.last_activity_preview?.state===`running`}function Ia(e){return[...e].sort((e,t)=>Pa(t).localeCompare(Pa(e)))}function La(e,t){let n=t.updatedAt.localeCompare(e.updatedAt);return n===0?e.status===t.status||t.status===`idle`:n>0}function Ra(e,t){if(e[0]!==`ncp-sessions`)return!1;let n=typeof e[2]==`string`?e[2].trim():``;return!n||t.peerId===n}function za(e,t){if(!e)return e;let n=e.sessions.findIndex(e=>e.sessionId===t.sessionId),r=Ia(n>=0?e.sessions.map((e,r)=>r===n&&La(e,t)?{...t,status:t.status===`idle`&&Fa(t)?e.status:t.status}:e):[...e.sessions,t]);return{...e,sessions:r,total:r.length}}function Ba(e,t){if(!e)return e;let n=t.trim();if(!n)return e;let r=e.sessions.filter(e=>e.sessionId!==n);return r.length===e.sessions.length?e:{...e,sessions:r,total:r.length}}function Va(e,t){e?.setQueriesData({predicate:e=>Ra(e.queryKey,t)},e=>za(e,t))}function Ha(e,t){if(!e)return e;let n=t.sessionKey.trim();if(!n)return e;let r=!1,i=e.sessions.map(e=>e.sessionId!==n||e.status===t.status?e:(r=!0,{...e,status:t.status}));return r?{...e,sessions:i}:e}function Ua(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>Ha(e,t))}function Wa(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>Ba(e,t))}function Ga(e,t){if(e?.invalidateQueries({queryKey:[`ncp-session-pages`]}),t.type===`session.run-status`){Ua(e,t.payload);return}if(t.type===`session.summary.upsert`){Va(e,t.payload.summary),e?.invalidateQueries({queryKey:[`ncp-session-token-usage`,t.payload.summary.sessionId],exact:!0});return}Wa(e,t.payload.sessionKey)}async function Ka(){return await Q.remote.fetchStatus()}async function qa(){return await Q.remote.fetchDoctor()}async function Ja(e){return await Q.remote.startBrowserAuth(e)}async function Ya(e){return await Q.remote.pollBrowserAuth(e)}async function Xa(){return await Q.remote.logout()}async function Za(e){return await Q.remote.updateAccountProfile(e)}async function Qa(e){return await Q.remote.updateSettings(e)}async function $a(e){return await Q.remote.controlService(e)}async function eo(){return await Q.runtimeControl.fetch()}async function to(){return await Q.runtimeControl.startService()}async function no(){return await Q.runtimeControl.restartService()}async function ro(){return await Q.runtimeControl.stopService()}async function io(){let e=await $(`/api/runtime/extensions/catalog`);if(!e.ok)throw Error(e.error.message);return e.data}async function ao(){return await Q.runtimeUpdate.fetch()}async function oo(){return await Q.runtimeUpdate.check()}async function so(){return await Q.runtimeUpdate.download()}async function co(){return await Q.runtimeUpdate.apply()}async function lo(e){return await Q.runtimeUpdate.updateChannel(e)}var uo=`/api/server-paths/content`;async function fo(e){return await Q.serverPaths.browse(e)}async function po(e){return await Q.serverPaths.watch(e)}async function mo(e){await Q.serverPaths.unwatch(e)}async function ho(e){return await Q.serverPaths.createDirectory(e)}async function go(e){return await Q.serverPaths.createFile(e)}async function _o(e){return await Q.serverPaths.renameEntry(e)}async function vo(e){return await Q.serverPaths.deleteEntry(e)}async function yo(e){return await Q.serverPaths.uploadFiles(e)}async function bo(e){return await Q.serverPaths.read(e)}async function xo(e){return await Q.serverPaths.search(e)}function So(e,t){let n=e.trim(),r=n.startsWith(`/`)||/^[a-z]:[\\/]/i.test(n),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams({path:n});return i&&a.set(`basePath`,i),`${Mn}${uo}?${a.toString()}`}export{ra as $,Zn as $t,Ta as A,V as An,yi as At,ha as B,Cr as Bt,Va as C,qe as Cn,Wi as Ct,ka as D,Ve as Dn,Gi as Dt,Ma as E,Ue as En,Ii as Et,Ca as F,M as Fn,hi as Ft,la as G,ar as Gt,ma as H,vr as Ht,ba as I,h as In,Q as It,ua as J,rr as Jt,ca as K,or as Kt,_a as L,T as Ln,ci as Lt,ya as M,Oe as Mn,_i as Mt,va as N,we as Nn,gi as Nt,Oa as O,Re as On,Fi as Ot,xa as P,ye as Pn,mi as Pt,na as Q,Qn as Qt,wa as R,E as Rn,Lr as Rt,Wa as S,Je as Sn,zi as St,ja as T,We as Tn,qi as Tt,pa as U,_r as Ut,ga as V,Er as Vt,fa as W,hr as Wt,aa as X,er as Xt,da as Y,X as Yt,ta as Z,$n as Zt,Ya as _,U as _n,Ui as _t,fo as a,Lt as an,Bi as at,Qa as b,Ye as bn,$i as bt,_o as c,Nt as cn,Oi as ct,po as d,G as dn,Zi as dt,Y as en,ia as et,io as f,jt as fn,Xi as ft,Xa as g,Tt as gn,Ai as gt,Ka as h,Et as hn,ji as ht,vo as i,Rt as in,Ri as it,Ea as j,De as jn,vi as jt,Da as k,Ie as kn,Ki as kt,mo as l,Mt as ln,ki as lt,qa as m,kt as mn,Mi as mt,ho as n,Mn as nn,Li as nt,bo as o,It as on,Yi as ot,$a as p,At as pn,Ji as pt,sa as q,lr as qt,go as r,q as rn,Qi as rt,xo as s,Pt as sn,Ei as st,So as t,J as tn,oa as tt,yo as u,K as un,Ni as ut,Ja as v,Ze as vn,Hi as vt,Na as w,He as wn,Pi as wt,Ga as x,Ge as xn,Vi as xt,Za as y,Xe as yn,ea as yt,Sa as z,u as zn,br as zt};
13
+ `);return r}async function Gr(e,t){let n=e.body?.getReader();if(!n)throw Error(`SSE response body unavailable`);let r=new TextDecoder,i=``,a;try{for(;;){let{value:e,done:o}=await n.read();if(o)break;i+=r.decode(e,{stream:!0}),i=Wr(i,t,e=>{a=e})}i.trim()&&Ur(i,t,e=>{a=e})}finally{n.releaseLock()}return a}function Kr(e,t){let n=e.replace(/\/$/,``);try{let e=new URL(n,window.location.origin);return`${e.protocol===`https:`?`wss:`:e.protocol===`http:`?`ws:`:e.protocol}//${e.host}${t}`}catch{return n.startsWith(`wss://`)||n.startsWith(`ws://`)?`${n}${t}`:n.startsWith(`https://`)?`${n.replace(/^https:/,`wss:`)}${t}`:n.startsWith(`http://`)?`${n.replace(/^http:/,`ws:`)}${t}`:`${n}${t}`}}function qr(e,t){if(!e.ok){let n=Error(e.error?.message||t);return n.code=e.error?.code,n.details=e.error?.details,n}return Error(t)}function Jr(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown error`}return String(e??`Unknown error`)}function Yr(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}var Xr=class{constructor(e){this.wsUrl=e,this.socket=null,this.reconnectTimer=null,this.manualClose=!1,this.subscribers=new Set,this.subscribe=e=>(this.subscribers.add(e),this.subscribers.size===1?this.connect():this.socket?.readyState===WebSocket.OPEN&&e({type:`connection.open`,payload:{}}),()=>{this.subscribers.delete(e),this.subscribers.size===0&&this.disconnect()}),this.emit=e=>{for(let t of this.subscribers)t(e)},this.connect=()=>{if(this.socket&&(this.socket.readyState===WebSocket.CONNECTING||this.socket.readyState===WebSocket.OPEN))return;this.manualClose=!1;let e=new WebSocket(this.wsUrl);this.socket=e,e.onopen=()=>{this.emit({type:`connection.open`,payload:{}})},e.onmessage=e=>{try{let t=JSON.parse(String(e.data??``));this.emit(t)}catch(e){console.error(`Failed to parse websocket message:`,e)}},e.onerror=()=>{this.emit({type:`connection.error`,payload:{message:`websocket error`}})},e.onclose=()=>{this.emit({type:`connection.close`,payload:{}}),this.socket=null,!this.manualClose&&this.subscribers.size>0&&this.scheduleReconnect()}},this.scheduleReconnect=()=>{this.reconnectTimer===null&&(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},3e3))},this.disconnect=()=>{this.manualClose=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.socket?.close(),this.socket=null}}},Zr=class{constructor(e={}){this.options=e,this.request=async e=>{let t=Number.isFinite(e.timeoutMs)&&(e.timeoutMs??0)>0?Math.trunc(e.timeoutMs):null,n=t?new AbortController:null,r=t?window.setTimeout(()=>n?.abort(`Request timed out after ${t}ms: ${e.method} ${e.path}`),t):null,i=Qr(e.body);try{let t=await Vr(this.apiBase,e.path,{method:e.method,...i===void 0?{}:{body:i},...e.headers?{headers:e.headers}:{},signal:n?.signal??e.signal});if(!t.ok)throw qr(t,`Request failed for ${e.method} ${e.path}`);return t.data}catch(t){if(n?.signal.aborted){let{reason:t}=n.signal;throw Error(typeof t==`string`&&t.trim()?t:`Request timed out: ${e.method} ${e.path}`)}throw t instanceof Error?t:Yr(`Request failed for ${e.method} ${e.path} | ${Jr(t)}`,t)}finally{r!==null&&window.clearTimeout(r)}},this.openStream=e=>{let t=new AbortController,n=()=>t.abort();return e.signal&&(e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0})),{finished:(async()=>{let r;try{r=await fetch(`${this.apiBase}${e.path}`,{method:e.method,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`text/event-stream`},...e.body===void 0?{}:{body:JSON.stringify(e.body)},signal:t.signal})}catch(t){throw X.reportTransportFailure(Jr(t)),Yr(`Stream request failed for ${e.method} ${e.path} | ${Jr(t)}`,t)}if(!r.ok){let t=(await r.text()).trim();throw Error(t?`Stream request failed for ${e.method} ${e.path} | HTTP ${r.status} | ${t}`:`Stream request failed for ${e.method} ${e.path} | HTTP ${r.status}`)}try{return await Gr(r,e.onEvent)}finally{e.signal?.removeEventListener(`abort`,n)}})(),cancel:()=>t.abort()}},this.subscribe=e=>this.realtimeGateway.subscribe(e),this.apiBase=e.apiBase??((void 0)?.trim().replace(/\/$/,``)||(typeof window<`u`?window.location.origin:`http://127.0.0.1:55667`)),this.realtimeGateway=new Xr(Kr(this.apiBase,e.wsPath??`/ws`))}};function Qr(e){if(e!==void 0)return e instanceof FormData||e instanceof URLSearchParams||e instanceof Blob||e instanceof ArrayBuffer||typeof e==`string`?e:JSON.stringify(e)}function $r(e,t,n){if(typeof e==`object`&&e&&`ok`in e){let r=e;if(r.ok===!1&&r.error?.message){let e=Error(r.error.message);return e.code=r.error.code,e.details=r.error.details,e.status=t,e}if(r.ok===!0)return Error(n)}return typeof e==`string`&&e.trim()?Error(e.trim()):Error(`${n} (${t})`)}function ei(e){if(typeof e==`object`&&e&&`ok`in e){let t=e;if(t.ok===!1){let e=Error(t.error?.message??`Remote request failed.`);throw e.code=t.error?.code,e.details=t.error?.details,e}if(t.ok===!0)return t.data}return e}function ti(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var ni=15e3,ri=class{constructor(e,t=(void 0)?.trim().replace(/\/$/,``)||(typeof window<`u`?window.location.origin:`http://127.0.0.1:55667`)){this.runtime=e,this.apiBase=t,this.socket=null,this.connectPromise=null,this.connectTimeoutId=null,this.reconnectTimer=null,this.manualClose=!1,this.subscribers=new Set,this.pendingRequests=new Map,this.pendingStreams=new Map,this.request=async e=>{await this.ensureSocket();let t=ti(`req`),n=Number.isFinite(e.timeoutMs)&&(e.timeoutMs??0)>0?Math.trunc(e.timeoutMs):ni;return await new Promise((r,i)=>{let a=window.setTimeout(()=>{this.pendingRequests.delete(t),i(Error(`Timed out waiting for remote request response after ${n}ms: ${e.method} ${e.path}`))},n);this.pendingRequests.set(t,{resolve:e=>r(e),reject:i,timeoutId:a}),this.send({type:`request`,id:t,target:{method:e.method,path:e.path,...e.headers?{headers:e.headers}:{},...e.body===void 0?{}:{body:e.body}}})})},this.openStream=e=>{let t=ti(`stream`),n=!1,r=e=>{n||(n=!0,a(e))},i,a,o=new Promise((e,t)=>{i=e,a=t}),s=()=>{this.pendingStreams.delete(t),!n&&(n=!0,this.send({type:`stream.cancel`,streamId:t}),a(Error(`stream cancelled`)))};this.pendingStreams.set(t,{onEvent:e.onEvent,finalResult:void 0,resolve:e=>{n||(n=!0,i(e))},reject:e=>{n||(n=!0,a(e))}});let c=()=>s();return e.signal&&(e.signal.aborted?s():e.signal.addEventListener(`abort`,c,{once:!0})),this.ensureSocket().then(()=>{n||this.send({type:`stream.open`,streamId:t,target:{method:e.method,path:e.path,...e.body===void 0?{}:{body:e.body}}})}).catch(e=>{this.pendingStreams.delete(t),r(e instanceof Error?e:Error(String(e)))}),{finished:o.finally(()=>{e.signal?.removeEventListener(`abort`,c),this.pendingStreams.delete(t)}),cancel:s}},this.subscribe=e=>(this.subscribers.add(e),this.ensureSocket().catch(t=>{e({type:`connection.error`,payload:{message:t instanceof Error?t.message:String(t)}})}),()=>{this.subscribers.delete(e)}),this.emit=e=>{for(let t of this.subscribers)t(e)},this.send=e=>{if(!this.socket||this.socket.readyState!==WebSocket.OPEN)throw Error(`Remote transport websocket is not connected.`);this.socket.send(JSON.stringify(e))},this.ensureSocket=async()=>{if(this.socket?.readyState===WebSocket.OPEN&&this.connectPromise===null)return;if(this.connectPromise)return await this.connectPromise;let e=Kr(this.apiBase,this.runtime.wsPath);this.manualClose=!1,this.connectPromise=new Promise((t,n)=>{let r=new WebSocket(e);this.socket=r;let i=!1,a=()=>{this.connectTimeoutId!==null&&(window.clearTimeout(this.connectTimeoutId),this.connectTimeoutId=null)};this.connectTimeoutId=window.setTimeout(()=>{this.connectTimeoutId=null,n(Error(`Timed out waiting for remote transport websocket.`)),r.close()},8e3),r.onopen=()=>{i=!0,a(),this.connectPromise=null,t(),this.emit({type:`connection.open`,payload:{}})},r.onmessage=e=>{try{let t=JSON.parse(String(e.data??``));if(t.type===`connection.ready`)return;this.handleFrame(t)}catch(e){console.error(`Failed to parse remote websocket frame:`,e)}},r.onerror=()=>{this.emit({type:`connection.error`,payload:{message:`remote websocket error`}})},r.onclose=()=>{a();let e=this.connectPromise!==null;this.socket=null,this.connectPromise=null,this.failPendingWork(Error(`Remote transport connection closed.`)),this.emit({type:`connection.close`,payload:{}}),e&&!i&&n(Error(`Remote transport connection closed before ready.`)),!this.manualClose&&this.subscribers.size>0&&this.scheduleReconnect()}});let{connectPromise:t}=this;return await t},this.scheduleReconnect=()=>{this.reconnectTimer===null&&(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.ensureSocket().catch(()=>void 0)},3e3))},this.failPendingWork=e=>{for(let t of this.pendingRequests.values())window.clearTimeout(t.timeoutId),t.reject(e);this.pendingRequests.clear();for(let t of this.pendingStreams.values())t.reject(e);this.pendingStreams.clear()},this.handleFrame=e=>{if(e.type===`response`||e.type===`request.error`){this.handleRequestFrame(e);return}if(e.type===`stream.event`||e.type===`stream.end`||e.type===`stream.error`){this.handleStreamFrame(e);return}if(e.type===`event`){this.emit(e.event);return}e.type===`connection.error`&&this.emit({type:`connection.error`,payload:{message:e.message}})},this.handleRequestFrame=e=>{let t=this.pendingRequests.get(e.id);if(t){if(this.pendingRequests.delete(e.id),window.clearTimeout(t.timeoutId),e.type===`request.error`){t.reject(Error(e.message));return}if(e.status>=400){t.reject($r(e.body,e.status,`Remote request failed.`));return}try{t.resolve(ei(e.body))}catch(e){t.reject(e instanceof Error?e:Error(String(e)))}}},this.handleStreamFrame=e=>{let t=this.pendingStreams.get(e.streamId);if(t){if(e.type===`stream.event`){try{e.event===`final`&&(t.finalResult=e.payload),t.onEvent({name:e.event,payload:e.payload})}catch(n){this.pendingStreams.delete(e.streamId),t.reject(n instanceof Error?n:Error(String(n)))}return}if(this.pendingStreams.delete(e.streamId),e.type===`stream.end`){t.resolve(t.finalResult);return}t.reject(Error(e.message))}}}},ii=`/_remote/runtime`,ai={mode:`remote`,protocolVersion:1,wsPath:`/_remote/ws`};async function oi(e){let t=`${e.replace(/\/$/,``)}${ii}`,n;try{n=await fetch(t,{method:`GET`,credentials:`include`,cache:`no-store`})}catch{return new Zr({apiBase:e})}if(n.status===404)return new Zr({apiBase:e});if(!(n.headers.get(`content-type`)?.toLowerCase()??``).includes(`application/json`))return n.status>=400?new ri(ai,e):new Zr({apiBase:e});let r=null;try{r=await n.json()}catch{return n.status>=400?new ri(ai,e):new Zr({apiBase:e})}return n.ok&&r.ok&&r.data?.mode===`remote`?new ri(r.data,e):n.status>=400?new ri(ai,e):new Zr({apiBase:e})}var si=new class{constructor(e=(void 0)?.trim().replace(/\/$/,``)||(typeof window<`u`?window.location.origin:`http://127.0.0.1:55667`)){this.apiBase=e,this.transportPromise=null,this.getTransport=async()=>(this.transportPromise||=oi(this.apiBase),await this.transportPromise),this.request=async e=>await(await this.getTransport()).request(e),this.openStream=e=>{let t=null,n,r,i=new Promise((e,t)=>{n=e,r=t});return this.getTransport().then(i=>{t=i.openStream(e),t.finished.then(n).catch(e=>{r(e instanceof Error?e:Error(String(e)))})}).catch(e=>{r(e instanceof Error?e:Error(String(e)))}),{finished:i,cancel:()=>t?.cancel()}},this.subscribe=e=>{let t=()=>{},n=!0;return this.getTransport().then(r=>{n&&(t=r.subscribe(e))}).catch(t=>{e({type:`connection.error`,payload:{message:t instanceof Error?t.message:String(t)}})}),()=>{n=!1,t()}}}};function ci(e){let t=e.trim().toLowerCase();return t?[`failed to fetch`,`networkerror`,`network request failed`,`load failed`,`request timed out`,`timed out waiting for remote request response`,`remote transport connection closed`,`websocket error`,`fetch failed on `,`stream request failed for `,`ncp fetch failed for `].some(e=>t.includes(e)):!1}var Q=new kn({baseUrl:jn,transport:{request:async({body:e,headers:t,method:n,path:r,query:i,signal:a,timeoutMs:o})=>await si.request({method:n,path:fi(r,di(i)),...e===void 0?{}:{body:e},...t?{headers:t}:{},...a?{signal:a}:{},...o===void 0?{}:{timeoutMs:o}}),upload:async({formData:e,headers:t,path:n,signal:r})=>{let i=await fetch(`${jn}${n}`,{method:`POST`,body:e,credentials:`include`,...t?{headers:t}:{},...r?{signal:r}:{}}),a=await i.json();if(!i.ok||!a.ok)throw new q({message:pi(a,`Upload failed for ${n}`),status:i.status,code:a.ok?void 0:a.error.code,details:a.ok?void 0:a.error.details});return a.data},subscribe:e=>si.subscribe(e)}});async function $(e,t={}){let n=(t.method||`GET`).toUpperCase();try{return{ok:!0,data:await si.request({method:n,path:e,...t.timeoutMs===void 0?{}:{timeoutMs:t.timeoutMs},...t.body===void 0?{}:{body:ui(t.body)}})}}catch(t){return{ok:!1,error:{code:`REQUEST_FAILED`,message:t instanceof Error?t.message:String(t),details:{method:n,endpoint:e}}}}}var li={get:(e,t={})=>$(e,{...t,method:`GET`}),put:(e,t)=>$(e,{method:`PUT`,body:JSON.stringify(t)}),post:(e,t)=>$(e,{method:`POST`,body:JSON.stringify(t)}),delete:e=>$(e,{method:`DELETE`})};function ui(e){if(e!=null){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}}function di(e){if(!e)return;if(e instanceof URLSearchParams)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r:[r];for(let r of e)r!=null&&t.append(n,String(r))}return t}function fi(e,t){let n=t?.toString();return n?`${e}${e.includes(`?`)?`&`:`?`}${n}`:e}function pi(e,t){return e.ok?t:e.error.message}async function mi(){return{agents:await Q.agents.list()}}async function hi(e,t){return await Q.agents.update(e,t)}async function gi(e){return await Q.agents.delete(e)}async function _i(e,t={}){return await Q.channelAuth.start(e,t)}async function vi(e,t){return await Q.channelAuth.poll(e,t)}async function yi(e,t){return await Q.channelAuth.connect(e,t)}async function bi(e={}){return await Q.auth.fetchStatus({timeoutMs:e.timeoutMs??5e3})}async function xi(e){return await Q.auth.setup(e)}async function Si(e){return await Q.auth.login(e)}async function Ci(){return await Q.auth.logout()}async function wi(e){return await Q.auth.updatePassword(e)}async function Ti(e){return await Q.auth.updateEnabled(e)}async function Ei(){return await Q.app.fetchMeta()}async function Di(e={}){return await Q.app.fetchBootstrapStatus(e)}async function Oi(){return await Q.config.fetch()}async function ki(){return await Q.config.fetchMeta()}async function Ai(){return await Q.providers.list()}async function ji(){return await Q.providers.listTemplates()}async function Mi(){return await Q.providers.listModelCatalog()}async function Ni(){return await Q.config.fetchSchema()}async function Pi(e){return await Q.config.updateModel(e)}async function Fi(e){return await Q.config.updateSearch(e)}async function Ii(e,t){return await Q.providers.update(e,t)}async function Li(e={}){return await Q.providers.create(e)}async function Ri(e){return await Q.providers.delete(e)}async function zi(e,t){return await Q.providers.testConnection(e,t)}async function Bi(e,t){return await Q.providers.discoverModels(e,t)}async function Vi(e,t={}){return await Q.providers.startAuth(e,t)}async function Hi(e,t){return await Q.providers.pollAuth(e,t)}async function Ui(e){return await Q.providers.importAuthFromCli(e)}async function Wi(e,t){return await Q.config.updateChannel(e,t)}async function Gi(e){return await Q.config.updateRuntime(e)}async function Ki(e){return await Q.config.updateSecrets(e)}async function qi(e){return await Q.config.updateProductAnalytics(e)}async function Ji(){return await Q.config.fetchProductAnalyticsStatus()}async function Yi(e,t){return await Q.config.executeAction(e,t)}async function Xi(){return await Q.config.fetchChatSessionTypes()}async function Zi(e){return await Q.config.fetchCronJobs(e)}async function Qi(e){return await Q.config.deleteCronJob(e)}async function $i(e,t){return await Q.config.setCronJobEnabled(e,t)}async function ea(e,t){return await Q.config.runCronJob(e,t)}async function ta(e){return await Q.marketplace.fetchItems(e)}async function na(e){return await Q.marketplace.fetchSkillContent(e)}async function ra(){return await Q.marketplace.fetchSkillScenes()}async function ia(e){return await Q.marketplace.install(e)}async function aa(e){return await Q.marketplace.fetchInstalled(e)}async function oa(e){return await Q.marketplace.manage(e)}async function sa(e){return await Q.mcpMarketplace.fetchItems(e)}async function ca(){return await Q.mcpMarketplace.fetchInstalled()}async function la(e){return await Q.mcpMarketplace.fetchContent(e)}async function ua(e){return await Q.mcpMarketplace.install({type:`mcp`,...e})}async function da(e){return await Q.mcpMarketplace.manage({type:`mcp`,...e})}async function fa(e){return await Q.mcpMarketplace.doctor(e)}async function pa(e){return await Q.mcp.testConnection(e)}async function ma(e){return await Q.mcp.createConnection(e)}function ha(e){return`${jn}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}async function ga(e){return(await Q.sessions.uploadAssets(e)).assets.map(e=>({id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,assetUri:e.assetUri,url:e.url}))}async function _a(e){return await Q.sessions.list(e)}async function va(e,t={}){return await Q.sessions.listMessages(e,t)}async function ya(e,t,n,r){let i=(await va(e,{cursor:n,limit:1,...r?{signal:r}:{}})).messages[0];if(!i||i.id!==t)throw Error(`Session message detail no longer matches ${t}.`);return i}async function ba(e){return await Q.sessions.getUsage(e)}async function xa(e){let t=await $(`/api/ncp/sessions/${encodeURIComponent(e)}/observations`);if(!t.ok)throw Error(t.error.message);return t.data}async function Sa(e,t){let n=await $(`/api/ncp/sessions/${encodeURIComponent(e)}/observations/${t.kind}/${encodeURIComponent(t.id)}`,{method:`PATCH`,body:JSON.stringify({action:t.action})});if(!n.ok)throw Error(n.error.message);return n.data}async function Ca(e,t){return await Q.sessions.listSkills(e,t)}async function wa(e,t){return await Q.sessions.update(e,t)}async function Ta(e){return await Q.sessions.compactContext(e)}async function Ea(e){return await Q.sessions.delete(e)}async function Da(){return await Q.projects.list()}async function Oa(e){return await Q.projects.create(e)}async function ka(e){return await Q.projects.addExisting(e)}function Aa(e){return encodeURIComponent(e)}async function ja(e){let t=await li.get(`/api/preferences/${Aa(e)}`);if(!t.ok)throw Error(t.error.message);return t.data}async function Ma(e,t){let n=await li.put(`/api/preferences/${Aa(e)}`,{value:t});if(!n.ok)throw Error(n.error.message);return n.data}var Na={chat:{modelFavorites:`chat.modelFavorites`,newSessionType:`chat.newSession.sessionType`}};function Pa(e){return e.lastMessageAt??e.createdAt??e.updatedAt}function Fa(e){return e.metadata?.last_activity_preview?.state===`running`}function Ia(e){return[...e].sort((e,t)=>Pa(t).localeCompare(Pa(e)))}function La(e,t){let n=t.updatedAt.localeCompare(e.updatedAt);return n===0?e.status===t.status||t.status===`idle`:n>0}function Ra(e,t){if(e[0]!==`ncp-sessions`)return!1;let n=typeof e[2]==`string`?e[2].trim():``;return!n||t.peerId===n}function za(e,t){if(!e)return e;let n=e.sessions.findIndex(e=>e.sessionId===t.sessionId),r=Ia(n>=0?e.sessions.map((e,r)=>r===n&&La(e,t)?{...t,status:t.status===`idle`&&Fa(t)?e.status:t.status}:e):[...e.sessions,t]);return{...e,sessions:r,total:r.length}}function Ba(e,t){if(!e)return e;let n=t.trim();if(!n)return e;let r=e.sessions.filter(e=>e.sessionId!==n);return r.length===e.sessions.length?e:{...e,sessions:r,total:r.length}}function Va(e,t){e?.setQueriesData({predicate:e=>Ra(e.queryKey,t)},e=>za(e,t))}function Ha(e,t){if(!e)return e;let n=t.sessionKey.trim();if(!n)return e;let r=!1,i=e.sessions.map(e=>e.sessionId!==n||e.status===t.status?e:(r=!0,{...e,status:t.status}));return r?{...e,sessions:i}:e}function Ua(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>Ha(e,t))}function Wa(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>Ba(e,t))}function Ga(e,t){if(e?.invalidateQueries({queryKey:[`ncp-session-pages`]}),t.type===`session.run-status`){Ua(e,t.payload);return}if(t.type===`session.summary.upsert`){Va(e,t.payload.summary),e?.invalidateQueries({queryKey:[`ncp-session-token-usage`,t.payload.summary.sessionId],exact:!0});return}Wa(e,t.payload.sessionKey)}async function Ka(){return await Q.remote.fetchStatus()}async function qa(){return await Q.remote.fetchDoctor()}async function Ja(e){return await Q.remote.startBrowserAuth(e)}async function Ya(e){return await Q.remote.pollBrowserAuth(e)}async function Xa(){return await Q.remote.logout()}async function Za(e){return await Q.remote.updateAccountProfile(e)}async function Qa(e){return await Q.remote.updateSettings(e)}async function $a(e){return await Q.remote.controlService(e)}async function eo(){return await Q.runtimeControl.fetch()}async function to(){return await Q.runtimeControl.startService()}async function no(){return await Q.runtimeControl.restartService()}async function ro(){return await Q.runtimeControl.stopService()}async function io(){let e=await $(`/api/runtime/extensions/catalog`);if(!e.ok)throw Error(e.error.message);return e.data}async function ao(){return await Q.runtimeUpdate.fetch()}async function oo(){return await Q.runtimeUpdate.check()}async function so(){return await Q.runtimeUpdate.download()}async function co(){return await Q.runtimeUpdate.apply()}async function lo(e){return await Q.runtimeUpdate.updateChannel(e)}var uo=`/api/server-paths/content`;async function fo(e){return await Q.serverPaths.browse(e)}async function po(e){return await Q.serverPaths.watch(e)}async function mo(e){await Q.serverPaths.unwatch(e)}async function ho(e){return await Q.serverPaths.createDirectory(e)}async function go(e){return await Q.serverPaths.createFile(e)}async function _o(e){return await Q.serverPaths.renameEntry(e)}async function vo(e){return await Q.serverPaths.deleteEntry(e)}async function yo(e){return await Q.serverPaths.uploadFiles(e)}async function bo(e){return await Q.serverPaths.read(e)}async function xo(e){return await Q.serverPaths.search(e)}function So(e,t){let n=e.trim(),r=n.startsWith(`/`)||/^[a-z]:[\\/]/i.test(n),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams({path:n});return i&&a.set(`basePath`,i),`${jn}${uo}?${a.toString()}`}export{ra as $,Xn as $t,Ta as A,V as An,yi as At,ha as B,Cr as Bt,Va as C,qe as Cn,Wi as Ct,ka as D,Ve as Dn,Gi as Dt,Ma as E,Ue as En,Ii as Et,Ca as F,M as Fn,hi as Ft,la as G,ir as Gt,ma as H,vr as Ht,ba as I,h as In,Q as It,ua as J,nr as Jt,ca as K,ar as Kt,_a as L,T as Ln,ci as Lt,ya as M,Oe as Mn,_i as Mt,va as N,we as Nn,gi as Nt,Oa as O,Re as On,Fi as Ot,xa as P,ye as Pn,mi as Pt,na as Q,Zn as Qt,wa as R,E as Rn,Lr as Rt,Wa as S,Je as Sn,zi as St,ja as T,We as Tn,qi as Tt,pa as U,_r as Ut,ga as V,Er as Vt,fa as W,hr as Wt,aa as X,$n as Xt,da as Y,Z as Yt,ta as Z,Qn as Zt,Ya as _,U as _n,Ui as _t,fo as a,Lt as an,Bi as at,Qa as b,Ye as bn,$i as bt,_o as c,Nt as cn,Oi as ct,po as d,G as dn,Zi as dt,X as en,ia as et,io as f,jt as fn,Xi as ft,Xa as g,Tt as gn,Ai as gt,Ka as h,Et as hn,ji as ht,vo as i,Rt as in,Ri as it,Ea as j,De as jn,vi as jt,Da as k,Ie as kn,Ki as kt,mo as l,Mt as ln,ki as lt,qa as m,kt as mn,Mi as mt,ho as n,jn as nn,Li as nt,bo as o,It as on,Yi as ot,$a as p,At as pn,Ji as pt,sa as q,cr as qt,go as r,q as rn,Qi as rt,xo as s,Pt as sn,Ei as st,So as t,Y as tn,oa as tt,yo as u,K as un,Ni as ut,Ja as v,Ze as vn,Hi as vt,Na as w,He as wn,Pi as wt,Ga as x,Ge as xn,Vi as xt,Za as y,Xe as yn,ea as yt,Sa as z,u as zn,br as zt};
@@ -1 +1 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r,a as i,o as a}from"./react-CVFx225w.js";import{Ht as o,an as s,in as c,on as l,sn as u}from"./api-aEu9cEI8.js";import{x as d}from"./mcp-marketplace-page-COUopIOc.js";import{a as f,i as p,n as m,r as h,t as g,w as _}from"./select-DPKCWajZ.js";import{H as v,f as y,n as b,u as x}from"./index-zuqzAvNx.js";var S=e(n(),1);function C(){let{language:e,setLanguage:t}=d();return{currentLanguage:e,currentLanguageLabel:a.find(t=>t.value===e)?.label??e,languageOptions:a,selectLanguage:(0,S.useCallback)(n=>{e!==n&&(t(n),window.location.reload())},[e,t])}}var w=t(),T=[{value:`card`,labelKey:`chatMessageLayoutCard`,descriptionKey:`chatMessageLayoutCardDescription`},{value:`flat`,labelKey:`chatMessageLayoutFlat`,descriptionKey:`chatMessageLayoutFlatDescription`}];function E(){let{theme:e,setTheme:t}=x(),{currentLanguage:n,languageOptions:a,selectLanguage:d}=C(),S=v(e=>e.layout),E=v(e=>e.setLayout),D=b(e=>e.isVisible),O=b(e=>e.setVisible);return(0,w.jsx)(u,{title:i(`appearance`),children:(0,w.jsx)(l,{children:(0,w.jsxs)(s,{children:[(0,w.jsx)(c,{title:i(`theme`),control:(0,w.jsxs)(g,{value:e,onValueChange:e=>t(e),children:[(0,w.jsx)(p,{"aria-label":i(`theme`),className:`w-36 sm:w-44`,children:(0,w.jsx)(f,{})}),(0,w.jsx)(m,{children:y.map(e=>(0,w.jsx)(h,{value:e.value,children:i(e.labelKey)},e.value))})]})}),(0,w.jsx)(c,{title:i(`language`),control:(0,w.jsxs)(g,{value:n,onValueChange:e=>d(e),children:[(0,w.jsx)(p,{"aria-label":i(`language`),className:`w-36 sm:w-44`,children:(0,w.jsx)(f,{})}),(0,w.jsx)(m,{children:a.map(e=>(0,w.jsx)(h,{value:e.value,children:e.label},e.value))})]})}),(0,w.jsx)(c,{title:i(`chatMessageLayoutTitle`),description:i(`chatMessageLayoutDescription`),layout:`stacked`,children:(0,w.jsx)(`div`,{role:`radiogroup`,"aria-label":i(`chatMessageLayoutTitle`),className:`grid gap-1 rounded-xl bg-background/65 p-1 sm:grid-cols-2`,children:T.map(e=>{let t=e.value===S;return(0,w.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>E(e.value),className:r(`flex min-w-0 items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,t?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:bg-card/60 hover:text-foreground`),children:[(0,w.jsx)(`span`,{className:r(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full ring-1`,t?`bg-primary text-primary-foreground ring-primary`:`bg-background ring-border`),children:t?(0,w.jsx)(_,{className:`h-2.5 w-2.5`,strokeWidth:3}):null}),(0,w.jsxs)(`span`,{className:`min-w-0`,children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium`,children:i(e.labelKey)}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-muted-foreground`,children:i(e.descriptionKey)})]})]},e.value)})})}),(0,w.jsx)(c,{title:i(`sideDockVisibilityTitle`),description:i(`sideDockVisibilityDescription`),control:(0,w.jsx)(o,{id:`appearance-side-dock-visible`,"aria-label":i(`sideDockVisibilityTitle`),checked:D,onCheckedChange:O})})]})})})}export{E as AppearanceSettingsPage};
1
+ import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r,a as i,o as a}from"./react-CVFx225w.js";import{Ht as o,an as s,in as c,on as l,sn as u}from"./api-n96IfCKb.js";import{x as d}from"./mcp-marketplace-page-s9PTnSDT.js";import{a as f,i as p,n as m,r as h,t as g,w as _}from"./select-DPKCWajZ.js";import{H as v,f as y,n as b,u as x}from"./index-CLw9DuCJ.js";var S=e(n(),1);function C(){let{language:e,setLanguage:t}=d();return{currentLanguage:e,currentLanguageLabel:a.find(t=>t.value===e)?.label??e,languageOptions:a,selectLanguage:(0,S.useCallback)(n=>{e!==n&&(t(n),window.location.reload())},[e,t])}}var w=t(),T=[{value:`card`,labelKey:`chatMessageLayoutCard`,descriptionKey:`chatMessageLayoutCardDescription`},{value:`flat`,labelKey:`chatMessageLayoutFlat`,descriptionKey:`chatMessageLayoutFlatDescription`}];function E(){let{theme:e,setTheme:t}=x(),{currentLanguage:n,languageOptions:a,selectLanguage:d}=C(),S=v(e=>e.layout),E=v(e=>e.setLayout),D=b(e=>e.isVisible),O=b(e=>e.setVisible);return(0,w.jsx)(u,{title:i(`appearance`),children:(0,w.jsx)(l,{children:(0,w.jsxs)(s,{children:[(0,w.jsx)(c,{title:i(`theme`),control:(0,w.jsxs)(g,{value:e,onValueChange:e=>t(e),children:[(0,w.jsx)(p,{"aria-label":i(`theme`),className:`w-36 sm:w-44`,children:(0,w.jsx)(f,{})}),(0,w.jsx)(m,{children:y.map(e=>(0,w.jsx)(h,{value:e.value,children:i(e.labelKey)},e.value))})]})}),(0,w.jsx)(c,{title:i(`language`),control:(0,w.jsxs)(g,{value:n,onValueChange:e=>d(e),children:[(0,w.jsx)(p,{"aria-label":i(`language`),className:`w-36 sm:w-44`,children:(0,w.jsx)(f,{})}),(0,w.jsx)(m,{children:a.map(e=>(0,w.jsx)(h,{value:e.value,children:e.label},e.value))})]})}),(0,w.jsx)(c,{title:i(`chatMessageLayoutTitle`),description:i(`chatMessageLayoutDescription`),layout:`stacked`,children:(0,w.jsx)(`div`,{role:`radiogroup`,"aria-label":i(`chatMessageLayoutTitle`),className:`grid gap-1 rounded-xl bg-background/65 p-1 sm:grid-cols-2`,children:T.map(e=>{let t=e.value===S;return(0,w.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>E(e.value),className:r(`flex min-w-0 items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,t?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:bg-card/60 hover:text-foreground`),children:[(0,w.jsx)(`span`,{className:r(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full ring-1`,t?`bg-primary text-primary-foreground ring-primary`:`bg-background ring-border`),children:t?(0,w.jsx)(_,{className:`h-2.5 w-2.5`,strokeWidth:3}):null}),(0,w.jsxs)(`span`,{className:`min-w-0`,children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium`,children:i(e.labelKey)}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-muted-foreground`,children:i(e.descriptionKey)})]})]},e.value)})})}),(0,w.jsx)(c,{title:i(`sideDockVisibilityTitle`),description:i(`sideDockVisibilityDescription`),control:(0,w.jsx)(o,{id:`appearance-side-dock-visible`,"aria-label":i(`sideDockVisibilityTitle`),checked:D,onCheckedChange:O})})]})})})}export{E as AppearanceSettingsPage};
@@ -1,4 +1,4 @@
1
- import{i as e,t}from"./chunk-DseTPa7n.js";import{B as n,F as r,H as i,L as a,a as o,r as s,s as c}from"./react-CVFx225w.js";import{n as l,t as u}from"./navigation-link-Ci4Z7Phi.js";import{An as d,At as f,Ht as p,It as m,Mt as h,_n as g,dn as _,fn as v,jt as y,sn as b,un as x,vn as S,yn as C}from"./api-aEu9cEI8.js";import{C as w,a as T,i as E,n as D,r as O,t as k}from"./select-DPKCWajZ.js";import{t as A}from"./createLucideIcon-CgM0rnsa.js";import{t as ee}from"./search-msqk2-rd.js";import{t as te}from"./book-open-DYRapW_h.js";import{t as ne}from"./loader-circle-D9etMT9f.js";import{t as re}from"./x-Dp5GAFmP.js";import{t as ie}from"./tag-chip-ClBWeQ4p.js";import{G as ae,J as j,K as M,St as oe,U as se,W as N,_t as ce,b as le,g as P,h as F,k as ue,m as I,mt as de,p as fe,q as pe,wt as me,xt as he}from"./index-zuqzAvNx.js";import{t as ge}from"./form-actions-CzGmrPAv.js";import{t as L}from"./config-hints-nV5HPOvq.js";import{a as _e,c as ve,i as ye,l as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./config-split-page-DJDp86Ne.js";var Ee=A(`Hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),De=A(`Mail`,[[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}]]),R=A(`MessageCircleMore`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),z=A(`QrCode`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),Oe=A(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),B=e(i(),1),V=n();function ke({value:e,onChange:t,className:n,placeholder:r=``}){let[i,s]=(0,B.useState)(``),c=n=>{n.key===`Enter`&&i.trim()?(n.preventDefault(),t([...e,i.trim()]),s(``)):n.key===`Backspace`&&!i&&e.length>0&&t(e.slice(0,-1))},l=n=>{t(e.filter((e,t)=>t!==n))};return(0,V.jsxs)(`div`,{className:a(`flex min-h-[42px] flex-wrap gap-2 rounded-xl border border-gray-200/80 bg-white p-2`,n),children:[e.map((e,t)=>(0,V.jsxs)(ie,{tone:`info`,className:`gap-1 px-2 py-1 text-sm`,children:[e,(0,V.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`transition-colors hover:text-rose-200`,children:(0,V.jsx)(re,{className:`h-3 w-3`})})]},t)),(0,V.jsx)(`input`,{type:`text`,value:i,onChange:e=>s(e.target.value),onKeyDown:c,className:`flex-1 outline-none min-w-[100px] bg-transparent text-sm`,placeholder:r||o(`enterTag`)})]})}function Ae(e){return e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?(0,V.jsx)(oe,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`url`)||e.includes(`host`)?(0,V.jsx)(me,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`email`)||e.includes(`mail`)?(0,V.jsx)(De,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`id`)||e.includes(`from`)?(0,V.jsx)(Ee,{className:`h-3.5 w-3.5 text-gray-500`}):e===`enabled`||e===`consentGranted`?(0,V.jsx)(Oe,{className:`h-3.5 w-3.5 text-gray-500`}):(0,V.jsx)(ce,{className:`h-3.5 w-3.5 text-gray-500`})}function je({channelName:e,fields:t,formData:n,jsonDrafts:r,setJsonDrafts:i,updateField:a,uiHints:s}){return(0,V.jsx)(V.Fragment,{children:t.map(t=>{let c=L(`channels.${e}.${t.name}`,s),l=c?.label??t.label,u=c?.placeholder;return(0,V.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,V.jsxs)(x,{htmlFor:t.name,className:`flex items-center gap-2 text-sm font-medium text-gray-900`,children:[Ae(t.name),l]}),t.type===`boolean`&&(0,V.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl bg-gray-50 p-3`,children:[(0,V.jsx)(`span`,{className:`text-sm text-gray-500`,children:n[t.name]?o(`enabled`):o(`disabled`)}),(0,V.jsx)(p,{id:t.name,checked:n[t.name]||!1,onCheckedChange:e=>a(t.name,e),className:`data-[state=checked]:bg-emerald-500`})]}),(t.type===`text`||t.type===`email`)&&(0,V.jsx)(_,{id:t.name,type:t.type,value:n[t.name]||``,onChange:e=>a(t.name,e.target.value),placeholder:u,className:`rounded-xl`}),t.type===`password`&&(0,V.jsx)(_,{id:t.name,type:`password`,value:n[t.name]||``,onChange:e=>a(t.name,e.target.value),placeholder:u??o(`leaveBlankToKeepUnchanged`),className:`rounded-xl`}),t.type===`number`&&(0,V.jsx)(_,{id:t.name,type:`number`,value:n[t.name]||0,onChange:e=>a(t.name,parseInt(e.target.value,10)||0),placeholder:u,className:`rounded-xl`}),t.type===`tags`&&(0,V.jsx)(ke,{value:n[t.name]||[],onChange:e=>a(t.name,e)}),t.type===`select`&&(0,V.jsxs)(k,{value:n[t.name]||``,onValueChange:e=>a(t.name,e),children:[(0,V.jsx)(E,{className:`rounded-xl`,children:(0,V.jsx)(T,{})}),(0,V.jsx)(D,{children:(t.options??[]).map(e=>(0,V.jsx)(O,{value:e.value,children:e.label},e.value))})]}),t.type===`json`&&(0,V.jsx)(`textarea`,{id:t.name,value:r[t.name]??`{}`,onChange:e=>i(n=>({...n,[t.name]:e.target.value})),className:`min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`})]},t.name)})})}var Me=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),H=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),U=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Ne=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Pe=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Fe=t((e=>{var t=H().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Ie=t((e=>{var t=H().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Le=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),W=t((e=>{var t=U(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Re=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),ze=t((e=>{var t=Re();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Be=t(((e,t)=>{var n=ze();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),G=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),K=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
1
+ import{i as e,t}from"./chunk-DseTPa7n.js";import{B as n,F as r,H as i,L as a,a as o,r as s,s as c}from"./react-CVFx225w.js";import{n as l,t as u}from"./navigation-link-Ci4Z7Phi.js";import{An as d,At as f,Ht as p,It as m,Mt as h,_n as g,dn as _,fn as v,jt as y,sn as b,un as x,vn as S,yn as C}from"./api-n96IfCKb.js";import{C as w,a as T,i as E,n as D,r as O,t as k}from"./select-DPKCWajZ.js";import{t as A}from"./createLucideIcon-CgM0rnsa.js";import{t as ee}from"./search-msqk2-rd.js";import{t as te}from"./book-open-DYRapW_h.js";import{t as ne}from"./loader-circle-D9etMT9f.js";import{t as re}from"./x-Dp5GAFmP.js";import{t as ie}from"./tag-chip-Dc_NcCEe.js";import{G as ae,J as j,K as M,St as oe,U as se,W as N,_t as ce,b as le,g as P,h as F,k as ue,m as I,mt as de,p as fe,q as pe,wt as me,xt as he}from"./index-CLw9DuCJ.js";import{t as ge}from"./form-actions-CzGmrPAv.js";import{t as L}from"./config-hints-nV5HPOvq.js";import{a as _e,c as ve,i as ye,l as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./config-split-page-DJDp86Ne.js";var Ee=A(`Hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),De=A(`Mail`,[[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}]]),R=A(`MessageCircleMore`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),z=A(`QrCode`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),Oe=A(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),B=e(i(),1),V=n();function ke({value:e,onChange:t,className:n,placeholder:r=``}){let[i,s]=(0,B.useState)(``),c=n=>{n.key===`Enter`&&i.trim()?(n.preventDefault(),t([...e,i.trim()]),s(``)):n.key===`Backspace`&&!i&&e.length>0&&t(e.slice(0,-1))},l=n=>{t(e.filter((e,t)=>t!==n))};return(0,V.jsxs)(`div`,{className:a(`flex min-h-[42px] flex-wrap gap-2 rounded-xl border border-gray-200/80 bg-white p-2`,n),children:[e.map((e,t)=>(0,V.jsxs)(ie,{tone:`info`,className:`gap-1 px-2 py-1 text-sm`,children:[e,(0,V.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`transition-colors hover:text-rose-200`,children:(0,V.jsx)(re,{className:`h-3 w-3`})})]},t)),(0,V.jsx)(`input`,{type:`text`,value:i,onChange:e=>s(e.target.value),onKeyDown:c,className:`flex-1 outline-none min-w-[100px] bg-transparent text-sm`,placeholder:r||o(`enterTag`)})]})}function Ae(e){return e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?(0,V.jsx)(oe,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`url`)||e.includes(`host`)?(0,V.jsx)(me,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`email`)||e.includes(`mail`)?(0,V.jsx)(De,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`id`)||e.includes(`from`)?(0,V.jsx)(Ee,{className:`h-3.5 w-3.5 text-gray-500`}):e===`enabled`||e===`consentGranted`?(0,V.jsx)(Oe,{className:`h-3.5 w-3.5 text-gray-500`}):(0,V.jsx)(ce,{className:`h-3.5 w-3.5 text-gray-500`})}function je({channelName:e,fields:t,formData:n,jsonDrafts:r,setJsonDrafts:i,updateField:a,uiHints:s}){return(0,V.jsx)(V.Fragment,{children:t.map(t=>{let c=L(`channels.${e}.${t.name}`,s),l=c?.label??t.label,u=c?.placeholder;return(0,V.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,V.jsxs)(x,{htmlFor:t.name,className:`flex items-center gap-2 text-sm font-medium text-gray-900`,children:[Ae(t.name),l]}),t.type===`boolean`&&(0,V.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl bg-gray-50 p-3`,children:[(0,V.jsx)(`span`,{className:`text-sm text-gray-500`,children:n[t.name]?o(`enabled`):o(`disabled`)}),(0,V.jsx)(p,{id:t.name,checked:n[t.name]||!1,onCheckedChange:e=>a(t.name,e),className:`data-[state=checked]:bg-emerald-500`})]}),(t.type===`text`||t.type===`email`)&&(0,V.jsx)(_,{id:t.name,type:t.type,value:n[t.name]||``,onChange:e=>a(t.name,e.target.value),placeholder:u,className:`rounded-xl`}),t.type===`password`&&(0,V.jsx)(_,{id:t.name,type:`password`,value:n[t.name]||``,onChange:e=>a(t.name,e.target.value),placeholder:u??o(`leaveBlankToKeepUnchanged`),className:`rounded-xl`}),t.type===`number`&&(0,V.jsx)(_,{id:t.name,type:`number`,value:n[t.name]||0,onChange:e=>a(t.name,parseInt(e.target.value,10)||0),placeholder:u,className:`rounded-xl`}),t.type===`tags`&&(0,V.jsx)(ke,{value:n[t.name]||[],onChange:e=>a(t.name,e)}),t.type===`select`&&(0,V.jsxs)(k,{value:n[t.name]||``,onValueChange:e=>a(t.name,e),children:[(0,V.jsx)(E,{className:`rounded-xl`,children:(0,V.jsx)(T,{})}),(0,V.jsx)(D,{children:(t.options??[]).map(e=>(0,V.jsx)(O,{value:e.value,children:e.label},e.value))})]}),t.type===`json`&&(0,V.jsx)(`textarea`,{id:t.name,value:r[t.name]??`{}`,onChange:e=>i(n=>({...n,[t.name]:e.target.value})),className:`min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`})]},t.name)})})}var Me=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),H=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),U=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Ne=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Pe=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Fe=t((e=>{var t=H().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Ie=t((e=>{var t=H().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Le=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),W=t((e=>{var t=U(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Re=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),ze=t((e=>{var t=Re();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Be=t(((e,t)=>{var n=ze();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),G=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),K=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
2
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),q=t((e=>{var t=G(),n=K();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Ve=t((e=>{var t=H(),n=W(),r=U(),i=q(),a=G(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),He=t((e=>{var t=H(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),Ue=t(((e,t)=>{var n=q();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),We=t(((e,t)=>{var n=q(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),Ge=t(((e,t)=>{var n=q();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Ke=t(((e,t)=>{var n=q(),r=H();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),qe=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),Je=t((e=>{var t=q(),n=Ue(),r=We(),i=Ge(),a=Ke(),o=K(),s=H(),c=qe();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
4
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),Ye=t((e=>{var t=H(),n=U(),r=Ne(),i=Pe(),a=Fe(),o=Ie(),s=Le(),c=W(),l=Be(),u=Ve(),d=He(),f=q(),p=Je();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`