@nextclaw/ui 0.14.4 → 0.15.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.
- package/CHANGELOG.md +54 -0
- package/dist/assets/api-DLtsiBKm.js +13 -0
- package/dist/assets/appearance-settings-page-CtkeYXux.js +1 -0
- package/dist/assets/book-open-BQwWBDKb.js +1 -0
- package/dist/assets/channels-list-page-Cv8o9Hxg.js +8 -0
- package/dist/assets/chat-page-BtA7H1Ea.js +1 -0
- package/dist/assets/{config-split-page-CRhlZ_pH.js → config-split-page-EidRBpP2.js} +1 -1
- package/dist/assets/confirm-dialog-iIJFFp2T.js +5 -0
- package/dist/assets/desktop-update-config-C6n_TB1r.js +1 -0
- package/dist/assets/{dist-CikkhOlq.js → dist-CBxWOazz.js} +1 -1
- package/dist/assets/{dist-PVA_xL1D.js → dist-D2eZC3OR.js} +1 -1
- package/dist/assets/doc-browser-B76XOXmW.js +1 -0
- package/dist/assets/doc-browser-DBnj9UMB.js +1 -0
- package/dist/assets/{doc-browser-context-MTw4EvKd.js → doc-browser-context-Sv-044Cl.js} +1 -1
- package/dist/assets/{ellipsis-y6vDtq4M.js → ellipsis-2uzhypw5.js} +1 -1
- package/dist/assets/es2015-DhQo_oS6.js +41 -0
- package/dist/assets/{external-link-DVJIQf_G.js → external-link-CM5dnUI6.js} +1 -1
- package/dist/assets/host-capabilities-9bB_998Z.js +1 -0
- package/dist/assets/i18n-provider-di1waTGX.js +1 -0
- package/dist/assets/index-CBRP-7-a.css +1 -0
- package/dist/assets/index-Z1fYpbNd.js +104 -0
- package/dist/assets/loader-circle-BjmN5DeJ.js +1 -0
- package/dist/assets/mcp-marketplace-page-C_MVQUbT.js +9 -0
- package/dist/assets/mcp-marketplace-page-CoZIiD6G.js +1 -0
- package/dist/assets/model-config-page-Cdr9P6TQ.js +1 -0
- package/dist/assets/plus-3ztRZD_l.js +1 -0
- package/dist/assets/provider-scoped-model-input-g1WkGiJ8.js +1 -0
- package/dist/assets/providers-config-page-CWlO7J4A.js +1 -0
- package/dist/assets/{react-VNqT5Zp7.js → react-DjpzoZXB.js} +1 -1
- package/dist/assets/refresh-cw-DaTv3zxE.js +1 -0
- package/dist/assets/remote-CKWZfVVB.js +1 -0
- package/dist/assets/rotate-cw-CHcaRUDz.js +1 -0
- package/dist/assets/runtime-config-page-CfTqh1nv.js +1 -0
- package/dist/assets/{save-BOJ477H-.js → save-BZof1uie.js} +1 -1
- package/dist/assets/{search-BEti5beA.js → search-MxAarS_g.js} +1 -1
- package/dist/assets/search-config-page-Dm8daYny.js +1 -0
- package/dist/assets/{secrets-config-page--IzrIOid.js → secrets-config-page-D8AbcR05.js} +2 -2
- package/dist/assets/security-config-Ds0LsJmo.js +1 -0
- package/dist/assets/select-D7GcNP0z.js +1 -0
- package/dist/assets/setting-row-CuozlnJd.js +1 -0
- package/dist/assets/side-dock-BcLau5S_.js +3 -0
- package/dist/assets/skeleton-shfmXuYp.js +1 -0
- package/dist/assets/switch-C1BWMU5c.js +1 -0
- package/dist/assets/tag-chip-DCUrQUCP.js +1 -0
- package/dist/assets/tooltip-DfAHHA76.js +1 -0
- package/dist/assets/use-config-DAdbT5QJ.js +1 -0
- package/dist/assets/use-confirm-dialog-eWcJ6V-s.js +1 -0
- package/dist/assets/x-DqL1mYLC.js +1 -0
- package/dist/index.html +53 -17
- package/index.html +25 -2
- package/package.json +9 -9
- package/src/app/components/layout/__tests__/app-layout.test.tsx +27 -0
- package/src/app/components/layout/__tests__/settings-entry-page.test.tsx +9 -1
- package/src/app/components/layout/__tests__/sidebar.layout.test.tsx +6 -3
- package/src/app/components/layout/app-layout.tsx +10 -3
- package/src/app/components/layout/sidebar-items.tsx +8 -8
- package/src/app/components/layout/sidebar-rail.styles.ts +4 -2
- package/src/app/components/layout/sidebar.tsx +21 -28
- package/src/app/configs/app-navigation.config.ts +11 -5
- package/src/app/index.tsx +8 -0
- package/src/app/managers/__tests__/viewport-layout.manager.test.ts +59 -0
- package/src/app/managers/viewport-layout.manager.ts +39 -0
- package/src/app/presenters/app.presenter.ts +25 -2
- package/src/app/styles/design-system.css +91 -4
- package/src/features/chat/components/conversation/__tests__/chat-conversation-content.test.tsx +86 -0
- package/src/features/chat/components/conversation/chat-conversation-content.tsx +47 -17
- package/src/features/chat/components/layout/__tests__/chat-sidebar-read-state.test.tsx +7 -0
- package/src/features/chat/components/layout/chat-sidebar-desktop-layout.tsx +9 -5
- package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +5 -5
- package/src/features/chat/features/conversation/components/__tests__/session-conversation-area.test.tsx +51 -2
- package/src/features/chat/features/conversation/components/__tests__/session-conversation-input.streaming.test.tsx +170 -1
- package/src/features/chat/features/conversation/components/session-conversation-area.tsx +23 -1
- package/src/features/chat/features/conversation/components/session-conversation-input.tsx +24 -7
- package/src/features/chat/features/conversation/components/session-queued-input-rows.tsx +96 -0
- package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-controller.test.tsx +181 -0
- package/src/features/chat/features/conversation/hooks/use-session-conversation-controller.ts +351 -89
- package/src/features/chat/features/input/hooks/__tests__/use-chat-input-surface-state.test.tsx +29 -4
- package/src/features/chat/features/input/hooks/use-chat-input-surface-state.ts +28 -3
- package/src/features/chat/features/input/input-surface-plugins/__tests__/slash-command-plugin.test.ts +108 -8
- package/src/features/chat/features/input/input-surface-plugins/panel-app-reference-plugin.utils.ts +50 -14
- package/src/features/chat/features/input/input-surface-plugins/slash-command-plugin.utils.ts +77 -6
- package/src/features/chat/features/message/components/__tests__/chat-inline-panel-app-card.test.tsx +21 -12
- package/src/features/chat/features/message/components/__tests__/chat-message-list.container.test.tsx +166 -0
- package/src/features/chat/features/message/components/chat-inline-panel-app-card.tsx +19 -11
- package/src/features/chat/features/message/components/chat-message-list.container.tsx +38 -64
- package/src/features/chat/features/message/utils/__tests__/chat-message-process-summary.utils.test.ts +59 -0
- package/src/features/chat/features/message/utils/__tests__/chat-message-show-content-tool-card.utils.test.ts +56 -1
- package/src/features/chat/features/message/utils/chat-inline-panel-app-card.utils.ts +0 -2
- package/src/features/chat/features/message/utils/chat-message-process-summary.utils.ts +80 -0
- package/src/features/chat/features/message/utils/chat-message-show-content-tool-card.utils.ts +12 -3
- package/src/features/chat/features/message/utils/chat-message-texts.utils.ts +60 -0
- package/src/features/chat/features/message/utils/chat-message.utils.ts +3 -0
- package/src/features/chat/features/ncp/hooks/__tests__/use-ncp-agent-runtime.test.tsx +39 -0
- package/src/features/chat/features/session/components/chat-sidebar-project-groups.tsx +2 -2
- package/src/features/chat/features/session/components/chat-sidebar-session-item.tsx +1 -1
- package/src/features/chat/features/session/components/session-header/__tests__/chat-session-header-actions.test.tsx +3 -1
- package/src/features/chat/features/session/components/session-header/chat-session-metadata-dialog.tsx +1 -1
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-file-preview.test.tsx +270 -115
- package/src/features/chat/features/workspace/components/chat-session-workspace-file-breadcrumb-browser.tsx +121 -0
- package/src/features/chat/features/workspace/components/chat-session-workspace-file-breadcrumbs.tsx +75 -20
- package/src/features/chat/features/workspace/components/chat-session-workspace-file-preview.tsx +70 -5
- package/src/features/chat/features/workspace/utils/chat-workspace-file-tab-persistence.utils.ts +83 -0
- package/src/features/chat/managers/__tests__/chat-thread.manager.test.ts +79 -1
- package/src/features/chat/managers/__tests__/chat-ui.manager.test.ts +2 -0
- package/src/features/chat/managers/chat-thread.manager.ts +9 -3
- package/src/features/chat/managers/chat-ui.manager.ts +5 -1
- package/src/features/chat/presenters/chat.presenter.ts +2 -1
- package/src/features/chat/stores/__tests__/chat-thread.store.test.ts +4 -0
- package/src/features/chat/stores/chat-thread.store.ts +6 -64
- package/src/features/chat/types/chat-message.types.ts +4 -0
- package/src/features/marketplace/components/__tests__/marketplace-page-detail.test.tsx +33 -26
- package/src/features/marketplace/components/__tests__/marketplace-page.test.tsx +1 -0
- package/src/features/marketplace/components/curated-shelves/__tests__/marketplace-curated-scene-route.test.tsx +1 -0
- package/src/features/marketplace/components/detail-doc/__tests__/marketplace-detail-doc.test.tsx +115 -0
- package/src/features/marketplace/components/marketplace-detail-doc.tsx +441 -0
- package/src/features/marketplace/components/mcp/__tests__/mcp-marketplace-page.test.tsx +3 -3
- package/src/features/marketplace/components/mcp/mcp-marketplace-doc.ts +0 -60
- package/src/features/marketplace/components/mcp/mcp-marketplace-page.tsx +64 -29
- package/src/features/marketplace/hooks/use-marketplace-item-detail.ts +42 -31
- package/src/features/marketplace/index.ts +3 -0
- package/src/features/marketplace/stores/marketplace-detail-doc.store.ts +38 -0
- package/src/features/panel-apps/components/__tests__/panel-apps-list.test.tsx +32 -2
- package/src/features/pwa/managers/__tests__/pwa-shell-theme.manager.test.ts +11 -0
- package/src/features/pwa/managers/pwa-shell-theme.manager.ts +8 -3
- package/src/features/settings/pages/__tests__/appearance-settings-page.test.tsx +25 -0
- package/src/features/settings/pages/appearance-settings-page.tsx +40 -0
- package/src/features/side-dock/components/__tests__/side-dock.test.tsx +44 -2
- package/src/features/side-dock/components/side-dock.tsx +100 -13
- package/src/features/side-dock/configs/side-dock-built-in-items.config.ts +10 -0
- package/src/features/side-dock/managers/__tests__/side-dock.manager.test.ts +32 -2
- package/src/features/side-dock/managers/side-dock.manager.ts +17 -7
- package/src/features/side-dock/stores/side-dock.store.ts +9 -0
- package/src/features/side-dock/types/side-dock.types.ts +10 -3
- package/src/features/side-dock/utils/side-dock-item.utils.ts +15 -2
- package/src/index.css +501 -27
- package/src/platforms/desktop/components/desktop-window-chrome.tsx +1 -1
- package/src/shared/components/doc-browser/__tests__/doc-browser-context.test.tsx +30 -1
- package/src/shared/components/doc-browser/__tests__/doc-browser.test.tsx +206 -38
- package/src/shared/components/doc-browser/doc-browser-panel-parts.tsx +34 -11
- package/src/shared/components/doc-browser/doc-browser-renderer.types.ts +1 -1
- package/src/shared/components/doc-browser/doc-browser-tab-strip.tsx +23 -5
- package/src/shared/components/doc-browser/doc-browser.tsx +128 -75
- package/src/shared/components/doc-browser/managers/doc-browser.manager.ts +9 -1
- package/src/shared/components/doc-browser/utils/doc-browser-floating-panel.utils.ts +83 -0
- package/src/shared/components/ui/__tests__/dialog.test.tsx +27 -0
- package/src/shared/components/ui/actions/icon-action-button.tsx +14 -2
- package/src/shared/components/ui/dialog.tsx +2 -2
- package/src/shared/components/ui/popover.tsx +1 -1
- package/src/shared/components/ui/select.tsx +1 -1
- package/src/shared/components/ui/switch.tsx +4 -3
- package/src/shared/components/ui/tab-strip/__tests__/compact-tab-strip.test.tsx +54 -0
- package/src/shared/components/ui/tab-strip/compact-tab-strip.tsx +4 -5
- package/src/shared/components/ui/tooltip.tsx +1 -1
- package/src/shared/lib/api/utils/server-path.utils.ts +27 -1
- package/src/shared/lib/i18n/locales/en-US/chat.json +15 -6
- package/src/shared/lib/i18n/locales/en-US/core.json +2 -0
- package/src/shared/lib/i18n/locales/en-US/doc-browser.json +11 -0
- package/src/shared/lib/i18n/locales/en-US/marketplace.json +5 -0
- package/src/shared/lib/i18n/locales/zh-CN/chat.json +15 -6
- package/src/shared/lib/i18n/locales/zh-CN/core.json +2 -0
- package/src/shared/lib/i18n/locales/zh-CN/doc-browser.json +11 -0
- package/src/shared/lib/i18n/locales/zh-CN/marketplace.json +5 -0
- package/src/shared/lib/session-project/__tests__/workspace-file-breadcrumb.test.ts +14 -0
- package/src/shared/lib/session-project/index.ts +1 -1
- package/src/shared/lib/session-project/{workspace-file-breadcrumb.ts → workspace-file-breadcrumb.utils.ts} +62 -8
- package/src/shared/lib/theme/index.ts +51 -13
- package/dist/assets/api-BP_8IaxB.js +0 -13
- package/dist/assets/channels-list-page-DEh5Jjqx.js +0 -8
- package/dist/assets/chat-page-BRB0N5WW.js +0 -105
- package/dist/assets/confirm-dialog-DsivFJ4r.js +0 -5
- package/dist/assets/desktop-update-config-B0w9p2ep.js +0 -1
- package/dist/assets/doc-browser-BoNJ7-tE.js +0 -1
- package/dist/assets/doc-browser-CdJ_d4ik.js +0 -1
- package/dist/assets/index-BiE-K8-q.css +0 -1
- package/dist/assets/index-D9BAE_L_.js +0 -105
- package/dist/assets/mcp-marketplace-page-B1SZNY5m.js +0 -40
- package/dist/assets/mcp-marketplace-page-Cq_Tw42T.js +0 -1
- package/dist/assets/model-config-page-DotaTUHb.js +0 -1
- package/dist/assets/plus-BbZqquJe.js +0 -1
- package/dist/assets/provider-scoped-model-input-DsFRuWJH.js +0 -1
- package/dist/assets/providers-config-page-DW4tQSLN.js +0 -1
- package/dist/assets/remote-B8TiUfwW.js +0 -1
- package/dist/assets/rotate-cw-DjHDTkCv.js +0 -1
- package/dist/assets/runtime-config-page-S6ErRHR8.js +0 -1
- package/dist/assets/search-config-page-DGj5am03.js +0 -1
- package/dist/assets/select-hoj8dK4K.js +0 -41
- package/dist/assets/tag-chip-T8-h-die.js +0 -1
- package/dist/assets/use-config-CjRV2hwL.js +0 -1
- package/dist/assets/x-D9PXs_xP.js +0 -1
- package/src/features/marketplace/components/detail-doc/__tests__/marketplace-detail-doc.test.ts +0 -40
- package/src/features/marketplace/components/detail-doc/marketplace-detail-doc-renderer.ts +0 -201
- package/src/features/marketplace/components/marketplace-detail-doc.ts +0 -142
- /package/dist/assets/{config-hints-BkYBc7z0.js → config-hints-fGnUjDe9.js} +0 -0
- /package/dist/assets/{middleware-CkFT3R4v.js → middleware-BILWbJE4.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @nextclaw/ui
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Publish the full public NextClaw workspace as a stable minor release.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 3cf5890: Fix chat attachments being dropped after upload or paste, and stop sending a default image detail value that some OpenAI-compatible providers reject.
|
|
12
|
+
- 9df29a4: Collapse completed assistant reasoning and tool-process content behind a processed summary while keeping the final answer visible.
|
|
13
|
+
- bf1917a: Add inert `nextclaw-inline` Markdown code blocks for inline display declarations, keep model-visible show-content tools side-panel only without a `placement` parameter, and render inline Panel App declarations without a side-panel expand action.
|
|
14
|
+
- b2032cf: Add chat input queuing while an agent run is active, with editable queued drafts that send in order after the current run completes.
|
|
15
|
+
- ad67894: Add a floating scroll-to-bottom action in chat conversations when the message list is away from the latest message.
|
|
16
|
+
- fd95ade: Show failed session previews inside the chat detail view near the composer so conversation-level errors are visible beyond the session list.
|
|
17
|
+
- 854f3db: Expand compact workspace/browser tab hit areas so clicking the full visible tab selects it while close buttons remain isolated.
|
|
18
|
+
- 2e15783: Auto-collapse the left sidebar on narrower desktop layouts when docked DocBrowser and the chat workspace right panel are both opened, keeping the central chat workspace usable without turning the behavior into a continuous layout state calculation.
|
|
19
|
+
- d9b60a7: Improve floating DocBrowser interactions: drag from the header, resize from all four corners, use a semantic float icon, and keep tooltips, popovers, and dialogs above floating panels.
|
|
20
|
+
- 191c011: Serve rendered local HTML previews through unrestricted iframe URLs so scripts and relative assets can run closer to normal browser behavior.
|
|
21
|
+
- 2d9d1b7: Fix Markdown absolute file links so local file anchors keep clean DOM output and continue opening through the chat workspace file preview action.
|
|
22
|
+
- 33a931f: Add standard NCP event timing and message lifecycle fields so completed assistant process summaries can show real elapsed time derived from started and ended timestamps.
|
|
23
|
+
Stamp first-party runtime, transport, and extension-produced NCP events at their producer boundary instead of estimating duration in UI or journal consumers.
|
|
24
|
+
Make Codex app-server aborts emit the standard NCP abort event promptly so the conversation leaves the running state without waiting for another app-server notification.
|
|
25
|
+
- fee6faa: Add a Night theme with dark appearance persistence and improve dark-mode readability for Markdown, status surfaces, error notices, switches, composer file tokens, native right-side marketplace detail views, and the session metadata dialog.
|
|
26
|
+
- 7bcc180: Split the model-facing `show_content` display tool into `show_file`, `show_url`, and `show_panel_app` so required display parameters are explicit JSON Schema properties instead of nested description-only payload fields.
|
|
27
|
+
- 854f3db: Allow source and rendered previews for the same file to stay open as separate chat workspace tabs.
|
|
28
|
+
- 2d9d1b7: Add a rendered file-preview viewer for `show_content` so agents can open local HTML/page prototypes in the chat workspace side panel.
|
|
29
|
+
- 7bcc180: Open `show_url` targets as browser-like content tabs with address, refresh, external-open controls, and local development server guidance.
|
|
30
|
+
- be1759e: Add bottom SideDock utilities for opening the NextClaw GitHub project, hiding the dock with confirmation, and restoring it from Appearance settings.
|
|
31
|
+
- c6ca436: Align left sidebar hover and selected-state feedback across navigation, utility, and session-adjacent rows so scheduled tasks, skills, agent management, and session list items share the same understated gray interaction treatment. The fixed sidebar footer now drops the divider line and uses a subtle scroll-edge fade above the bottom controls to make the list-to-footer handoff feel lighter.
|
|
32
|
+
- 2d8a871: Add Slash menu category filters with counts and let Slash panel app actions open panel apps in the right sidebar without inserting input tokens.
|
|
33
|
+
- 9338c97: Make workspace file preview breadcrumbs clickable so users can browse nearby folders and open files directly from the breadcrumb menu.
|
|
34
|
+
- eb0d40a: Highlight code syntax in workspace file previews by reusing the existing chat code highlighter and server language hints.
|
|
35
|
+
- Updated dependencies [9df29a4]
|
|
36
|
+
- Updated dependencies [bf1917a]
|
|
37
|
+
- Updated dependencies [b2032cf]
|
|
38
|
+
- Updated dependencies [ad67894]
|
|
39
|
+
- Updated dependencies
|
|
40
|
+
- Updated dependencies [2d9d1b7]
|
|
41
|
+
- Updated dependencies [61e7a7a]
|
|
42
|
+
- Updated dependencies [33a931f]
|
|
43
|
+
- Updated dependencies [fee6faa]
|
|
44
|
+
- Updated dependencies [2d9d1b7]
|
|
45
|
+
- Updated dependencies [2d8a871]
|
|
46
|
+
- Updated dependencies [7a77c87]
|
|
47
|
+
- Updated dependencies [eb0d40a]
|
|
48
|
+
- @nextclaw/agent-chat-ui@0.6.0
|
|
49
|
+
- @nextclaw/agent-chat@0.3.0
|
|
50
|
+
- @nextclaw/client-sdk@0.5.0
|
|
51
|
+
- @nextclaw/ncp@0.7.0
|
|
52
|
+
- @nextclaw/ncp-http-agent-client@0.4.0
|
|
53
|
+
- @nextclaw/ncp-react@0.5.0
|
|
54
|
+
- @nextclaw/ncp-toolkit@0.6.0
|
|
55
|
+
- @nextclaw/shared@0.4.0
|
|
56
|
+
|
|
3
57
|
## 0.14.4
|
|
4
58
|
|
|
5
59
|
### Patch Changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{h as e,m as t,p as n,r,t as i,u as a,v as o}from"./react-DjpzoZXB.js";import{a as s,c,i as l,l as u,n as d,o as f,r as p,s as m,t as h}from"./switch-C1BWMU5c.js";var g=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},v=new class{#e=_;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function y(e){setTimeout(e,0)}var b=typeof window>`u`||`Deno`in globalThis;function x(){}function S(e,t){return typeof e==`function`?e(t):e}function C(e){return typeof e==`number`&&e>=0&&e!==1/0}function w(e,t){return Math.max(e+(t||0)-Date.now(),0)}function T(e,t){return typeof e==`function`?e(t):e}function E(e,t){return typeof e==`function`?e(t):e}function ee(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==O(o,t.options))return!1}else if(!te(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function D(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(k(t.options.mutationKey)!==k(a))return!1}else if(!te(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function O(e,t){return(t?.queryKeyHashFn||k)(e)}function k(e){return JSON.stringify(e,(e,t)=>P(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function te(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>te(e[n],t[n])):!1}var A=Object.prototype.hasOwnProperty;function j(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=N(e)&&N(t);if(!r&&!(P(e)&&P(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:A.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=j(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function M(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function N(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function P(e){if(!ne(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ne(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ne(e){return Object.prototype.toString.call(e)===`[object Object]`}function re(e){return new Promise(t=>{v.setTimeout(t,e)})}function ie(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:j(e,t)}function ae(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function oe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var se=Symbol();function ce(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===se?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function le(e,t){return typeof e==`function`?e(...t):!!e}function ue(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var de=new class extends g{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!b&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}};function fe(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var F=y;function pe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=F,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var I=pe(),L=new class extends g{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!b&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function me(e){return Math.min(1e3*2**e,3e4)}function he(e){return(e??`online`)===`online`?L.isOnline():!0}var ge=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function _e(e){let t=!1,n=0,r,i=fe(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ge(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>de.isFocused()&&(e.networkMode===`always`||L.isOnline())&&e.canRun(),u=()=>he(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(b?0:3),o=e.retryDelay??me,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),re(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var ve=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),C(this.gcTime)&&(this.#e=v.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(b?1/0:300*1e3))}clearGcTimeout(){this.#e&&=(v.clearTimeout(this.#e),void 0)}},ye=class extends ve{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=xe(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=xe(this.options);e.data!==void 0&&(this.setState(R(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=ie(this.state.data,e,this.options);return this.#s({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(x).catch(x):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>E(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===se||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>T(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!w(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=ce(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=_e({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ge&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#s({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#s({type:`pause`})},onContinue:()=>{this.#s({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ge){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#s({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#s(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...be(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...R(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),I.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function be(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:he(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function R(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function xe(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var z=class extends g{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=fe(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ce(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return we(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return we(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof E(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!M(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Te(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||E(this.options.enabled,this.#t)!==E(t.enabled,this.#t)||T(this.options.staleTime,this.#t)!==T(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||E(this.options.enabled,this.#t)!==E(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return De(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(x)),t}#g(){this.#b();let e=T(this.options.staleTime,this.#t);if(b||this.#r.isStale||!C(e))return;let t=w(this.#r.dataUpdatedAt,e)+1;this.#d=v.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(b||E(this.options.enabled,this.#t)===!1||!C(this.#p)||this.#p===0)&&(this.#f=v.setInterval(()=>{(this.options.refetchIntervalInBackground||de.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(v.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(v.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Ce(e,t),o=i&&Te(e,n,t,r);(a||o)&&(l={...l,...be(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=ie(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ie(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Ee(e,t),refetch:this.refetch,promise:this.#o,isEnabled:E(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=fe())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!M(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){I.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Se(e,t){return E(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function Ce(e,t){return Se(e,t)||e.state.data!==void 0&&we(e,t,t.refetchOnMount)}function we(e,t,n){if(E(t.enabled,e)!==!1&&T(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Ee(e,t)}return!1}function Te(e,t,n,r){return(e!==t||E(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Ee(e,n)}function Ee(e,t){return E(t.enabled,e)!==!1&&e.isStaleByTime(T(t.staleTime,e))}function De(e,t){return!M(e.getCurrentResult(),t)}function B(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ue(e,()=>t.signal,()=>n=!0)},u=ce(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?oe:ae;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?ke:Oe,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Oe(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Oe(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ke(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Ae(e,t){return t?Oe(e,t)!=null:!1}function je(e,t){return!t||!e.getPreviousPageParam?!1:ke(e,t)!=null}var Me=class extends ve{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ne(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=_e({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),I.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ne(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Pe=class extends g{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Me({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Fe(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Fe(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Fe(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Fe(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){I.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>D(t,e))}findAll(e={}){return this.getAll().filter(t=>D(e,t))}notify(e){I.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return I.batch(()=>Promise.all(e.map(e=>e.continue().catch(x))))}};function Fe(e){return e.options.scope?.id}var Ie=class extends g{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),M(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&k(t.mutationKey)!==k(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Ne();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){I.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Le=class extends g{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??O(r,t),a=this.get(i);return a||(a=new ye({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){I.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ee(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ee(e,t)):t}notify(e){I.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){I.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){I.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Re=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Le,this.#t=e.mutationCache||new Pe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=de.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=L.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(T(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=S(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return I.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;I.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return I.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=I.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(x).catch(x)}invalidateQueries(e,t={}){return I.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=I.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(x)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(x)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(T(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(x).catch(x)}fetchInfiniteQuery(e){return e.behavior=B(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(x).catch(x)}ensureInfiniteQueryData(e){return e.behavior=B(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return L.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(k(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{te(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(k(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{te(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=O(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===se&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},V=o(e(),1),H=n(),ze=V.createContext(void 0),U=e=>{let t=V.useContext(ze);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Be=({client:e,children:t})=>(V.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,H.jsx)(ze.Provider,{value:e,children:t})),Ve=V.createContext(!1),He=()=>V.useContext(Ve);Ve.Provider;function Ue(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var We=V.createContext(Ue()),Ge=()=>V.useContext(We),Ke=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?le(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},qe=e=>{V.useEffect(()=>{e.clearReset()},[e])},Je=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||le(n,[e.error,r])),Ye=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Xe=(e,t)=>e.isLoading&&e.isFetching&&!t,Ze=(e,t)=>e?.suspense&&t.isPending,Qe=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function $e(e,t,n){let r=He(),i=Ge(),a=U(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Ye(o),Ke(o,i,s),qe(i);let c=!a.getQueryCache().get(o.queryHash),[l]=V.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(V.useSyncExternalStore(V.useCallback(e=>{let t=d?l.subscribe(I.batchCalls(e)):x;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),V.useEffect(()=>{l.setOptions(o)},[o,l]),Ze(o,u))throw Qe(o,l,i);if(Je({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!b&&Xe(u,r)&&(c?Qe(o,l,i):s?.promise)?.catch(x).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function et(e,t){return $e(e,z,t)}function tt(e,t){let n=U(t),[r]=V.useState(()=>new Ie(n,e));V.useEffect(()=>{r.setOptions(e)},[r,e]);let i=V.useSyncExternalStore(V.useCallback(e=>r.subscribe(I.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=V.useCallback((e,t)=>{r.mutate(e,t).catch(x)},[r]);if(i.error&&le(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var nt=o(t(),1),rt=e=>{switch(e){case`success`:return ot;case`info`:return ct;case`warning`:return st;case`error`:return lt;default:return null}},it=Array(12).fill(0),at=({visible:e,className:t})=>V.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},V.createElement(`div`,{className:`sonner-spinner`},it.map((e,t)=>V.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),ot=V.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},V.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),st=V.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},V.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),ct=V.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},V.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),lt=V.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},V.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ut=V.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},V.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),V.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),dt=()=>{let[e,t]=V.useState(document.hidden);return V.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},ft=1,W=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:ft++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=e instanceof Promise?e:e(),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],V.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(mt(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description;this.create({id:n,type:`error`,message:r,description:a})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description;this.create({id:n,type:`success`,message:r,description:a})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description;this.create({id:n,type:`error`,message:r,description:a})}}).finally(()=>{var e;i&&(this.dismiss(n),n=void 0),(e=t.finally)==null||e.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||ft++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},pt=(e,t)=>{let n=t?.id||ft++;return W.addToast({title:e,...t,id:n}),n},mt=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,G=Object.assign(pt,{success:W.success,info:W.info,warning:W.warning,error:W.error,custom:W.custom,message:W.message,promise:W.promise,dismiss:W.dismiss,loading:W.loading},{getHistory:()=>W.toasts,getToasts:()=>W.getActiveToasts()});function ht(e,{insertAt:t}={}){if(!e||typeof document>`u`)return;let n=document.head||document.getElementsByTagName(`head`)[0],r=document.createElement(`style`);r.type=`text/css`,t===`top`&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}ht(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
2
|
+
`);function gt(e){return e.label!==void 0}var _t=3,vt=`32px`,yt=`16px`,bt=4e3,xt=356,St=14,Ct=20,wt=200;function K(...e){return e.filter(Boolean).join(` `)}function Tt(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Et=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,loadingIcon:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`,pauseWhenPageIsHidden:ee}=e,[D,O]=V.useState(null),[k,te]=V.useState(null),[A,j]=V.useState(!1),[M,N]=V.useState(!1),[P,ne]=V.useState(!1),[re,ie]=V.useState(!1),[ae,oe]=V.useState(!1),[se,ce]=V.useState(0),[le,ue]=V.useState(0),de=V.useRef(n.duration||y||bt),fe=V.useRef(null),F=V.useRef(null),pe=c===0,I=c+1<=o,L=n.type,me=n.dismissible!==!1,he=n.className||``,ge=n.descriptionClassName||``,_e=V.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),ve=V.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ye=V.useMemo(()=>n.duration||y||bt,[n.duration,y]),be=V.useRef(0),R=V.useRef(0),xe=V.useRef(0),z=V.useRef(null),[Se,Ce]=b.split(`-`),we=V.useMemo(()=>s.reduce((e,t,n)=>n>=_e?e:e+t.height,0),[s,_e]),Te=dt(),Ee=n.invert||t,De=L===`loading`;R.current=V.useMemo(()=>_e*x+we,[_e,we]),V.useEffect(()=>{de.current=ye},[ye]),V.useEffect(()=>{j(!0)},[]),V.useEffect(()=>{let e=F.current;if(e){let t=e.getBoundingClientRect().height;return ue(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),V.useLayoutEffect(()=>{if(!A)return;let e=F.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ue(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id]);let B=V.useCallback(()=>{N(!0),ce(R.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},wt)},[n,d,a,R]);V.useEffect(()=>{if(n.promise&&L===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||ee&&Te?(()=>{if(xe.current<be.current){let e=new Date().getTime()-be.current;de.current-=e}xe.current=new Date().getTime()})():de.current!==1/0&&(be.current=new Date().getTime(),e=setTimeout(()=>{var e;(e=n.onAutoClose)==null||e.call(n,n),B()},de.current)),()=>clearTimeout(e)},[u,i,n,L,ee,Te,B]),V.useEffect(()=>{n.delete&&B()},[B,n.delete]);function Oe(){return T!=null&&T.loading?V.createElement(`div`,{className:K(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":L===`loading`},T.loading):S?V.createElement(`div`,{className:K(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":L===`loading`},S):V.createElement(at,{className:K(w?.loader,n?.classNames?.loader),visible:L===`loading`})}return V.createElement(`li`,{tabIndex:0,ref:F,className:K(_,he,w?.toast,n?.classNames?.toast,w?.default,w?.[L],n?.classNames?.[L]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":ae,"data-removed":M,"data-visible":I,"data-y-position":Se,"data-x-position":Ce,"data-index":c,"data-front":pe,"data-swiping":P,"data-dismissible":me,"data-type":L,"data-invert":Ee,"data-swipe-out":re,"data-swipe-direction":k,"data-expanded":!!(u||C&&A),style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?se:R.current}px`,"--initial-height":C?`auto`:`${le}px`,...m,...n.style},onDragEnd:()=>{ne(!1),O(null),z.current=null},onPointerDown:e=>{De||!me||(fe.current=new Date,ce(R.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(ne(!0),z.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e;if(re||!me)return;z.current=null;let t=Number(F.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),r=Number(F.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),i=new Date().getTime()-fe.current?.getTime(),a=D===`x`?t:r,o=Math.abs(a)/i;if(Math.abs(a)>=Ct||o>.11){ce(R.current),(e=n.onDismiss)==null||e.call(n,n),te(D===`x`?t>0?`right`:`left`:r>0?`down`:`up`),B(),ie(!0),oe(!1);return}ne(!1),O(null)},onPointerMove:t=>{var n,r;if(!z.current||!me||window.getSelection()?.toString().length>0)return;let i=t.clientY-z.current.y,a=t.clientX-z.current.x,o=e.swipeDirections??Tt(b);!D&&(Math.abs(a)>1||Math.abs(i)>1)&&O(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0};D===`y`?(o.includes(`top`)||o.includes(`bottom`))&&(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)&&(s.y=i):D===`x`&&(o.includes(`left`)||o.includes(`right`))&&(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)&&(s.x=a),(Math.abs(s.x)>0||Math.abs(s.y)>0)&&oe(!0),(n=F.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=F.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},ve&&!n.jsx?V.createElement(`button`,{"aria-label":E,"data-disabled":De,"data-close-button":!0,onClick:De||!me?()=>{}:()=>{var e;B(),(e=n.onDismiss)==null||e.call(n,n)},className:K(w?.closeButton,n?.classNames?.closeButton)},T?.close??ut):null,n.jsx||(0,V.isValidElement)(n.title)?n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title:V.createElement(V.Fragment,null,L||n.icon||n.promise?V.createElement(`div`,{"data-icon":``,className:K(w?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Oe():null,n.type===`loading`?null:n.icon||T?.[L]||rt(L)):null,V.createElement(`div`,{"data-content":``,className:K(w?.content,n?.classNames?.content)},V.createElement(`div`,{"data-title":``,className:K(w?.title,n?.classNames?.title)},typeof n.title==`function`?n.title():n.title),n.description?V.createElement(`div`,{"data-description":``,className:K(v,ge,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),(0,V.isValidElement)(n.cancel)?n.cancel:n.cancel&>(n.cancel)?V.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{var t,r;gt(n.cancel)&&me&&((r=(t=n.cancel).onClick)==null||r.call(t,e),B())},className:K(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,(0,V.isValidElement)(n.action)?n.action:n.action&>(n.action)?V.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{var t,r;gt(n.action)&&((r=(t=n.action).onClick)==null||r.call(t,e),!e.defaultPrevented&&B())},className:K(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null))};function Dt(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function Ot(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?yt:vt;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var kt=(0,V.forwardRef)(function(e,t){let{invert:n,position:r=`bottom-right`,hotkey:i=[`altKey`,`KeyT`],expand:a,closeButton:o,className:s,offset:c,mobileOffset:l,theme:u=`light`,richColors:d,duration:f,style:p,visibleToasts:m=_t,toastOptions:h,dir:g=Dt(),gap:_=St,loadingIcon:v,icons:y,containerAriaLabel:b=`Notifications`,pauseWhenPageIsHidden:x}=e,[S,C]=V.useState([]),w=V.useMemo(()=>Array.from(new Set([r].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,r]),[T,E]=V.useState([]),[ee,D]=V.useState(!1),[O,k]=V.useState(!1),[te,A]=V.useState(u===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:u),j=V.useRef(null),M=i.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),N=V.useRef(null),P=V.useRef(!1),ne=V.useCallback(e=>{C(t=>{var n;return(n=t.find(t=>t.id===e.id))!=null&&n.delete||W.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return V.useEffect(()=>W.subscribe(e=>{if(e.dismiss){C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t));return}setTimeout(()=>{nt.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),V.useEffect(()=>{if(u!==`system`){A(u);return}if(u===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?A(`dark`):A(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{A(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{A(e?`dark`:`light`)}catch(e){console.error(e)}})}},[u]),V.useEffect(()=>{S.length<=1&&D(!1)},[S]),V.useEffect(()=>{let e=e=>{var t,n;i.every(t=>e[t]||e.code===t)&&(D(!0),(t=j.current)==null||t.focus()),e.code===`Escape`&&(document.activeElement===j.current||(n=j.current)!=null&&n.contains(document.activeElement))&&D(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),V.useEffect(()=>{if(j.current)return()=>{N.current&&(N.current.focus({preventScroll:!0}),N.current=null,P.current=!1)}},[j.current]),V.createElement(`section`,{ref:t,"aria-label":`${b} ${M}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,r)=>{let[i,u]=t.split(`-`);return S.length?V.createElement(`ol`,{key:t,dir:g===`auto`?Dt():g,tabIndex:-1,ref:j,className:s,"data-sonner-toaster":!0,"data-theme":te,"data-y-position":i,"data-lifted":ee&&S.length>1&&!a,"data-x-position":u,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${xt}px`,"--gap":`${_}px`,...p,...Ot(c,l)},onBlur:e=>{P.current&&!e.currentTarget.contains(e.relatedTarget)&&(P.current=!1,N.current&&=(N.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||P.current||(P.current=!0,N.current=e.relatedTarget)},onMouseEnter:()=>D(!0),onMouseMove:()=>D(!0),onMouseLeave:()=>{O||D(!1)},onDragEnd:()=>D(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||k(!0)},onPointerUp:()=>k(!1)},S.filter(e=>!e.position&&r===0||e.position===t).map((r,i)=>V.createElement(Et,{key:r.id,icons:y,index:i,toast:r,defaultRichColors:d,duration:h?.duration??f,className:h?.className,descriptionClassName:h?.descriptionClassName,invert:n,visibleToasts:m,closeButton:h?.closeButton??o,interacting:O,position:t,style:h?.style,unstyled:h?.unstyled,classNames:h?.classNames,cancelButtonStyle:h?.cancelButtonStyle,actionButtonStyle:h?.actionButtonStyle,removeToast:ne,toasts:S.filter(e=>e.position==r.position),heights:T.filter(e=>e.position==r.position),setHeights:E,expandByDefault:a,gap:_,loadingIcon:v,expanded:ee,pauseWhenPageIsHidden:x,swipeDirections:e.swipeDirections}))):null}))}),At=new Re({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!0}}}),jt=V.forwardRef(({className:e,type:t,...n},r)=>(0,H.jsx)(`input`,{type:t,className:a(`flex h-9 w-full rounded-xl border border-border bg-card px-3.5 py-2 text-sm text-foreground file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground/55 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/50 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));jt.displayName=`Input`;var Mt=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`label`,{ref:n,className:a(`text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,e),...t}));Mt.displayName=`Label`;function q(e){let t=e.trim();if(!t)throw Error(`typed key id is required`);return{id:t}}function Nt(e){return typeof e==`string`?e.trim():e.id}var Pt=class{listeners=new Map;globalListeners=new Set;listenerCount=0;onFirstSubscriber;onListenerError;onNoSubscribers;constructor(e={}){this.onFirstSubscriber=e.onFirstSubscriber,this.onListenerError=e.onListenerError,this.onNoSubscribers=e.onNoSubscribers}emit=(e,t,n={})=>{let r={type:Nt(e),payload:t,...n.emittedAt?{emittedAt:n.emittedAt}:{},...n.source?{source:n.source}:{}};this.emitEnvelope(r)};emitEnvelope=e=>{let t=this.listeners.get(e.type);if(t)for(let n of t)this.safeInvokeListener(e,n);if(this.globalListeners.size!==0)for(let t of this.globalListeners)this.safeInvokeGlobalListener(e,t)};on=(e,t)=>{let n=Nt(e),r=this.listeners.get(n)??new Set,i=t,a=!r.has(i);return r.add(i),this.listeners.set(n,r),a&&this.registerSubscriber(),()=>{this.off(e,t)}};off=(e,t)=>{let n=Nt(e),r=this.listeners.get(n);if(!r)return;let i=r.delete(t);r.size===0&&this.listeners.delete(n),i&&this.unregisterSubscriber()};once=(e,t)=>{let n=this.on(e,(e,r)=>{n(),t(e,r)});return n};subscribeAll=e=>{let t=!this.globalListeners.has(e);return this.globalListeners.add(e),t&&this.registerSubscriber(),()=>{this.globalListeners.delete(e)&&this.unregisterSubscriber()}};registerSubscriber=()=>{this.listenerCount+=1,this.listenerCount===1&&this.onFirstSubscriber?.()};unregisterSubscriber=()=>{this.listenerCount=Math.max(0,this.listenerCount-1),this.listenerCount===0&&this.onNoSubscribers?.()};safeInvokeListener=(e,t)=>{try{t(e.payload,e)}catch(t){this.onListenerError?.({type:e.type,payload:e.payload,error:t})}};safeInvokeGlobalListener=(e,t)=>{try{t(e)}catch(t){this.onListenerError?.({type:e.type,payload:e.payload,error:t})}}};function J(e){return q(e)}var Ft={configUpdated:J(`config.updated`),channelConfigApplyStatus:J(`channel.config.apply-status`),sessionUpdated:J(`session.updated`),sessionRunStatus:J(`session.run-status`),sessionMetadataChanged:J(`session.metadata.changed`),ncpEvent:J(`ncp.event`),sessionSummaryUpsert:J(`session.summary.upsert`),sessionSummaryDelete:J(`session.summary.delete`),uiShowContent:J(`ui.show-content`),configReloadStarted:J(`config.reload.started`),configReloadFinished:J(`config.reload.finished`),error:J(`error`),connectionOpen:J(`connection.open`),connectionClose:J(`connection.close`),connectionError:J(`connection.error`),runtimeUpdateSnapshot:J(`runtime.update.snapshot`)},It=`session_materialization`;q(`extension.channel.config.get`),q(`extension.channel.message.submit`),q(`extension.channel.command.list`),q(`extension.channel.command.execute`),q(`extension.response`),q(`agent-run.send`),q(`agent-run.abort`),q(`agent-run.session-message.request`);var Lt=`__nextclaw_runtime_default__`;function Rt(e){return e===Lt}function zt(e){let t=e.trim().replace(/\/+$/,``);if(!t)throw Error(`NextClaw client baseUrl is required.`);return t}function Bt(e,t){return`${zt(e)}${t.startsWith(`/`)?t:`/${t}`}`}function Vt(e,t){if(!t)return e;let n=typeof t==`string`?t:t.toString();return n?`${e}${e.includes(`?`)?`&`:`?`}${n}`:e}function Ht(e,t){let n=new URL(Bt(e,t));return n.protocol===`https:`?n.protocol=`wss:`:n.protocol===`http:`&&(n.protocol=`ws:`),n.toString()}function Ut(e){let t=e??globalThis.fetch;if(typeof t!=`function`)throw Error(`NextClaw fetch transport is not available in this environment.`);return((e,n)=>t.call(globalThis,e,n))}function Wt(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){if(e.startsWith(`event:`)){n=e.slice(6).trim();continue}e.startsWith(`data:`)&&r.push(e.slice(5).trimStart())}return r.length===0?null:{event:n,data:r.join(`
|
|
3
|
+
`)}}function Gt(e){try{let t=JSON.parse(e);return t&&typeof t==`object`&&`type`in t?t:null}catch{return null}}var Kt=class{baseUrl;defaultHeaders;fetchImpl;transport;constructor(e,t){this.requestService=e;let{baseUrl:n,fetchImpl:r,headers:i,token:a,transport:o}=t;this.baseUrl=n,this.fetchImpl=Ut(r),this.transport=o,this.defaultHeaders={Accept:`application/json`,...i??{},...a?{Authorization:`Bearer ${a}`}:{}}}send=async e=>await this.requestService.post(`/api/agent-runs/send`,e);abort=async e=>await this.requestService.post(`/api/agent-runs/abort`,e);stream=(e,t,n={})=>{if(this.transport)throw Error(`Agent run streaming requires the HTTP fetch transport.`);let r=new AbortController,i=()=>r.abort(n.signal?.reason);return n.signal?.addEventListener(`abort`,i,{once:!0}),this.consumeStream(e,t,r.signal,n.onError).finally(()=>{n.signal?.removeEventListener(`abort`,i)}),{close:()=>{r.abort(),n.signal?.removeEventListener(`abort`,i)}}};consumeStream=async(e,t,n,r)=>{try{let r=new URL(Bt(this.baseUrl,`/api/agent-runs/stream`));r.searchParams.set(`sessionId`,e.sessionId);let i=await this.fetchImpl(r.toString(),{method:`GET`,headers:{...this.defaultHeaders,Accept:`text/event-stream`},signal:n});if(!i.ok)throw Error(`Agent run stream failed with HTTP ${i.status}.`);if(!i.body)throw Error(`Agent run stream response has no body.`);await this.readEventStream(i.body,t,n)}catch(e){if(n.aborted)return;r?.(e)}};readEventStream=async(e,t,n)=>{let r=e.getReader(),i=new TextDecoder,a=``;try{for(;!n.aborted;){let{done:e,value:n}=await r.read();if(e)break;a+=i.decode(n,{stream:!0}),a=this.drainFrames(a,t)}a+=i.decode(),this.drainFrames(`${a}\n\n`,t)}finally{r.releaseLock()}};drainFrames=(e,t)=>{let n=e.replaceAll(`\r
|
|
4
|
+
`,`
|
|
5
|
+
`).split(`
|
|
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}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)},Xt=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)},Zt=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);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:e.all?{all:`1`}:void 0});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)},Qt=class{constructor(e){this.requestService=e}fetchItems=async e=>await this.requestService.get(`${$t(e.type)}/items`,{query:en(e)});fetchItem=async(e,t)=>await this.requestService.get(`${$t(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(`${$t(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(`${$t(tn(e.type))}/install`,e);fetchInstalled=async e=>await this.requestService.get(`${$t(e)}/installed`);manage=async e=>await this.requestService.post(`${$t(tn(e.type))}/manage`,e)};function $t(e){return e===`skill`?`/api/marketplace/skills`:`/api/marketplace/mcp`}function en(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 tn(e){if(!e)throw Error(`Marketplace request type is required.`);return e}var nn=class{constructor(e){this.requestService=e}fetchItems=async(e={})=>await this.requestService.get(`/api/marketplace/mcp/items`,{query:rn(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 rn(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 an=`x-nextclaw-panel-bridge-session`;function on(e){return e?{[an]:e}:void 0}var sn=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:on(t.bridgeSessionToken)});generateAgentObject=async(e,t={})=>await this.requestService.post(`/api/panel-app-agent/generate-object`,e,{headers:on(t.bridgeSessionToken)});grantAgentCapability=async(e,t={})=>await this.requestService.post(`/api/panel-app-agent-capabilities/${encodeURIComponent(e)}/grant`,{},{headers:on(t.bridgeSessionToken)})},cn=class{constructor(e){this.requestService=e}list=async()=>await this.requestService.get(`/api/providers`);listTemplates=async()=>await this.requestService.get(`/api/provider-templates`);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);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`,{})},ln=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}}},un=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}`,{})},Y=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 dn(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function fn(e,t){return dn(e)?e[t]:void 0}var pn=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 Y({message:e.message,status:t.status,code:e.code,details:e.details})}if(!this.isApiResponse(n))throw new Y({message:`Unexpected NextClaw API response shape.`,status:t.status});if(!n.ok)throw new Y({message:n.error.message,status:t.status,code:n.error.code,details:n.error.details});return n.data}catch(e){throw e instanceof Y?e:e instanceof Error&&e.name===`AbortError`?new Y({message:`NextClaw API request timed out after ${l}ms.`}):new Y({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 Y({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 Y)throw e;let t=fn(e,`code`),n=fn(e,`details`),r=fn(e,`status`);throw new Y({message:e instanceof Error?e.message:`NextClaw API request failed.`,code:typeof t==`string`?t:void 0,details:dn(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`,...mn(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 Y({message:e.message,status:n.status,code:e.code,details:e.details})}if(!this.isApiResponse(i)||!i.ok)throw new Y({message:`Unexpected NextClaw upload response shape.`,status:n.status});return i.data}catch(e){throw e instanceof Y?e:e instanceof Error&&e.name===`AbortError`?new Y({message:`NextClaw API upload timed out after ${s}ms.`}):new Y({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 mn(e){return e?{Authorization:`Bearer ${e}`}:null}var hn=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`,{})},gn=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`,{});updatePreferences=async e=>await this.requestService.put(`/api/runtime/update/preferences`,e);updateChannel=async e=>await this.requestService.put(`/api/runtime/update/channel`,{channel:e})},_n=class{constructor(e){this.requestService=e}browse=async e=>{let t=typeof e?.path==`string`?e.path.trim():``;return await this.requestService.get(`/api/server-paths/browse`,{query:{...t?{path:t}:{},...e?.includeFiles?{includeFiles:`1`}:{}}})};read=async e=>{let t=e.path.trim(),n=typeof e.basePath==`string`?e.basePath.trim():``;return await this.requestService.get(`/api/server-paths/read`,{query:{path:t,...n?{basePath:n}:{}}})}},vn=`x-nextclaw-panel-bridge-session`;function yn(e){return e?{[vn]:e}:void 0}var bn=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=>await this.requestService.delete(`/api/service-apps/${encodeURIComponent(e)}`);listServiceActions=async(e={})=>{let t=e.appId?`?${new URLSearchParams({appId:e.appId}).toString()}`:``;return await this.requestService.get(`/api/service-actions${t}`,{headers:yn(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:yn(n.bridgeSessionToken)});grantServiceAction=async(e,t={})=>await this.requestService.post(`/api/service-actions/${encodeURIComponent(e)}/grant`,{},{headers:yn(t.bridgeSessionToken)});grantServiceActions=async(e,t={})=>await this.requestService.post(`/api/service-action-grants`,{actionIds:e},{headers:yn(t.bridgeSessionToken)});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:yn(t.bridgeSessionToken)});revokeServiceActionGrant=async e=>{let t=new URLSearchParams({surface:e.caller.surface,appId:e.caller.appId});return await this.requestService.delete(`/api/service-action-grants/${encodeURIComponent(e.actionId)}?${t.toString()}`)}},xn=class{constructor(e,t){this.requestService=e,this.eventBus=t}list=async e=>{let{limit:t,peerId:n}=e??{},r=new URLSearchParams;typeof t==`number`&&Number.isFinite(t)&&r.set(`limit`,String(Math.max(1,Math.trunc(t))));let i=n?.trim();return i&&r.set(`peerId`,i),await this.requestService.get(`/api/ncp/sessions`,{...r.size>0?{query:r}:{}})};get=async e=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}`);listMessages=async(e,t=200)=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/messages`,{query:{limit:Math.max(1,Math.trunc(t))}});listSkills=async(e,t)=>await this.requestService.get(`/api/ncp/sessions/${encodeURIComponent(e)}/skills`,{query:t?.projectRoot?.trim()?{projectRoot:t.projectRoot.trim()}:void 0});update=async(e,t)=>await this.requestService.put(`/api/ncp/sessions/${encodeURIComponent(e)}`,t);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)})})},Sn=class{baseUrl;agentRuns;app;agents;auth;channelAuth;config;eventBus;marketplace;mcpMarketplace;panelApps;providers;realtime;remote;runtimeControl;runtimeUpdate;serverPaths;serviceApps;sessions;constructor(e){this.baseUrl=zt(e.baseUrl);let t={...e,baseUrl:this.baseUrl},n=new pn(t);this.realtime=new ln(t);let r=null;this.eventBus=new Pt({onFirstSubscriber:()=>{r??=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:()=>{r?.close(),r=null}}),this.agentRuns=new Kt(n,t),this.app=new Jt(n),this.agents=new qt(n,this.baseUrl),this.auth=new Yt(n),this.channelAuth=new Xt(n),this.config=new Zt(n),this.marketplace=new Qt(n),this.mcpMarketplace=new nn(n),this.panelApps=new sn(n),this.providers=new cn(n),this.remote=new un(n),this.runtimeControl=new hn(n),this.runtimeUpdate=new gn(n),this.serverPaths=new _n(n),this.serviceApps=new bn(n),this.sessions=new xn(n,this.eventBus)}},Cn=`http://127.0.0.1:55667`,wn=(()=>{let e=(void 0)?.trim();return e?e.replace(/\/$/,``):typeof window<`u`&&window.location?.origin?window.location.origin:Cn})(),Tn={"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 En(e){return e.activeSystemAction?`service-transitioning`:e.lifecyclePhase}function Dn(e){return e===`ready`?`connected`:e===`startup-failed`||e===`stalled`?`disconnected`:`connecting`}function On(e){let t=En(e);return{...e,phase:t,connectionStatus:Dn(t)}}function kn(e){return e===`start-service`?`starting-service`:e===`stop-service`?`stopping-service`:e===`restart-service`?`restarting-service`:`restarting-app`}function An(e){return e===`start-service`?`starting`:e===`stop-service`?`stopping`:e===`restart-service`?`restarting`:null}function X(e){if(!e)return null;let t=Tn[e.trim()];return t?r(t):e}function jn(e){let{action:t,message:n}=e;return{action:t,lifecycle:kn(t),serviceState:An(t),message:n}}function Mn(e){if(e.runtimeControlError)return{tone:`inactive`,title:r(`runtimeControlLoadFailed`),description:e.runtimeControlError,reasonLines:[],actionLabel:null,isBusy:!1};if(!e.runtimeControlView)return{tone:`inactive`,title:r(`runtimeStatusLoadingTitle`),description:r(`runtimeStatusLoadingDescription`),reasonLines:[],actionLabel:null,isBusy:!!e.activeSystemAction};if(e.activeSystemAction)return{tone:`attention`,title:r(`runtimeControlTitle`),description:X(e.activeSystemAction.message)||X(e.runtimeControlView.message)||r(`runtimeControlDescription`),reasonLines:[],actionLabel:null,isBusy:!0};let t=e.runtimeControlView;return t.pendingRestart?{tone:`attention`,title:r(`runtimeStatusPendingRestartTitle`),description:r(`runtimeStatusPendingRestartDescription`),reasonLines:t.pendingRestart.changedPaths.length>0?t.pendingRestart.changedPaths.map(e=>r(`runtimeStatusPendingRestartReasonItem`).replace(`{path}`,e)):[t.pendingRestart.message],actionLabel:t.canRestartService.available?r(`runtimeStatusRestartAction`):null,isBusy:!1}:{tone:t.lifecycle===`healthy`?`healthy`:`inactive`,title:r(`runtimeStatusHealthyTitle`),description:r(`runtimeStatusHealthyDescription`),reasonLines:[],actionLabel:null,isBusy:!1}}function Nn(e){let t=e.activeSystemAction,n=e.runtimeControlView;return{controlView:n,visibleLifecycle:t?.lifecycle??n?.lifecycle??`healthy`,visibleServiceState:t?.serviceState??n?.serviceState??`unknown`,visibleMessage:X(t?.message)||X(e.lastSystemActionError)||X(n?.message)||r(`runtimeControlDescription`),busyAction:t?.action??null,busy:!!t,pendingRestart:n?.pendingRestart??null,errorMessage:X(e.lastSystemActionError)||X(e.runtimeControlError)||null}}var Pn={lifecyclePhase:`cold-starting`,hasReachedReady:!1,lastReadyAt:null,recoveryStartedAt:null,bootstrapStatus:null,lastError:null,lastTransportError:null,runtimeControlView:null,runtimeControlError:null,activeSystemAction:null,lastSystemActionError:null},Fn=i(e=>({state:Pn,patchState:t=>e(e=>({state:{...e.state,...t}}))}));function In(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 Ln=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],In(e.stages),this.clock=e.clock??(()=>Date.now())}},Rn=3e4,zn={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 Bn(e){return e instanceof Error?e.message:String(e??``)}function Vn(e){return e&&(e.ncpAgent.error?.trim()||e.lastError?.trim())||null}function Hn(e){return r(e===`start-service`?`runtimeControlStartingServiceHelp`:e===`restart-service`?`runtimeControlRestartingServiceHelp`:e===`stop-service`?`runtimeControlStoppingServiceHelp`:`runtimeControlRestartingAppHelp`)}var Z=new class{constructor(){this.recoveryTimeoutId=null,this.runtimeBootstrapProbeCadence=new Ln(zn),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 ga()),this.reportBootstrapStatus=e=>{let t=this.getState(),n=Vn(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=Bn(e).trim();if(t&&!this.reportTransportFailure(t)){if(this.getState().hasReachedReady){this.transitionToRecovering(t);return}this.transitionToStartupFailed(t)}},this.reportTransportFailure=e=>{let t=Bn(e).trim();return zr(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=Bn(e).trim();t&&this.patchState({runtimeControlError:t})},this.runRuntimeControlAction=async e=>{this.patchState({activeSystemAction:jn({action:e,message:Hn(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:r(`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:r(`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=()=>On(this.getState()),this.requestRuntimeBootstrapProbeNow=()=>{this.runtimeBootstrapProbeCadence.requestManualTrigger(),At.refetchQueries({queryKey:[`runtime-bootstrap-status`]})},this.resetForTests=()=>{this.clearRecoveryTimeout(),this.runtimeBootstrapProbeCadence.reset(),Fn.setState({state:Pn})},this.getState=()=>Fn.getState().state,this.patchState=e=>{Fn.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`})},Rn)),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&&At.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 _a();if(e===`stop-service`)return await ya();if(e===`restart-app`){if(!t||typeof t.restartApp!=`function`)throw Error(r(`runtimeRestartAppUnavailable`));let e=await t.restartApp();return{accepted:e.accepted,action:`restart-app`,lifecycle:e.lifecycle,message:e.message}}return await va()},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(r(`runtimeRecoveryTimedOut`))},this.refreshRuntimeControlView=async()=>{try{let e=await this.getRuntimeControl();this.syncRuntimeControlQueryCache(e),this.reportRuntimeControlView(e)}catch(e){this.reportRuntimeControlError(e)}},this.syncRuntimeControlQueryCache=e=>{At.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:r(`runtimeControlEnvironmentDesktop`),managementHint:r(`runtimeControlDesktopServiceHint`)}},this.getDesktopBridge=()=>typeof window>`u`?null:window.nextclawDesktop??null}};function Un(){let e=et({queryKey:[`runtime-bootstrap-status`],queryFn:()=>ai({timeoutMs:5e3}),refetchInterval:e=>Z.getRuntimeBootstrapPollInterval(e.state.data),retry:!1}),t=et({queryKey:[`runtime-control`],queryFn:async()=>await Z.getRuntimeControl(),staleTime:5e3});(0,V.useEffect)(()=>{e.data&&Z.reportBootstrapStatus(e.data)},[e.data]),(0,V.useEffect)(()=>{e.error&&Z.reportBootstrapQueryError(e.error)},[e.error]),(0,V.useEffect)(()=>{t.data&&Z.reportRuntimeControlView(t.data)},[t.data]),(0,V.useEffect)(()=>{t.error&&Z.reportRuntimeControlError(t.error)},[t.error])}function Wn(){return On(Fn(e=>e.state))}function Gn(){return Mn(Fn(e=>e.state))}function Kn(){return Nn(Fn(e=>e.state))}var Q=i(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),qn=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.updatePreferences=async e=>await this.desktopApi.updatePreferences(e),this.updateChannel=async e=>await this.desktopApi.updateChannel(e)}},Jn=class{constructor(){this.kind=`runtime-host`,this.getState=async()=>await ba(),this.checkForUpdates=async()=>await xa(),this.downloadUpdate=async()=>await Sa(),this.applyDownloadedUpdate=async()=>await Ca(),this.updatePreferences=async e=>await wa(e),this.updateChannel=async e=>await Ta(e)}},Yn=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){Q.setState({supported:!1,initialized:!0,snapshot:null});return}e.kind===`desktop-bridge`&&!this.unsubscribe&&(this.unsubscribe=e.subscribe(e=>{Q.setState({supported:!0,initialized:!0,snapshot:e})})),Q.setState({supported:!0,initialized:!1});try{let t=await e.getState();Q.setState({supported:!0,initialized:!0,snapshot:t})}catch(t){if(e.kind===`runtime-host`&&this.isUnsupportedError(t)){Q.setState({supported:!1,initialized:!0,snapshot:null});return}Q.setState({supported:!0,initialized:!0}),G.error(`${r(`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`&&Q.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`,r(`runtimeUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){G.success(r(`runtimeUpdatesAlreadyLatest`));return}if(e.status===`update-available`){G.success(r(`runtimeUpdatesAvailable`).replace(`{version}`,e.availableVersion??r(`runtimeUpdatesUnknownVersion`)));return}e.status===`downloaded`&&G.success(r(`runtimeUpdatesReadyToApply`))},this.downloadUpdate=async()=>{try{await this.runSnapshotCommand(`downloading`,r(`runtimeUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,r(`runtimeUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,r(`runtimeUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(Q.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,r(`runtimeUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){G.success(r(`runtimeUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}G.success(r(`runtimeUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.refreshSnapshot=async()=>{if(!(!this.source||this.source.kind!==`runtime-host`))try{let e=await this.source.getState();Q.setState({supported:!0,initialized:!0,snapshot:e})}catch{}},this.runSnapshotCommand=async(e,t,n)=>{let i=this.source??this.resolveSource();if(!i)throw Error(r(`runtimeUpdatesUnavailableDescription`));this.source=i,Q.setState({busyAction:e});try{let e=await n(i);return Q.setState({snapshot:e}),e}catch(e){throw G.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{Q.setState({busyAction:null})}},this.resolveSource=()=>{let e=this.getDesktopApi();return e?new qn(e):new Jn},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:r(`error`),this.getChannelLabel=e=>r(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}},Xn={maxRetries:8,startupTimeoutMs:2e3,settledTimeoutMs:5e3,retryBaseDelayMs:500,retryMaxDelayMs:3e3};function Zn(e){return e instanceof Error?zr(e.message):!1}function Qn(e,t){return e>=Xn.maxRetries?!1:Zn(t)}function $n(e){return Math.min(Xn.retryMaxDelayMs,Xn.retryBaseDelayMs*2**Math.max(0,e-1))}function er(){let[e,t]=(0,V.useState)(!1),n=et({queryKey:[`auth-status`],queryFn:()=>Qr({timeoutMs:e?Xn.settledTimeoutMs:Xn.startupTimeoutMs}),staleTime:5e3,retry:Qn,retryDelay:$n});return(0,V.useEffect)(()=>{n.isSuccess&&!e&&t(!0)},[e,n.isSuccess]),n}function tr(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 nr(){let e=U();return tt({mutationFn:$r,onSuccess:async()=>{await tr(e),G.success(r(`authSetupSuccess`))},onError:e=>{G.error(`${r(`authActionFailed`)}: ${e.message}`)}})}function rr(){let e=U();return tt({mutationFn:ei,onSuccess:async()=>{await tr(e),G.success(r(`authLoginSuccess`))},onError:e=>{G.error(`${r(`authActionFailed`)}: ${e.message}`)}})}function ir(){let e=U();return tt({mutationFn:ti,onSuccess:async()=>{await tr(e),G.success(r(`authLogoutSuccess`))},onError:e=>{G.error(`${r(`authActionFailed`)}: ${e.message}`)}})}function ar(){let e=U();return tt({mutationFn:ni,onSuccess:async()=>{await tr(e),G.success(r(`authPasswordUpdated`))},onError:e=>{G.error(`${r(`authActionFailed`)}: ${e.message}`)}})}function or(){let e=U();return tt({mutationFn:ri,onSuccess:async(t,n)=>{await tr(e),G.success(n.enabled?r(`authEnabledSuccess`):r(`authDisabledSuccess`))},onError:e=>{G.error(`${r(`authActionFailed`)}: ${e.message}`)}})}var sr=8;function cr(e){return e.trim().length>=sr}function lr(e,t){return e===t?!0:(G.error(r(`authPasswordMismatch`)),!1)}function ur({children:e,contentClassName:t=`space-y-6`}){return(0,H.jsxs)(d,{children:[(0,H.jsxs)(s,{children:[(0,H.jsx)(f,{children:r(`authSecurityTitle`)}),(0,H.jsx)(l,{children:r(`authSecurityDescription`)})]}),(0,H.jsx)(p,{className:t,children:e})]})}function dr({canSubmitSetup:e,isPending:t,onSubmit:n,setSetupConfirmPassword:i,setSetupPassword:a,setSetupUsername:o,setupConfirmPassword:s,setupPassword:c,setupUsername:l}){return(0,H.jsxs)(ur,{contentClassName:`space-y-5`,children:[(0,H.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50/70 p-4`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:r(`authSetupTitle`)}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-gray-500`,children:r(`authSetupDescription`)})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Mt,{htmlFor:`auth-setup-username`,children:r(`authUsername`)}),(0,H.jsx)(jt,{id:`auth-setup-username`,value:l,onChange:e=>o(e.target.value),placeholder:r(`authUsernamePlaceholder`)})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Mt,{htmlFor:`auth-setup-password`,children:r(`authPassword`)}),(0,H.jsx)(jt,{id:`auth-setup-password`,type:`password`,value:c,onChange:e=>a(e.target.value),placeholder:r(`authPasswordPlaceholder`)})]})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Mt,{htmlFor:`auth-setup-confirm`,children:r(`authConfirmPassword`)}),(0,H.jsx)(jt,{id:`auth-setup-confirm`,type:`password`,value:s,onChange:e=>i(e.target.value),placeholder:r(`authConfirmPasswordPlaceholder`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`authPasswordMinLengthHint`)})]}),(0,H.jsx)(u,{type:`button`,disabled:!e,onClick:()=>void n(),children:r(t?`authSettingUp`:`authSetupAction`)})]})}function fr({authenticated:e,canUpdatePassword:t,enabled:n,isLoggingOut:i,isUpdatingEnabled:a,isUpdatingPassword:o,nextConfirmPassword:s,nextPassword:c,onEnabledChange:l,onLogout:d,onPasswordUpdate:f,setNextConfirmPassword:p,setNextPassword:m,username:g}){return(0,H.jsxs)(ur,{children:[(0,H.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-start md:justify-between`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:r(`authStatusLabel`)}),(0,H.jsx)(`p`,{className:`text-sm text-gray-600`,children:r(`authStatusConfiguredUser`).replace(`{username}`,g??``)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`authUsernameFixedHelp`)})]}),(0,H.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-gray-100 px-3 py-1 text-xs font-medium text-gray-700`,children:r(n?`enabled`:`disabled`)})]}),(0,H.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4 border-t border-gray-200 pt-4 md:flex-row md:items-center md:justify-between`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:r(`authEnableLabel`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(n?`authEnableOnHelp`:`authEnableOffHelp`)})]}),(0,H.jsx)(h,{checked:n,disabled:a,onCheckedChange:e=>{l(e)}})]})]}),(0,H.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-4 space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:r(`authPasswordSectionTitle`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`authPasswordSectionDescription`)})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Mt,{htmlFor:`auth-password-next`,children:r(`authPassword`)}),(0,H.jsx)(jt,{id:`auth-password-next`,type:`password`,value:c,onChange:e=>m(e.target.value),placeholder:r(`authPasswordPlaceholder`)})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Mt,{htmlFor:`auth-password-confirm`,children:r(`authConfirmPassword`)}),(0,H.jsx)(jt,{id:`auth-password-confirm`,type:`password`,value:s,onChange:e=>p(e.target.value),placeholder:r(`authConfirmPasswordPlaceholder`)})]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(u,{type:`button`,disabled:!t,onClick:()=>void f(),children:r(o?`authPasswordUpdating`:`authPasswordAction`)}),n&&e?(0,H.jsx)(u,{type:`button`,variant:`outline`,disabled:i,onClick:()=>void d(),children:r(i?`authLoggingOut`:`authLogoutAction`)}):null]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`authSessionMemoryNotice`)})]})]})}function pr(){let e=er(),t=nr(),n=or(),i=ar(),a=ir(),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(``),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(``),_=e.data,v=o.trim().length>0&&cr(c)&&c===d&&!t.isPending,y=cr(p)&&p===h&&!i.isPending;return e.isLoading&&!_?(0,H.jsx)(ur,{contentClassName:`text-sm text-gray-500`,children:r(`loading`)}):e.isError||!_?(0,H.jsxs)(ur,{contentClassName:`space-y-4`,children:[(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:r(`authStatusLoadFailed`)}),(0,H.jsx)(u,{variant:`outline`,onClick:()=>void e.refetch(),children:r(`authRetryStatus`)})]}):_.configured?(0,H.jsx)(fr,{authenticated:_.authenticated,enabled:_.enabled,username:_.username,nextPassword:p,setNextPassword:m,nextConfirmPassword:h,setNextConfirmPassword:g,canUpdatePassword:y,isUpdatingEnabled:n.isPending,isUpdatingPassword:i.isPending,isLoggingOut:a.isPending,onEnabledChange:async e=>{try{await n.mutateAsync({enabled:e})}catch{}},onPasswordUpdate:async()=>{if(lr(p,h))try{await i.mutateAsync({password:p}),m(``),g(``)}catch{}},onLogout:async()=>{try{await a.mutateAsync()}catch{}}}):(0,H.jsx)(dr,{setupUsername:o,setSetupUsername:s,setupPassword:c,setSetupPassword:l,setupConfirmPassword:d,setSetupConfirmPassword:f,canSubmitSetup:v,isPending:t.isPending,onSubmit:async()=>{if(lr(c,d))try{await t.mutateAsync({username:o.trim(),password:c}),l(``),f(``)}catch{}}})}function mr(){return(0,H.jsxs)(c,{className:`space-y-6`,children:[(0,H.jsx)(m,{title:r(`authSecurityTitle`),description:r(`authSecurityDescription`)}),(0,H.jsx)(pr,{})]})}function hr(e){return e.replace(/\s+/g,` `).trim().slice(0,200)}function gr(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 _r(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=_r(e);return Z.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?hr(o):``,n=gr(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 yr(e){let t=e.split(`
|
|
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
|
+
`);if(a)try{i=JSON.parse(a)}catch{i=a}return{name:n,payload:i}}function br(e,t,n){let r=yr(e);r&&(r.name===`final`&&n(r.payload),t(r))}function xr(e,t,n){let r=e,i=r.indexOf(`
|
|
10
|
+
|
|
11
|
+
`);for(;i!==-1;)br(r.slice(0,i),t,n),r=r.slice(i+2),i=r.indexOf(`
|
|
12
|
+
|
|
13
|
+
`);return r}async function Sr(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=xr(i,t,e=>{a=e})}i.trim()&&br(i,t,e=>{a=e})}finally{n.releaseLock()}return a}function Cr(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 wr(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 Tr(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 Er(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}var Dr=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}}},Or=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=kr(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 wr(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:Er(`Request failed for ${e.method} ${e.path} | ${Tr(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 Z.reportTransportFailure(Tr(t)),Er(`Stream request failed for ${e.method} ${e.path} | ${Tr(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 Sr(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 Dr(Cr(this.apiBase,e.wsPath??`/ws`))}};function kr(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 Ar(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 jr(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 Mr(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var Nr=15e3,Pr=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=Mr(`req`),n=Number.isFinite(e.timeoutMs)&&(e.timeoutMs??0)>0?Math.trunc(e.timeoutMs):Nr;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=Mr(`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=Cr(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(Ar(e.body,e.status,`Remote request failed.`));return}try{t.resolve(jr(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))}}}},Fr=`/_remote/runtime`,Ir={mode:`remote`,protocolVersion:1,wsPath:`/_remote/ws`};async function Lr(e){let t=`${e.replace(/\/$/,``)}${Fr}`,n;try{n=await fetch(t,{method:`GET`,credentials:`include`,cache:`no-store`})}catch{return new Or({apiBase:e})}if(n.status===404)return new Or({apiBase:e});if(!(n.headers.get(`content-type`)?.toLowerCase()??``).includes(`application/json`))return n.status>=400?new Pr(Ir,e):new Or({apiBase:e});let r=null;try{r=await n.json()}catch{return n.status>=400?new Pr(Ir,e):new Or({apiBase:e})}return n.ok&&r.ok&&r.data?.mode===`remote`?new Pr(r.data,e):n.status>=400?new Pr(Ir,e):new Or({apiBase:e})}var Rr=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||=Lr(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 zr(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 $=new Sn({baseUrl:wn,transport:{request:async({body:e,headers:t,method:n,path:r,query:i,signal:a,timeoutMs:o})=>await Rr.request({method:n,path:Wr(r,Ur(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(`${wn}${n}`,{method:`POST`,body:e,credentials:`include`,...t?{headers:t}:{},...r?{signal:r}:{}}),a=await i.json();if(!i.ok||!a.ok)throw Error(Gr(a,`Upload failed for ${n}`));return a.data},subscribe:e=>Rr.subscribe(e)}});async function Br(e,t={}){let n=(t.method||`GET`).toUpperCase();try{return{ok:!0,data:await Rr.request({method:n,path:e,...t.timeoutMs===void 0?{}:{timeoutMs:t.timeoutMs},...t.body===void 0?{}:{body:Hr(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 Vr={get:(e,t={})=>Br(e,{...t,method:`GET`}),put:(e,t)=>Br(e,{method:`PUT`,body:JSON.stringify(t)}),post:(e,t)=>Br(e,{method:`POST`,body:JSON.stringify(t)}),delete:e=>Br(e,{method:`DELETE`})};function Hr(e){if(e!=null){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}}function Ur(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 Wr(e,t){let n=t?.toString();return n?`${e}${e.includes(`?`)?`&`:`?`}${n}`:e}function Gr(e,t){return e.ok?t:e.error.message}async function Kr(){return{agents:await $.agents.list()}}async function qr(e,t){return await $.agents.update(e,t)}async function Jr(e){return await $.agents.delete(e)}async function Yr(e,t={}){return await $.channelAuth.start(e,t)}async function Xr(e,t){return await $.channelAuth.poll(e,t)}async function Zr(e,t){return await $.channelAuth.connect(e,t)}async function Qr(e={}){return await $.auth.fetchStatus({timeoutMs:e.timeoutMs??5e3})}async function $r(e){return await $.auth.setup(e)}async function ei(e){return await $.auth.login(e)}async function ti(){return await $.auth.logout()}async function ni(e){return await $.auth.updatePassword(e)}async function ri(e){return await $.auth.updateEnabled(e)}async function ii(){return await $.app.fetchMeta()}async function ai(e={}){return await $.app.fetchBootstrapStatus(e)}async function oi(){return await $.config.fetch()}async function si(){return await $.config.fetchMeta()}async function ci(){return await $.providers.list()}async function li(){return await $.providers.listTemplates()}async function ui(){return await $.config.fetchSchema()}async function di(e){return await $.config.updateModel(e)}async function fi(e){return await $.config.updateSearch(e)}async function pi(e,t){return await $.providers.update(e,t)}async function mi(e={}){return await $.providers.create(e)}async function hi(e){return await $.providers.delete(e)}async function gi(e,t){return await $.providers.testConnection(e,t)}async function _i(e,t={}){return await $.providers.startAuth(e,t)}async function vi(e,t){return await $.providers.pollAuth(e,t)}async function yi(e){return await $.providers.importAuthFromCli(e)}async function bi(e,t){return await $.config.updateChannel(e,t)}async function xi(e){return await $.config.updateRuntime(e)}async function Si(e){return await $.config.updateSecrets(e)}async function Ci(e,t){return await $.config.executeAction(e,t)}async function wi(){return await $.config.fetchChatSessionTypes()}async function Ti(e){return await $.config.fetchCronJobs(e)}async function Ei(e){return await $.config.deleteCronJob(e)}async function Di(e,t){return await $.config.setCronJobEnabled(e,t)}async function Oi(e,t){return await $.config.runCronJob(e,t)}async function ki(e){return await $.marketplace.fetchItems(e)}async function Ai(e){return await $.marketplace.fetchSkillContent(e)}async function ji(){return await $.marketplace.fetchSkillScenes()}async function Mi(e){return await $.marketplace.install(e)}async function Ni(e){return await $.marketplace.fetchInstalled(e)}async function Pi(e){return await $.marketplace.manage(e)}async function Fi(e){return await $.mcpMarketplace.fetchItems(e)}async function Ii(){return await $.mcpMarketplace.fetchInstalled()}async function Li(e){return await $.mcpMarketplace.fetchContent(e)}async function Ri(e){return await $.mcpMarketplace.install({type:`mcp`,...e})}async function zi(e){return await $.mcpMarketplace.manage({type:`mcp`,...e})}async function Bi(e){return await $.mcpMarketplace.doctor(e)}async function Vi(e){return(await $.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 Hi(e){return await $.sessions.list(e)}async function Ui(e,t=200){return await $.sessions.listMessages(e,t)}async function Wi(e,t){return await $.sessions.listSkills(e,t)}async function Gi(e,t){return await $.sessions.update(e,t)}async function Ki(e){return await $.sessions.delete(e)}function qi(e){return encodeURIComponent(e)}async function Ji(e){let t=await Vr.get(`/api/preferences/${qi(e)}`);if(!t.ok)throw Error(t.error.message);return t.data}async function Yi(e,t){let n=await Vr.put(`/api/preferences/${qi(e)}`,{value:t});if(!n.ok)throw Error(n.error.message);return n.data}var Xi={chat:{modelFavorites:`chat.modelFavorites`,newSessionType:`chat.newSession.sessionType`}};function Zi(e){return e.lastMessageAt??e.createdAt??e.updatedAt}function Qi(e){return[...e].sort((e,t)=>Zi(t).localeCompare(Zi(e)))}function $i(e,t){let n=t.updatedAt.localeCompare(e.updatedAt);return n===0?e.status===t.status||t.status===`idle`:n>0}function ea(e,t){if(e[0]!==`ncp-sessions`)return!1;let n=typeof e[2]==`string`?e[2].trim():``;return!n||t.peerId===n}function ta(e,t){if(!e)return e;let n=e.sessions.findIndex(e=>e.sessionId===t.sessionId),r=Qi(n>=0?e.sessions.map((e,r)=>r===n&&$i(e,t)?{...t,status:e.status===`running`&&t.status===`idle`?`running`:t.status}:e):[...e.sessions,t]);return{...e,sessions:r,total:r.length}}function na(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 ra(e,t){e?.setQueriesData({predicate:e=>ea(e.queryKey,t)},e=>ta(e,t))}function ia(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 aa(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>ia(e,t))}function oa(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>na(e,t))}function sa(e,t){if(t.type===`session.run-status`){aa(e,t.payload);return}if(t.type===`session.summary.upsert`){ra(e,t.payload.summary);return}oa(e,t.payload.sessionKey)}async function ca(){return await $.remote.fetchStatus()}async function la(){return await $.remote.fetchDoctor()}async function ua(e){return await $.remote.startBrowserAuth(e)}async function da(e){return await $.remote.pollBrowserAuth(e)}async function fa(){return await $.remote.logout()}async function pa(e){return await $.remote.updateAccountProfile(e)}async function ma(e){return await $.remote.updateSettings(e)}async function ha(e){return await $.remote.controlService(e)}async function ga(){return await $.runtimeControl.fetch()}async function _a(){return await $.runtimeControl.startService()}async function va(){return await $.runtimeControl.restartService()}async function ya(){return await $.runtimeControl.stopService()}async function ba(){return await $.runtimeUpdate.fetch()}async function xa(){return await $.runtimeUpdate.check()}async function Sa(){return await $.runtimeUpdate.download()}async function Ca(){return await $.runtimeUpdate.apply()}async function wa(e){return await $.runtimeUpdate.updatePreferences(e)}async function Ta(e){return await $.runtimeUpdate.updateChannel(e)}var Ea=`/api/server-paths/content`,Da=`__abs__`,Oa=`__win__`;function ka(e){return e.replace(/\\/g,`/`).split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}async function Aa(e){return await $.serverPaths.browse(e)}async function ja(e){return await $.serverPaths.read(e)}function Ma(e){let t=e.trim();if(/^[a-z]:[\\/]/i.test(t)){let[e,...n]=t.replace(/\\/g,`/`).split(`/`);return`${wn}${Ea}/${Oa}/${encodeURIComponent(e)}/${n.filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}`}return`${wn}${Ea}/${Da}/${ka(t)}`}export{gi as $,z as $t,Ni as A,It as At,ii as B,Ye as Bt,Vi as C,Un as Ct,Fi as D,Y as Dt,Ii as E,wn as Et,Pi as F,kt as Ft,wi as G,qe as Gt,si as H,Ze as Ht,mi as I,G as It,yi as J,Be as Jt,li as K,Ge as Kt,Ei as L,tt as Lt,Ai as M,Mt,ji as N,jt as Nt,Ri as O,Lt as Ot,Mi as P,At as Pt,_i as Q,B as Qt,hi as R,et as Rt,Gi as S,Wn as St,Li as T,X as Tt,ui as U,Ke as Ut,oi as V,Qe as Vt,Ti as W,Je as Wt,Oi as X,Ae as Xt,vi as Y,U as Yt,Di as Z,je as Zt,Yi as _,rr as _t,la as a,Si as at,Wi as b,Kn as bt,da as c,Yr as ct,ma as d,qr as dt,I as en,bi as et,sa as f,$ as ft,Ji as g,er as gt,Xi as h,Zn as ht,ha as i,g as in,fi as it,ki as j,Ft as jt,zi as k,Rt as kt,ua as l,Jr as lt,ra as m,mr as mt,Aa as n,j as nn,pi as nt,ca as o,Zr as ot,oa as p,zr as pt,ci as q,He as qt,ja as r,M as rn,xi as rt,fa as s,Xr as st,Ma as t,x as tn,di as tt,pa as u,Kr as ut,Ki as v,Yn as vt,Bi as w,Z as wt,Hi as x,Gn as xt,Ui as y,Q as yt,Ci as z,$e as zt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e,r as t}from"./react-DjpzoZXB.js";import{p as n,r}from"./side-dock-BcLau5S_.js";import{a as i,c as a,n as o,o as s,r as c,s as l,t as u}from"./switch-C1BWMU5c.js";import{t as d}from"./setting-row-CuozlnJd.js";var f=e();function p(){let e=r(e=>e.isVisible),p=r(e=>e.setVisible);return(0,f.jsxs)(a,{children:[(0,f.jsx)(l,{title:t(`appearance`)}),(0,f.jsxs)(o,{children:[(0,f.jsx)(i,{children:(0,f.jsxs)(s,{className:`flex items-center gap-2`,children:[(0,f.jsx)(n,{className:`h-4 w-4`}),t(`appearance`)]})}),(0,f.jsx)(c,{children:(0,f.jsx)(d,{title:t(`sideDockVisibilityTitle`),description:t(`sideDockVisibilityDescription`),control:(0,f.jsx)(u,{id:`appearance-side-dock-visible`,"aria-label":t(`sideDockVisibilityTitle`),checked:e,onCheckedChange:p})})})]})]})}export{p as AppearanceSettingsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./dist-D2eZC3OR.js";var t=e(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]);export{t};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as e,g as t,h as n,n as r,p as i,r as a,u as o,v as s}from"./react-DjpzoZXB.js";import{It as c,Lt as l,Mt as u,Nt as d,Rt as f,Yt as p,ct as m,ft as h,jt as g,ot as _,st as v}from"./api-DLtsiBKm.js";import{c as y,l as b,s as x,t as S}from"./switch-C1BWMU5c.js";import{c as C}from"./dist-D2eZC3OR.js";import{t as w}from"./search-MxAarS_g.js";import{t as T}from"./book-open-BQwWBDKb.js";import{C as E,a as D,i as O,n as ee,r as k,t as A}from"./select-D7GcNP0z.js";import{t as j}from"./external-link-CM5dnUI6.js";import{t as te}from"./loader-circle-BjmN5DeJ.js";import{t as ne}from"./x-DqL1mYLC.js";import{t as re}from"./tag-chip-DCUrQUCP.js";import{C as ie,I as ae,L as oe,S as se,dt as ce,f as le,lt as ue,nt as M,ot as de,pt as fe,w as N,x as P}from"./index-Z1fYpbNd.js";import{n as F,o as pe,p as me,r as I,t as L}from"./use-config-DAdbT5QJ.js";import{t as R}from"./config-hints-fGnUjDe9.js";import{a as z,c as B,i as he,n as ge,o as V,r as _e,s as ve,t as ye}from"./config-split-page-EidRBpP2.js";var be=C(`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`}]]),xe=C(`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`}]]),H=C(`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`}]]),Se=C(`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`}]]),Ce=C(`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`}]]),U=s(n(),1),W=i();function we({value:e,onChange:t,className:n,placeholder:r=``}){let[i,s]=(0,U.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,W.jsxs)(`div`,{className:o(`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,W.jsxs)(re,{tone:`info`,className:`gap-1 px-2 py-1 text-sm`,children:[e,(0,W.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`transition-colors hover:text-rose-200`,children:(0,W.jsx)(ne,{className:`h-3 w-3`})})]},t)),(0,W.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||a(`enterTag`)})]})}function Te(e){return e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?(0,W.jsx)(ce,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`url`)||e.includes(`host`)?(0,W.jsx)(fe,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`email`)||e.includes(`mail`)?(0,W.jsx)(xe,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`id`)||e.includes(`from`)?(0,W.jsx)(be,{className:`h-3.5 w-3.5 text-gray-500`}):e===`enabled`||e===`consentGranted`?(0,W.jsx)(Ce,{className:`h-3.5 w-3.5 text-gray-500`}):(0,W.jsx)(de,{className:`h-3.5 w-3.5 text-gray-500`})}function Ee({channelName:e,fields:t,formData:n,jsonDrafts:r,setJsonDrafts:i,updateField:o,uiHints:s}){return(0,W.jsx)(W.Fragment,{children:t.map(t=>{let c=R(`channels.${e}.${t.name}`,s),l=c?.label??t.label,f=c?.placeholder;return(0,W.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,W.jsxs)(u,{htmlFor:t.name,className:`flex items-center gap-2 text-sm font-medium text-gray-900`,children:[Te(t.name),l]}),t.type===`boolean`&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl bg-gray-50 p-3`,children:[(0,W.jsx)(`span`,{className:`text-sm text-gray-500`,children:n[t.name]?a(`enabled`):a(`disabled`)}),(0,W.jsx)(S,{id:t.name,checked:n[t.name]||!1,onCheckedChange:e=>o(t.name,e),className:`data-[state=checked]:bg-emerald-500`})]}),(t.type===`text`||t.type===`email`)&&(0,W.jsx)(d,{id:t.name,type:t.type,value:n[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:f,className:`rounded-xl`}),t.type===`password`&&(0,W.jsx)(d,{id:t.name,type:`password`,value:n[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:f??a(`leaveBlankToKeepUnchanged`),className:`rounded-xl`}),t.type===`number`&&(0,W.jsx)(d,{id:t.name,type:`number`,value:n[t.name]||0,onChange:e=>o(t.name,parseInt(e.target.value,10)||0),placeholder:f,className:`rounded-xl`}),t.type===`tags`&&(0,W.jsx)(we,{value:n[t.name]||[],onChange:e=>o(t.name,e)}),t.type===`select`&&(0,W.jsxs)(A,{value:n[t.name]||``,onValueChange:e=>o(t.name,e),children:[(0,W.jsx)(O,{className:`rounded-xl`,children:(0,W.jsx)(D,{})}),(0,W.jsx)(ee,{children:(t.options??[]).map(e=>(0,W.jsx)(k,{value:e.value,children:e.label},e.value))})]}),t.type===`json`&&(0,W.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 De=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),G=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)}})),K=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}}})),Oe=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})),ke=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})),Ae=t((e=>{var t=G().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}})),je=t((e=>{var t=G().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Me=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}})),q=t((e=>{var t=K(),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}}})),Ne=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]]}})),Pe=t((e=>{var t=Ne();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}})),Fe=t(((e,t)=>{var n=Pe();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})),Ie=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Le=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
|
+
]))+`;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)}})),J=t((e=>{var t=Ie(),n=Le();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}}})),Re=t((e=>{var t=G(),n=q(),r=K(),i=J(),a=Ie(),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}})),ze=t((e=>{var t=G(),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}})),Be=t(((e,t)=>{var n=J();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})),Ve=t(((e,t)=>{var n=J(),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})),He=t(((e,t)=>{var n=J();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})),Ue=t(((e,t)=>{var n=J(),r=G();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
|
+
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),We=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)})),Ge=t((e=>{var t=J(),n=Be(),r=Ve(),i=He(),a=Ue(),o=Le(),s=G(),c=We();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
|
+
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()))}})),Ke=t((e=>{var t=G(),n=K(),r=Oe(),i=ke(),a=Ae(),o=je(),s=Me(),c=q(),l=Fe(),u=Re(),d=ze(),f=J(),p=Ge();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(`
|
|
5
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
+
Minimum version required to store current data is: `+c+`.
|
|
7
|
+
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),qe=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[a[t*i+r]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),Je=t((e=>{var t=qe();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Ye=t((e=>{var t=qe();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
8
|
+
`;return typeof a==`function`&&a(null,p),p}})),Xe=t((e=>{var t=De(),n=Ke(),r=Je(),i=Ye();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))();function Ze(){return l({mutationFn:({channel:e,data:t})=>m(e,t)})}function Qe(){return l({mutationFn:({channel:e,data:t})=>v(e,t)})}function $e(){return l({mutationFn:({channel:e,data:t})=>_(e,t)})}var et={weixin:{title:`weixinAuthTitle`,description:`weixinAuthDescription`,hint:`weixinAuthHint`,capabilityHint:`weixinAuthCapabilityHint`,disabledHint:`weixinAuthDisabledHint`,connect:`weixinAuthConnect`,qrAlt:`weixinAuthQrAlt`,scanPrompt:`weixinAuthScanPrompt`,readyTitle:`weixinAuthReadyTitle`,readyDescription:`weixinAuthReadyDescription`,advancedTitle:`weixinAuthAdvancedTitle`,advancedDescription:`weixinAuthAdvancedDescription`},feishu:{title:`feishuAuthTitle`,description:`feishuAuthDescription`,hint:`feishuAuthHint`,capabilityHint:`feishuAuthCapabilityHint`,disabledHint:`feishuAuthDisabledHint`,connect:`feishuAuthConnect`,qrAlt:`feishuAuthQrAlt`,scanPrompt:`feishuAuthScanPrompt`,readyTitle:`feishuAuthReadyTitle`,readyDescription:`feishuAuthReadyDescription`,advancedTitle:`feishuAuthAdvancedTitle`,advancedDescription:`feishuAuthAdvancedDescription`,domainLabel:`feishuAuthDomain`}};function tt(e){let{accounts:t}=e,n=new Set;if(typeof e.defaultAccountId==`string`&&e.defaultAccountId.trim()&&n.add(e.defaultAccountId.trim()),t&&typeof t==`object`&&!Array.isArray(t))for(let e of Object.keys(t)){let t=e.trim();t&&n.add(t)}return[...n]}function nt(e,t){if(typeof e.baseUrl==`string`&&e.baseUrl.trim())return e.baseUrl.trim();if(typeof t.baseUrl==`string`&&t.baseUrl.trim())return t.baseUrl.trim()}function rt(e,t){return(typeof e.domain==`string`?e.domain.trim():``)||(typeof t.domain==`string`?t.domain.trim():``)||void 0}function it(e,t){return rt(e,t)===`lark`?`lark`:`feishu`}function at(e){return e===`lark`?`https://open.larksuite.com/app`:`https://open.feishu.cn/app`}function ot(e,t){return f({queryKey:[`channel-qr`,e,t],enabled:!!t,queryFn:()=>(0,Xe.toDataURL)(t,{errorCorrectionLevel:`M`,margin:1,width:480})}).data??null}function st({activeSession:e,baseUrl:t,channelEnabled:n,copy:r,connectButtonLabel:i,connectedAccountIds:s,disabled:c,domain:l,handleStartAuth:u,hasConnectedAccount:d,primaryAccountId:f,statusLabel:p}){return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full bg-white/90 px-3 py-1 text-xs font-medium text-primary shadow-sm`,children:[(0,W.jsx)(Se,{className:`h-3.5 w-3.5`}),a(r.title)]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-base font-semibold text-gray-900`,children:a(r.description)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-gray-600`,children:a(r.hint)})]}),(0,W.jsxs)(`div`,{className:o(`inline-flex w-fit items-center gap-2 rounded-full px-3 py-1 text-xs font-medium`,e?`bg-amber-50 text-amber-700`:d?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-600`),children:[e?(0,W.jsx)(te,{className:`h-3.5 w-3.5 animate-spin`}):(0,W.jsx)(H,{className:`h-3.5 w-3.5`}),p]}),(0,W.jsxs)(`div`,{className:`space-y-1 text-sm text-gray-600`,children:[(0,W.jsx)(`p`,{children:a(n||!d?r.capabilityHint:r.disabledHint)}),f?(0,W.jsxs)(`p`,{children:[a(`weixinAuthPrimaryAccount`),`: `,(0,W.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:f})]}):null,s.length>1?(0,W.jsxs)(`p`,{children:[a(`weixinAuthConnectedAccounts`),`: `,(0,W.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:s.join(`, `)})]}):null,t?(0,W.jsxs)(`p`,{children:[a(`weixinAuthBaseUrl`),`: `,(0,W.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:t})]}):null,l&&r.domainLabel?(0,W.jsxs)(`p`,{children:[a(r.domainLabel),`: `,(0,W.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:l})]}):null]}),(0,W.jsx)(b,{type:`button`,onClick:()=>void u(),disabled:c,className:`rounded-xl`,children:i})]})}function ct({activeSession:e,authMessage:t,copy:n,qrDataUrl:i}){return(0,W.jsx)(`div`,{className:`w-full max-w-sm rounded-2xl border border-dashed border-primary/25 bg-white/85 p-4 shadow-sm`,children:e?(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-100 bg-white p-3`,children:i?(0,W.jsx)(`img`,{src:i,alt:a(n.qrAlt),className:`mx-auto aspect-square w-full max-w-[240px] object-contain`}):(0,W.jsx)(`div`,{className:`flex aspect-square w-full items-center justify-center rounded-xl bg-gray-50 text-gray-500`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center`,children:[(0,W.jsx)(te,{className:`h-5 w-5 animate-spin`}),(0,W.jsx)(`p`,{className:`text-xs`,children:a(`weixinAuthStarting`)})]})})}),(0,W.jsxs)(`div`,{className:`space-y-1 text-xs text-gray-500`,children:[(0,W.jsx)(`p`,{children:t||e.note||a(n.scanPrompt)}),(0,W.jsxs)(`p`,{children:[a(`weixinAuthExpiresAt`),`: `,r(e.expiresAt)]})]}),(0,W.jsxs)(`a`,{href:e.qrCodeUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,W.jsx)(j,{className:`h-3.5 w-3.5`}),a(`weixinAuthOpenQr`)]})]}):(0,W.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center rounded-2xl bg-gray-50/80 px-6 text-center`,children:[(0,W.jsx)(Se,{className:`h-9 w-9 text-gray-300`}),(0,W.jsx)(`p`,{className:`mt-3 text-sm font-medium text-gray-700`,children:a(n.readyTitle)}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500`,children:a(n.readyDescription)})]})})}function lt({channelConfig:e,channelEnabled:t,channelName:n,disabled:r,formData:i}){let o=p(),s=Ze(),l=Qe(),[u,d]=(0,U.useState)(null),[f,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(!1),_=(0,U.useMemo)(()=>tt(e),[e]),v=_[0],y=nt(i,e),b=n===`feishu`?rt(i,e):void 0,x=_.length>0,S=x&&!h?null:u,C=ot(n,S?.qrCodeUrl),w=et[n];(0,U.useEffect)(()=>{if(!S)return;let e=!1,t=null,r=async()=>{try{let i=await l.mutateAsync({channel:n,data:{sessionId:S.sessionId}});if(e)return;if(m(i),i.status===`authorized`){await o.invalidateQueries({queryKey:[`config`]}),await o.invalidateQueries({queryKey:[`config-meta`]}),c.success(i.message||a(`weixinAuthAuthorized`)),d(null);return}if(i.status===`expired`||i.status===`error`){c.error(i.message||a(`weixinAuthRetryRequired`)),d(null);return}t=setTimeout(r,i.nextPollMs??S.intervalMs)}catch(t){e||(c.error(`${a(`error`)}: ${t instanceof Error?t.message:String(t)}`),d(null))}};return t=setTimeout(r,S.intervalMs),()=>{e=!0,t&&clearTimeout(t)}},[n,S,l,o]);let T=async()=>{try{let e=await s.mutateAsync({channel:n,data:{baseUrl:y,domain:b,accountId:typeof i.defaultAccountId==`string`&&i.defaultAccountId.trim()?i.defaultAccountId.trim():void 0}});g(x),d(e),m({channel:n,status:`pending`,message:e.note,nextPollMs:e.intervalMs})}catch(e){c.error(`${a(`error`)}: ${e instanceof Error?e.message:String(e)}`)}},E=S?f?.status===`scanned`?a(`weixinAuthScanned`):a(`weixinAuthWaiting`):a(x?t?`weixinAuthAuthorized`:`weixinAuthConnectedDisabled`:`weixinAuthNotConnected`),D=s.isPending?a(`weixinAuthStarting`):a(S?`weixinAuthWaiting`:x?`weixinAuthReconnect`:w.connect),O=x?a(`weixinAuthAuthorized`):f?.message;return(0,W.jsx)(`section`,{className:`rounded-2xl border border-primary/20 bg-gradient-to-br from-primary-50/70 via-white to-emerald-50/60 p-5`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:[(0,W.jsx)(st,{activeSession:S,baseUrl:y,channelEnabled:t,copy:w,connectButtonLabel:D,connectedAccountIds:_,disabled:r||s.isPending||!!S,domain:b,handleStartAuth:T,hasConnectedAccount:x,primaryAccountId:v,statusLabel:E}),(0,W.jsx)(ct,{activeSession:S,authMessage:O,copy:w,qrDataUrl:C})]})})}function ut({channelConfig:e,disabled:t,formData:n}){let r=p(),i=$e(),[o,s]=(0,U.useState)(()=>it(n,e)),[l,f]=(0,U.useState)(``),[m,h]=(0,U.useState)(``),g=at(o),_=!!(l.trim()&&m.trim())&&!t&&!i.isPending,v=async()=>{try{let e=await i.mutateAsync({channel:`feishu`,data:{domain:o,fields:{appId:l.trim(),appSecret:m.trim()}}});await r.invalidateQueries({queryKey:[`config`]}),await r.invalidateQueries({queryKey:[`config-meta`]}),c.success(e.message||a(`feishuExistingAgentConnectSuccess`)),h(``)}catch(e){c.error(`${a(`error`)}: ${e instanceof Error?e.message:String(e)}`)}};return(0,W.jsx)(`section`,{className:`rounded-2xl border border-primary/20 bg-white p-5`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:[(0,W.jsxs)(`div`,{className:`max-w-xl space-y-3`,children:[(0,W.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full bg-gray-100 px-3 py-1 text-xs font-medium text-gray-700`,children:[(0,W.jsx)(H,{className:`h-3.5 w-3.5`}),a(`feishuExistingAgentTitle`)]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-base font-semibold text-gray-900`,children:a(`feishuExistingAgentDescription`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-gray-600`,children:a(`feishuExistingAgentHint`)})]}),(0,W.jsxs)(`a`,{href:g,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-sm text-primary transition-colors hover:text-primary-hover`,children:[(0,W.jsx)(j,{className:`h-4 w-4`}),a(o===`lark`?`feishuExistingAgentOpenLarkList`:`feishuExistingAgentOpenFeishuList`)]})]}),(0,W.jsxs)(`div`,{className:`w-full max-w-sm space-y-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(u,{htmlFor:`feishu-existing-platform`,children:a(`feishuPlatform`)}),(0,W.jsxs)(A,{value:o,onValueChange:e=>s(e===`lark`?`lark`:`feishu`),children:[(0,W.jsx)(O,{id:`feishu-existing-platform`,className:`rounded-xl`,children:(0,W.jsx)(D,{})}),(0,W.jsxs)(ee,{children:[(0,W.jsx)(k,{value:`feishu`,children:`Feishu`}),(0,W.jsx)(k,{value:`lark`,children:`Lark`})]})]})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(u,{htmlFor:`feishu-existing-app-id`,children:`App ID`}),(0,W.jsx)(d,{id:`feishu-existing-app-id`,value:l,onChange:e=>f(e.target.value),className:`rounded-xl`})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(u,{htmlFor:`feishu-existing-app-secret`,children:`App Secret`}),(0,W.jsx)(d,{id:`feishu-existing-app-secret`,type:`password`,value:m,onChange:e=>h(e.target.value),className:`rounded-xl`})]}),(0,W.jsx)(b,{type:`button`,onClick:()=>void v(),disabled:!_,className:`w-full rounded-xl`,children:i.isPending?a(`feishuExistingAgentConnecting`):a(`feishuExistingAgentConnect`)})]})]})})}function dt(e){let[t,n]=(0,U.useState)(`create`);return(0,W.jsxs)(P,{value:t,onValueChange:e=>n(e===`existing`?`existing`:`create`),children:[(0,W.jsxs)(ie,{children:[(0,W.jsx)(N,{value:`create`,children:a(`feishuAuthCreateNew`)}),(0,W.jsx)(N,{value:`existing`,children:a(`feishuAuthConnectExisting`)})]}),(0,W.jsx)(se,{value:`create`,className:`mt-4`,children:(0,W.jsx)(lt,{...e,channelName:`feishu`})}),(0,W.jsx)(se,{value:`existing`,className:`mt-4`,children:(0,W.jsx)(ut,{...e})})]})}var ft=[{value:`pairing`,label:`pairing`},{value:`allowlist`,label:`allowlist`},{value:`open`,label:`open`},{value:`disabled`,label:`disabled`}],Y=[{value:`open`,label:`open`},{value:`allowlist`,label:`allowlist`},{value:`disabled`,label:`disabled`}],pt=[{value:`feishu`,label:`feishu`},{value:`lark`,label:`lark`}],mt=[{value:`off`,label:`off`},{value:`partial`,label:`partial`},{value:`block`,label:`block`},{value:`progress`,label:`progress`}];function ht(){return{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`),section:`primary`},{name:`defaultAccountId`,type:`text`,label:a(`defaultAccountId`)},{name:`domain`,type:`select`,label:a(`feishuAuthDomain`),options:pt},{name:`allowFrom`,type:`tags`,label:a(`allowFrom`)},{name:`groupPolicy`,type:`select`,label:a(`groupPolicy`),options:Y},{name:`requireMention`,type:`boolean`,label:a(`requireMention`)},{name:`accounts`,type:`json`,label:a(`accountsJson`)}],layout:[{type:`fields`,section:`primary`},{type:`custom`,sectionId:`feishu-auth`},{type:`fields`,section:`advanced`,collapsible:{title:a(`feishuAuthAdvancedTitle`),description:a(`feishuAuthAdvancedDescription`)}}]}}function gt(){return{telegram:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`)},{name:`token`,type:`password`,label:a(`botToken`)},{name:`allowFrom`,type:`tags`,label:a(`allowFrom`)},{name:`proxy`,type:`text`,label:a(`proxy`)},{name:`accountId`,type:`text`,label:a(`accountId`)},{name:`dmPolicy`,type:`select`,label:a(`dmPolicy`),options:ft},{name:`groupPolicy`,type:`select`,label:a(`groupPolicy`),options:Y},{name:`groupAllowFrom`,type:`tags`,label:a(`groupAllowFrom`)},{name:`requireMention`,type:`boolean`,label:a(`requireMention`)},{name:`mentionPatterns`,type:`tags`,label:a(`mentionPatterns`)},{name:`groups`,type:`json`,label:a(`groupRulesJson`)}]},discord:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`)},{name:`token`,type:`password`,label:a(`botToken`)},{name:`allowBots`,type:`boolean`,label:a(`allowBotMessages`)},{name:`allowFrom`,type:`tags`,label:a(`allowFrom`)},{name:`gatewayUrl`,type:`text`,label:a(`gatewayUrl`)},{name:`intents`,type:`number`,label:a(`intents`)},{name:`proxy`,type:`text`,label:a(`proxy`)},{name:`mediaMaxMb`,type:`number`,label:a(`attachmentMaxSizeMb`)},{name:`streaming`,type:`select`,label:a(`streamingMode`),options:mt},{name:`draftChunk`,type:`json`,label:a(`draftChunkingJson`)},{name:`textChunkLimit`,type:`number`,label:a(`textChunkLimit`)},{name:`accountId`,type:`text`,label:a(`accountId`)},{name:`dmPolicy`,type:`select`,label:a(`dmPolicy`),options:ft},{name:`groupPolicy`,type:`select`,label:a(`groupPolicy`),options:Y},{name:`groupAllowFrom`,type:`tags`,label:a(`groupAllowFrom`)},{name:`requireMention`,type:`boolean`,label:a(`requireMention`)},{name:`mentionPatterns`,type:`tags`,label:a(`mentionPatterns`)},{name:`groups`,type:`json`,label:a(`groupRulesJson`)}]},whatsapp:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`)},{name:`bridgeUrl`,type:`text`,label:a(`bridgeUrl`)},{name:`allowFrom`,type:`tags`,label:a(`allowFrom`)}]},feishu:ht(),dingtalk:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`)},{name:`clientId`,type:`text`,label:a(`clientId`)},{name:`clientSecret`,type:`password`,label:a(`clientSecret`)},{name:`allowFrom`,type:`tags`,label:a(`allowFrom`)}]},wecom:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`)},{name:`corpId`,type:`text`,label:a(`corpId`)},{name:`agentId`,type:`text`,label:a(`agentId`)},{name:`secret`,type:`password`,label:a(`secret`)},{name:`token`,type:`password`,label:a(`token`)},{name:`callbackPort`,type:`number`,label:a(`callbackPort`)},{name:`callbackPath`,type:`text`,label:a(`callbackPath`)},{name:`allowFrom`,type:`tags`,label:a(`allowFrom`)}]},weixin:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`),section:`primary`},{name:`defaultAccountId`,type:`text`,label:a(`defaultAccountId`)},{name:`baseUrl`,type:`text`,label:a(`baseUrl`)},{name:`pollTimeoutMs`,type:`number`,label:a(`pollTimeoutMs`)},{name:`allowFrom`,type:`tags`,label:a(`allowFrom`)},{name:`accounts`,type:`json`,label:a(`accountsJson`)}],layout:[{type:`fields`,section:`primary`},{type:`custom`,sectionId:`weixin-auth`},{type:`fields`,section:`advanced`,collapsible:{title:a(`weixinAuthAdvancedTitle`),description:a(`weixinAuthAdvancedDescription`)}}]},slack:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`)},{name:`mode`,type:`text`,label:a(`mode`)},{name:`webhookPath`,type:`text`,label:a(`webhookPath`)},{name:`allowBots`,type:`boolean`,label:a(`allowBotMessages`)},{name:`botToken`,type:`password`,label:a(`botToken`)},{name:`appToken`,type:`password`,label:a(`appToken`)}]},email:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`)},{name:`consentGranted`,type:`boolean`,label:a(`consentGranted`)},{name:`imapHost`,type:`text`,label:a(`imapHost`)},{name:`imapPort`,type:`number`,label:a(`imapPort`)},{name:`imapUsername`,type:`text`,label:a(`imapUsername`)},{name:`imapPassword`,type:`password`,label:a(`imapPassword`)},{name:`fromAddress`,type:`email`,label:a(`fromAddress`)}]},qq:{fields:[{name:`enabled`,type:`boolean`,label:a(`enabled`)},{name:`appId`,type:`text`,label:a(`appId`)},{name:`secret`,type:`password`,label:a(`appSecret`)},{name:`markdownSupport`,type:`boolean`,label:a(`markdownSupport`)},{name:`allowFrom`,type:`tags`,label:a(`allowFrom`)}]}}}function _t(t){let n=e();return t.tutorialUrls?.[n]||t.tutorialUrls?.default||t.tutorialUrl}var vt=[],yt=[{type:`fields`,section:`all`}],X=new Set,Z=new Map,Q=null;function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bt(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]=$(n[e])&&$(r)?bt(n[e],r):r;return n}function xt(e,t){let n={},r=n,i=e.split(`.`);for(let e=0;e<i.length-1;e+=1)r[i[e]]={},r=r[i[e]];return r[i[i.length-1]]=t,n}function St(e,t){return t===`all`?e:e.filter(e=>t===`primary`?e.section===`primary`:e.section!==`primary`)}function Ct(e,t){let n={};return t.filter(e=>e.type===`json`).forEach(t=>{n[t.name]=JSON.stringify(e[t.name]??{},null,2)}),n}function wt(){Q||=h.eventBus.on(g.channelConfigApplyStatus,e=>{Z.set(e.channel,e.status===`started`?{status:`applying`}:e.status===`succeeded`?{status:`applied`}:{status:`failed`,message:e.message}),X.forEach(e=>e())})}function Tt(e){return X.add(e),wt(),()=>{X.delete(e),!X.size&&Q&&(Q(),Q=null,Z.clear())}}function Et(e){return(0,U.useSyncExternalStore)(Tt,()=>e?Z.get(e)??null:null,()=>null)}function Dt(e){return e?e.status===`applying`?{className:`text-amber-600`,label:a(`channelConfigApplying`)}:e.status===`applied`?{className:`text-emerald-600`,label:a(`channelConfigApplied`)}:{className:`text-red-600`,label:`${a(`channelConfigApplyFailed`)}${e.message?`: ${e.message}`:``}`}:null}function Ot({channelApplyStatus:e,channelLabel:t,channelName:n,enabled:r,tutorialUrl:i}){return(0,W.jsx)(B,{className:`px-6 py-5`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(ae,{name:n,src:oe(n),className:o(`h-9 w-9 rounded-lg border`,r?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,W.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:n[0]})}),(0,W.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900 capitalize`,children:t})]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:a(`channelsFormDescription`)}),e?(0,W.jsx)(`p`,{className:o(`mt-2 text-xs font-medium`,e.className),children:e.label}):null,i?(0,W.jsxs)(`a`,{href:i,className:`mt-2 inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,W.jsx)(T,{className:`h-3.5 w-3.5`}),a(`channelsGuideTitle`)]}):null]}),(0,W.jsx)(M,{status:r?`active`:`inactive`,label:a(r?`statusActive`:`statusInactive`)})]})})}function kt({channelConfig:e,channelName:t,disabled:n,enabled:r,fields:i,formData:a,jsonDrafts:o,layoutBlocks:s,setJsonDrafts:c,uiHints:l,updateField:u}){return(0,W.jsx)(W.Fragment,{children:s.map((s,d)=>{if(s.type===`fields`){let e=St(i,s.section);if(e.length===0)return null;let n=(0,W.jsx)(Ee,{channelName:t,fields:e,formData:a,jsonDrafts:o,setJsonDrafts:c,updateField:u,uiHints:l});return s.collapsible?(0,W.jsxs)(`details`,{className:`group rounded-2xl border border-gray-200/80 bg-white`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-5 py-4 text-sm font-medium text-gray-900`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{children:s.collapsible.title}),s.collapsible.description?(0,W.jsx)(`p`,{className:`mt-1 text-xs font-normal text-gray-500`,children:s.collapsible.description}):null]}),(0,W.jsx)(E,{className:`h-4 w-4 text-gray-400 transition-transform group-open:rotate-180`})]}),(0,W.jsx)(`div`,{className:`space-y-6 border-t border-gray-100 px-5 py-5`,children:n})]},`${s.type}-${s.section}-${d}`):(0,W.jsx)(`div`,{children:n},`${s.type}-${s.section}-${d}`)}return s.sectionId===`feishu-auth`?(0,W.jsx)(dt,{channelConfig:e,formData:a,channelEnabled:r,disabled:n},`${s.type}-${s.sectionId}-${d}`):s.sectionId===`weixin-auth`?(0,W.jsx)(lt,{channelConfig:e,formData:a,channelName:`weixin`,channelEnabled:r,disabled:n},`${s.type}-${s.sectionId}-${d}`):null})})}function At({actions:e,channelConfig:t,channelLabel:n,channelName:r,fields:i,layoutBlocks:o,tutorialUrl:s,uiHints:l}){let u=me(),d=pe(),[f,p]=(0,U.useState)(()=>({...t})),[m,h]=(0,U.useState)(()=>Ct(t,i)),[g,_]=(0,U.useState)(null),v=Dt(Et(r)),y=typeof f.enabled==`boolean`?f.enabled:!!t.enabled,x=u.isPending||!!g,S=(e,t)=>p(n=>({...n,[e]:t})),C=e=>{e.preventDefault();let t={...f};for(let e of i){if(e.type===`password`){let n=t[e.name];(typeof n!=`string`||n.length===0)&&delete t[e.name]}if(e.type===`json`)try{t[e.name]=(m[e.name]??``).trim()?JSON.parse(m[e.name]):{}}catch{c.error(`${a(`invalidJson`)}: ${e.name}`);return}}u.mutate({channel:r,data:t})},w=e=>{if(!$(e?.channels)||!$(e.channels[r]))return;let t=e.channels[r];p(e=>bt(e,t)),h(e=>{let n={...e},r=!1;for(let e of i)e.type!==`json`||!Object.prototype.hasOwnProperty.call(t,e.name)||(n[e.name]=JSON.stringify(t[e.name]??{},null,2),r=!0);return r?n:e})},T=async e=>{_(e.id);try{let t=`channels.${r}`,n={...f};e.saveBeforeRun&&(n={...n,...e.savePatch??{}},p(n),await u.mutateAsync({channel:r,data:n}));let i=await d.mutateAsync({actionId:e.id,data:{scope:t,draftConfig:xt(t,n)}});w(i.patch),i.ok?c.success(i.message||a(`success`)):c.error(i.message||a(`error`))}catch(e){c.error(`${a(`error`)}: ${e instanceof Error?e.message:String(e)}`)}finally{_(null)}};return(0,W.jsxs)(z,{children:[(0,W.jsx)(Ot,{channelName:r,channelLabel:n,enabled:y,tutorialUrl:s,channelApplyStatus:v}),(0,W.jsxs)(`form`,{onSubmit:C,className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsx)(V,{className:`space-y-6 px-6 py-5`,children:(0,W.jsx)(kt,{channelConfig:t,channelName:r,enabled:y,fields:i,formData:f,jsonDrafts:m,layoutBlocks:o,setJsonDrafts:h,uiHints:l,updateField:S,disabled:x})}),(0,W.jsxs)(ve,{className:`flex flex-wrap items-center justify-between gap-3 px-6 py-4`,children:[(0,W.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.filter(e=>e.trigger===`manual`).map(e=>(0,W.jsx)(b,{type:`button`,onClick:()=>void T(e),disabled:x,variant:`secondary`,children:g===e.id?a(`connecting`):e.title},e.id))}),(0,W.jsx)(b,{type:`submit`,disabled:x,children:u.isPending?a(`saving`):a(`save`)})]})]})]})}function jt({channelName:e}){let{data:t}=L(),{data:n}=F(),{data:r}=I(),i=e?t?.channels[e]??null:null,o=n?.channels.find(t=>t.name===e),s=(0,U.useMemo)(()=>gt()[e||``],[e]);if(!e||!o||!i)return(0,W.jsx)(ge,{children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:a(`channelsSelectTitle`)}),(0,W.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:a(`channelsSelectDescription`)})]})});let c=s?.fields??vt,l=s?.layout??yt,u=r?.uiHints,d=R(`channels.${e}`,u)?.label??e,f=_t(o),p=JSON.stringify({channelName:e,channelConfig:i,jsonFields:c.filter(e=>e.type===`json`).map(e=>e.name)});return(0,W.jsx)(At,{actions:r?.actions?.filter(t=>t.scope===`channels.${e}`)??[],channelConfig:i,channelLabel:d,channelName:e,fields:c,layoutBlocks:l,tutorialUrl:f,uiHints:u},p)}var Mt={telegram:`channelDescTelegram`,slack:`channelDescSlack`,email:`channelDescEmail`,webhook:`channelDescWebhook`,discord:`channelDescDiscord`,feishu:`channelDescFeishu`,weixin:`channelDescWeixin`},Nt=[`weixin`,`feishu`,`discord`,`qq`];function Pt(e){let t=new Map(Nt.map((e,t)=>[e,t]));return e.map((e,t)=>({channel:e,index:t})).sort((e,n)=>{let r=t.get(e.channel.name)??1/0,i=t.get(n.channel.name)??1/0;return r===i?e.index-n.index:r-i}).map(({channel:e})=>e)}function Ft(){let{isMobile:e}=le(),{data:t}=L(),{data:n}=F(),{data:r}=I(),[i,s]=(0,U.useState)(`enabled`),[c,l]=(0,U.useState)(null),[u,f]=(0,U.useState)(``),p=(0,U.useMemo)(()=>Pt(n?.channels??[]),[n?.channels]),m=t?.channels,h=(0,U.useMemo)(()=>{let e=u.trim().toLowerCase();return p.filter(e=>i!==`enabled`||!!m?.[e.name]?.enabled).filter(t=>e?(t.displayName||t.name).toLowerCase().includes(e)||t.name.toLowerCase().includes(e):!0)},[i,m,p,u]),g=c&&h.some(e=>e.name===c)?c:e?null:h[0]?.name??null;return!t||!n?(0,W.jsx)(`div`,{className:`p-8 text-gray-400`,children:a(`channelsLoading`)}):(0,W.jsxs)(y,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,W.jsx)(x,{title:a(`channelsPageTitle`),description:a(`channelsPageDescription`)}),(0,W.jsxs)(he,{className:`xl:min-h-0`,mobileView:e?g?`detail`:`list`:void 0,onMobileBack:()=>l(null),mobileListLabel:a(`channelsPageTitle`),children:[(0,W.jsxs)(z,{children:[(0,W.jsx)(B,{className:`px-4 pt-4`,children:(0,W.jsx)(P,{value:i,onValueChange:s,children:(0,W.jsxs)(ie,{className:`mb-0 h-auto gap-3 border-b-0 bg-transparent p-0`,children:[(0,W.jsxs)(N,{value:`enabled`,className:`gap-1.5 px-0 pb-3`,children:[a(`channelsTabEnabled`),(0,W.jsx)(`span`,{className:`text-[11px] font-medium text-gray-500`,children:p.filter(e=>m?.[e.name]?.enabled).length})]}),(0,W.jsxs)(N,{value:`all`,className:`gap-1.5 px-0 pb-3`,children:[a(`channelsTabAll`),(0,W.jsx)(`span`,{className:`text-[11px] font-medium text-gray-500`,children:p.length})]})]})})}),(0,W.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(w,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,W.jsx)(d,{value:u,onChange:e=>f(e.target.value),placeholder:a(`channelsFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,W.jsxs)(V,{className:`space-y-2 p-3`,children:[h.map(e=>{let n=!!t.channels[e.name]?.enabled,i=_t(e),s=R(`channels.${e.name}`,r?.uiHints)?.help||a(Mt[e.name]||`channelDescriptionDefault`);return(0,W.jsx)(ye,{onClick:()=>l(e.name),active:g===e.name,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,W.jsx)(ae,{name:e.name,src:oe(e.name),className:o(`h-10 w-10 rounded-lg border`,n?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,W.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:e.name[0]})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName||e.name}),(0,W.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:s})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i?(0,W.jsx)(`a`,{href:i,onClick:e=>e.stopPropagation(),className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100/70 hover:text-gray-500`,title:a(`channelsGuideTitle`),children:(0,W.jsx)(j,{className:`h-3.5 w-3.5`})}):null,(0,W.jsx)(M,{status:n?`active`:`inactive`,label:a(n?`statusActive`:`statusInactive`),className:`min-w-[56px] justify-center`})]})]})},e.name)}),h.length===0?(0,W.jsx)(_e,{icon:ue,title:a(`channelsNoMatch`)}):null]})]}),(0,W.jsx)(jt,{channelName:g??void 0})]})]})}export{Ft as ChannelsList};
|