@xopcai/xopc 0.0.101 → 0.0.102
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/feishu/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/src/adapters/streaming-adapter.js +1 -1
- package/dist/extensions/telegram/src/inbound-processor.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/telegram/src/update-offset-store.js +1 -1
- package/dist/extensions/telegram/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.js +2 -2
- package/dist/extensions/weixin/src/auth/accounts.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/media/data-url.js +1 -1
- package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
- package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
- package/dist/extensions/weixin/src/workflow-progress.js +1 -1
- package/dist/gateway/static/root/assets/{agents-u8cmUfGQ.js → agents-DQ0mQxIA.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DF8m9cUE.js → apps-page-Uv4kOmDE.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-BM3doRvi.js → channels-settings-BEtP53V6.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-ah4zWEIP.js → channels-status-swr-CxTtS1hI.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-api-DgMuL_2b.js → cron-api-CznlPIZT.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-COfUPKfq.js → cron-page-Dx6dE3eD.js} +1 -1
- package/dist/gateway/static/root/assets/{dist-Dzy3Q0ZH.js → dist-DH4IuRV0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-kyxxefKh.js → extension-debug-page-BNkhvRQW.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BVbCBHoI.js → extension-page-CcIGQah2.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-t1lb2A7v.js → extension-settings-page-DuDCSb3J.js} +1 -1
- package/dist/gateway/static/root/assets/{field-primitives-6Vo1Yga4.js → field-primitives-BUwUiDf5.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-BF3psu4O.js → heartbeat-config-api-BjFW1cl-.js} +1 -1
- package/dist/gateway/static/root/assets/{index-WAyKAilR.js → index-DKgHC1Ta.js} +4 -4
- package/dist/gateway/static/root/assets/{logs-page-BTVPXcHV.js → logs-page-CiG0m81R.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-page-DqSAg_5Z.js → note-detail-page-DG3DVFTf.js} +2 -2
- package/dist/gateway/static/root/assets/{note-time-FSOjchic.js → note-time-DjlllCF3.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-DkRX7BE2.js → notes-page-D40ZpS0Y.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-Khdw35Zk.js → sessions-page-BvtdbmW8.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-advanced-gate-DspC8oEm.js → settings-advanced-gate-BQamRjkV.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DuxvUuur.js → settings-form-section-C3_sEFfD.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DN8JBZ8F.js → settings-page-D972_jaS.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-UNAcbiMb.js → share-preview-page-CKCTMo0_.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-ByYT0fXZ.js → skills-page-QwFCB4yV.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-DK_1H47k.js → utils-DCm11_KW.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BYN2EIMs.js → voice-api-key-field-CywiB7Dw.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-page.utils-Bi19YNTr.js → workflow-page.utils-g57BRfEd.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DP57FEKW.js → workflows-page-Be7l_SWw.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +7 -7
- package/dist/src/agent/agent-scope.js +1 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
- package/dist/src/agent/context/workspace-seed.js +2 -2
- package/dist/src/agent/context/workspace-state.js +1 -1
- package/dist/src/agent/goals/goal-run-store.js +4 -4
- package/dist/src/agent/goals/persistent-goal-service.js +1 -1
- package/dist/src/agent/goals/post-turn.js +2 -2
- package/dist/src/agent/image/load-image-media.js +2 -2
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/ipc/inbox.js +2 -2
- package/dist/src/agent/ipc/socket.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
- package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
- package/dist/src/agent/memory/dreaming/events.js +1 -1
- package/dist/src/agent/memory/dreaming/last-run.js +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
- package/dist/src/agent/memory/dreaming/preview.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
- package/dist/src/agent/memory/dreaming/utils.js +1 -1
- package/dist/src/agent/memory/memory-flush.js +1 -1
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
- package/dist/src/agent/reply/post-compaction-context.js +1 -1
- package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
- package/dist/src/agent/sandbox/path-policy.js +2 -2
- package/dist/src/agent/service.js +4 -4
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/config.js +1 -1
- package/dist/src/agent/skills/hub-hash.js +2 -2
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +2 -2
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/scanner.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/workflow/catalog.js +1 -1
- package/dist/src/auth/credentials.js +3 -3
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/browser/cache-dir-policy.js +1 -1
- package/dist/src/browser/cdp-local-launcher.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +3 -3
- package/dist/src/browser/providers/cloakbrowser.js +4 -4
- package/dist/src/browser/providers/playwright-doctor.js +1 -1
- package/dist/src/browser/stealth.js +1 -1
- package/dist/src/channels/outbound/persist-store.js +1 -1
- package/dist/src/channels/pairing/allow-from-file.js +1 -1
- package/dist/src/channels/pairing/pairing-store.js +2 -2
- package/dist/src/chat-commands/agent-edit.js +2 -2
- package/dist/src/chat-commands/builtins/config.js +2 -2
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/config.js +1 -1
- package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
- package/dist/src/cli/commands/extension-dev.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/extension-pack.js +1 -1
- package/dist/src/cli/commands/gateway/logs.js +1 -1
- package/dist/src/cli/commands/image.js +1 -1
- package/dist/src/cli/commands/init.js +3 -3
- package/dist/src/cli/utils/init-workspace-core.js +2 -2
- package/dist/src/commands/agents.config.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/gateway-bind.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/paths-state.js +1 -1
- package/dist/src/config/profile.js +2 -2
- package/dist/src/config/workspace-path.js +1 -1
- package/dist/src/cron/executor.js +2 -2
- package/dist/src/cron/persistence.js +1 -1
- package/dist/src/daemon/constants.js +1 -1
- package/dist/src/daemon/install-plan.js +2 -2
- package/dist/src/daemon/launchd.js +2 -2
- package/dist/src/daemon/schtasks.js +2 -2
- package/dist/src/daemon/systemd.js +2 -2
- package/dist/src/extensions/bundle-mcp.js +1 -1
- package/dist/src/extensions/discover-extensions.js +1 -1
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/lockfile.js +2 -2
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agents-admin.js +3 -3
- package/dist/src/gateway/file-path-classifier.js +2 -2
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/lib/extension-store.js +2 -2
- package/dist/src/gateway/hono/lib/static-ui.js +2 -2
- package/dist/src/gateway/hono/oauth-async.js +1 -1
- package/dist/src/gateway/hono/oauth.js +1 -1
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +1 -1
- package/dist/src/gateway/hono/routes/host-fs.js +2 -2
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +9 -22
- package/dist/src/gateway/hono/routes/notes.js.map +1 -1
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +2 -2
- package/dist/src/gateway/lock.js +3 -3
- package/dist/src/gateway/ports.js +1 -1
- package/dist/src/gateway/service/agent-runner.js +2 -2
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service.js +1 -1
- package/dist/src/gateway/workspace-fs-file-list.js +1 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/brew.js +1 -1
- package/dist/src/infra/package-json.js +1 -1
- package/dist/src/infra/package-update-steps.js +1 -1
- package/dist/src/infra/path-env.js +2 -2
- package/dist/src/infra/restart.js +2 -2
- package/dist/src/infra/stable-node-path.js +1 -1
- package/dist/src/infra/update-check.js +1 -1
- package/dist/src/infra/update-global.js +1 -1
- package/dist/src/infra/update-lock.js +3 -3
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/infra/update-startup.js +2 -2
- package/dist/src/infra/write-file-atomic.js +2 -2
- package/dist/src/media/store.js +1 -1
- package/dist/src/notes/note-attachment-sync.d.ts +2 -3
- package/dist/src/notes/note-attachment-sync.js +2 -27
- package/dist/src/notes/note-attachment-sync.js.map +1 -1
- package/dist/src/notes/note-index-meta.d.ts +6 -2
- package/dist/src/notes/note-index-meta.js +11 -16
- package/dist/src/notes/note-index-meta.js.map +1 -1
- package/dist/src/notes/note-markdown.d.ts +61 -0
- package/dist/src/notes/note-markdown.js +177 -0
- package/dist/src/notes/note-markdown.js.map +1 -0
- package/dist/src/notes/service.d.ts +9 -7
- package/dist/src/notes/service.js +163 -312
- package/dist/src/notes/service.js.map +1 -1
- package/dist/src/notes/store.js +4 -5
- package/dist/src/notes/store.js.map +1 -1
- package/dist/src/notes/types.d.ts +29 -58
- package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/session/init-session-turn.js +2 -2
- package/dist/src/session/resolve-session.js +3 -3
- package/dist/src/session/session-title.js +2 -2
- package/dist/src/session/store.js +2 -2
- package/dist/src/share/share-auto.js +2 -2
- package/dist/src/share/share-store.js +3 -3
- package/dist/src/share/share-thumbnail.js +2 -2
- package/dist/src/share/share-zip.js +1 -1
- package/dist/src/share/site-share-store.js +3 -3
- package/dist/src/share/site-static-serve.js +1 -1
- package/dist/src/storage/sqlite/connection.js +2 -2
- package/dist/src/storage/sqlite/memory-index-repository.js +2 -2
- package/dist/src/storage/sqlite/migrations/003_add_note_markdown_meta.sql +4 -0
- package/dist/src/storage/sqlite/migrations/discover.js +1 -1
- package/dist/src/storage/sqlite/migrations/runner.d.ts +2 -2
- package/dist/src/storage/sqlite/migrations/runner.js +5 -5
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +2 -2
- package/dist/src/storage/sqlite/notes-repository.js +18 -6
- package/dist/src/storage/sqlite/notes-repository.js.map +1 -1
- package/dist/src/storage/sqlite/schema.js +4 -4
- package/dist/src/storage/sqlite/schema.sql +5 -1
- package/dist/src/tui/clipboard-image.js +3 -3
- package/dist/src/tui/theme-manager.js +1 -1
- package/dist/src/tui/tui-keybindings-file.js +1 -1
- package/dist/src/tui/tui-scoped-models.js +2 -2
- package/dist/src/tui/tui-settings.js +1 -1
- package/dist/src/tui/tui.js +3 -3
- package/dist/src/tunnel/frpc-binary.js +3 -3
- package/dist/src/tunnel/frpc-config.js +1 -1
- package/dist/src/tunnel/frpc-extract.js +1 -1
- package/dist/src/tunnel/tunnel-state.js +1 -1
- package/dist/src/utils/logger/audit.js +1 -1
- package/dist/src/utils/logger/log-store.js +1 -1
- package/dist/src/utils/logger/rotation.js +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/providers/edge-speech.js +2 -2
- package/dist/src/workflows/store/event-store.js +1 -1
- package/dist/src/workflows/store/run-store.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-page-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-page-D972_jaS.js","assets/rolldown-runtime-aKtaBQYM.js","assets/settings-advanced-gate-BQamRjkV.js","assets/vendor-swr-BIWyz7Rc.js","assets/vendor-react-BOUWij0V.js","assets/channels-status-swr-CxTtS1hI.js","assets/url-q28QhI7l.js","assets/cron-api-CznlPIZT.js","assets/fetch-drJUxxKP.js","assets/utils-DCm11_KW.js","assets/circle-check-C23XjkUj.js","assets/createLucideIcon-DPHK1VkS.js","assets/copy-Dv6d4Dvw.js","assets/theme-store-B6KXPHgK.js","assets/agents-DQ0mQxIA.js","assets/settings-form-section-C3_sEFfD.js","assets/heartbeat-config-api-BjFW1cl-.js","assets/voice-api-key-field-CywiB7Dw.js","assets/toast-z0toXu32.js","assets/sessions-page-BvtdbmW8.js","assets/logs-page-CiG0m81R.js","assets/cron-page-Dx6dE3eD.js","assets/dist-DH4IuRV0.js","assets/Combination-HAlzriaz.js","assets/workflow-page.utils-g57BRfEd.js","assets/skills-page-QwFCB4yV.js","assets/preload-helper-zJ_50EbN.js","assets/attachment-preview-renderer-CybMSIoS.js","assets/excel-worksheet-utils-EyvwNT4X.js","assets/attachment-process-heavy-RnGYy9bC.js","assets/vendor-codemirror-DYoKfS8f.js","assets/notes-page-D40ZpS0Y.js","assets/note-time-DjlllCF3.js","assets/note-detail-page-DG3DVFTf.js","assets/note-detail-page-D4ZIVQbk.css","assets/workflows-page-Be7l_SWw.js","assets/channels-settings-BEtP53V6.js","assets/field-primitives-BUwUiDf5.js","assets/apps-page-Uv4kOmDE.js","assets/extension-page-CcIGQah2.js","assets/extension-settings-page-DuDCSb3J.js","assets/extension-debug-page-BNkhvRQW.js","assets/share-preview-page-CKCTMo0_.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{i as e,n as t,r as n,t as r}from"./rolldown-runtime-aKtaBQYM.js";import{a as i,i as a,n as o,r as s,t as c}from"./vendor-react-BOUWij0V.js";import{a as l,f as u,h as d,i as f,l as p,m,o as h,p as g,s as _,t as v}from"./url-q28QhI7l.js";import{i as y,n as b,o as x,s as S,t as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./preload-helper-zJ_50EbN.js";import{t as T}from"./createLucideIcon-DPHK1VkS.js";import{t as E}from"./circle-check-C23XjkUj.js";import{t as D}from"./copy-Dv6d4Dvw.js";import{_ as O,a as k,b as A,c as ee,d as te,f as ne,g as re,h as ie,i as ae,l as oe,m as se,n as ce,o as le,r as ue,s as de,t as fe,u as pe,v as me,y as he}from"./Combination-HAlzriaz.js";import{a as ge,i as _e,n as ve,r as ye,t as be}from"./theme-store-B6KXPHgK.js";import{a as xe,i as Se,n as Ce,r as we,t as Te}from"./fetch-drJUxxKP.js";import{n as Ee,r as De}from"./toast-z0toXu32.js";import{_ as Oe,a as ke,b as Ae,c as je,f as Me,g as Ne,h as Pe,l as Fe,o as Ie,s as Le,u as Re,v as ze,w as Be,x as Ve,y as He}from"./vendor-codemirror-DYoKfS8f.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ue=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);Xe(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},We={},Ge=(e,t,n,r)=>{Xe(n)&&We[n]||(Xe(n)&&(We[n]=new Date),Ue(e,t,n,r))},Ke=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},qe=(e,t,n)=>{e.loadNamespaces(t,Ke(e,n))},Je=(e,t,n,r)=>{if(Xe(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return qe(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,Ke(e,r))},Ye=(e,t,n={})=>!t.languages||!t.languages.length?(Ge(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),Xe=e=>typeof e==`string`,Ze=e=>typeof e==`object`&&!!e,j=e(i()),Qe=(0,j.createContext)(),$e=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},et=S(),tt={t:(e,t)=>{if(Xe(t))return t;if(Ze(t)&&Xe(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},nt=()=>()=>{},rt=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,j.useContext)(Qe)||{},a=n||r||g();a&&!a.reportNamespaces&&(a.reportNamespaces=new $e),a||Ge(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let o=(0,j.useMemo)(()=>({...m(),...a?.options?.react,...t}),[a,t]),{useSuspense:s,keyPrefix:c}=o,l=e||i||a?.options?.defaultNS,u=Xe(l)?[l]:l||[`translation`],d=(0,j.useMemo)(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(d);let f=(0,j.useRef)(0),p=(0,j.useCallback)(e=>{if(!a)return nt;let{bindI18n:t,bindI18nStore:n}=o,r=()=>{f.current+=1,e()};return t&&a.on(t,r),n&&a.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>a.off(e,r)),n&&n.split(` `).forEach(e=>a.store.off(e,r))}},[a,o]),h=(0,j.useRef)(),_=(0,j.useCallback)(()=>{if(!a)return tt;let e=!!(a.isInitialized||a.initializedStoreOnce)&&d.every(e=>Ye(e,a,o)),n=t.lng||a.language,r=f.current,i=h.current;if(i&&i.ready===e&&i.lng===n&&i.keyPrefix===c&&i.revision===r)return i;let s={t:a.getFixedT(n,o.nsMode===`fallback`?d:d[0],c,{scopeNs:d}),ready:e,lng:n,keyPrefix:c,revision:r};return h.current=s,s},[a,d,c,o,t.lng]),[v,y]=(0,j.useState)(0),{t:b,ready:x}=(0,et.useSyncExternalStore)(p,_,_);(0,j.useEffect)(()=>{if(a&&!x&&!s){let e=()=>y(e=>e+1);t.lng?Je(a,t.lng,d,e):qe(a,d,e)}},[a,t.lng,d,x,s,v]);let S=a||{},C=(0,j.useRef)(null),w=(0,j.useRef)(),T=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},E=(0,j.useMemo)(()=>{let e=S,t=e?.language,n=e;e&&(C.current&&C.current.__original===e&&w.current===t?n=C.current:(n=T(e),C.current=n,w.current=t));let r=!x&&!s?(...e)=>(Ge(a,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),b(...e)):b,i=[r,n,x];return i.t=r,i.i18n=n,i.ready=x,i},[b,S,x,S.resolvedLanguage,S.language,S.languages]);if(a&&s&&!x)throw new Promise(e=>{let n=()=>e();t.lng?Je(a,t.lng,d,n):qe(a,d,n)});return E};function it({i18n:e,defaultNS:t,children:n}){let r=(0,j.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,j.createElement)(Qe.Provider,{value:r},n)}var at=e=>{throw TypeError(e)},ot=(e,t,n)=>t.has(e)||at(`Cannot `+n),st=(e,t,n)=>(ot(e,t,`read from private field`),n?n.call(e):t.get(e)),ct=(e,t,n)=>t.has(e)?at(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),lt=(e,t,n,r)=>(ot(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),ut=`popstate`;function dt(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function ft(e={}){function t(e,t){let{pathname:n=`/`,search:r=``,hash:i=``}=yt(e.location.hash.substring(1));return!n.startsWith(`/`)&&!n.startsWith(`.`)&&(n=`/`+n),_t(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){let n=e.document.querySelector(`base`),r=``;if(n&&n.getAttribute(`href`)){let t=e.location.href,n=t.indexOf(`#`);r=n===-1?t:t.slice(0,n)}return r+`#`+(typeof t==`string`?t:vt(t))}function r(e,t){mt(e.pathname.charAt(0)===`/`,`relative pathnames are not supported in hash history.push(${JSON.stringify(t)})`)}return bt(t,n,r,e)}function pt(e,t){if(e===!1||e==null)throw Error(t)}function mt(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function ht(){return Math.random().toString(36).substring(2,10)}function gt(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function _t(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?yt(t):t,state:n,key:t&&t.key||r||ht(),mask:i}}function vt({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function yt(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function bt(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=dt(e)?e:_t(h.location,e,t);n&&n(r,e),l=u()+1;let d=gt(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=dt(e)?e:_t(h.location,e,t);n&&n(r,e),l=u();let i=gt(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return xt(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(ut,d),c=e,()=>{i.removeEventListener(ut,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function xt(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),pt(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:vt(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}var St,Ct=class{constructor(e){if(ct(this,St,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(st(this,St).has(e))return st(this,St).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw Error(`No value found for context`)}set(e,t){st(this,St).set(e,t)}};St=new WeakMap;var wt=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`children`]);function Tt(e){return wt.has(e)}var Et=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`middleware`,`children`]);function Dt(e){return Et.has(e)}function Ot(e){return e.index===!0}function kt(e,t,n=[],r={},i=!1){return e.map((e,a)=>{let o=[...n,String(a)],s=typeof e.id==`string`?e.id:o.join(`-`);if(pt(e.index!==!0||!e.children,`Cannot specify children on an index route`),pt(i||!r[s],`Found a route id collision on id "${s}". Route id's must be globally unique within Data Router usages`),Ot(e)){let n={...e,id:s};return r[s]=At(n,t(n)),n}else{let n={...e,id:s,children:void 0};return r[s]=At(n,t(n)),e.children&&(n.children=kt(e.children,t,o,r,i)),n}})}function At(e,t){return Object.assign(e,{...t,...typeof t.lazy==`object`&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function jt(e,t,n=`/`){return Mt(e,t,n,!1)}function Mt(e,t,n,r,i){let a=Ft((typeof t==`string`?yt(t):t).pathname||`/`,n);if(a==null)return null;let o=i??Nt(e),s=null,c=hee(a);for(let e=0;s==null&&e<o.length;++e)s=pee(o[e],c,r);return s}function eee(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Nt(e){let t=tee(e);return ree(t),t}function tee(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;pt(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Ht([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(pt(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),tee(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:dee(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of nee(e.path))a(e,t,!0,n)}),t}function nee(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=nee(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function ree(e){e.sort((e,t)=>e.score===t.score?fee(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var iee=/^:[\w-]+$/,aee=3,oee=2,see=1,cee=10,lee=-2,uee=e=>e===`*`;function dee(e,t){let n=e.split(`/`),r=n.length;return n.some(uee)&&(r+=lee),t&&(r+=oee),n.filter(e=>!uee(e)).reduce((e,t)=>e+(iee.test(t)?aee:t===``?see:cee),r)}function fee(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function pee(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=Pt({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=Pt({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:Ht([a,u.pathname]),pathnameBase:bee(Ht([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=Ht([a,u.pathnameBase]))}return o}function Pt(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=mee(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function mee(e,t=!1,n=!0){mt(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function hee(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return mt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ft(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function gee({basename:e,pathname:t}){return t===`/`?e:Ht([e,t])}var _ee=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,It=e=>_ee.test(e);function vee(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?yt(e):e,a;return n?(n=Vt(n),a=n.startsWith(`/`)?yee(n.substring(1),`/`):yee(n,t)):a=t,{pathname:a,search:xee(r),hash:See(i)}}function yee(e,t){let n=Ut(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Lt(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Rt(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function zt(e){let t=Rt(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Bt(e,t,n,r=!1){let i;typeof e==`string`?i=yt(e):(i={...e},pt(!i.pathname||!i.pathname.includes(`?`),Lt(`?`,`pathname`,`search`,i)),pt(!i.pathname||!i.pathname.includes(`#`),Lt(`#`,`pathname`,`hash`,i)),pt(!i.search||!i.search.includes(`#`),Lt(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=vee(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Vt=e=>e.replace(/\/\/+/g,`/`),Ht=e=>Vt(e.join(`/`)),Ut=e=>e.replace(/\/+$/,``),bee=e=>Ut(e).replace(/^\/*/,`/`),xee=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,See=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Wt=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Gt(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Kt(e){return Ht(e.map(e=>e.route.path).filter(Boolean))||`/`}var Cee=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function wee(e,t){let n=e;if(typeof n!=`string`||!_ee.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Cee)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=Ft(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{mt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}var qt=Symbol(`Uninstrumented`);function Tee(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(e=>e({id:t.id,index:t.index,path:t.path,instrument(e){let t=Object.keys(n);for(let r of t)e[r]&&n[r].push(e[r])}}));let r={};if(typeof t.lazy==`function`&&n.lazy.length>0){let e=Jt(n.lazy,t.lazy,()=>void 0);e&&(r.lazy=e)}if(typeof t.lazy==`object`){let e=t.lazy;[`middleware`,`loader`,`action`].forEach(t=>{let i=e[t],a=n[`lazy.${t}`];if(typeof i==`function`&&a.length>0){let e=Jt(a,i,()=>void 0);e&&(r.lazy=Object.assign(r.lazy||{},{[t]:e}))}})}return[`loader`,`action`].forEach(e=>{let i=t[e];if(typeof i==`function`&&n[e].length>0){let t=i[qt]??i,a=Jt(n[e],t,(...e)=>Oee(e[0]));a&&(e===`loader`&&t.hydrate===!0&&(a.hydrate=!0),a[qt]=t,r[e]=a)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(e=>{let t=e[qt]??e,r=Jt(n.middleware,t,(...e)=>Oee(e[0]));return r?(r[qt]=t,r):e})),r}function Eee(e,t){let n={navigate:[],fetch:[]};if(t.forEach(e=>e({instrument(e){let t=Object.keys(e);for(let r of t)e[r]&&n[r].push(e[r])}})),n.navigate.length>0){let t=e.navigate[qt]??e.navigate,r=Jt(n.navigate,t,(...t)=>{let[n,r]=t;return{to:typeof n==`number`||typeof n==`string`?n:n?vt(n):`.`,...kee(e,r??{})}});r&&(r[qt]=t,e.navigate=r)}if(n.fetch.length>0){let t=e.fetch[qt]??e.fetch,r=Jt(n.fetch,t,(...t)=>{let[n,,r,i]=t;return{href:r??`.`,fetcherKey:n,...kee(e,i??{})}});r&&(r[qt]=t,e.fetch=r)}return e}function Jt(e,t,n){return e.length===0?null:async(...r)=>{let i=await Dee(e,n(...r),()=>t(...r),e.length-1);if(i.type===`error`)throw i.value;return i.value}}async function Dee(e,t,n,r){let i=e[r],a;if(i){let o,s=async()=>(o?console.error(`You cannot call instrumented handlers more than once`):o=Dee(e,t,n,r-1),a=await o,pt(a,`Expected a result`),a.type===`error`&&a.value instanceof Error?{status:`error`,error:a.value}:{status:`success`,error:void 0});try{await i(s,t)}catch(e){console.error(`An instrumentation function threw an error:`,e)}o||await s(),await o}else try{a={type:`success`,value:await n()}}catch(e){a={type:`error`,value:e}}return a||{type:`error`,value:Error(`No result assigned in instrumentation chain.`)}}function Oee(e){let{request:t,context:n,params:r,pattern:i}=e;return{request:Aee(t),params:{...r},pattern:i,context:jee(n)}}function kee(e,t){return{currentUrl:vt(e.state.location),...`formMethod`in t?{formMethod:t.formMethod}:{},...`formEncType`in t?{formEncType:t.formEncType}:{},...`formData`in t?{formData:t.formData}:{},...`body`in t?{body:t.body}:{}}}function Aee(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function jee(e){if(Nee(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var Mee=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function Nee(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===Mee}var Pee=[`POST`,`PUT`,`PATCH`,`DELETE`],Fee=new Set(Pee),Iee=[`GET`,...Pee],Lee=new Set(Iee),Yt=new Set([301,302,303,307,308]),Ree=new Set([307,308]),Xt={state:`idle`,location:void 0,matches:void 0,historyAction:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},zee={state:`idle`,data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Zt={state:`unblocked`,proceed:void 0,reset:void 0,location:void 0},Bee=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Vee=`remix-router-transitions`,Hee=Symbol(`ResetLoaderData`),Qt,$t,en,tn,Uee=class{constructor(e){ct(this,Qt),ct(this,$t),ct(this,en),ct(this,tn),lt(this,Qt,e),lt(this,$t,Nt(e))}get stableRoutes(){return st(this,Qt)}get activeRoutes(){return st(this,en)??st(this,Qt)}get branches(){return st(this,tn)??st(this,$t)}get hasHMRRoutes(){return st(this,en)!=null}setRoutes(e){lt(this,Qt,e),lt(this,$t,Nt(e))}setHmrRoutes(e){lt(this,en,e),lt(this,tn,Nt(e))}commitHmrRoutes(){st(this,en)&&(lt(this,Qt,st(this,en)),lt(this,$t,st(this,tn)),lt(this,en,void 0),lt(this,tn,void 0))}};Qt=new WeakMap,$t=new WeakMap,en=new WeakMap,tn=new WeakMap;function Wee(e){let t=e.window?e.window:typeof window<`u`?window:void 0,n=t!==void 0&&t.document!==void 0&&t.document.createElement!==void 0;pt(e.routes.length>0,`You must provide a non-empty routes array to createRouter`);let r=e.hydrationRouteProperties||[],i=e.mapRouteProperties||Bee,a=i;if(e.instrumentations){let t=e.instrumentations;a=e=>({...i(e),...Tee(t.map(e=>e.route).filter(Boolean),e)})}let o={},s=new Uee(kt(e.routes,a,void 0,o)),c=e.basename||`/`;c.startsWith(`/`)||(c=`/${c}`);let l=e.dataStrategy||nte,u={...e.future},d=null,f=new Set,p=null,m=null,h=null,g=null,_=e.hydrationData!=null,v=Mt(s.activeRoutes,e.history.location,c,!1,s.branches),y=!1,b=null,x,S;if(v==null&&!e.patchRoutesOnNavigation){let t=yn(404,{pathname:e.history.location.pathname}),{matches:n,route:r}=vn(s.activeRoutes);x=!0,S=!x,v=n,b={[r.id]:t}}else if(v&&!e.hydrationData&&Qe(v,s.activeRoutes,e.history.location.pathname).active&&(v=null),!v){x=!1,S=!x,v=[];let t=Qe(null,s.activeRoutes,e.history.location.pathname);t.active&&t.matches&&(y=!0,v=t.matches)}else if(v.some(e=>e.route.lazy))x=!1,S=!x;else if(!v.some(e=>rn(e.route)))x=!0,S=!x;else{let t=e.hydrationData?e.hydrationData.loaderData:null,n=e.hydrationData?e.hydrationData.errors:null,r=v;if(n){let e=v.findIndex(e=>n[e.route.id]!==void 0);r=r.slice(0,e+1)}S=!1,x=!0,r.forEach(e=>{let r=Jee(e.route,t,n);S||=r.renderFallback,x&&=!r.shouldLoad})}let C,w={historyAction:e.history.action,location:e.history.location,matches:v,initialized:x,renderFallback:S,navigation:Xt,restoreScrollPosition:e.hydrationData==null?null:!1,preventScrollReset:!1,revalidation:`idle`,loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||b,fetchers:new Map,blockers:new Map},T=`POP`,E=null,D=!1,O,k=!1,A=new Map,ee=null,te=!1,ne=!1,re=new Set,ie=new Map,ae=0,oe=-1,se=new Map,ce=new Set,le=new Map,ue=new Map,de=new Set,fe=new Map,pe,me=null;function he(){if(d=e.history.listen(({action:t,location:n,delta:r})=>{if(pe){pe(),pe=void 0;return}mt(fe.size===0||r!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let i=qe({currentLocation:w.location,nextLocation:n,historyAction:t});if(i&&r!=null){let t=new Promise(e=>{pe=e});e.history.go(r*-1),Ke(i,{state:`blocked`,location:n,proceed(){Ke(i,{state:`proceeding`,proceed:void 0,reset:void 0,location:n}),t.then(()=>e.history.go(r))},reset(){let e=new Map(w.blockers);e.set(i,Zt),ve({blockers:e})}}),E?.resolve(),E=null;return}return Se(t,n)}),n){Dte(t,A);let e=()=>Ote(t,A);t.addEventListener(`pagehide`,e),ee=()=>t.removeEventListener(`pagehide`,e)}return w.initialized||Se(`POP`,w.location,{initialHydration:!0}),C}function ge(){d&&d(),ee&&ee(),f.clear(),O&&O.abort(),w.fetchers.forEach((e,t)=>Re(w.fetchers,t)),w.blockers.forEach((e,t)=>Ge(t))}function _e(e){if(f.add(e),p){let{newErrors:t}=p;p=null,e(w,{deletedFetchers:[],newErrors:t,viewTransitionOpts:void 0,flushSync:!1})}return()=>f.delete(e)}function ve(e,t={}){e.matches&&=e.matches.map(e=>{let t=o[e.route.id],n=e.route;return n.element!==t.element||n.errorElement!==t.errorElement||n.hydrateFallbackElement!==t.hydrateFallbackElement?{...e,route:t}:e}),w={...w,...e};let n=[],r=[];w.fetchers.forEach((e,t)=>{e.state===`idle`&&(de.has(t)?n.push(t):r.push(t))}),de.forEach(e=>{!w.fetchers.has(e)&&!ie.has(e)&&n.push(e)}),f.size===0&&(p={newErrors:e.errors??null}),[...f].forEach(r=>r(w,{deletedFetchers:n,newErrors:e.errors??null,viewTransitionOpts:t.viewTransitionOpts,flushSync:t.flushSync===!0})),n.forEach(e=>Re(w.fetchers,e)),r.forEach(e=>w.fetchers.delete(e))}function ye(t,n,{flushSync:r}={}){let i=w.actionData!=null&&w.navigation.formMethod!=null&&Tn(w.navigation.formMethod)&&w.navigation.state===`loading`&&t.state?._isRedirect!==!0,a;a=n.actionData?Object.keys(n.actionData).length>0?n.actionData:null:i?w.actionData:null;let o=n.loaderData?hn(w.loaderData,n.loaderData,n.matches||[],n.errors):w.loaderData,c=w.blockers;c.size>0&&(c=new Map(c),c.forEach((e,t)=>c.set(t,Zt)));let l=te?!1:j(t,n.matches||w.matches),u=D===!0||w.navigation.formMethod!=null&&Tn(w.navigation.formMethod)&&t.state?._isRedirect!==!0;s.commitHmrRoutes(),te||T===`POP`||(T===`PUSH`?e.history.push(t,t.state):T===`REPLACE`&&e.history.replace(t,t.state));let d;if(T===`POP`){let e=A.get(w.location.pathname);e&&e.has(t.pathname)?d={currentLocation:w.location,nextLocation:t}:A.has(t.pathname)&&(d={currentLocation:t,nextLocation:w.location})}else if(k){let e=A.get(w.location.pathname);e?e.add(t.pathname):(e=new Set([t.pathname]),A.set(w.location.pathname,e)),d={currentLocation:w.location,nextLocation:t}}ve({...n,actionData:a,loaderData:o,historyAction:T,location:t,initialized:!0,renderFallback:!1,navigation:Xt,revalidation:`idle`,restoreScrollPosition:l,preventScrollReset:u,blockers:c},{viewTransitionOpts:d,flushSync:r===!0}),T=`POP`,D=!1,k=!1,te=!1,ne=!1,E?.resolve(),E=null,me?.resolve(),me=null}async function be(t,n){if(E?.resolve(),E=null,typeof t==`number`){E||=kte();let n=E.promise;return e.history.go(t),n}let{path:r,submission:i,error:a}=Kee(!1,nn(w.location,w.matches,c,t,n?.fromRouteId,n?.relative),n),o;n?.mask&&(o={pathname:``,search:``,hash:``,...typeof n.mask==`string`?yt(n.mask):{...w.location.mask,...n.mask}});let s=w.location,l=_t(s,r,n&&n.state,void 0,o);l={...l,...e.history.encodeLocation(l)};let u=n&&n.replace!=null?n.replace:void 0,d=`PUSH`;u===!0?d=`REPLACE`:u===!1||i!=null&&Tn(i.formMethod)&&i.formAction===w.location.pathname+w.location.search&&(d=`REPLACE`);let f=n&&`preventScrollReset`in n?n.preventScrollReset===!0:void 0,p=(n&&n.flushSync)===!0,m=qe({currentLocation:s,nextLocation:l,historyAction:d});if(m){Ke(m,{state:`blocked`,location:l,proceed(){Ke(m,{state:`proceeding`,proceed:void 0,reset:void 0,location:l}),be(t,n)},reset(){let e=new Map(w.blockers);e.set(m,Zt),ve({blockers:e})}});return}await Se(d,l,{submission:i,pendingError:a,preventScrollReset:f,replace:n&&n.replace,enableViewTransition:n&&n.viewTransition,flushSync:p,callSiteDefaultShouldRevalidate:n&&n.defaultShouldRevalidate})}function xe(){me||=kte(),Ne(),ve({revalidation:`loading`});let e=me.promise;return w.navigation.state===`submitting`?e:w.navigation.state===`idle`?(Se(w.historyAction,w.location,{startUninterruptedRevalidation:!0}),e):(Se(T||w.historyAction,w.navigation.location,{overrideNavigation:w.navigation,enableViewTransition:k===!0}),e)}async function Se(t,n,r){O&&O.abort(),O=null,T=t,te=(r&&r.startUninterruptedRevalidation)===!0,Ze(w.location,w.matches),D=(r&&r.preventScrollReset)===!0,k=(r&&r.enableViewTransition)===!0;let i=s.activeRoutes,a=r?.initialHydration&&w.matches&&w.matches.length>0&&!y?w.matches:Mt(i,n,c,!1,s.branches),o=(r&&r.flushSync)===!0;if(a&&w.initialized&&!ne&&hte(w.location,n)&&!(r&&r.submission&&Tn(r.submission.formMethod))){ye(n,{matches:a},{flushSync:o});return}let l=Qe(a,i,n.pathname);if(l.active&&l.matches&&(a=l.matches),!a){let{error:e,notFoundMatches:t,route:r}=Je(n.pathname);ye(n,{matches:t,loaderData:{},errors:{[r.id]:e}},{flushSync:o});return}let u=r&&r.overrideNavigation?{...r.overrideNavigation,matches:a,historyAction:t}:void 0;O=new AbortController;let d=pn(e.history,n,O.signal,r&&r.submission),f=e.getContext?await e.getContext():new Ct,p;if(r&&r.pendingError)p=[_n(a).route.id,{type:`error`,error:r.pendingError}];else if(r&&r.submission&&Tn(r.submission.formMethod)){let i=await Ce(d,n,r.submission,a,t,f,l.active,r&&r.initialHydration===!0,{replace:r.replace,flushSync:o});if(i.shortCircuited)return;if(i.pendingActionResult){let[e,t]=i.pendingActionResult;if(Sn(t)&&Gt(t.error)&&t.error.status===404){O=null,ye(n,{matches:i.matches,loaderData:{},errors:{[e]:t.error}});return}}a=i.matches||a,p=i.pendingActionResult,u=On(n,a,t,r.submission),o=!1,l.active=!1,d=pn(e.history,d.url,d.signal)}let{shortCircuited:m,matches:h,loaderData:g,errors:_,workingFetchers:v}=await we(d,n,a,t,f,l.active,u,r&&r.submission,r&&r.fetcherSubmission,r&&r.replace,r&&r.initialHydration===!0,o,p,r&&r.callSiteDefaultShouldRevalidate);m||(O=null,ye(n,{matches:h||a,...gn(p),loaderData:g,errors:_,...v?{fetchers:v}:{}}))}async function Ce(t,n,i,l,u,d,f,p,m={}){if(Ne(),ve({navigation:Tte(n,l,u,i)},{flushSync:m.flushSync===!0}),f){let e=await $e(l,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=vn(s.activeRoutes);return{matches:t,pendingActionResult:[n.id,{type:`error`,error:e.error}]}}let t=_n(e.partialMatches).route.id;return{matches:e.partialMatches,pendingActionResult:[t,{type:`error`,error:e.error}]}}else if(e.matches)l=e.matches;else{let{notFoundMatches:e,error:t,route:r}=Je(n.pathname);return{matches:e,pendingActionResult:[r.id,{type:`error`,error:t}]}}}let h,g=Dn(l,n);if(!g.route.action&&!g.route.lazy)h={type:`error`,error:yn(405,{method:t.method,pathname:n.pathname,routeId:g.route.id})};else{let e=await je(t,n,un(a,o,t,n,l,g,p?[]:r,d),d,null);if(h=e[g.route.id],!h){for(let t of l)if(e[t.route.id]){h=e[t.route.id];break}}if(t.signal.aborted)return{shortCircuited:!0}}if(Cn(h)){let n;return n=m&&m.replace!=null?m.replace:fn(h.response.headers.get(`Location`),new URL(t.url),c,e.history)===w.location.pathname+w.location.search,await Ae(t,h,!0,{submission:i,replace:n}),{shortCircuited:!0}}if(Sn(h)){let e=_n(l,g.route.id);return(m&&m.replace)!==!0&&(T=`PUSH`),{matches:l,pendingActionResult:[e.route.id,h,g.route.id]}}return{matches:l,pendingActionResult:[g.route.id,h]}}async function we(t,n,i,l,u,d,f,p,m,h,g,_,v,y){let b=f||On(n,i,l,p),x=p||m||wte(b),S=!te&&!g;if(d){if(S){let e=Te(v);ve({navigation:b,...e===void 0?{}:{actionData:e}},{flushSync:_})}let e=await $e(i,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=vn(s.activeRoutes);return{matches:t,loaderData:{},errors:{[n.id]:e.error}}}let t=_n(e.partialMatches).route.id;return{matches:e.partialMatches,loaderData:{},errors:{[t]:e.error}}}else if(e.matches)i=e.matches;else{let{error:e,notFoundMatches:t,route:r}=Je(n.pathname);return{matches:t,loaderData:{},errors:{[r.id]:e}}}}let C=s.activeRoutes,{dsMatches:T,revalidatingFetchers:E}=qee(t,u,a,o,e.history,w,i,x,n,g?[]:r,g===!0,ne,re,de,le,ce,C,c,e.patchRoutesOnNavigation!=null,s.branches,v,y);if(oe=++ae,!e.dataStrategy&&!T.some(e=>e.shouldLoad)&&!T.some(e=>e.route.middleware&&e.route.middleware.length>0)&&E.length===0){let e=new Map(w.fetchers),t=He(e);return ye(n,{matches:i,loaderData:{},errors:v&&Sn(v[1])?{[v[0]]:v[1].error}:null,...gn(v),...t?{fetchers:e}:{}},{flushSync:_}),{shortCircuited:!0}}if(S){let e={};if(!d){e.navigation=b;let t=Te(v);t!==void 0&&(e.actionData=t)}E.length>0&&(e.fetchers=Ee(E)),ve(e,{flushSync:_})}E.forEach(e=>{Be(e.key),e.controller&&ie.set(e.key,e.controller)});let D=()=>E.forEach(e=>Be(e.key));O&&O.signal.addEventListener(`abort`,D);let{loaderResults:k,fetcherResults:A}=await Me(T,E,t,n,u);if(t.signal.aborted)return{shortCircuited:!0};O&&O.signal.removeEventListener(`abort`,D),E.forEach(e=>ie.delete(e.key));let ee=bn(k);if(ee)return await Ae(t,ee.result,!0,{replace:h}),{shortCircuited:!0};if(ee=bn(A),ee)return ce.add(ee.key),await Ae(t,ee.result,!0,{replace:h}),{shortCircuited:!0};let se=new Map(w.fetchers),{loaderData:ue,errors:fe}=mte(w,i,k,v,E,A,se);g&&w.errors&&(fe={...w.errors,...fe});let pe=He(se),me=Ue(oe,se),he=pe||me||E.length>0;return{matches:i,loaderData:ue,errors:fe,...he?{workingFetchers:se}:{}}}function Te(e){if(e&&!Sn(e[1]))return{[e[0]]:e[1].data};if(w.actionData)return Object.keys(w.actionData).length===0?null:w.actionData}function Ee(e){let t=new Map(w.fetchers);return e.forEach(e=>{let n=t.get(e.key),r=kn(void 0,n?n.data:void 0);t.set(e.key,r)}),t}async function De(t,n,r,i){Be(t);let a=(i&&i.flushSync)===!0,o=s.activeRoutes,l=nn(w.location,w.matches,c,r,n,i?.relative),u=Mt(o,l,c,!1,s.branches),d=Qe(u,o,l);if(d.active&&d.matches&&(u=d.matches),!u){Fe(t,n,yn(404,{pathname:l}),{flushSync:a});return}let{path:f,submission:p,error:m}=Kee(!0,l,i);if(m){Fe(t,n,m,{flushSync:a});return}let h=e.getContext?await e.getContext():new Ct,g=(i&&i.preventScrollReset)===!0;if(p&&Tn(p.formMethod)){await Oe(t,n,f,u,h,d.active,a,g,p,i&&i.defaultShouldRevalidate);return}le.set(t,{routeId:n,path:f}),await ke(t,n,f,u,h,d.active,a,g,p)}async function Oe(t,n,i,l,u,d,f,p,m,h){Ne(),le.delete(t),Pe(t,Ete(m,w.fetchers.get(t)),{flushSync:f});let g=new AbortController,_=pn(e.history,i,g.signal,m);if(d){let e=await $e(l,new URL(_.url).pathname,_.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){Fe(t,n,e.error,{flushSync:f});return}else if(e.matches)l=e.matches;else{Fe(t,n,yn(404,{pathname:i}),{flushSync:f});return}}let v=Dn(l,i);if(!v.route.action&&!v.route.lazy){Fe(t,n,yn(405,{method:m.formMethod,pathname:i,routeId:n}),{flushSync:f});return}ie.set(t,g);let y=ae,b=un(a,o,_,i,l,v,r,u),x=await je(_,i,b,u,t),S=x[v.route.id];if(!S){for(let e of b)if(x[e.route.id]){S=x[e.route.id];break}}if(_.signal.aborted){ie.get(t)===g&&ie.delete(t);return}if(de.has(t)){if(Cn(S)||Sn(S)){Pe(t,An(void 0));return}}else{if(Cn(S))if(ie.delete(t),oe>y){Pe(t,An(void 0));return}else return ce.add(t),Pe(t,kn(m)),Ae(_,S,!1,{fetcherSubmission:m,preventScrollReset:p});if(Sn(S)){Fe(t,n,S.error);return}}let C=w.navigation.location||w.location,E=pn(e.history,C,g.signal),D=s.activeRoutes,k=w.navigation.state===`idle`?w.matches:Mt(D,w.navigation.location,c,!1,s.branches);pt(k,`Didn't find any matches after fetcher action`);let A=++ae;se.set(t,A);let{dsMatches:ee,revalidatingFetchers:te}=qee(E,u,a,o,e.history,w,k,m,C,r,!1,ne,re,de,le,ce,D,c,e.patchRoutesOnNavigation!=null,s.branches,[v.route.id,S],h),ue=kn(m,S.data),fe=new Map(w.fetchers);fe.set(t,ue),te.filter(e=>e.key!==t).forEach(e=>{let t=e.key,n=fe.get(t),r=kn(void 0,n?n.data:void 0);fe.set(t,r),Be(t),e.controller&&ie.set(t,e.controller)}),ve({fetchers:fe});let pe=()=>te.forEach(e=>Be(e.key));g.signal.addEventListener(`abort`,pe);let{loaderResults:me,fetcherResults:he}=await Me(ee,te,E,C,u);if(g.signal.aborted)return;g.signal.removeEventListener(`abort`,pe),se.delete(t),ie.delete(t),te.forEach(e=>ie.delete(e.key));let ge=w.fetchers.has(t),_e=e=>{if(!ge)return e;let n=new Map(e.fetchers);return n.set(t,An(S.data)),{...e,fetchers:n}},be=bn(me);if(be)return w=_e(w),Ae(E,be.result,!1,{preventScrollReset:p});if(be=bn(he),be)return ce.add(be.key),w=_e(w),Ae(E,be.result,!1,{preventScrollReset:p});let xe=new Map(w.fetchers);ge&&xe.set(t,An(S.data));let{loaderData:Se,errors:Ce}=mte(w,k,me,void 0,te,he,xe);Ue(A,xe),w.navigation.state===`loading`&&A>oe?(pt(T,`Expected pending action`),O&&O.abort(),ye(w.navigation.location,{matches:k,loaderData:Se,errors:Ce,fetchers:xe})):(ve({errors:Ce,loaderData:hn(w.loaderData,Se,k,Ce),fetchers:xe}),ne=!1)}async function ke(t,n,i,s,c,l,u,d,f){let p=w.fetchers.get(t);Pe(t,kn(f,p?p.data:void 0),{flushSync:u});let m=new AbortController,h=pn(e.history,i,m.signal);if(l){let e=await $e(s,new URL(h.url).pathname,h.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){Fe(t,n,e.error,{flushSync:u});return}else if(e.matches)s=e.matches;else{Fe(t,n,yn(404,{pathname:i}),{flushSync:u});return}}let g=Dn(s,i);ie.set(t,m);let _=ae,v=await je(h,i,un(a,o,h,i,s,g,r,c),c,t),y=v[g.route.id];if(!y){for(let e of s)if(v[e.route.id]){y=v[e.route.id];break}}if(ie.get(t)===m&&ie.delete(t),!h.signal.aborted){if(de.has(t)){Pe(t,An(void 0));return}if(Cn(y))if(oe>_){Pe(t,An(void 0));return}else{ce.add(t),await Ae(h,y,!1,{preventScrollReset:d});return}if(Sn(y)){Fe(t,n,y.error);return}Pe(t,An(y.data))}}async function Ae(r,i,a,{submission:o,fetcherSubmission:s,preventScrollReset:l,replace:u}={}){a||(E?.resolve(),E=null),i.response.headers.has(`X-Remix-Revalidate`)&&(ne=!0);let d=i.response.headers.get(`Location`);pt(d,`Expected a Location header on the redirect Response`),d=fn(d,new URL(r.url),c,e.history);let f=_t(w.location,d,{_isRedirect:!0});if(n){let e=!1;if(i.response.headers.has(`X-Remix-Reload-Document`))e=!0;else if(It(d)){let n=xt(t,d,!0);e=n.origin!==t.location.origin||Ft(n.pathname,c)==null}if(e){u?t.location.replace(d):t.location.assign(d);return}}O=null;let p=u===!0||i.response.headers.has(`X-Remix-Replace`)?`REPLACE`:`PUSH`,{formMethod:m,formAction:h,formEncType:g}=w.navigation;!o&&!s&&m&&h&&g&&(o=wte(w.navigation));let _=o||s;Ree.has(i.response.status)&&_&&Tn(_.formMethod)?await Se(p,f,{submission:{..._,formAction:d},preventScrollReset:l||D,enableViewTransition:a?k:void 0}):await Se(p,f,{overrideNavigation:On(f,[],p,o),fetcherSubmission:s,preventScrollReset:l||D,enableViewTransition:a?k:void 0})}async function je(e,t,n,r,i){let a,o={};try{a=await ote(l,e,t,n,i,r,!1)}catch(e){return n.filter(e=>e.shouldLoad).forEach(t=>{o[t.route.id]={type:`error`,error:e}}),o}if(e.signal.aborted)return o;if(!Tn(e.method))for(let e of n){if(a[e.route.id]?.type===`error`)break;!a.hasOwnProperty(e.route.id)&&!w.loaderData.hasOwnProperty(e.route.id)&&(!w.errors||!w.errors.hasOwnProperty(e.route.id))&&e.shouldCallHandler()&&(a[e.route.id]={type:`error`,result:Error(`No result returned from dataStrategy for route ${e.route.id}`)})}for(let[t,r]of Object.entries(a))if(yte(r)){let i=r.result;o[t]={type:`redirect`,response:ute(i,e,t,n,c)}}else o[t]=await lte(r);return o}async function Me(e,t,n,r,i){let a=je(n,r,e,i,null),o=Promise.all(t.map(async e=>{if(e.matches&&e.match&&e.request&&e.controller){let t=(await je(e.request,e.path,e.matches,i,e.key))[e.match.route.id];return{[e.key]:t}}else return Promise.resolve({[e.key]:{type:`error`,error:yn(404,{pathname:e.path})}})}));return{loaderResults:await a,fetcherResults:(await o).reduce((e,t)=>Object.assign(e,t),{})}}function Ne(){ne=!0,le.forEach((e,t)=>{ie.has(t)&&re.add(t),Be(t)})}function Pe(e,t,n={}){let r=new Map(w.fetchers);r.set(e,t),ve({fetchers:r},{flushSync:(n&&n.flushSync)===!0})}function Fe(e,t,n,r={}){let i=_n(w.matches,t),a=new Map(w.fetchers);Re(a,e),ve({errors:{[i.route.id]:n},fetchers:a},{flushSync:(r&&r.flushSync)===!0})}function Ie(e){return ue.set(e,(ue.get(e)||0)+1),de.has(e)&&de.delete(e),w.fetchers.get(e)||zee}function Le(e,t){Be(e,t?.reason),Pe(e,An(null))}function Re(e,t){let n=w.fetchers.get(t);ie.has(t)&&!(n&&n.state===`loading`&&se.has(t))&&Be(t),le.delete(t),se.delete(t),ce.delete(t),de.delete(t),re.delete(t),e.delete(t)}function ze(e){let t=(ue.get(e)||0)-1;t<=0?(ue.delete(e),de.add(e)):ue.set(e,t),ve({fetchers:new Map(w.fetchers)})}function Be(e,t){let n=ie.get(e);n&&(n.abort(t),ie.delete(e))}function Ve(e,t){for(let n of e){let e=t.get(n);pt(e,`Expected fetcher: ${n}`);let r=An(e.data);t.set(n,r)}}function He(e){let t=[],n=!1;for(let r of ce){let i=e.get(r);pt(i,`Expected fetcher: ${r}`),i.state===`loading`&&(ce.delete(r),t.push(r),n=!0)}return Ve(t,e),n}function Ue(e,t){let n=[];for(let[r,i]of se)if(i<e){let e=t.get(r);pt(e,`Expected fetcher: ${r}`),e.state===`loading`&&(Be(r),se.delete(r),n.push(r))}return Ve(n,t),n.length>0}function We(e,t){let n=w.blockers.get(e)||Zt;return fe.get(e)!==t&&fe.set(e,t),n}function Ge(e){w.blockers.delete(e),fe.delete(e)}function Ke(e,t){let n=w.blockers.get(e)||Zt;pt(n.state===`unblocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`proceeding`||n.state===`blocked`&&t.state===`unblocked`||n.state===`proceeding`&&t.state===`unblocked`,`Invalid blocker state transition: ${n.state} -> ${t.state}`);let r=new Map(w.blockers);r.set(e,t),ve({blockers:r})}function qe({currentLocation:e,nextLocation:t,historyAction:n}){if(fe.size===0)return;fe.size>1&&mt(!1,`A router only supports one blocker at a time`);let r=Array.from(fe.entries()),[i,a]=r[r.length-1],o=w.blockers.get(i);if(!(o&&o.state===`proceeding`)&&a({currentLocation:e,nextLocation:t,historyAction:n}))return i}function Je(e){let t=yn(404,{pathname:e}),n=s.activeRoutes,{matches:r,route:i}=vn(n);return{notFoundMatches:r,route:i,error:t}}function Ye(e,t,n){if(m=e,g=t,h=n||null,!_&&w.navigation===Xt){_=!0;let e=j(w.location,w.matches);e!=null&&ve({restoreScrollPosition:e})}return()=>{m=null,g=null,h=null}}function Xe(e,t){return h&&h(e,t.map(e=>eee(e,w.loaderData)))||e.key}function Ze(e,t){if(m&&g){let n=Xe(e,t);m[n]=g()}}function j(e,t){if(m){let n=Xe(e,t),r=m[n];if(typeof r==`number`)return r}return null}function Qe(t,n,r){if(e.patchRoutesOnNavigation){let e=s.branches;if(!t)return{active:!0,matches:Mt(n,r,c,!0,e)||[]};if(Object.keys(t[0].params).length>0)return{active:!0,matches:Mt(n,r,c,!0,e)}}return{active:!1,matches:null}}async function $e(t,n,r,i){if(!e.patchRoutesOnNavigation)return{type:`success`,matches:t};let l=t;for(;;){let t=o;try{await e.patchRoutesOnNavigation({signal:r,path:n,matches:l,fetcherKey:i,patch:(e,n)=>{r.aborted||Zee(e,n,s,t,a,!1)}})}catch(e){return{type:`error`,error:e,partialMatches:l}}if(r.aborted)return{type:`aborted`};let u=s.branches,d=Mt(s.activeRoutes,n,c,!1,u),f=null;if(d&&(Object.keys(d[0].params).length===0||(f=Mt(s.activeRoutes,n,c,!0,u),!(f&&l.length<f.length&&et(l,f.slice(0,l.length))))))return{type:`success`,matches:d};if(f||=Mt(s.activeRoutes,n,c,!0,u),!f||et(l,f))return{type:`success`,matches:null};l=f}}function et(e,t){return e.length===t.length&&e.every((e,n)=>e.route.id===t[n].route.id)}function tt(e){o={},s.setHmrRoutes(kt(e,a,void 0,o))}function nt(e,t,n=!1){Zee(e,t,s,o,a,n),s.hasHMRRoutes||ve({})}return C={get basename(){return c},get future(){return u},get state(){return w},get routes(){return s.stableRoutes},get branches(){return s.branches},get manifest(){return o},get window(){return t},initialize:he,subscribe:_e,enableScrollRestoration:Ye,navigate:be,fetch:De,revalidate:xe,createHref:t=>e.history.createHref(t),encodeLocation:t=>e.history.encodeLocation(t),getFetcher:Ie,resetFetcher:Le,deleteFetcher:ze,dispose:ge,getBlocker:We,deleteBlocker:Ge,patchRoutes:nt,_internalFetchControllers:ie,_internalSetRoutes:tt,_internalSetStateDoNotUseOrYouWillBreakYourApp(e){ve(e)}},e.instrumentations&&(C=Eee(C,e.instrumentations.map(e=>e.router).filter(Boolean))),C}function Gee(e){return e!=null&&(`formData`in e&&e.formData!=null||`body`in e&&e.body!==void 0)}function nn(e,t,n,r,i,a){let o,s;if(i){o=[];for(let e of t)if(o.push(e),e.route.id===i){s=e;break}}else o=t,s=t[t.length-1];let c=Bt(r||`.`,zt(o),Ft(e.pathname,n)||e.pathname,a===`path`);if(r??(c.search=e.search,c.hash=e.hash),(r==null||r===``||r===`.`)&&s){let e=En(c.search);if(s.route.index&&!e)c.search=c.search?c.search.replace(/^\?/,`?index&`):`?index`;else if(!s.route.index&&e){let e=new URLSearchParams(c.search),t=e.getAll(`index`);e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();c.search=n?`?${n}`:``}}return n!==`/`&&(c.pathname=gee({basename:n,pathname:c.pathname})),vt(c)}function Kee(e,t,n){if(!n||!Gee(n))return{path:t};if(n.formMethod&&!Cte(n.formMethod))return{path:t,error:yn(405,{method:n.formMethod})};let r=()=>({path:t,error:yn(400,{type:`invalid-body`})}),i=(n.formMethod||`get`).toUpperCase(),a=xn(t);if(n.body!==void 0){if(n.formEncType===`text/plain`){if(!Tn(i))return r();let e=typeof n.body==`string`?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((e,[t,n])=>`${e}${t}=${n}
|
|
3
3
|
`,``):String(n.body);return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:void 0,text:e}}}else if(n.formEncType===`application/json`){if(!Tn(i))return r();try{let e=typeof n.body==`string`?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:e,text:void 0}}}catch{return r()}}}pt(typeof FormData==`function`,`FormData is not available in this environment`);let o,s;if(n.formData)o=mn(n.formData),s=n.formData;else if(n.body instanceof FormData)o=mn(n.body),s=n.body;else if(n.body instanceof URLSearchParams)o=n.body,s=fte(o);else if(n.body==null)o=new URLSearchParams,s=new FormData;else try{o=new URLSearchParams(n.body),s=fte(o)}catch{return r()}let c={formMethod:i,formAction:a,formEncType:n&&n.formEncType||`application/x-www-form-urlencoded`,formData:s,json:void 0,text:void 0};if(Tn(c.formMethod))return{path:t,submission:c};let l=yt(t);return e&&l.search&&En(l.search)&&o.append(`index`,``),l.search=`?${o}`,{path:vt(l),submission:c}}function qee(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x){let S=b?Sn(b[1])?b[1].error:b[1].data:void 0,C=i.createURL(a.location),w=i.createURL(c),T;if(u&&a.errors){let e=Object.keys(a.errors)[0];T=o.findIndex(t=>t.route.id===e)}else if(b&&Sn(b[1])){let e=b[0];T=o.findIndex(t=>t.route.id===e)-1}let E=b?b[1].statusCode:void 0,D=E&&E>=400,O={currentUrl:C,currentParams:a.matches[0]?.params||{},nextUrl:w,nextParams:o[0].params,...s,actionResult:S,actionStatus:E},k=Kt(o),A=o.map((i,o)=>{let{route:s}=i,f=null;if(T!=null&&o>T)f=!1;else if(s.lazy)f=!0;else if(!rn(s))f=!1;else if(u){let{shouldLoad:e}=Jee(s,a.loaderData,a.errors);f=e}else Yee(a.loaderData,a.matches[o],i)&&(f=!0);if(f!==null)return ln(n,r,e,c,k,i,l,t,f);let p=!1;typeof x==`boolean`?p=x:D?p=!1:d||C.pathname+C.search===w.pathname+w.search?p=!0:C.search===w.search?Xee(a.matches[o],i)&&(p=!0):p=!0;let m={...O,defaultShouldRevalidate:p};return ln(n,r,e,c,k,i,l,t,an(i,m),m,x)}),ee=[];return m.forEach((e,s)=>{if(u||!o.some(t=>t.route.id===e.routeId)||p.has(s))return;let c=a.fetchers.get(s),m=c&&c.state!==`idle`&&c.data===void 0,b=Mt(g,e.path,_??`/`,!1,y);if(!b){if(v&&m)return;ee.push({key:s,routeId:e.routeId,path:e.path,matches:null,match:null,request:null,controller:null});return}if(h.has(s))return;let S=Dn(b,e.path),C=new AbortController,w=pn(i,e.path,C.signal),T=null;if(f.has(s))f.delete(s),T=un(n,r,w,e.path,b,S,l,t);else if(m)d&&(T=un(n,r,w,e.path,b,S,l,t));else{let i;i=typeof x==`boolean`?x:D?!1:d;let a={...O,defaultShouldRevalidate:i};an(S,a)&&(T=un(n,r,w,e.path,b,S,l,t,a))}T&&ee.push({key:s,routeId:e.routeId,path:e.path,matches:T,match:S,request:w,controller:C})}),{dsMatches:A,revalidatingFetchers:ee}}function rn(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function Jee(e,t,n){if(e.lazy)return{shouldLoad:!0,renderFallback:!0};if(!rn(e))return{shouldLoad:!1,renderFallback:!1};let r=t!=null&&e.id in t,i=n!=null&&n[e.id]!==void 0;if(!r&&i)return{shouldLoad:!1,renderFallback:!1};if(typeof e.loader==`function`&&e.loader.hydrate===!0)return{shouldLoad:!0,renderFallback:!r};let a=!r&&!i;return{shouldLoad:a,renderFallback:a}}function Yee(e,t,n){let r=!t||n.route.id!==t.route.id,i=!e.hasOwnProperty(n.route.id);return r||i}function Xee(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith(`*`)&&e.params[`*`]!==t.params[`*`]}function an(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n==`boolean`)return n}return t.defaultShouldRevalidate}function Zee(e,t,n,r,i,a){let o;if(e){let t=r[e];pt(t,`No route found to patch children into: routeId = ${e}`),t.children||=[],o=t.children}else o=n.activeRoutes;let s=[],c=[];if(t.forEach(e=>{let t=o.find(t=>on(e,t));t?c.push({existingRoute:t,newRoute:e}):s.push(e)}),s.length>0){let t=kt(s,i,[e||`_`,`patch`,String(o?.length||`0`)],r);o.push(...t)}if(a&&c.length>0)for(let e=0;e<c.length;e++){let{existingRoute:t,newRoute:n}=c[e],r=t,[a]=kt([n],i,[],{},!0);Object.assign(r,{element:a.element?a.element:r.element,errorElement:a.errorElement?a.errorElement:r.errorElement,hydrateFallbackElement:a.hydrateFallbackElement?a.hydrateFallbackElement:r.hydrateFallbackElement})}n.hasHMRRoutes||n.setRoutes([...n.activeRoutes])}function on(e,t){return`id`in e&&`id`in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children?.every((e,n)=>t.children?.some(t=>on(e,t)))??!1:!1}var Qee=new WeakMap,$ee=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let i=n[t.id];if(pt(i,`No route found in manifest`),!i.lazy||typeof i.lazy!=`object`)return;let a=i.lazy[e];if(!a)return;let o=Qee.get(i);o||(o={},Qee.set(i,o));let s=o[e];if(s)return s;let c=(async()=>{let t=Tt(e),n=i[e]!==void 0&&e!==`hasErrorBoundary`;if(t)mt(!t,`Route property `+e+` is not a supported lazy route property. This property will be ignored.`),o[e]=Promise.resolve();else if(n)mt(!1,`Route "${i.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let t=await a();t!=null&&(Object.assign(i,{[e]:t}),Object.assign(i,r(i)))}typeof i.lazy==`object`&&(i.lazy[e]=void 0,Object.values(i.lazy).every(e=>e===void 0)&&(i.lazy=void 0))})();return o[e]=c,c},ete=new WeakMap;function tte(e,t,n,r,i){let a=n[e.id];if(pt(a,`No route found in manifest`),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy==`function`){let t=ete.get(a);if(t)return{lazyRoutePromise:t,lazyHandlerPromise:t};let n=(async()=>{pt(typeof e.lazy==`function`,`No lazy route function found`);let t=await e.lazy(),n={};for(let e in t){let r=t[e];if(r===void 0)continue;let i=Dt(e),o=a[e]!==void 0&&e!==`hasErrorBoundary`;i?mt(!i,`Route property `+e+` is not a supported property to be returned from a lazy route function. This property will be ignored.`):o?mt(!o,`Route "${a.id}" has a static property "${e}" defined but its lazy function is also returning a value for this property. The lazy route property "${e}" will be ignored.`):n[e]=r}Object.assign(a,n),Object.assign(a,{...r(a),lazy:void 0})})();return ete.set(a,n),n.catch(()=>{}),{lazyRoutePromise:n,lazyHandlerPromise:n}}let o=Object.keys(e.lazy),s=[],c;for(let a of o){if(i&&i.includes(a))continue;let o=$ee({key:a,route:e,manifest:n,mapRouteProperties:r});o&&(s.push(o),a===t&&(c=o))}let l=s.length>0?Promise.all(s).then(()=>{}):void 0;return l?.catch(()=>{}),c?.catch(()=>{}),{lazyRoutePromise:l,lazyHandlerPromise:c}}async function sn(e){let t=e.matches.filter(e=>e.shouldLoad),n={};return(await Promise.all(t.map(e=>e.resolve()))).forEach((e,r)=>{n[t[r].route.id]=e}),n}async function nte(e){return e.matches.some(e=>e.route.middleware)?cn(e,()=>sn(e)):sn(e)}function cn(e,t){return rte(e,t,e=>{if(Ste(e))throw e;return e},_te,n);function n(t,n,r){if(r)return Promise.resolve(Object.assign(r.value,{[n]:{type:`error`,result:t}}));{let{matches:r}=e,i=_n(r,r[Math.min(Math.max(r.findIndex(e=>e.route.id===n),0),Math.max(r.findIndex(e=>e.shouldCallHandler()),0))].route.id).route.id;return Promise.resolve({[i]:{type:`error`,result:t}})}}}async function rte(e,t,n,r,i){let{matches:a,...o}=e;return await ite(o,a.flatMap(e=>e.route.middleware?e.route.middleware.map(t=>[e.route.id,t]):[]),t,n,r,i)}async function ite(e,t,n,r,i,a,o=0){let{request:s}=e;if(s.signal.aborted)throw s.signal.reason??Error(`Request aborted: ${s.method} ${s.url}`);let c=t[o];if(!c)return await n();let[l,u]=c,d,f=async()=>{if(d)throw Error("You may only call `next()` once per middleware");try{return d={value:await ite(e,t,n,r,i,a,o+1)},d.value}catch(e){return d={value:await a(e,l,d)},d.value}};try{let t=await u(e,f),n=t==null?void 0:r(t);return i(n)?n:d?n??d.value:(d={value:await f()},d.value)}catch(e){return await a(e,l,d)}}function ate(e,t,n,r,i){let a=$ee({key:`middleware`,route:r.route,manifest:t,mapRouteProperties:e}),o=tte(r.route,Tn(n.method)?`action`:`loader`,t,e,i);return{middleware:a,route:o.lazyRoutePromise,handler:o.lazyHandlerPromise}}function ln(e,t,n,r,i,a,o,s,c,l=null,u){let d=!1,f=ate(e,t,n,a,o);return{...a,_lazyPromises:f,shouldLoad:c,shouldRevalidateArgs:l,shouldCallHandler(e){return d=!0,l?typeof u==`boolean`?an(a,{...l,defaultShouldRevalidate:u}):typeof e==`boolean`?an(a,{...l,defaultShouldRevalidate:e}):an(a,l):c},resolve(e){let{lazy:t,loader:o,middleware:l}=a.route,u=d||c||e&&!Tn(n.method)&&(t||o),p=l&&l.length>0&&!o&&!t;return u&&(Tn(n.method)||!p)?ste({request:n,path:r,pattern:i,match:a,lazyHandlerPromise:f?.handler,lazyRoutePromise:f?.route,handlerOverride:e,scopedContext:s}):Promise.resolve({type:`data`,result:void 0})}}}function un(e,t,n,r,i,a,o,s,c=null){return i.map(l=>l.route.id===a.route.id?ln(e,t,n,r,Kt(i),l,o,s,!0,c):{...l,shouldLoad:!1,shouldRevalidateArgs:c,shouldCallHandler:()=>!1,_lazyPromises:ate(e,t,n,l,o),resolve:()=>Promise.resolve({type:`data`,result:void 0})})}async function ote(e,t,n,r,i,a,o){r.some(e=>e._lazyPromises?.middleware)&&await Promise.all(r.map(e=>e._lazyPromises?.middleware));let s={request:t,url:dte(t,n),pattern:Kt(r),params:r[0].params,context:a,matches:r},c=o?()=>{throw Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:e=>{let t=s;return cn(t,()=>e({...t,fetcherKey:i,runClientMiddleware:()=>{throw Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))},l=await e({...s,fetcherKey:i,runClientMiddleware:c});try{await Promise.all(r.flatMap(e=>[e._lazyPromises?.handler,e._lazyPromises?.route]))}catch{}return l}async function ste({request:e,path:t,pattern:n,match:r,lazyHandlerPromise:i,lazyRoutePromise:a,handlerOverride:o,scopedContext:s}){let c,l,u=Tn(e.method),d=u?`action`:`loader`,f=i=>{let a,c=new Promise((e,t)=>a=t);l=()=>a(),e.signal.addEventListener(`abort`,l);let u=a=>typeof i==`function`?i({request:e,url:dte(e,t),pattern:n,params:r.params,context:s},...a===void 0?[]:[a]):Promise.reject(Error(`You cannot call the handler for a route which defines a boolean "${d}" [routeId: ${r.route.id}]`)),f=(async()=>{try{return{type:`data`,result:await(o?o(e=>u(e)):u())}}catch(e){return{type:`error`,result:e}}})();return Promise.race([f,c])};try{let t=u?r.route.action:r.route.loader;if(i||a)if(t){let e,[n]=await Promise.all([f(t).catch(t=>{e=t}),i,a]);if(e!==void 0)throw e;c=n}else{await i;let t=u?r.route.action:r.route.loader;if(t)[c]=await Promise.all([f(t),a]);else if(d===`action`){let t=new URL(e.url),n=t.pathname+t.search;throw yn(405,{method:e.method,pathname:n,routeId:r.route.id})}else return{type:`data`,result:void 0}}else if(t)c=await f(t);else{let t=new URL(e.url);throw yn(404,{pathname:t.pathname+t.search})}}catch(e){return{type:`error`,result:e}}finally{l&&e.signal.removeEventListener(`abort`,l)}return c}async function cte(e){let t=e.headers.get(`Content-Type`);return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function lte(e){let{result:t,type:n}=e;if(wn(t)){let e;try{e=await cte(t)}catch(e){return{type:`error`,error:e}}return n===`error`?{type:`error`,error:new Wt(t.status,t.statusText,e),statusCode:t.status,headers:t.headers}:{type:`data`,data:e,statusCode:t.status,headers:t.headers}}return n===`error`?bte(t)?t.data instanceof Error?{type:`error`,error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:gte(t),statusCode:Gt(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:t,statusCode:Gt(t)?t.status:void 0}:bte(t)?{type:`data`,data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`data`,data:t}}function ute(e,t,n,r,i){let a=e.headers.get(`Location`);if(pt(a,`Redirects returned/thrown from loaders/actions must have a Location header`),!It(a)){let o=r.slice(0,r.findIndex(e=>e.route.id===n)+1);a=nn(new URL(t.url),o,i,a),e.headers.set(`Location`,a)}return e}var dn=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function fn(e,t,n,r){if(It(e)){let r=e,i=r.startsWith(`//`)?new URL(t.protocol+r):new URL(r);if(dn.includes(i.protocol))throw Error(`Invalid redirect location`);let a=Ft(i.pathname,n)!=null;if(i.origin===t.origin&&a)return Vt(i.pathname)+i.search+i.hash}try{let t=r.createURL(e);if(dn.includes(t.protocol))throw Error(`Invalid redirect location`)}catch{}return e}function pn(e,t,n,r){let i=e.createURL(xn(t)).toString(),a={signal:n};if(r&&Tn(r.formMethod)){let{formMethod:e,formEncType:t}=r;a.method=e.toUpperCase(),t===`application/json`?(a.headers=new Headers({"Content-Type":t}),a.body=JSON.stringify(r.json)):t===`text/plain`?a.body=r.text:t===`application/x-www-form-urlencoded`&&r.formData?a.body=mn(r.formData):a.body=r.formData}return new Request(i,a)}function dte(e,t){let n=new URL(e.url),r=typeof t==`string`?yt(t):t;if(n.pathname=r.pathname||`/`,r.search){let e=new URLSearchParams(r.search),t=e.getAll(`index`);e.delete(`index`);for(let n of t.filter(Boolean))e.append(`index`,n);n.search=e.size?`?${e.toString()}`:``}else n.search=``;return n.hash=r.hash||``,n}function mn(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r==`string`?r:r.name);return t}function fte(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function pte(e,t,n,r=!1,i=!1){let a={},o=null,s,c=!1,l={},u=n&&Sn(n[1])?n[1].error:void 0;return e.forEach(n=>{if(!(n.route.id in t))return;let d=n.route.id,f=t[d];if(pt(!Cn(f),`Cannot handle redirect results in processLoaderData`),Sn(f)){let t=f.error;if(u!==void 0&&(t=u,u=void 0),o||={},i)o[d]=t;else{let n=_n(e,d);o[n.route.id]??(o[n.route.id]=t)}r||(a[d]=Hee),c||(c=!0,s=Gt(f.error)?f.error.status:500),f.headers&&(l[d]=f.headers)}else a[d]=f.data,f.statusCode&&f.statusCode!==200&&!c&&(s=f.statusCode),f.headers&&(l[d]=f.headers)}),u!==void 0&&n&&(o={[n[0]]:u},n[2]&&(a[n[2]]=void 0)),{loaderData:a,errors:o,statusCode:s||200,loaderHeaders:l}}function mte(e,t,n,r,i,a,o){let{loaderData:s,errors:c}=pte(t,n,r);return i.filter(e=>!e.matches||e.matches.some(e=>e.shouldLoad)).forEach(t=>{let{key:n,match:r,controller:i}=t;if(i&&i.signal.aborted)return;let s=a[n];if(pt(s,`Did not find corresponding fetcher result`),Sn(s)){let t=_n(e.matches,r?.route.id);c&&c[t.route.id]||(c={...c,[t.route.id]:s.error}),o.delete(n)}else if(Cn(s))pt(!1,`Unhandled fetcher revalidation redirect`);else{let e=An(s.data);o.set(n,e)}}),{loaderData:s,errors:c}}function hn(e,t,n,r){let i=Object.entries(t).filter(([,e])=>e!==Hee).reduce((e,[t,n])=>(e[t]=n,e),{});for(let a of n){let n=a.route.id;if(!t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&a.route.loader&&(i[n]=e[n]),r&&r.hasOwnProperty(n))break}return i}function gn(e){return e?Sn(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function _n(e,t){return(t?e.slice(0,e.findIndex(e=>e.route.id===t)+1):[...e]).reverse().find(e=>e.route.hasErrorBoundary===!0)||e[0]}function vn(e){let t=e.length===1?e[0]:e.find(e=>e.index||!e.path||e.path===`/`)||{id:`__shim-error-route__`};return{matches:[{params:{},pathname:``,pathnameBase:``,route:t}],route:t}}function yn(e,{pathname:t,routeId:n,method:r,type:i,message:a}={}){let o=`Unknown Server Error`,s=`Unknown @remix-run/router error`;return e===400?(o=`Bad Request`,r&&t&&n?s=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:i===`invalid-body`&&(s=`Unable to encode submission body`)):e===403?(o=`Forbidden`,s=`Route "${n}" does not match URL "${t}"`):e===404?(o=`Not Found`,s=`No route matches URL "${t}"`):e===405&&(o=`Method Not Allowed`,r&&t&&n?s=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(s=`Invalid request method "${r.toUpperCase()}"`)),new Wt(e||500,o,Error(s),!0)}function bn(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;e--){let[n,r]=t[e];if(Cn(r))return{key:n,result:r}}}function xn(e){return vt({...typeof e==`string`?yt(e):e,hash:``})}function hte(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===``?t.hash!==``:e.hash===t.hash?!0:t.hash!==``}function gte(e){return new Wt(e.init?.status??500,e.init?.statusText??`Internal Server Error`,e.data)}function _te(e){return typeof e==`object`&&!!e&&Object.entries(e).every(([e,t])=>typeof e==`string`&&vte(t))}function vte(e){return typeof e==`object`&&!!e&&`type`in e&&`result`in e&&(e.type===`data`||e.type===`error`)}function yte(e){return wn(e.result)&&Yt.has(e.result.status)}function Sn(e){return e.type===`error`}function Cn(e){return(e&&e.type)===`redirect`}function bte(e){return typeof e==`object`&&!!e&&`type`in e&&`data`in e&&`init`in e&&e.type===`DataWithResponseInit`}function wn(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.headers==`object`&&e.body!==void 0}function xte(e){return Yt.has(e)}function Ste(e){return wn(e)&&xte(e.status)&&e.headers.has(`Location`)}function Cte(e){return Lee.has(e.toUpperCase())}function Tn(e){return Fee.has(e.toUpperCase())}function En(e){return new URLSearchParams(e).getAll(`index`).some(e=>e===``)}function Dn(e,t){let n=typeof t==`string`?yt(t).search:t.search;if(e[e.length-1].route.index&&En(n||``))return e[e.length-1];let r=Rt(e);return r[r.length-1]}function wte(e){let{formMethod:t,formAction:n,formEncType:r,text:i,formData:a,json:o}=e;if(!(!t||!n||!r)){if(i!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:i};if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:a,json:void 0,text:void 0};if(o!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:o,text:void 0}}}function On(e,t,n,r){return r?{state:`loading`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}:{state:`loading`,location:e,matches:t,historyAction:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Tte(e,t,n,r){return{state:`submitting`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}}function kn(e,t){return e?{state:`loading`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:`loading`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function Ete(e,t){return{state:`submitting`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function An(e){return{state:`idle`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Dte(e,t){try{let n=e.sessionStorage.getItem(Vee);if(n){let e=JSON.parse(n);for(let[n,r]of Object.entries(e||{}))r&&Array.isArray(r)&&t.set(n,new Set(r||[]))}}catch{}}function Ote(e,t){if(t.size>0){let n={};for(let[e,r]of t)n[e]=[...r];try{e.sessionStorage.setItem(Vee,JSON.stringify(n))}catch(e){mt(!1,`Failed to save applied view transitions in sessionStorage (${e}).`)}}}function kte(){let e,t,n=new Promise((r,i)=>{e=async e=>{r(e);try{await n}catch{}},t=async e=>{i(e);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var jn=j.createContext(null);jn.displayName=`DataRouter`;var Mn=j.createContext(null);Mn.displayName=`DataRouterState`;var Nn=j.createContext(!1);function Pn(){return j.useContext(Nn)}var Fn=j.createContext({isTransitioning:!1});Fn.displayName=`ViewTransition`;var In=j.createContext(new Map);In.displayName=`Fetchers`;var Ate=j.createContext(null);Ate.displayName=`Await`;var Ln=j.createContext(null);Ln.displayName=`Navigation`;var Rn=j.createContext(null);Rn.displayName=`Location`;var zn=j.createContext({outlet:null,matches:[],isDataRoute:!1});zn.displayName=`Route`;var Bn=j.createContext(null);Bn.displayName=`RouteError`;var jte=`REACT_ROUTER_ERROR`,Mte=`REDIRECT`,Nte=`ROUTE_ERROR_RESPONSE`;function Pte(e){if(e.startsWith(`${jte}:${Mte}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Fte(e){if(e.startsWith(`${jte}:${Nte}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Wt(t.status,t.statusText,t.data)}catch{}}function Ite(e,{relative:t}={}){pt(Vn(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=j.useContext(Ln),{hash:i,pathname:a,search:o}=Gn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Ht([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Vn(){return j.useContext(Rn)!=null}function Hn(){return pt(Vn(),`useLocation() may be used only in the context of a <Router> component.`),j.useContext(Rn).location}var Lte=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Rte(e){j.useContext(Ln).static||j.useLayoutEffect(e)}function Un(){let{isDataRoute:e}=j.useContext(zn);return e?tne():zte()}function zte(){pt(Vn(),`useNavigate() may be used only in the context of a <Router> component.`);let e=j.useContext(jn),{basename:t,navigator:n}=j.useContext(Ln),{matches:r}=j.useContext(zn),{pathname:i}=Hn(),a=JSON.stringify(zt(r)),o=j.useRef(!1);return Rte(()=>{o.current=!0}),j.useCallback((r,s={})=>{if(mt(o.current,Lte),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Bt(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Ht([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var Bte=j.createContext(null);function Vte(e){let t=j.useContext(zn).outlet;return j.useMemo(()=>t&&j.createElement(Bte.Provider,{value:e},t),[t,e])}function Wn(){let{matches:e}=j.useContext(zn);return e[e.length-1]?.params??{}}function Gn(e,{relative:t}={}){let{matches:n}=j.useContext(zn),{pathname:r}=Hn(),i=JSON.stringify(zt(n));return j.useMemo(()=>Bt(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Hte(e,t,n){pt(Vn(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=j.useContext(Ln),{matches:i}=j.useContext(zn),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;nne(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
10
10
|
|
|
11
11
|
`,fv=/\r\n/g,pv=`xopc.npmPendingRestart`,mv=typeof window<`u`&&window.electronAPI?.updater!==void 0;function hv(){return null}function gv(e){if(!(!e||typeof window>`u`))try{let t=sessionStorage.getItem(pv);if(!t)return;let n=JSON.parse(t),r=typeof n.installedVersion==`string`?n.installedVersion.trim():``;r&&r===e&&sessionStorage.removeItem(pv)}catch{}}function _v(e){return gv(e.currentVersion),e}function rOe(){let[e,t]=(0,j.useState)(null),[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(()=>hv()),[o,s]=(0,j.useState)(mv?{state:`idle`}:hv()),c=(0,j.useRef)(null),l=mv||i!==null;(0,j.useEffect)(()=>{if(l)return;iOe().then(e=>t(_v(e))).catch(()=>{});let e=e=>{let n=e.detail;if(n===null)t(e=>e&&_v({...e,updateAvailable:!1,latestVersion:null,channel:null}));else if(n&&typeof n==`object`){let e=n;t(_v({currentVersion:e.currentVersion??``,updateAvailable:!0,latestVersion:e.latestVersion??null,channel:e.channel??null}))}};return window.addEventListener(`update-available`,e),()=>window.removeEventListener(`update-available`,e)},[l]),(0,j.useEffect)(()=>{if(!mv)return;let e=window.electronAPI.updater;return e.getStatus().then(e=>s(e)),e.onStatusChanged(e=>s(e))},[]),(0,j.useEffect)(()=>{},[]),(0,j.useEffect)(()=>()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]);let u=(0,j.useCallback)(async()=>{if(l)return!1;try{let e=await Te(v(`/api/update/check`),{method:`POST`});if(!e.ok)return!1;let n=await e.json();return n.payload?(t(_v(n.payload)),!0):!1}catch{return!1}},[l]),d=(0,j.useCallback)(async()=>{if(l)return{ok:!1,error:`not-applicable`,message:`npm update is not used in the desktop app.`,status:400};r(!0);try{let e=await Te(v(`/api/update/run/stream`),{method:`POST`,headers:{Accept:`text/event-stream`}});if(!e.ok||!e.body){let t=await e.text().catch(()=>``),n=`HTTP ${e.status}`;try{let e=JSON.parse(t);typeof e.message==`string`&&(n=e.message)}catch{t&&(n=t.slice(0,500))}return{ok:!1,error:e.status===409?`busy`:`unknown`,message:n,status:e.status}}let t=await aOe(e.body);if(t.ok&&t.result){let e=t.result;if(e&&typeof e==`object`&&e.status===`ok`&&typeof e.installedVersion==`string`){try{sessionStorage.setItem(pv,JSON.stringify({installedVersion:e.installedVersion}))}catch{}window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e.installedVersion}}))}else e&&typeof e==`object`&&e.status===`up-to-date`&&typeof e.latestVersion==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e.latestVersion}}))}return t}catch(e){return{ok:!1,error:`network`,message:e instanceof Error?e.message:String(e),status:0}}finally{r(!1)}},[l]),f=(0,j.useCallback)(()=>{if(mv){window.electronAPI.updater.check();return}},[i]),p=(0,j.useCallback)(()=>{mv&&window.electronAPI.updater.quitAndInstall()},[]);return{npm:e,electron:mv?o:i??o,isElectron:l,checkNow:u,runNpmUpdate:d,npmUpdateRunning:n,electronCheck:f,electronQuitAndInstall:p}}var vv=null;async function iOe(){return vv||(vv=(async()=>{let e=await Te(v(`/api/update/status`));if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).payload})().finally(()=>{vv=null}),vv)}async function aOe(e){let t=e.getReader(),n=new TextDecoder,r=``,i=null,a=e=>{try{let t=JSON.parse(e);typeof t.line==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-progress`,{detail:{line:t.line,source:t.source===`stderr`?`stderr`:`stdout`}}))}catch{}},o=e=>{let t=``,n=``;for(let r of e.split(`
|
|
12
12
|
`)){let e=r.replace(/\r$/,``);e.startsWith(`event:`)?t=e.slice(6).trim():e.startsWith(`data:`)&&(n+=e.slice(5).trimStart())}if(n){if(t===`progress`){a(n);return}if(t===`result`)try{let e=JSON.parse(n);i=e.ok?{ok:!0,result:e.result??null}:{ok:!1,error:String(e.error??`unknown`),message:String(e.message??`Update failed`),status:e.error===`busy`?409:400,result:e.result??null}}catch{i={ok:!1,error:`parse`,message:`Invalid update stream`,status:0}}}};try{let e=async()=>{if(i!==null)return i;let{done:a,value:s}=await t.read();if(a)return i;r+=n.decode(s,{stream:!0}),r=r.replace(fv,`
|
|
13
|
-
`);let c=r.split(dv);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var yv=`xopc.updateReminder.dismissed`,oOe=typeof window<`u`&&window.electronAPI?.updater!==void 0,bv=`xopc:electron-update-recheck`;function xv(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(yv);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var Sv=160;function sOe(e){let t=e.trim();return t.length<=Sv?t:`${t.slice(0,Sv-1)}…`}function Cv(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=rOe(),[o,s]=(0,j.useState)(xv),[c,l]=(0,j.useState)({downloading:!1,electronError:!1}),[u,d]=(0,j.useState)(()=>{if(typeof window>`u`||oOe)return null;try{let e=sessionStorage.getItem(pv);if(!e)return null;let t=JSON.parse(e);return(typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null}catch{return null}}),f=(0,j.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,j.useRef)(null);if(u&&e?.currentVersion===u&&p.current!==u){p.current=u;try{sessionStorage.removeItem(pv)}catch{}d(null)}(0,j.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(pv);if(!e){d(null);return}let t=JSON.parse(e);d((typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,j.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(yv,JSON.stringify(t))}catch{}return t})};return window.addEventListener(bv,e),()=>window.removeEventListener(bv,e)},[]),(0,j.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(yv,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,j.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:sOe(t.message)}:!n&&u&&e&&e.currentVersion!==u?{kind:`npm-restart-required`,version:u}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,j.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`){try{sessionStorage.removeItem(pv)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(yv,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var wv={version:`0.0.101`,commit:`f1eaadcba672d377d0ffae75f11c5b19e433ba5a`,buildTimeIso:`2026-06-16T18:00:20.483Z`};function cOe(){return function(e,t){switch(t.type){case`start`:return e.loading?e:{...e,loading:!0,error:null};case`success`:return{data:t.data,loading:!1,error:null};case`error`:return{data:t.data,loading:!1,error:t.error};case`patch`:return{...e,data:t.updater(e.data)}}}}function Tv(e,t,n){let{enabled:r=!0,initial:i,errorData:a}=n,[o,s]=(0,j.useReducer)(cOe(),void 0,()=>({data:i,loading:!1,error:null})),c=(0,j.useRef)(e);c.current=e;let l=(0,j.useRef)(a);l.current=a;let u=(0,j.useRef)(i);u.current=i,(0,j.useEffect)(()=>{if(!r)return;let e=!1;return s({type:`start`}),c.current().then(t=>{e||s({type:`success`,data:t})}).catch(t=>{if(e)return;let n=l.current;s({type:`error`,data:typeof n==`function`?n(t):n===void 0?u.current:n,error:t})}),()=>{e=!0}},[r,...t]);let d=(0,j.useCallback)(e=>{s({type:`patch`,updater:typeof e==`function`?e:()=>e})},[]);return{...o,setData:d}}var lOe=`https://github.com/xopcai/xopc`,uOe=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),dOe=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function Ev(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?uOe:dOe).format(n)}catch{return n.toISOString()}}function Dv({open:e,onOpenChange:t}){let n=f(e=>e.language),r=h(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:d,npmUpdateRunning:p}=rOe(),[m,g]=(0,j.useState)(!1),[_,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),{data:S}=Tv(async()=>{let e=await Ce(v(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),C=(0,j.useCallback)(e=>{e||(g(!1),y(!1),x(!1)),t(e)},[t]),w=(0,j.useCallback)(async()=>{let e=h(n).updatePanel,t=await d();if(t.ok){De({type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail});return}De({type:`error`,title:t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed,message:t.message})},[d,n]),T=wv.commit,E=n===`zh`?`zh-CN`:`en-US`,D=Ev(wv.buildTimeIso,E),O=new Date().getFullYear(),k=i.copyright.replace(`{year}`,String(O));return(0,z.jsx)(iv,{open:e,onOpenChange:C,children:(0,z.jsxs)(av,{children:[(0,z.jsx)(ov,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,z.jsxs)(sv,{className:fh(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,z.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,z.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,z.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,z.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(uv,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,z.jsx)(rm,{className:`size-4`,strokeWidth:2})})})}),(0,z.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,z.jsx)(ph,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,z.jsx)(cv,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,z.jsx)(lv,{className:`sr-only`,children:i.windowTitle})]}),(0,z.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:wv.version}),(0,z.jsx)(`button`,{type:`button`,className:fh(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(bv)),g(!0),c()):(g(!0),x(!1),y(!0),(async()=>{let e=await l();y(!1),e||x(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(_||p),children:o&&s?.state===`checking`||!o&&_?(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(Ts,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&m&&(0,z.jsx)(Ov,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&m&&(0,z.jsx)(kv,{checking:_,checkFailed:b,npm:u,npmUpdateRunning:p,onUpgrade:w,d:i,tp:a}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:T})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,z.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:D})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,z.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:S??i.gatewayUnavailable})]}),(0,z.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,z.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,z.jsxs)(`p`,{children:[i.openSourceLead,(0,z.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:lOe,target:`_blank`,rel:`noopener noreferrer`,children:i.openSourceLink})]}),(0,z.jsx)(`p`,{className:`mt-2`,children:k})]})]})]})]})})}function Ov(e){let t=(0,fm.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(Ts,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,z.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(pi,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,z.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(xu,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,z.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(na,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,z.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(na,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,z.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(di,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,z.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function kv(e){let t=(0,fm.c)(25),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,onUpgrade:o,d:s,tp:c}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(Ts,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===s.checkUpdatesChecking?n=t[2]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,z.jsx)(`span`,{children:s.checkUpdatesChecking})]}),t[1]=s.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(di,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===s.checkUpdatesError?n=t[5]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,z.jsx)(`span`,{children:s.checkUpdatesError})]}),t[4]=s.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(Ts,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===c.updateRunning?n=t[8]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,z.jsx)(`span`,{children:c.updateRunning})]}),t[7]=c.updateRunning,t[8]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(xu,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;t[10]!==i.latestVersion||t[11]!==c.reminderNpm?(n=c.reminderNpm.replace(`{{version}}`,i.latestVersion),t[10]=i.latestVersion,t[11]=c.reminderNpm,t[12]=n):n=t[12];let r;t[13]===n?r=t[14]:(r=(0,z.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,z.jsx)(`span`,{children:n})]}),t[13]=n,t[14]=r);let a;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(a=fh(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-white`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[15]=a):a=t[15];let s;t[16]!==o||t[17]!==c.updateNow?(s=(0,z.jsx)(`button`,{type:`button`,onClick:o,className:a,children:c.updateNow}),t[16]=o,t[17]=c.updateNow,t[18]=s):s=t[18];let l;return t[19]!==r||t[20]!==s?(l=(0,z.jsxs)(`div`,{className:`space-y-2`,children:[r,s]}),t[19]=r,t[20]=s,t[21]=l):l=t[21],l}let l;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(pi,{className:`size-3.5`}),t[22]=l):l=t[22];let u;return t[23]===s.checkUpdatesUpToDate?u=t[24]:(u=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[l,(0,z.jsx)(`span`,{children:s.checkUpdatesUpToDate})]}),t[23]=s.checkUpdatesUpToDate,t[24]=u),u}var Av=fh(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),jv=fh(`rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,`dark:border-edge`);function Mv(e){let t=(0,fm.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=fh(`flex w-full items-center justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=fh(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,z.jsx)(ei,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=u);let d;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,u]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function fOe(e){let t=(0,fm.c)(190),{onOpenFullSettings:n,onAboutClick:r}=e,[i,a]=(0,j.useState)(null),o=f(Iv),s=f(mOe),c=_e(Fv),l=_e(Pv),u=Fh(Nv),d=Fh(pOe),p;t[0]===o?p=t[1]:(p=h(o),t[0]=o,t[1]=p);let m=p,g=m.appearanceSettings,_=o===`zh`?g.langOptionZh:g.langOptionEn,v=c===`light`?g.themeOptionLight:c===`dark`?g.themeOptionDark:g.themeOptionSystem,y=u===`compact`?g.fontScaleCompact:u===`large`?g.fontScaleLarge:g.fontScaleDefault,b;t[2]===i?b=t[3]:(b=e=>fh(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,i===e?`block`:`hidden`),t[2]=i,t[3]=b);let x=b,S;t[4]===i?S=t[5]:(S=e=>fh(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,i===e?`pointer-events-auto`:`pointer-events-none`),t[4]=i,t[5]=S);let C=S,w;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>a(null),t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>a(`lang`),t[7]=T):T=t[7];let E=i===`lang`&&`bg-surface-hover`,D;t[8]===E?D=t[9]:(D=fh(Av,E),t[8]=E,t[9]=D);let O=i===`lang`,k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,z.jsx)(so,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[10]=k):k=t[10];let A;t[11]===g.languageTitle?A=t[12]:(A=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.languageTitle}),t[11]=g.languageTitle,t[12]=A);let ee;t[13]===_?ee=t[14]:(ee=(0,z.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:_}),t[13]=_,t[14]=ee);let te;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,z.jsx)(ai,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[15]=te):te=t[15];let ne;t[16]!==A||t[17]!==ee||t[18]!==D||t[19]!==O?(ne=(0,z.jsxs)(`button`,{type:`button`,className:D,"aria-haspopup":`menu`,"aria-expanded":O,children:[k,A,ee,te]}),t[16]=A,t[17]=ee,t[18]=D,t[19]=O,t[20]=ne):ne=t[20];let re;t[21]===C?re=t[22]:(re=C(`lang`),t[21]=C,t[22]=re);let ie;t[23]===re?ie=t[24]:(ie=(0,z.jsx)(`div`,{className:re,"aria-hidden":!0}),t[23]=re,t[24]=ie);let ae;t[25]===x?ae=t[26]:(ae=x(`lang`),t[25]=x,t[26]=ae);let oe=o===`en`,se;t[27]===s?se=t[28]:(se=()=>s(`en`),t[27]=s,t[28]=se);let ce;t[29]!==g.langOptionEn||t[30]!==oe||t[31]!==se?(ce=(0,z.jsx)(Mv,{selected:oe,label:g.langOptionEn,onSelect:se}),t[29]=g.langOptionEn,t[30]=oe,t[31]=se,t[32]=ce):ce=t[32];let le=o===`zh`,ue;t[33]===s?ue=t[34]:(ue=()=>s(`zh`),t[33]=s,t[34]=ue);let de;t[35]!==g.langOptionZh||t[36]!==le||t[37]!==ue?(de=(0,z.jsx)(Mv,{selected:le,label:g.langOptionZh,onSelect:ue}),t[35]=g.langOptionZh,t[36]=le,t[37]=ue,t[38]=de):de=t[38];let fe;t[39]!==ce||t[40]!==de?(fe=(0,z.jsxs)(`div`,{className:jv,children:[ce,de]}),t[39]=ce,t[40]=de,t[41]=fe):fe=t[41];let pe;t[42]!==g.languageTitle||t[43]!==ae||t[44]!==fe?(pe=(0,z.jsx)(`div`,{className:ae,role:`menu`,"aria-label":g.languageTitle,children:fe}),t[42]=g.languageTitle,t[43]=ae,t[44]=fe,t[45]=pe):pe=t[45];let me;t[46]!==ne||t[47]!==ie||t[48]!==pe?(me=(0,z.jsxs)(`div`,{className:`relative`,onMouseEnter:T,children:[ne,ie,pe]}),t[46]=ne,t[47]=ie,t[48]=pe,t[49]=me):me=t[49];let he;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>a(`theme`),t[50]=he):he=t[50];let ge=i===`theme`&&`bg-surface-hover`,ve;t[51]===ge?ve=t[52]:(ve=fh(Av,ge),t[51]=ge,t[52]=ve);let ye=i===`theme`,be;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,z.jsx)(il,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[53]=be):be=t[53];let xe;t[54]===g.themeTitle?xe=t[55]:(xe=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.themeTitle}),t[54]=g.themeTitle,t[55]=xe);let Se;t[56]===v?Se=t[57]:(Se=(0,z.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:v}),t[56]=v,t[57]=Se);let Ce;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,z.jsx)(ai,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[58]=Ce):Ce=t[58];let we;t[59]!==ve||t[60]!==ye||t[61]!==xe||t[62]!==Se?(we=(0,z.jsxs)(`button`,{type:`button`,className:ve,"aria-haspopup":`menu`,"aria-expanded":ye,children:[be,xe,Se,Ce]}),t[59]=ve,t[60]=ye,t[61]=xe,t[62]=Se,t[63]=we):we=t[63];let Te;t[64]===C?Te=t[65]:(Te=C(`theme`),t[64]=C,t[65]=Te);let Ee;t[66]===Te?Ee=t[67]:(Ee=(0,z.jsx)(`div`,{className:Te,"aria-hidden":!0}),t[66]=Te,t[67]=Ee);let De;t[68]===x?De=t[69]:(De=x(`theme`),t[68]=x,t[69]=De);let Oe=c===`light`,ke;t[70]===l?ke=t[71]:(ke=()=>l(`light`),t[70]=l,t[71]=ke);let Ae;t[72]!==g.themeOptionLight||t[73]!==Oe||t[74]!==ke?(Ae=(0,z.jsx)(Mv,{selected:Oe,label:g.themeOptionLight,onSelect:ke}),t[72]=g.themeOptionLight,t[73]=Oe,t[74]=ke,t[75]=Ae):Ae=t[75];let je=c===`dark`,Me;t[76]===l?Me=t[77]:(Me=()=>l(`dark`),t[76]=l,t[77]=Me);let Ne;t[78]!==g.themeOptionDark||t[79]!==je||t[80]!==Me?(Ne=(0,z.jsx)(Mv,{selected:je,label:g.themeOptionDark,onSelect:Me}),t[78]=g.themeOptionDark,t[79]=je,t[80]=Me,t[81]=Ne):Ne=t[81];let Pe=c===`system`,Fe;t[82]===l?Fe=t[83]:(Fe=()=>l(`system`),t[82]=l,t[83]=Fe);let Ie;t[84]!==g.themeOptionSystem||t[85]!==Pe||t[86]!==Fe?(Ie=(0,z.jsx)(Mv,{selected:Pe,label:g.themeOptionSystem,onSelect:Fe}),t[84]=g.themeOptionSystem,t[85]=Pe,t[86]=Fe,t[87]=Ie):Ie=t[87];let Le;t[88]!==Ae||t[89]!==Ne||t[90]!==Ie?(Le=(0,z.jsxs)(`div`,{className:jv,children:[Ae,Ne,Ie]}),t[88]=Ae,t[89]=Ne,t[90]=Ie,t[91]=Le):Le=t[91];let Re;t[92]!==g.themeTitle||t[93]!==De||t[94]!==Le?(Re=(0,z.jsx)(`div`,{className:De,role:`menu`,"aria-label":g.themeTitle,children:Le}),t[92]=g.themeTitle,t[93]=De,t[94]=Le,t[95]=Re):Re=t[95];let ze;t[96]!==we||t[97]!==Ee||t[98]!==Re?(ze=(0,z.jsxs)(`div`,{className:`relative`,onMouseEnter:he,children:[we,Ee,Re]}),t[96]=we,t[97]=Ee,t[98]=Re,t[99]=ze):ze=t[99];let Be;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Be=()=>a(`font`),t[100]=Be):Be=t[100];let Ve=i===`font`&&`bg-surface-hover`,He;t[101]===Ve?He=t[102]:(He=fh(Av,Ve),t[101]=Ve,t[102]=He);let Ue=i===`font`,We;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,z.jsx)(jSe,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[103]=We):We=t[103];let Ge;t[104]===g.fontScaleTitle?Ge=t[105]:(Ge=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.fontScaleTitle}),t[104]=g.fontScaleTitle,t[105]=Ge);let Ke;t[106]===y?Ke=t[107]:(Ke=(0,z.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:y}),t[106]=y,t[107]=Ke);let qe;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,z.jsx)(ai,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[108]=qe):qe=t[108];let Je;t[109]!==He||t[110]!==Ue||t[111]!==Ge||t[112]!==Ke?(Je=(0,z.jsxs)(`button`,{type:`button`,className:He,"aria-haspopup":`menu`,"aria-expanded":Ue,children:[We,Ge,Ke,qe]}),t[109]=He,t[110]=Ue,t[111]=Ge,t[112]=Ke,t[113]=Je):Je=t[113];let Ye;t[114]===C?Ye=t[115]:(Ye=C(`font`),t[114]=C,t[115]=Ye);let Xe;t[116]===Ye?Xe=t[117]:(Xe=(0,z.jsx)(`div`,{className:Ye,"aria-hidden":!0}),t[116]=Ye,t[117]=Xe);let Ze;t[118]===x?Ze=t[119]:(Ze=x(`font`),t[118]=x,t[119]=Ze);let Qe=u===`compact`,$e;t[120]===d?$e=t[121]:($e=()=>d(`compact`),t[120]=d,t[121]=$e);let et;t[122]!==g.fontScaleCompact||t[123]!==Qe||t[124]!==$e?(et=(0,z.jsx)(Mv,{selected:Qe,label:g.fontScaleCompact,onSelect:$e}),t[122]=g.fontScaleCompact,t[123]=Qe,t[124]=$e,t[125]=et):et=t[125];let tt=u==="default",nt;t[126]===d?nt=t[127]:(nt=()=>d(`default`),t[126]=d,t[127]=nt);let rt;t[128]!==g.fontScaleDefault||t[129]!==tt||t[130]!==nt?(rt=(0,z.jsx)(Mv,{selected:tt,label:g.fontScaleDefault,onSelect:nt}),t[128]=g.fontScaleDefault,t[129]=tt,t[130]=nt,t[131]=rt):rt=t[131];let it=u===`large`,at;t[132]===d?at=t[133]:(at=()=>d(`large`),t[132]=d,t[133]=at);let ot;t[134]!==g.fontScaleLarge||t[135]!==it||t[136]!==at?(ot=(0,z.jsx)(Mv,{selected:it,label:g.fontScaleLarge,onSelect:at}),t[134]=g.fontScaleLarge,t[135]=it,t[136]=at,t[137]=ot):ot=t[137];let st;t[138]!==et||t[139]!==rt||t[140]!==ot?(st=(0,z.jsxs)(`div`,{className:jv,children:[et,rt,ot]}),t[138]=et,t[139]=rt,t[140]=ot,t[141]=st):st=t[141];let ct;t[142]!==g.fontScaleTitle||t[143]!==Ze||t[144]!==st?(ct=(0,z.jsx)(`div`,{className:Ze,role:`menu`,"aria-label":g.fontScaleTitle,children:st}),t[142]=g.fontScaleTitle,t[143]=Ze,t[144]=st,t[145]=ct):ct=t[145];let lt;t[146]!==Je||t[147]!==Xe||t[148]!==ct?(lt=(0,z.jsxs)(`div`,{className:`relative`,onMouseEnter:Be,children:[Je,Xe,ct]}),t[146]=Je,t[147]=Xe,t[148]=ct,t[149]=lt):lt=t[149];let ut;t[150]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,z.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[150]=ut):ut=t[150];let dt;t[151]===r?dt=t[152]:(dt=()=>r?.(),t[151]=r,t[152]=dt);let ft,pt,mt;t[153]===Symbol.for(`react.memo_cache_sentinel`)?(ft=()=>a(null),pt=()=>a(null),mt=(0,z.jsx)(Ro,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[153]=ft,t[154]=pt,t[155]=mt):(ft=t[153],pt=t[154],mt=t[155]);let ht;t[156]===g.aboutApp?ht=t[157]:(ht=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.aboutApp}),t[156]=g.aboutApp,t[157]=ht);let gt;t[158]!==dt||t[159]!==ht?(gt=(0,z.jsxs)(`button`,{type:`button`,className:Av,onClick:dt,onMouseEnter:ft,onFocus:pt,children:[mt,ht]}),t[158]=dt,t[159]=ht,t[160]=gt):gt=t[160];let _t;t[161]===o?_t=t[162]:(_t=_Te(o),t[161]=o,t[162]=_t);let vt,yt,bt;t[163]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>a(null),yt=()=>a(null),bt=(0,z.jsx)(qr,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[163]=vt,t[164]=yt,t[165]=bt):(vt=t[163],yt=t[164],bt=t[165]);let xt;t[166]===m.sidebar.helpDocs?xt=t[167]:(xt=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:m.sidebar.helpDocs}),t[166]=m.sidebar.helpDocs,t[167]=xt);let St;t[168]===Symbol.for(`react.memo_cache_sentinel`)?(St=(0,z.jsx)(aa,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[168]=St):St=t[168];let Ct;t[169]!==_t||t[170]!==xt?(Ct=(0,z.jsxs)(`a`,{href:_t,target:`_blank`,rel:`noopener noreferrer`,className:Av,onMouseEnter:vt,onFocus:yt,children:[bt,xt,St]}),t[169]=_t,t[170]=xt,t[171]=Ct):Ct=t[171];let wt,Tt,Et;t[172]===Symbol.for(`react.memo_cache_sentinel`)?(wt=fh(Av,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),Tt=()=>a(null),Et=()=>a(null),t[172]=wt,t[173]=Tt,t[174]=Et):(wt=t[172],Tt=t[173],Et=t[174]);let Dt;t[175]===n?Dt=t[176]:(Dt=()=>n?.(),t[175]=n,t[176]=Dt);let Ot;t[177]===Symbol.for(`react.memo_cache_sentinel`)?(Ot=(0,z.jsx)(fd,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[177]=Ot):Ot=t[177];let kt;t[178]===g.openFullPreferences?kt=t[179]:(kt=(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:g.openFullPreferences}),t[178]=g.openFullPreferences,t[179]=kt);let At;t[180]!==Dt||t[181]!==kt?(At=(0,z.jsxs)(mr,{to:`/settings/overview`,className:wt,onMouseEnter:Tt,onFocus:Et,onClick:Dt,children:[Ot,kt]}),t[180]=Dt,t[181]=kt,t[182]=At):At=t[182];let jt;return t[183]!==me||t[184]!==ze||t[185]!==lt||t[186]!==gt||t[187]!==Ct||t[188]!==At?(jt=(0,z.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:w,children:[me,ze,lt,ut,gt,Ct,At]}),t[183]=me,t[184]=ze,t[185]=lt,t[186]=gt,t[187]=Ct,t[188]=At,t[189]=jt):jt=t[189],jt}function pOe(e){return e.setPreference}function Nv(e){return e.preference}function Pv(e){return e.setPreference}function Fv(e){return e.preference}function mOe(e){return e.setLanguage}function Iv(e){return e.language}function Lv({collapsed:e=!1,onNavigate:t}){let n=h(f(e=>e.language)),r=n.appearanceSettings,[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{w(()=>import(`./settings-page-DN8JBZ8F.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])),w(()=>import(`./sessions-page-Khdw35Zk.js`),__vite__mapDeps([19,1,3,4,6,15,8])),w(()=>import(`./logs-page-BTVPXcHV.js`),__vite__mapDeps([20,1,6,4,8])),w(()=>import(`./cron-page-COfUPKfq.js`),__vite__mapDeps([21,1,22,23,4,2,3,6,12,11,13,7,8,16,15,24])),w(()=>import(`./skills-page-ByYT0fXZ.js`),__vite__mapDeps([25,1,26,22,23,4,6,8]))},[]),(0,z.jsxs)(`div`,{className:fh(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[(0,z.jsxs)(k_,{open:i,onOpenChange:a,children:[e?(0,z.jsx)(A_,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:fh(`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full outline-none ring-offset-surface-base transition-transform`,`hover:opacity-95 active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,i&&`ring-2 ring-accent`,`motion-reduce:opacity-100 motion-reduce:active:scale-100`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,z.jsx)(ph,{className:`size-full rounded-full`,alt:n.appBrand})})}):(0,z.jsx)(A_,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,className:fh(`flex w-full min-w-0 items-center gap-2 rounded-xl p-1 text-left outline-none transition-colors duration-150 ease-out`,`hover:bg-surface-active/70`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i&&`bg-surface-active/70`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,z.jsx)(`span`,{className:`size-8 shrink-0 overflow-hidden rounded-full`,"aria-hidden":!0,children:(0,z.jsx)(ph,{className:`size-full rounded-full`,alt:``,"aria-hidden":!0})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:r.quickMenuHint})]}),(0,z.jsx)(`span`,{className:fh(`flex size-9 shrink-0 items-center justify-center rounded-xl text-fg-muted transition-colors`,i&&`bg-accent-soft text-accent-fg`),"aria-hidden":!0,children:(0,z.jsx)(fd,{className:`size-[18px]`,strokeWidth:1.5})})]})}),(0,z.jsx)(j_,{children:(0,z.jsx)(M_,{className:fh(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-panel p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,z.jsx)(fOe,{onOpenFullSettings:()=>{a(!1),t?.()},onAboutClick:()=>{s(!0),a(!1)}})})})]}),(0,z.jsx)(Dv,{open:o,onOpenChange:s})]})}var Rv=`xopc-web-sidebar-nav-order`;function zv(){try{let e=globalThis.localStorage?.getItem(Rv);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Bv(e){try{globalThis.localStorage?.setItem(Rv,JSON.stringify(e))}catch{}}function hOe(e,t,n,r,i){if(t===n)return e;let a=e.filter(e=>e!==t),o=a.indexOf(n),s=o===-1?a.length:r===`before`?o:o+1;return _Oe([...a.slice(0,s),t,...a.slice(s)],i)}function gOe(e,t,n){return _Oe([...e.filter(e=>e!==t),t],n)}function _Oe(e,t){let n=new Set(e),r=[];for(let e of t)n.has(e)||r.push(e);return r.length===0?e:[...e,...r]}var Vv=l((e,t)=>({order:zv(),move:(n,r,i)=>{let a=hOe(t().order,n,r,i,new Set(t().order));a!==t().order&&(e({order:a}),queueMicrotask(()=>Bv(a)))},moveToEnd:n=>{let r=gOe(t().order,n,new Set(t().order));r!==t().order&&(e({order:r}),queueMicrotask(()=>Bv(r)))},setOrder:t=>{e({order:t}),queueMicrotask(()=>Bv(t))}})),Hv=null,Uv=l((e,t)=>({variables:{},loaded:!1,updateContext:t=>e(e=>({variables:{...e.variables,...t}})),setContext:t=>e({variables:t,loaded:!0}),fetchContext:async()=>Hv||(Hv=(async()=>{let e=await Ce(v(`/api/context`));t().setContext(e)})().finally(()=>{Hv=null}),Hv)})),Wv=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({}),vOe=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function Gv(e){let t=getComputedStyle(document.documentElement),n={};for(let e of vOe){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var yOe={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"ui.navigate":`theme`,"theme.get":`theme`},Kv=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n){let r=this.iframes.get(e);r&&r!==t&&r.contentWindow&&this.byContentWindow.delete(r.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{sessionKey:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow??(t?.source instanceof Window?t.source:null),o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};a&&a.postMessage(o,`*`)}isTrustedExtensionSource(e,t){if(t.source===null)return!0;let n=e.contentWindow;if(t.source===n)return!0;if(n&&typeof Window<`u`&&t.source instanceof Window)try{return t.source.frameElement===e}catch{}return!1}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`)return;let n,r=t.extensionId;if(e.source instanceof Window){let t=this.byContentWindow.get(e.source);t&&(n=t.iframe,r=t.extensionId)}if(n||(n=this.iframes.get(t.extensionId),r=t.extensionId),!n||!(e.source instanceof Window&&this.byContentWindow.has(e.source))&&!this.isTrustedExtensionSource(n,e))return;if(t.type===`event`){this.handleExtensionEvent(r,t.event,t.data);let e=this.eventSubscribers.get(r);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:i,method:a,params:o}=t,s=this.handlers.get(a);if(!s){this.postResponse(n,e,i,void 0,{code:Wv.MethodNotFound,message:`Unknown method: ${a}`});return}let c=yOe[a],l=this.extensionPermissions.get(r)??new Set;if(c&&!l.has(c)){this.postResponse(n,e,i,void 0,{code:Wv.PermissionDenied,message:`Missing permission: ${c}`});return}try{let t=await s(r,o);this.postResponse(n,e,i,t)}catch(t){let r=t instanceof Error?t.message:String(t);this.postResponse(n,e,i,void 0,{code:Wv.InternalError,message:r})}}};function qv(e){e.registerMethod(`theme.get`,async()=>Gv(_e.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;n&&window.dispatchEvent(new CustomEvent(`extension-navigate`,{detail:{path:n}}))}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&De({type:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,duration:typeof n.duration==`number`?n.duration:void 0})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`sessionKey`in t?String(t.sessionKey??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await Te(v(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({sessionKey:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,sessionKey:r,newSession:i}=t,a=await Te(v(`/api/agent`),{method:`POST`,headers:{Accept:`application/json`},body:JSON.stringify({message:n,channel:`webchat`,sessionKey:i?void 0:r,newSession:!!i})});if(!a.ok)throw Error(`Agent request failed: ${a.status}`);let o=await a.json();return{sessionKey:o.payload?.sessionKey??o.payload?.key??o.sessionKey??r??``}}),e.registerMethod(`config.get`,async e=>{let t=await Te(v(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await Te(v(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Te(v(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,i=await Te(v(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!i.ok)throw Error(`Failed to set storage key: ${i.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Te(v(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await Te(v(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function Jv(e){return e.active||e.activationEligible===!0}function Yv(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0||Array.isArray(t.sidebarPanels)&&t.sidebarPanels.length>0:!1}function bOe(e){return e.source===`bundled`&&e.hasUi===!0&&Yv(e)}function Xv(e){return e.kind===`image-generation`||e.kind===`media-provider`}function xOe(e){return Jv(e)?e.hasConfigSchema||Xv(e)?!0:e.hasUi?Yv(e):!1:!1}function Zv(e){return xOe(e)||bOe(e)}var Qv=(0,j.createContext)(null);function SOe({children:e}){let t=(0,j.useRef)(null);if(!t.current){let e=new Kv;qv(e),t.current=e}let n=t.current,r=xe(e=>!!e.token),{data:i,isLoading:a}=y(r?`gateway-extensions-list`:null,()=>Ce(v(`/api/extensions`)),{revalidateOnFocus:!1}),o=i?.extensions??[],s=_e(e=>e.resolved);(0,j.useEffect)(()=>{r&&Uv.getState().fetchContext()},[r]),(0,j.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&!Array.isArray(t)&&Uv.getState().updateContext(t)},t=()=>{Uv.getState().fetchContext()};return window.addEventListener(`context-update`,e),window.addEventListener(`config-reload`,t),window.addEventListener(`registry-updated`,t),()=>{window.removeEventListener(`context-update`,e),window.removeEventListener(`config-reload`,t),window.removeEventListener(`registry-updated`,t)}},[]);let c=(0,j.useCallback)(e=>{let t=e.detail;t?.sessionKey&&n.forwardAgentStreamEvent(t.sessionKey,t.event??t)},[n]),l=(0,j.useRef)(c);l.current=c,(0,j.useEffect)(()=>{let e=e=>{l.current(e)};return window.addEventListener(`agent-stream-event`,e),()=>{window.removeEventListener(`agent-stream-event`,e)}},[]),(0,j.useEffect)(()=>{let e=Gv(s);n.broadcastEvent(`theme.changed`,e)},[s,n]);let u=(0,j.useRef)(n);u.current=n,(0,j.useEffect)(()=>()=>{u.current.dispose(),t.current=null},[]);let d=(0,j.useMemo)(()=>({router:n,extensions:o,loading:a}),[n,o,a]);return(0,z.jsx)(Qv.Provider,{value:d,children:e})}function $v(){let e=(0,j.useContext)(Qv);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function COe(){let e=(0,j.useContext)(Qv);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function ey(){let e=(0,fm.c)(2),t=COe(),n;return e[0]===t?n=e[1]:(n=t.filter(xOe),e[0]=t,e[1]=n),n}function ty(){let e=(0,j.useContext)(Qv);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}function ny(e,t){return t.path.startsWith(`/apps/`)?t.path:`/apps/${e}/${t.id.startsWith(`${e}.`)?t.id.slice(e.length+1):t.id}`}function wOe(e){return um[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var TOe=[{id:`builtin:agents`,to:`/agents`,Icon:zp},{id:`builtin:skills`,to:`/skills`,Icon:os},{id:`builtin:cron`,to:`/cron`,Icon:ki},{id:`builtin:channels`,to:`/channels`,Icon:Wl},{id:`builtin:notes`,to:`/notes`,Icon:Df},{id:`builtin:workflows`,to:`/workflows`,Icon:no}];function ry(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=[],i=new Set;for(let e of t){let t=n.get(e);!t||i.has(e)||(r.push(t),i.add(e))}for(let t of e)i.has(t.id)||(r.push(t),i.add(t.id));return r.length<=4?{visible:r,overflow:[],hasOverflow:!1}:{visible:r.slice(0,4),overflow:r.slice(4),hasOverflow:!0}}var iy=`text/plain`,V=`xopc-nav:`;function ay(e){return`${V}${e}`}function EOe(e){return e.startsWith(V)?e.slice(9):null}function DOe(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function OOe({isActive:e},t,n,r){return fh(`group relative flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,t?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,n&&`opacity-40`,r===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,r===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function kOe({isActive:e},t,n){return fh(`group relative flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium leading-5 transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,t&&`opacity-40`,n===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,n===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function AOe(e){let t=(0,fm.c)(11),{item:n,collapsed:r}=e,{Icon:i,letter:a}=n;if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=fh(`size-4`,`shrink-0 opacity-90`),t[0]=e):e=t[0];let n;return t[1]===i?n=t[2]:(n=(0,z.jsx)(i,{className:e,strokeWidth:1.75,"aria-hidden":!0}),t[1]=i,t[2]=n),n}let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=fh(`size-4`,`flex shrink-0 items-center justify-center text-[10px] font-bold opacity-70`),t[3]=o):o=t[3];let s;t[4]!==n.label||t[5]!==a?(s=a??n.label.charAt(0),t[4]=n.label,t[5]=a,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=s.toUpperCase(),t[7]=s,t[8]=c);let l;return t[9]===c?l=t[10]:(l=(0,z.jsx)(`span`,{className:o,"aria-hidden":!0,children:c}),t[9]=c,t[10]=l),l}function jOe(e){let t=[];for(let n of e){if(n.activationEligible===!1)continue;let e=n.ui?.contributions?.pages;if(e)for(let r of e){if(!r.showInNav)continue;let e=r.navIcon?wOe(r.navIcon):void 0;t.push({id:`ext:${n.id}:${r.id}`,kind:`extension`,label:r.title,to:ny(n.id,r),Icon:e,letter:r.title.charAt(0),title:r.title})}}return t}function oy(e){let t=(0,fm.c)(52),{collapsed:n,onNavigate:r}=e,i=n===void 0?!1:n,a=f(uy),o;t[0]===a?o=t[1]:(o=h(a),t[0]=a,t[1]=o);let s=o,c=ey(),l=Vv(ly),u=Vv(cy),d=Vv(sy),[p,m]=(0,j.useState)(null),[g,_]=(0,j.useState)(null),[v,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),S;if(t[2]!==s.nav||t[3]!==c){let e;t[5]===s.nav?e=t[6]:(e=e=>{let t=e.id.slice(8);return{id:e.id,kind:`builtin`,label:s.nav[t],to:e.to,Icon:e.Icon}},t[5]=s.nav,t[6]=e);let n=TOe.map(e),r=jOe(c);S=[...n,...r],t[2]=s.nav,t[3]=c,t[4]=S}else S=t[4];let C=S,w;t[7]!==C||t[8]!==l?(w=ry(C,l),t[7]=C,t[8]=l,t[9]=w):w=t[9];let T=w,E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>t=>{t.dataTransfer.setData(iy,ay(e)),t.dataTransfer.effectAllowed=`move`,m(e)},t[10]=E):E=t[10];let D=E,O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{m(null),_(null),y(!1)},t[11]=O):O=t[11];let k=O,A;t[12]!==p||t[13]!==g?(A=e=>t=>{if(!p)return;t.preventDefault(),t.dataTransfer.dropEffect=`move`;let n=DOe(t);g?.id===e&&g.position===n||_({id:e,position:n})},t[12]=p,t[13]=g,t[14]=A):A=t[14];let ee=A,te;t[15]===u?te=t[16]:(te=e=>t=>{t.preventDefault();let n=EOe(t.dataTransfer.getData(iy));if(!n||n===e){k();return}u(n,e,DOe(t)),k()},t[15]=u,t[16]=te);let ne=te,re;t[17]===p?re=t[18]:(re=e=>{p&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,y(!0))},t[17]=p,t[18]=re);let ie=re,ae;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>y(!1),t[19]=ae):ae=t[19];let oe=ae,se;t[20]===d?se=t[21]:(se=e=>{e.preventDefault();let t=EOe(e.dataTransfer.getData(iy));t&&d(t),k()},t[20]=d,t[21]=se);let ce=se,le;t[22]!==i||t[23]!==p||t[24]!==g||t[25]!==r||t[26]!==ee||t[27]!==ne?(le=function(e){let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,z.jsxs)(hr,{to:e.to,draggable:!0,onDragStart:D(e.id),onDragEnd:k,onDragOver:ee(e.id),onDrop:ne(e.id),className:e=>OOe(e,i,t,n),title:e.title??e.label,onClick:()=>r?.(),children:[(0,z.jsx)(AOe,{item:e,collapsed:i}),i?null:(0,z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id)},t[22]=i,t[23]=p,t[24]=g,t[25]=r,t[26]=ee,t[27]=ne,t[28]=le):le=t[28];let ue=le,de;t[29]!==i||t[30]!==p||t[31]!==g||t[32]!==s.sidebar.moreApps||t[33]!==s.sidebar.moreAppsAria||t[34]!==v||t[35]!==ie||t[36]!==ce||t[37]!==r||t[38]!==ee||t[39]!==ne||t[40]!==b||t[41]!==T.overflow?(de=function(){return(0,z.jsxs)(k_,{open:b,onOpenChange:x,children:[(0,z.jsx)(A_,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,onDragOver:ie,onDragLeave:oe,onDrop:ce,className:fh(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,b?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,v&&`ring-2 ring-accent ring-offset-2 ring-offset-surface-base`),"aria-label":s.sidebar.moreAppsAria,title:s.sidebar.moreApps,children:[(0,z.jsx)(ra,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),i?null:(0,z.jsx)(`span`,{className:`truncate`,children:s.sidebar.moreApps})]})}),(0,z.jsx)(j_,{children:(0,z.jsx)(M_,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:fh(`z-50 min-w-[14rem] max-w-[20rem] rounded-lg border border-edge bg-surface-panel p-1 shadow-md`),onOpenAutoFocus:MOe,children:(0,z.jsx)(`ul`,{className:`flex flex-col gap-0.5`,role:`list`,"aria-label":s.sidebar.moreAppsAria,children:T.overflow.map(e=>{let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,z.jsx)(`li`,{className:`contents`,children:(0,z.jsxs)(hr,{to:e.to,draggable:!0,onDragStart:D(e.id),onDragEnd:k,onDragOver:ee(e.id),onDrop:ne(e.id),className:e=>kOe(e,t,n),title:e.title??e.label,onClick:()=>{x(!1),r?.()},children:[(0,z.jsx)(AOe,{item:e}),(0,z.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id)})})})})]})},t[29]=i,t[30]=p,t[31]=g,t[32]=s.sidebar.moreApps,t[33]=s.sidebar.moreAppsAria,t[34]=v,t[35]=ie,t[36]=ce,t[37]=r,t[38]=ee,t[39]=ne,t[40]=b,t[41]=T.overflow,t[42]=de):de=t[42];let fe=de,pe;t[43]!==T.visible||t[44]!==ue?(pe=T.visible.map(ue),t[43]=T.visible,t[44]=ue,t[45]=pe):pe=t[45];let me;t[46]!==T.hasOverflow||t[47]!==fe?(me=T.hasOverflow?fe():null,t[46]=T.hasOverflow,t[47]=fe,t[48]=me):me=t[48];let he;return t[49]!==pe||t[50]!==me?(he=(0,z.jsxs)(z.Fragment,{children:[pe,me]}),t[49]=pe,t[50]=me,t[51]=he):he=t[51],he}function MOe(e){return e.preventDefault()}function sy(e){return e.moveToEnd}function cy(e){return e.move}function ly(e){return e.order}function uy(e){return e.language}var NOe={feishu:`/channel-icons/feishu.svg`,lark:`/channel-icons/lark.svg`};function dy(e){let t=(0,fm.c)(9),{sourceChannel:n,className:r}=e,i=NOe[n.toLowerCase()];if(i){let e;t[0]===r?e=t[1]:(e=fh(`shrink-0`,r),t[0]=r,t[1]=e);let n;return t[2]!==i||t[3]!==e?(n=(0,z.jsx)(`img`,{src:i,alt:``,draggable:!1,className:e,"aria-hidden":!0}),t[2]=i,t[3]=e,t[4]=n):n=t[4],n}let a;t[5]===r?a=t[6]:(a=fh(`shrink-0`,r),t[5]=r,t[6]=a);let o;return t[7]===a?o=t[8]:(o=(0,z.jsx)(go,{className:a,strokeWidth:1.75,"aria-hidden":!0}),t[7]=a,t[8]=o),o}var POe=`inline-flex items-center gap-px rounded-pill border border-edge bg-surface-hover p-1 dark:border-edge`,fy=`inline-flex shrink-0 items-center justify-center rounded-pill text-xs font-medium leading-none transition-[color,background-color,box-shadow] duration-150 ease-out text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100`,py=`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,my=1;function FOe(e,t){let n=0,r=0,i=e;for(;i&&i!==t;)n+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;return i===t?{x:n,y:r}:null}var hy=`pointer-events-none absolute left-0 top-0 z-[1] rounded-pill bg-surface-panel shadow-sm will-change-transform [backface-visibility:hidden] dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,IOe=`relative z-[2] box-border flex h-6 min-h-0 min-w-0 flex-1 cursor-pointer items-center justify-center gap-1 rounded-pill border-0 bg-transparent px-2 py-0 text-center text-xs font-medium leading-none outline-none transition-[color,background-color,box-shadow] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`;function gy({value:e,onChange:t,options:n,"aria-label":r,className:i,buttonClassName:a}){let o=(0,j.useRef)(null),s=(0,j.useRef)([]),[c,l]=(0,j.useState)({x:0,y:0,w:0,h:0}),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=(0,j.useCallback)(()=>{let t=o.current;if(!t)return;let r=n.findIndex(t=>t.value===e);if(r<0)return;let i=s.current[r];if(!i)return;let a=my,c=t.getBoundingClientRect(),u=i.getBoundingClientRect(),f=FOe(i,t),p,m;if(f)p=f.x,m=f.y;else{let e=getComputedStyle(t),n=parseFloat(e.borderLeftWidth)||0,r=parseFloat(e.borderTopWidth)||0;p=u.left-c.left-n,m=u.top-c.top-r}l({x:p+a,y:m+a,w:Math.max(0,u.width-a*2),h:Math.max(0,u.height-a*2)}),d(!0)},[n,e]),h=(0,j.useRef)(m);return h.current=m,(0,j.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>m());return()=>cancelAnimationFrame(e)},[m]),(0,j.useEffect)(()=>{let e=requestAnimationFrame(()=>{requestAnimationFrame(()=>p(!0))});return()=>cancelAnimationFrame(e)},[]),(0,j.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{requestAnimationFrame(()=>h.current())},n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,z.jsxs)(`div`,{ref:o,className:fh(POe,`relative isolate flex w-full max-w-full flex-row items-center`,i),role:`group`,"aria-label":r,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,className:fh(hy,`motion-reduce:!transition-none motion-reduce:!duration-0`,f&&`transition-[transform,width,height] duration-300 [transition-timing-function:cubic-bezier(0.32,0.72,0,1)]`),style:{width:c.w,height:c.h,transform:`translate3d(${c.x}px, ${c.y}px, 0)`,opacity:u&&c.w>0?1:0}}),n.map((n,r)=>{let i=n.icon,o=e===n.value;return(0,z.jsxs)(`button`,{ref:e=>{s.current[r]=e},type:`button`,"aria-pressed":o,title:n.title??n.label,onClick:()=>t(n.value),className:fh(IOe,o?`text-fg`:`text-fg-subtle`,a),children:[i?(0,z.jsx)(i,{className:`block size-3 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,z.jsx)(`span`,{className:`min-w-0 shrink truncate leading-none`,children:n.label})]},n.value)})]})}function _y(){return v(`/api/config`)}var vy=null;async function LOe(){return vy||(vy=Ce(_y()).finally(()=>{vy=null}),vy)}function yy(e){let t=(0,fm.c)(6),n;t[0]===e?n=t[1]:(n=e?_y():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=y(r,LOe,i),o,s;return t[3]===e?(o=t[4],s=t[5]):(o=()=>{if(!e)return;let t=_y(),n=()=>{x(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},s=[e],t[3]=e,t[4]=o,t[5]=s),(0,j.useEffect)(o,s),a}function by(){return x(_y())}var xy=null;async function H(){return xy||(xy=ROe().finally(()=>{xy=null}),xy)}async function ROe(){let e=await Te(v(`/api/agents?locale=${encodeURIComponent(p())}`));if(e.ok){let t=await e.json();if(t.ok&&t.payload?.defaultId&&Array.isArray(t.payload.agents)){let e=t.payload.defaultId.trim().toLowerCase(),n=t.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));if(n.length>0)return{defaultId:e,items:n}}}let t=(await LOe()).payload?.config?.agents,n=(t?.defaultId??`main`).trim().toLowerCase(),r=(Array.isArray(t?.list)?t.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));return r.length===0?{defaultId:n,items:[{id:n}]}:{defaultId:n,items:r}}function zOe(e){return typeof e==`object`&&!!e&&`role`in e}function Sy(e){if(!e||typeof e!=`object`)return!1;let t=e.type;return t===`tool_use`||t===`tool_call`||t===`toolCall`}function Cy(e){return typeof e==`object`&&!!e}function BOe(e){return typeof e.id==`string`&&e.id.length>0?e.id:crypto.randomUUID()}function wy(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function VOe(e){return wy(e.args??e.arguments??e.input??e.function?.arguments)??{}}function Ty(e){if(typeof e==`string`){let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}return Date.now()}var Ey=3e5;function Dy(e,t){let n=new URLSearchParams({uri:e.trim()});return t?.trim()&&n.set(`sessionKey`,t.trim()),`/api/media/read?${n.toString()}`}function Oy(e){if(typeof e.content==`string`&&e.content.length>0)return e.content;if(typeof e.data==`string`&&e.data.length>0)return e.data}var ky=[`.txt`,`.md`,`.json`,`.xml`,`.html`,`.css`,`.js`,`.ts`,`.jsx`,`.tsx`,`.yml`,`.yaml`];function HOe(e){let t=e.mimeType?.toLowerCase()??``;if(t.startsWith(`text/`)||t===`application/json`||t===`application/xml`||t===`application/javascript`||t===`application/typescript`)return!0;let n=e.name?.toLowerCase()??``;return ky.some(e=>n.endsWith(e))}function UOe(e){if(e.extractedText!=null&&e.extractedText!==``)return e.extractedText;if(!HOe(e))return;let t=Oy(e);if(t)try{let e=Ay(t);return new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(e))}catch{return}}function WOe(e,t){let n=t.trim();if(n.startsWith(`data:`))return n;let r=n.replace(/\s/g,``);return`data:${e&&typeof e==`string`&&e.includes(`/`)?e:`application/octet-stream`};base64,${r}`}function GOe(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode(...i)}return btoa(n)}function Ay(e){if(e==null||e===``)throw Error(`Missing file data`);let t=e;if(e.startsWith(`data:`)){let n=e.match(/base64,(.+)/);n&&(t=n[1])}let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}function KOe(e){let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(1)} ${t[n]}`}function qOe(e){let t=(e.mimeType??``).toLowerCase(),n=t.split(`;`)[0]?.trim()??``,r=e.name?.toLowerCase()??``;return e.type===`image`||n.startsWith(`image/`)?`image`:n===`application/pdf`||t.includes(`application/pdf`)||r.endsWith(`.pdf`)?`pdf`:n===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||t.includes(`wordprocessingml`)||r.endsWith(`.docx`)?`docx`:n===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||t.includes(`presentationml`)||r.endsWith(`.pptx`)?`pptx`:[`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(n)||t.includes(`spreadsheetml`)||t.includes(`ms-excel`)||r.endsWith(`.xlsx`)||r.endsWith(`.xls`)?`excel`:[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.bmp`,`.svg`].some(e=>r.endsWith(e))?`image`:`text`}function jy(e){let t=e.toLowerCase();for(let[e,n]of[[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.bmp`,`image/bmp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.ico`,`image/x-icon`],[`.tif`,`image/tiff`],[`.tiff`,`image/tiff`],[`.avif`,`image/avif`],[`.jxl`,`image/jxl`]])if(t.endsWith(e))return n}function JOe(e,t){return(t?.startsWith(`text/`)??!1)||ky.some(t=>e.toLowerCase().endsWith(t))}function My(e){if(Array.isArray(e))return e.map(e=>YOe(e))}function YOe(e){if(!e||typeof e!=`object`)return{name:`file`,mimeType:`application/octet-stream`};let t=e,n=Ny(t.uri),r=XOe(t.name),i=ZOe(t.mimeType,r),a=typeof t.type==`string`?t.type:void 0,o=a===`photo`||a===`image`||i.startsWith(`image/`)?`image`:a===`voice`||a===`audio`||i.startsWith(`audio/`)?`voice`:a;return{id:typeof t.id==`string`?t.id:void 0,name:r,mimeType:i,type:o,size:typeof t.size==`number`?t.size:void 0,uri:n,bucket:typeof t.bucket==`string`?t.bucket:void 0,path:typeof t.path==`string`?t.path:void 0}}function Ny(e){return typeof e==`string`&&e.trim().startsWith(`media://`)?e.trim():void 0}function XOe(e){return typeof e==`string`&&e.trim().length>0?e.trim():`file`}function ZOe(e,t){if(typeof e==`string`&&e.trim().length>0){let t=e.trim();if(t.toLowerCase().split(`;`)[0]?.trim()!==`application/octet-stream`)return t}return jy(t)??`application/octet-stream`}function Py(e){let t=e.uri?.trim();return t?`uri:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function Fy(e){if(!e?.length)return;let t=[],n=new Set;for(let r of e){let e=Py(r);n.has(e)||(n.add(e),t.push(r))}return t.length?t:void 0}var QOe=`[Startup context loaded by runtime]`,$Oe=`...[additional startup memory truncated]...`,eke=`END_QUOTED_NOTES`;function tke(e){if(!e.includes(QOe))return e;let t=e.replace(/^\uFEFF/,``);if(!t.startsWith(QOe))return e;let n=-1,r=t.lastIndexOf(eke);if(r>=0)n=r+16;else{let e=t.indexOf($Oe);e>=0&&(n=e+43)}if(n<0){let n=t.slice(35),r=n.indexOf(`
|
|
13
|
+
`);let c=r.split(dv);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var yv=`xopc.updateReminder.dismissed`,oOe=typeof window<`u`&&window.electronAPI?.updater!==void 0,bv=`xopc:electron-update-recheck`;function xv(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(yv);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var Sv=160;function sOe(e){let t=e.trim();return t.length<=Sv?t:`${t.slice(0,Sv-1)}…`}function Cv(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=rOe(),[o,s]=(0,j.useState)(xv),[c,l]=(0,j.useState)({downloading:!1,electronError:!1}),[u,d]=(0,j.useState)(()=>{if(typeof window>`u`||oOe)return null;try{let e=sessionStorage.getItem(pv);if(!e)return null;let t=JSON.parse(e);return(typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null}catch{return null}}),f=(0,j.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,j.useRef)(null);if(u&&e?.currentVersion===u&&p.current!==u){p.current=u;try{sessionStorage.removeItem(pv)}catch{}d(null)}(0,j.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(pv);if(!e){d(null);return}let t=JSON.parse(e);d((typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,j.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(yv,JSON.stringify(t))}catch{}return t})};return window.addEventListener(bv,e),()=>window.removeEventListener(bv,e)},[]),(0,j.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(yv,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,j.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:sOe(t.message)}:!n&&u&&e&&e.currentVersion!==u?{kind:`npm-restart-required`,version:u}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,j.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`){try{sessionStorage.removeItem(pv)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(yv,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var wv={version:`0.0.102`,commit:`b504fd04b0e7182f561fc6334b864cbe67663352`,buildTimeIso:`2026-06-17T00:48:03.797Z`};function cOe(){return function(e,t){switch(t.type){case`start`:return e.loading?e:{...e,loading:!0,error:null};case`success`:return{data:t.data,loading:!1,error:null};case`error`:return{data:t.data,loading:!1,error:t.error};case`patch`:return{...e,data:t.updater(e.data)}}}}function Tv(e,t,n){let{enabled:r=!0,initial:i,errorData:a}=n,[o,s]=(0,j.useReducer)(cOe(),void 0,()=>({data:i,loading:!1,error:null})),c=(0,j.useRef)(e);c.current=e;let l=(0,j.useRef)(a);l.current=a;let u=(0,j.useRef)(i);u.current=i,(0,j.useEffect)(()=>{if(!r)return;let e=!1;return s({type:`start`}),c.current().then(t=>{e||s({type:`success`,data:t})}).catch(t=>{if(e)return;let n=l.current;s({type:`error`,data:typeof n==`function`?n(t):n===void 0?u.current:n,error:t})}),()=>{e=!0}},[r,...t]);let d=(0,j.useCallback)(e=>{s({type:`patch`,updater:typeof e==`function`?e:()=>e})},[]);return{...o,setData:d}}var lOe=`https://github.com/xopcai/xopc`,uOe=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),dOe=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function Ev(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?uOe:dOe).format(n)}catch{return n.toISOString()}}function Dv({open:e,onOpenChange:t}){let n=f(e=>e.language),r=h(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:d,npmUpdateRunning:p}=rOe(),[m,g]=(0,j.useState)(!1),[_,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),{data:S}=Tv(async()=>{let e=await Ce(v(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),C=(0,j.useCallback)(e=>{e||(g(!1),y(!1),x(!1)),t(e)},[t]),w=(0,j.useCallback)(async()=>{let e=h(n).updatePanel,t=await d();if(t.ok){De({type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail});return}De({type:`error`,title:t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed,message:t.message})},[d,n]),T=wv.commit,E=n===`zh`?`zh-CN`:`en-US`,D=Ev(wv.buildTimeIso,E),O=new Date().getFullYear(),k=i.copyright.replace(`{year}`,String(O));return(0,z.jsx)(iv,{open:e,onOpenChange:C,children:(0,z.jsxs)(av,{children:[(0,z.jsx)(ov,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,z.jsxs)(sv,{className:fh(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,z.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,z.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,z.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,z.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(uv,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,z.jsx)(rm,{className:`size-4`,strokeWidth:2})})})}),(0,z.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,z.jsx)(ph,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,z.jsx)(cv,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,z.jsx)(lv,{className:`sr-only`,children:i.windowTitle})]}),(0,z.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:wv.version}),(0,z.jsx)(`button`,{type:`button`,className:fh(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(bv)),g(!0),c()):(g(!0),x(!1),y(!0),(async()=>{let e=await l();y(!1),e||x(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(_||p),children:o&&s?.state===`checking`||!o&&_?(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(Ts,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&m&&(0,z.jsx)(Ov,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&m&&(0,z.jsx)(kv,{checking:_,checkFailed:b,npm:u,npmUpdateRunning:p,onUpgrade:w,d:i,tp:a}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:T})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,z.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:D})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,z.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,z.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:S??i.gatewayUnavailable})]}),(0,z.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,z.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,z.jsxs)(`p`,{children:[i.openSourceLead,(0,z.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:lOe,target:`_blank`,rel:`noopener noreferrer`,children:i.openSourceLink})]}),(0,z.jsx)(`p`,{className:`mt-2`,children:k})]})]})]})]})})}function Ov(e){let t=(0,fm.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(Ts,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,z.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(pi,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,z.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(xu,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,z.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(na,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,z.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(na,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,z.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(di,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,z.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function kv(e){let t=(0,fm.c)(25),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,onUpgrade:o,d:s,tp:c}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(Ts,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===s.checkUpdatesChecking?n=t[2]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,z.jsx)(`span`,{children:s.checkUpdatesChecking})]}),t[1]=s.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(di,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===s.checkUpdatesError?n=t[5]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,z.jsx)(`span`,{children:s.checkUpdatesError})]}),t[4]=s.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(Ts,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===c.updateRunning?n=t[8]:(n=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,z.jsx)(`span`,{children:c.updateRunning})]}),t[7]=c.updateRunning,t[8]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(xu,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;t[10]!==i.latestVersion||t[11]!==c.reminderNpm?(n=c.reminderNpm.replace(`{{version}}`,i.latestVersion),t[10]=i.latestVersion,t[11]=c.reminderNpm,t[12]=n):n=t[12];let r;t[13]===n?r=t[14]:(r=(0,z.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,z.jsx)(`span`,{children:n})]}),t[13]=n,t[14]=r);let a;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(a=fh(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-white`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[15]=a):a=t[15];let s;t[16]!==o||t[17]!==c.updateNow?(s=(0,z.jsx)(`button`,{type:`button`,onClick:o,className:a,children:c.updateNow}),t[16]=o,t[17]=c.updateNow,t[18]=s):s=t[18];let l;return t[19]!==r||t[20]!==s?(l=(0,z.jsxs)(`div`,{className:`space-y-2`,children:[r,s]}),t[19]=r,t[20]=s,t[21]=l):l=t[21],l}let l;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(pi,{className:`size-3.5`}),t[22]=l):l=t[22];let u;return t[23]===s.checkUpdatesUpToDate?u=t[24]:(u=(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[l,(0,z.jsx)(`span`,{children:s.checkUpdatesUpToDate})]}),t[23]=s.checkUpdatesUpToDate,t[24]=u),u}var Av=fh(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),jv=fh(`rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,`dark:border-edge`);function Mv(e){let t=(0,fm.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=fh(`flex w-full items-center justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=fh(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,z.jsx)(ei,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=u);let d;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,u]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function fOe(e){let t=(0,fm.c)(190),{onOpenFullSettings:n,onAboutClick:r}=e,[i,a]=(0,j.useState)(null),o=f(Iv),s=f(mOe),c=_e(Fv),l=_e(Pv),u=Fh(Nv),d=Fh(pOe),p;t[0]===o?p=t[1]:(p=h(o),t[0]=o,t[1]=p);let m=p,g=m.appearanceSettings,_=o===`zh`?g.langOptionZh:g.langOptionEn,v=c===`light`?g.themeOptionLight:c===`dark`?g.themeOptionDark:g.themeOptionSystem,y=u===`compact`?g.fontScaleCompact:u===`large`?g.fontScaleLarge:g.fontScaleDefault,b;t[2]===i?b=t[3]:(b=e=>fh(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,i===e?`block`:`hidden`),t[2]=i,t[3]=b);let x=b,S;t[4]===i?S=t[5]:(S=e=>fh(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,i===e?`pointer-events-auto`:`pointer-events-none`),t[4]=i,t[5]=S);let C=S,w;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>a(null),t[6]=w):w=t[6];let T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>a(`lang`),t[7]=T):T=t[7];let E=i===`lang`&&`bg-surface-hover`,D;t[8]===E?D=t[9]:(D=fh(Av,E),t[8]=E,t[9]=D);let O=i===`lang`,k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,z.jsx)(so,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[10]=k):k=t[10];let A;t[11]===g.languageTitle?A=t[12]:(A=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.languageTitle}),t[11]=g.languageTitle,t[12]=A);let ee;t[13]===_?ee=t[14]:(ee=(0,z.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:_}),t[13]=_,t[14]=ee);let te;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,z.jsx)(ai,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[15]=te):te=t[15];let ne;t[16]!==A||t[17]!==ee||t[18]!==D||t[19]!==O?(ne=(0,z.jsxs)(`button`,{type:`button`,className:D,"aria-haspopup":`menu`,"aria-expanded":O,children:[k,A,ee,te]}),t[16]=A,t[17]=ee,t[18]=D,t[19]=O,t[20]=ne):ne=t[20];let re;t[21]===C?re=t[22]:(re=C(`lang`),t[21]=C,t[22]=re);let ie;t[23]===re?ie=t[24]:(ie=(0,z.jsx)(`div`,{className:re,"aria-hidden":!0}),t[23]=re,t[24]=ie);let ae;t[25]===x?ae=t[26]:(ae=x(`lang`),t[25]=x,t[26]=ae);let oe=o===`en`,se;t[27]===s?se=t[28]:(se=()=>s(`en`),t[27]=s,t[28]=se);let ce;t[29]!==g.langOptionEn||t[30]!==oe||t[31]!==se?(ce=(0,z.jsx)(Mv,{selected:oe,label:g.langOptionEn,onSelect:se}),t[29]=g.langOptionEn,t[30]=oe,t[31]=se,t[32]=ce):ce=t[32];let le=o===`zh`,ue;t[33]===s?ue=t[34]:(ue=()=>s(`zh`),t[33]=s,t[34]=ue);let de;t[35]!==g.langOptionZh||t[36]!==le||t[37]!==ue?(de=(0,z.jsx)(Mv,{selected:le,label:g.langOptionZh,onSelect:ue}),t[35]=g.langOptionZh,t[36]=le,t[37]=ue,t[38]=de):de=t[38];let fe;t[39]!==ce||t[40]!==de?(fe=(0,z.jsxs)(`div`,{className:jv,children:[ce,de]}),t[39]=ce,t[40]=de,t[41]=fe):fe=t[41];let pe;t[42]!==g.languageTitle||t[43]!==ae||t[44]!==fe?(pe=(0,z.jsx)(`div`,{className:ae,role:`menu`,"aria-label":g.languageTitle,children:fe}),t[42]=g.languageTitle,t[43]=ae,t[44]=fe,t[45]=pe):pe=t[45];let me;t[46]!==ne||t[47]!==ie||t[48]!==pe?(me=(0,z.jsxs)(`div`,{className:`relative`,onMouseEnter:T,children:[ne,ie,pe]}),t[46]=ne,t[47]=ie,t[48]=pe,t[49]=me):me=t[49];let he;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>a(`theme`),t[50]=he):he=t[50];let ge=i===`theme`&&`bg-surface-hover`,ve;t[51]===ge?ve=t[52]:(ve=fh(Av,ge),t[51]=ge,t[52]=ve);let ye=i===`theme`,be;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,z.jsx)(il,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[53]=be):be=t[53];let xe;t[54]===g.themeTitle?xe=t[55]:(xe=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.themeTitle}),t[54]=g.themeTitle,t[55]=xe);let Se;t[56]===v?Se=t[57]:(Se=(0,z.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:v}),t[56]=v,t[57]=Se);let Ce;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,z.jsx)(ai,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[58]=Ce):Ce=t[58];let we;t[59]!==ve||t[60]!==ye||t[61]!==xe||t[62]!==Se?(we=(0,z.jsxs)(`button`,{type:`button`,className:ve,"aria-haspopup":`menu`,"aria-expanded":ye,children:[be,xe,Se,Ce]}),t[59]=ve,t[60]=ye,t[61]=xe,t[62]=Se,t[63]=we):we=t[63];let Te;t[64]===C?Te=t[65]:(Te=C(`theme`),t[64]=C,t[65]=Te);let Ee;t[66]===Te?Ee=t[67]:(Ee=(0,z.jsx)(`div`,{className:Te,"aria-hidden":!0}),t[66]=Te,t[67]=Ee);let De;t[68]===x?De=t[69]:(De=x(`theme`),t[68]=x,t[69]=De);let Oe=c===`light`,ke;t[70]===l?ke=t[71]:(ke=()=>l(`light`),t[70]=l,t[71]=ke);let Ae;t[72]!==g.themeOptionLight||t[73]!==Oe||t[74]!==ke?(Ae=(0,z.jsx)(Mv,{selected:Oe,label:g.themeOptionLight,onSelect:ke}),t[72]=g.themeOptionLight,t[73]=Oe,t[74]=ke,t[75]=Ae):Ae=t[75];let je=c===`dark`,Me;t[76]===l?Me=t[77]:(Me=()=>l(`dark`),t[76]=l,t[77]=Me);let Ne;t[78]!==g.themeOptionDark||t[79]!==je||t[80]!==Me?(Ne=(0,z.jsx)(Mv,{selected:je,label:g.themeOptionDark,onSelect:Me}),t[78]=g.themeOptionDark,t[79]=je,t[80]=Me,t[81]=Ne):Ne=t[81];let Pe=c===`system`,Fe;t[82]===l?Fe=t[83]:(Fe=()=>l(`system`),t[82]=l,t[83]=Fe);let Ie;t[84]!==g.themeOptionSystem||t[85]!==Pe||t[86]!==Fe?(Ie=(0,z.jsx)(Mv,{selected:Pe,label:g.themeOptionSystem,onSelect:Fe}),t[84]=g.themeOptionSystem,t[85]=Pe,t[86]=Fe,t[87]=Ie):Ie=t[87];let Le;t[88]!==Ae||t[89]!==Ne||t[90]!==Ie?(Le=(0,z.jsxs)(`div`,{className:jv,children:[Ae,Ne,Ie]}),t[88]=Ae,t[89]=Ne,t[90]=Ie,t[91]=Le):Le=t[91];let Re;t[92]!==g.themeTitle||t[93]!==De||t[94]!==Le?(Re=(0,z.jsx)(`div`,{className:De,role:`menu`,"aria-label":g.themeTitle,children:Le}),t[92]=g.themeTitle,t[93]=De,t[94]=Le,t[95]=Re):Re=t[95];let ze;t[96]!==we||t[97]!==Ee||t[98]!==Re?(ze=(0,z.jsxs)(`div`,{className:`relative`,onMouseEnter:he,children:[we,Ee,Re]}),t[96]=we,t[97]=Ee,t[98]=Re,t[99]=ze):ze=t[99];let Be;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Be=()=>a(`font`),t[100]=Be):Be=t[100];let Ve=i===`font`&&`bg-surface-hover`,He;t[101]===Ve?He=t[102]:(He=fh(Av,Ve),t[101]=Ve,t[102]=He);let Ue=i===`font`,We;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,z.jsx)(jSe,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[103]=We):We=t[103];let Ge;t[104]===g.fontScaleTitle?Ge=t[105]:(Ge=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.fontScaleTitle}),t[104]=g.fontScaleTitle,t[105]=Ge);let Ke;t[106]===y?Ke=t[107]:(Ke=(0,z.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:y}),t[106]=y,t[107]=Ke);let qe;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,z.jsx)(ai,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[108]=qe):qe=t[108];let Je;t[109]!==He||t[110]!==Ue||t[111]!==Ge||t[112]!==Ke?(Je=(0,z.jsxs)(`button`,{type:`button`,className:He,"aria-haspopup":`menu`,"aria-expanded":Ue,children:[We,Ge,Ke,qe]}),t[109]=He,t[110]=Ue,t[111]=Ge,t[112]=Ke,t[113]=Je):Je=t[113];let Ye;t[114]===C?Ye=t[115]:(Ye=C(`font`),t[114]=C,t[115]=Ye);let Xe;t[116]===Ye?Xe=t[117]:(Xe=(0,z.jsx)(`div`,{className:Ye,"aria-hidden":!0}),t[116]=Ye,t[117]=Xe);let Ze;t[118]===x?Ze=t[119]:(Ze=x(`font`),t[118]=x,t[119]=Ze);let Qe=u===`compact`,$e;t[120]===d?$e=t[121]:($e=()=>d(`compact`),t[120]=d,t[121]=$e);let et;t[122]!==g.fontScaleCompact||t[123]!==Qe||t[124]!==$e?(et=(0,z.jsx)(Mv,{selected:Qe,label:g.fontScaleCompact,onSelect:$e}),t[122]=g.fontScaleCompact,t[123]=Qe,t[124]=$e,t[125]=et):et=t[125];let tt=u==="default",nt;t[126]===d?nt=t[127]:(nt=()=>d(`default`),t[126]=d,t[127]=nt);let rt;t[128]!==g.fontScaleDefault||t[129]!==tt||t[130]!==nt?(rt=(0,z.jsx)(Mv,{selected:tt,label:g.fontScaleDefault,onSelect:nt}),t[128]=g.fontScaleDefault,t[129]=tt,t[130]=nt,t[131]=rt):rt=t[131];let it=u===`large`,at;t[132]===d?at=t[133]:(at=()=>d(`large`),t[132]=d,t[133]=at);let ot;t[134]!==g.fontScaleLarge||t[135]!==it||t[136]!==at?(ot=(0,z.jsx)(Mv,{selected:it,label:g.fontScaleLarge,onSelect:at}),t[134]=g.fontScaleLarge,t[135]=it,t[136]=at,t[137]=ot):ot=t[137];let st;t[138]!==et||t[139]!==rt||t[140]!==ot?(st=(0,z.jsxs)(`div`,{className:jv,children:[et,rt,ot]}),t[138]=et,t[139]=rt,t[140]=ot,t[141]=st):st=t[141];let ct;t[142]!==g.fontScaleTitle||t[143]!==Ze||t[144]!==st?(ct=(0,z.jsx)(`div`,{className:Ze,role:`menu`,"aria-label":g.fontScaleTitle,children:st}),t[142]=g.fontScaleTitle,t[143]=Ze,t[144]=st,t[145]=ct):ct=t[145];let lt;t[146]!==Je||t[147]!==Xe||t[148]!==ct?(lt=(0,z.jsxs)(`div`,{className:`relative`,onMouseEnter:Be,children:[Je,Xe,ct]}),t[146]=Je,t[147]=Xe,t[148]=ct,t[149]=lt):lt=t[149];let ut;t[150]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,z.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[150]=ut):ut=t[150];let dt;t[151]===r?dt=t[152]:(dt=()=>r?.(),t[151]=r,t[152]=dt);let ft,pt,mt;t[153]===Symbol.for(`react.memo_cache_sentinel`)?(ft=()=>a(null),pt=()=>a(null),mt=(0,z.jsx)(Ro,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[153]=ft,t[154]=pt,t[155]=mt):(ft=t[153],pt=t[154],mt=t[155]);let ht;t[156]===g.aboutApp?ht=t[157]:(ht=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.aboutApp}),t[156]=g.aboutApp,t[157]=ht);let gt;t[158]!==dt||t[159]!==ht?(gt=(0,z.jsxs)(`button`,{type:`button`,className:Av,onClick:dt,onMouseEnter:ft,onFocus:pt,children:[mt,ht]}),t[158]=dt,t[159]=ht,t[160]=gt):gt=t[160];let _t;t[161]===o?_t=t[162]:(_t=_Te(o),t[161]=o,t[162]=_t);let vt,yt,bt;t[163]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>a(null),yt=()=>a(null),bt=(0,z.jsx)(qr,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[163]=vt,t[164]=yt,t[165]=bt):(vt=t[163],yt=t[164],bt=t[165]);let xt;t[166]===m.sidebar.helpDocs?xt=t[167]:(xt=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:m.sidebar.helpDocs}),t[166]=m.sidebar.helpDocs,t[167]=xt);let St;t[168]===Symbol.for(`react.memo_cache_sentinel`)?(St=(0,z.jsx)(aa,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[168]=St):St=t[168];let Ct;t[169]!==_t||t[170]!==xt?(Ct=(0,z.jsxs)(`a`,{href:_t,target:`_blank`,rel:`noopener noreferrer`,className:Av,onMouseEnter:vt,onFocus:yt,children:[bt,xt,St]}),t[169]=_t,t[170]=xt,t[171]=Ct):Ct=t[171];let wt,Tt,Et;t[172]===Symbol.for(`react.memo_cache_sentinel`)?(wt=fh(Av,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),Tt=()=>a(null),Et=()=>a(null),t[172]=wt,t[173]=Tt,t[174]=Et):(wt=t[172],Tt=t[173],Et=t[174]);let Dt;t[175]===n?Dt=t[176]:(Dt=()=>n?.(),t[175]=n,t[176]=Dt);let Ot;t[177]===Symbol.for(`react.memo_cache_sentinel`)?(Ot=(0,z.jsx)(fd,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[177]=Ot):Ot=t[177];let kt;t[178]===g.openFullPreferences?kt=t[179]:(kt=(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:g.openFullPreferences}),t[178]=g.openFullPreferences,t[179]=kt);let At;t[180]!==Dt||t[181]!==kt?(At=(0,z.jsxs)(mr,{to:`/settings/overview`,className:wt,onMouseEnter:Tt,onFocus:Et,onClick:Dt,children:[Ot,kt]}),t[180]=Dt,t[181]=kt,t[182]=At):At=t[182];let jt;return t[183]!==me||t[184]!==ze||t[185]!==lt||t[186]!==gt||t[187]!==Ct||t[188]!==At?(jt=(0,z.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:w,children:[me,ze,lt,ut,gt,Ct,At]}),t[183]=me,t[184]=ze,t[185]=lt,t[186]=gt,t[187]=Ct,t[188]=At,t[189]=jt):jt=t[189],jt}function pOe(e){return e.setPreference}function Nv(e){return e.preference}function Pv(e){return e.setPreference}function Fv(e){return e.preference}function mOe(e){return e.setLanguage}function Iv(e){return e.language}function Lv({collapsed:e=!1,onNavigate:t}){let n=h(f(e=>e.language)),r=n.appearanceSettings,[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{w(()=>import(`./settings-page-D972_jaS.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])),w(()=>import(`./sessions-page-BvtdbmW8.js`),__vite__mapDeps([19,1,3,4,6,15,8])),w(()=>import(`./logs-page-CiG0m81R.js`),__vite__mapDeps([20,1,6,4,8])),w(()=>import(`./cron-page-Dx6dE3eD.js`),__vite__mapDeps([21,1,22,23,4,2,3,6,12,11,13,7,8,16,15,24])),w(()=>import(`./skills-page-QwFCB4yV.js`),__vite__mapDeps([25,1,26,22,23,4,6,8]))},[]),(0,z.jsxs)(`div`,{className:fh(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[(0,z.jsxs)(k_,{open:i,onOpenChange:a,children:[e?(0,z.jsx)(A_,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:fh(`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full outline-none ring-offset-surface-base transition-transform`,`hover:opacity-95 active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,i&&`ring-2 ring-accent`,`motion-reduce:opacity-100 motion-reduce:active:scale-100`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,z.jsx)(ph,{className:`size-full rounded-full`,alt:n.appBrand})})}):(0,z.jsx)(A_,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,className:fh(`flex w-full min-w-0 items-center gap-2 rounded-xl p-1 text-left outline-none transition-colors duration-150 ease-out`,`hover:bg-surface-active/70`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i&&`bg-surface-active/70`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,z.jsx)(`span`,{className:`size-8 shrink-0 overflow-hidden rounded-full`,"aria-hidden":!0,children:(0,z.jsx)(ph,{className:`size-full rounded-full`,alt:``,"aria-hidden":!0})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:r.quickMenuHint})]}),(0,z.jsx)(`span`,{className:fh(`flex size-9 shrink-0 items-center justify-center rounded-xl text-fg-muted transition-colors`,i&&`bg-accent-soft text-accent-fg`),"aria-hidden":!0,children:(0,z.jsx)(fd,{className:`size-[18px]`,strokeWidth:1.5})})]})}),(0,z.jsx)(j_,{children:(0,z.jsx)(M_,{className:fh(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-panel p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,z.jsx)(fOe,{onOpenFullSettings:()=>{a(!1),t?.()},onAboutClick:()=>{s(!0),a(!1)}})})})]}),(0,z.jsx)(Dv,{open:o,onOpenChange:s})]})}var Rv=`xopc-web-sidebar-nav-order`;function zv(){try{let e=globalThis.localStorage?.getItem(Rv);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Bv(e){try{globalThis.localStorage?.setItem(Rv,JSON.stringify(e))}catch{}}function hOe(e,t,n,r,i){if(t===n)return e;let a=e.filter(e=>e!==t),o=a.indexOf(n),s=o===-1?a.length:r===`before`?o:o+1;return _Oe([...a.slice(0,s),t,...a.slice(s)],i)}function gOe(e,t,n){return _Oe([...e.filter(e=>e!==t),t],n)}function _Oe(e,t){let n=new Set(e),r=[];for(let e of t)n.has(e)||r.push(e);return r.length===0?e:[...e,...r]}var Vv=l((e,t)=>({order:zv(),move:(n,r,i)=>{let a=hOe(t().order,n,r,i,new Set(t().order));a!==t().order&&(e({order:a}),queueMicrotask(()=>Bv(a)))},moveToEnd:n=>{let r=gOe(t().order,n,new Set(t().order));r!==t().order&&(e({order:r}),queueMicrotask(()=>Bv(r)))},setOrder:t=>{e({order:t}),queueMicrotask(()=>Bv(t))}})),Hv=null,Uv=l((e,t)=>({variables:{},loaded:!1,updateContext:t=>e(e=>({variables:{...e.variables,...t}})),setContext:t=>e({variables:t,loaded:!0}),fetchContext:async()=>Hv||(Hv=(async()=>{let e=await Ce(v(`/api/context`));t().setContext(e)})().finally(()=>{Hv=null}),Hv)})),Wv=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({}),vOe=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function Gv(e){let t=getComputedStyle(document.documentElement),n={};for(let e of vOe){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var yOe={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"ui.navigate":`theme`,"theme.get":`theme`},Kv=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n){let r=this.iframes.get(e);r&&r!==t&&r.contentWindow&&this.byContentWindow.delete(r.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{sessionKey:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow??(t?.source instanceof Window?t.source:null),o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};a&&a.postMessage(o,`*`)}isTrustedExtensionSource(e,t){if(t.source===null)return!0;let n=e.contentWindow;if(t.source===n)return!0;if(n&&typeof Window<`u`&&t.source instanceof Window)try{return t.source.frameElement===e}catch{}return!1}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`)return;let n,r=t.extensionId;if(e.source instanceof Window){let t=this.byContentWindow.get(e.source);t&&(n=t.iframe,r=t.extensionId)}if(n||(n=this.iframes.get(t.extensionId),r=t.extensionId),!n||!(e.source instanceof Window&&this.byContentWindow.has(e.source))&&!this.isTrustedExtensionSource(n,e))return;if(t.type===`event`){this.handleExtensionEvent(r,t.event,t.data);let e=this.eventSubscribers.get(r);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:i,method:a,params:o}=t,s=this.handlers.get(a);if(!s){this.postResponse(n,e,i,void 0,{code:Wv.MethodNotFound,message:`Unknown method: ${a}`});return}let c=yOe[a],l=this.extensionPermissions.get(r)??new Set;if(c&&!l.has(c)){this.postResponse(n,e,i,void 0,{code:Wv.PermissionDenied,message:`Missing permission: ${c}`});return}try{let t=await s(r,o);this.postResponse(n,e,i,t)}catch(t){let r=t instanceof Error?t.message:String(t);this.postResponse(n,e,i,void 0,{code:Wv.InternalError,message:r})}}};function qv(e){e.registerMethod(`theme.get`,async()=>Gv(_e.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;n&&window.dispatchEvent(new CustomEvent(`extension-navigate`,{detail:{path:n}}))}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&De({type:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,duration:typeof n.duration==`number`?n.duration:void 0})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`sessionKey`in t?String(t.sessionKey??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await Te(v(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({sessionKey:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,sessionKey:r,newSession:i}=t,a=await Te(v(`/api/agent`),{method:`POST`,headers:{Accept:`application/json`},body:JSON.stringify({message:n,channel:`webchat`,sessionKey:i?void 0:r,newSession:!!i})});if(!a.ok)throw Error(`Agent request failed: ${a.status}`);let o=await a.json();return{sessionKey:o.payload?.sessionKey??o.payload?.key??o.sessionKey??r??``}}),e.registerMethod(`config.get`,async e=>{let t=await Te(v(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await Te(v(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Te(v(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,i=await Te(v(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!i.ok)throw Error(`Failed to set storage key: ${i.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Te(v(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await Te(v(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function Jv(e){return e.active||e.activationEligible===!0}function Yv(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0||Array.isArray(t.sidebarPanels)&&t.sidebarPanels.length>0:!1}function bOe(e){return e.source===`bundled`&&e.hasUi===!0&&Yv(e)}function Xv(e){return e.kind===`image-generation`||e.kind===`media-provider`}function xOe(e){return Jv(e)?e.hasConfigSchema||Xv(e)?!0:e.hasUi?Yv(e):!1:!1}function Zv(e){return xOe(e)||bOe(e)}var Qv=(0,j.createContext)(null);function SOe({children:e}){let t=(0,j.useRef)(null);if(!t.current){let e=new Kv;qv(e),t.current=e}let n=t.current,r=xe(e=>!!e.token),{data:i,isLoading:a}=y(r?`gateway-extensions-list`:null,()=>Ce(v(`/api/extensions`)),{revalidateOnFocus:!1}),o=i?.extensions??[],s=_e(e=>e.resolved);(0,j.useEffect)(()=>{r&&Uv.getState().fetchContext()},[r]),(0,j.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&!Array.isArray(t)&&Uv.getState().updateContext(t)},t=()=>{Uv.getState().fetchContext()};return window.addEventListener(`context-update`,e),window.addEventListener(`config-reload`,t),window.addEventListener(`registry-updated`,t),()=>{window.removeEventListener(`context-update`,e),window.removeEventListener(`config-reload`,t),window.removeEventListener(`registry-updated`,t)}},[]);let c=(0,j.useCallback)(e=>{let t=e.detail;t?.sessionKey&&n.forwardAgentStreamEvent(t.sessionKey,t.event??t)},[n]),l=(0,j.useRef)(c);l.current=c,(0,j.useEffect)(()=>{let e=e=>{l.current(e)};return window.addEventListener(`agent-stream-event`,e),()=>{window.removeEventListener(`agent-stream-event`,e)}},[]),(0,j.useEffect)(()=>{let e=Gv(s);n.broadcastEvent(`theme.changed`,e)},[s,n]);let u=(0,j.useRef)(n);u.current=n,(0,j.useEffect)(()=>()=>{u.current.dispose(),t.current=null},[]);let d=(0,j.useMemo)(()=>({router:n,extensions:o,loading:a}),[n,o,a]);return(0,z.jsx)(Qv.Provider,{value:d,children:e})}function $v(){let e=(0,j.useContext)(Qv);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function COe(){let e=(0,j.useContext)(Qv);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function ey(){let e=(0,fm.c)(2),t=COe(),n;return e[0]===t?n=e[1]:(n=t.filter(xOe),e[0]=t,e[1]=n),n}function ty(){let e=(0,j.useContext)(Qv);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}function ny(e,t){return t.path.startsWith(`/apps/`)?t.path:`/apps/${e}/${t.id.startsWith(`${e}.`)?t.id.slice(e.length+1):t.id}`}function wOe(e){return um[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var TOe=[{id:`builtin:agents`,to:`/agents`,Icon:zp},{id:`builtin:skills`,to:`/skills`,Icon:os},{id:`builtin:cron`,to:`/cron`,Icon:ki},{id:`builtin:channels`,to:`/channels`,Icon:Wl},{id:`builtin:notes`,to:`/notes`,Icon:Df},{id:`builtin:workflows`,to:`/workflows`,Icon:no}];function ry(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=[],i=new Set;for(let e of t){let t=n.get(e);!t||i.has(e)||(r.push(t),i.add(e))}for(let t of e)i.has(t.id)||(r.push(t),i.add(t.id));return r.length<=4?{visible:r,overflow:[],hasOverflow:!1}:{visible:r.slice(0,4),overflow:r.slice(4),hasOverflow:!0}}var iy=`text/plain`,V=`xopc-nav:`;function ay(e){return`${V}${e}`}function EOe(e){return e.startsWith(V)?e.slice(9):null}function DOe(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function OOe({isActive:e},t,n,r){return fh(`group relative flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,t?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,n&&`opacity-40`,r===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,r===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function kOe({isActive:e},t,n){return fh(`group relative flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium leading-5 transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,t&&`opacity-40`,n===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,n===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function AOe(e){let t=(0,fm.c)(11),{item:n,collapsed:r}=e,{Icon:i,letter:a}=n;if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=fh(`size-4`,`shrink-0 opacity-90`),t[0]=e):e=t[0];let n;return t[1]===i?n=t[2]:(n=(0,z.jsx)(i,{className:e,strokeWidth:1.75,"aria-hidden":!0}),t[1]=i,t[2]=n),n}let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=fh(`size-4`,`flex shrink-0 items-center justify-center text-[10px] font-bold opacity-70`),t[3]=o):o=t[3];let s;t[4]!==n.label||t[5]!==a?(s=a??n.label.charAt(0),t[4]=n.label,t[5]=a,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=s.toUpperCase(),t[7]=s,t[8]=c);let l;return t[9]===c?l=t[10]:(l=(0,z.jsx)(`span`,{className:o,"aria-hidden":!0,children:c}),t[9]=c,t[10]=l),l}function jOe(e){let t=[];for(let n of e){if(n.activationEligible===!1)continue;let e=n.ui?.contributions?.pages;if(e)for(let r of e){if(!r.showInNav)continue;let e=r.navIcon?wOe(r.navIcon):void 0;t.push({id:`ext:${n.id}:${r.id}`,kind:`extension`,label:r.title,to:ny(n.id,r),Icon:e,letter:r.title.charAt(0),title:r.title})}}return t}function oy(e){let t=(0,fm.c)(52),{collapsed:n,onNavigate:r}=e,i=n===void 0?!1:n,a=f(uy),o;t[0]===a?o=t[1]:(o=h(a),t[0]=a,t[1]=o);let s=o,c=ey(),l=Vv(ly),u=Vv(cy),d=Vv(sy),[p,m]=(0,j.useState)(null),[g,_]=(0,j.useState)(null),[v,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),S;if(t[2]!==s.nav||t[3]!==c){let e;t[5]===s.nav?e=t[6]:(e=e=>{let t=e.id.slice(8);return{id:e.id,kind:`builtin`,label:s.nav[t],to:e.to,Icon:e.Icon}},t[5]=s.nav,t[6]=e);let n=TOe.map(e),r=jOe(c);S=[...n,...r],t[2]=s.nav,t[3]=c,t[4]=S}else S=t[4];let C=S,w;t[7]!==C||t[8]!==l?(w=ry(C,l),t[7]=C,t[8]=l,t[9]=w):w=t[9];let T=w,E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>t=>{t.dataTransfer.setData(iy,ay(e)),t.dataTransfer.effectAllowed=`move`,m(e)},t[10]=E):E=t[10];let D=E,O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{m(null),_(null),y(!1)},t[11]=O):O=t[11];let k=O,A;t[12]!==p||t[13]!==g?(A=e=>t=>{if(!p)return;t.preventDefault(),t.dataTransfer.dropEffect=`move`;let n=DOe(t);g?.id===e&&g.position===n||_({id:e,position:n})},t[12]=p,t[13]=g,t[14]=A):A=t[14];let ee=A,te;t[15]===u?te=t[16]:(te=e=>t=>{t.preventDefault();let n=EOe(t.dataTransfer.getData(iy));if(!n||n===e){k();return}u(n,e,DOe(t)),k()},t[15]=u,t[16]=te);let ne=te,re;t[17]===p?re=t[18]:(re=e=>{p&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,y(!0))},t[17]=p,t[18]=re);let ie=re,ae;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>y(!1),t[19]=ae):ae=t[19];let oe=ae,se;t[20]===d?se=t[21]:(se=e=>{e.preventDefault();let t=EOe(e.dataTransfer.getData(iy));t&&d(t),k()},t[20]=d,t[21]=se);let ce=se,le;t[22]!==i||t[23]!==p||t[24]!==g||t[25]!==r||t[26]!==ee||t[27]!==ne?(le=function(e){let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,z.jsxs)(hr,{to:e.to,draggable:!0,onDragStart:D(e.id),onDragEnd:k,onDragOver:ee(e.id),onDrop:ne(e.id),className:e=>OOe(e,i,t,n),title:e.title??e.label,onClick:()=>r?.(),children:[(0,z.jsx)(AOe,{item:e,collapsed:i}),i?null:(0,z.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id)},t[22]=i,t[23]=p,t[24]=g,t[25]=r,t[26]=ee,t[27]=ne,t[28]=le):le=t[28];let ue=le,de;t[29]!==i||t[30]!==p||t[31]!==g||t[32]!==s.sidebar.moreApps||t[33]!==s.sidebar.moreAppsAria||t[34]!==v||t[35]!==ie||t[36]!==ce||t[37]!==r||t[38]!==ee||t[39]!==ne||t[40]!==b||t[41]!==T.overflow?(de=function(){return(0,z.jsxs)(k_,{open:b,onOpenChange:x,children:[(0,z.jsx)(A_,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,onDragOver:ie,onDragLeave:oe,onDrop:ce,className:fh(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,b?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,v&&`ring-2 ring-accent ring-offset-2 ring-offset-surface-base`),"aria-label":s.sidebar.moreAppsAria,title:s.sidebar.moreApps,children:[(0,z.jsx)(ra,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),i?null:(0,z.jsx)(`span`,{className:`truncate`,children:s.sidebar.moreApps})]})}),(0,z.jsx)(j_,{children:(0,z.jsx)(M_,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:fh(`z-50 min-w-[14rem] max-w-[20rem] rounded-lg border border-edge bg-surface-panel p-1 shadow-md`),onOpenAutoFocus:MOe,children:(0,z.jsx)(`ul`,{className:`flex flex-col gap-0.5`,role:`list`,"aria-label":s.sidebar.moreAppsAria,children:T.overflow.map(e=>{let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,z.jsx)(`li`,{className:`contents`,children:(0,z.jsxs)(hr,{to:e.to,draggable:!0,onDragStart:D(e.id),onDragEnd:k,onDragOver:ee(e.id),onDrop:ne(e.id),className:e=>kOe(e,t,n),title:e.title??e.label,onClick:()=>{x(!1),r?.()},children:[(0,z.jsx)(AOe,{item:e}),(0,z.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id)})})})})]})},t[29]=i,t[30]=p,t[31]=g,t[32]=s.sidebar.moreApps,t[33]=s.sidebar.moreAppsAria,t[34]=v,t[35]=ie,t[36]=ce,t[37]=r,t[38]=ee,t[39]=ne,t[40]=b,t[41]=T.overflow,t[42]=de):de=t[42];let fe=de,pe;t[43]!==T.visible||t[44]!==ue?(pe=T.visible.map(ue),t[43]=T.visible,t[44]=ue,t[45]=pe):pe=t[45];let me;t[46]!==T.hasOverflow||t[47]!==fe?(me=T.hasOverflow?fe():null,t[46]=T.hasOverflow,t[47]=fe,t[48]=me):me=t[48];let he;return t[49]!==pe||t[50]!==me?(he=(0,z.jsxs)(z.Fragment,{children:[pe,me]}),t[49]=pe,t[50]=me,t[51]=he):he=t[51],he}function MOe(e){return e.preventDefault()}function sy(e){return e.moveToEnd}function cy(e){return e.move}function ly(e){return e.order}function uy(e){return e.language}var NOe={feishu:`/channel-icons/feishu.svg`,lark:`/channel-icons/lark.svg`};function dy(e){let t=(0,fm.c)(9),{sourceChannel:n,className:r}=e,i=NOe[n.toLowerCase()];if(i){let e;t[0]===r?e=t[1]:(e=fh(`shrink-0`,r),t[0]=r,t[1]=e);let n;return t[2]!==i||t[3]!==e?(n=(0,z.jsx)(`img`,{src:i,alt:``,draggable:!1,className:e,"aria-hidden":!0}),t[2]=i,t[3]=e,t[4]=n):n=t[4],n}let a;t[5]===r?a=t[6]:(a=fh(`shrink-0`,r),t[5]=r,t[6]=a);let o;return t[7]===a?o=t[8]:(o=(0,z.jsx)(go,{className:a,strokeWidth:1.75,"aria-hidden":!0}),t[7]=a,t[8]=o),o}var POe=`inline-flex items-center gap-px rounded-pill border border-edge bg-surface-hover p-1 dark:border-edge`,fy=`inline-flex shrink-0 items-center justify-center rounded-pill text-xs font-medium leading-none transition-[color,background-color,box-shadow] duration-150 ease-out text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100`,py=`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,my=1;function FOe(e,t){let n=0,r=0,i=e;for(;i&&i!==t;)n+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;return i===t?{x:n,y:r}:null}var hy=`pointer-events-none absolute left-0 top-0 z-[1] rounded-pill bg-surface-panel shadow-sm will-change-transform [backface-visibility:hidden] dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,IOe=`relative z-[2] box-border flex h-6 min-h-0 min-w-0 flex-1 cursor-pointer items-center justify-center gap-1 rounded-pill border-0 bg-transparent px-2 py-0 text-center text-xs font-medium leading-none outline-none transition-[color,background-color,box-shadow] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`;function gy({value:e,onChange:t,options:n,"aria-label":r,className:i,buttonClassName:a}){let o=(0,j.useRef)(null),s=(0,j.useRef)([]),[c,l]=(0,j.useState)({x:0,y:0,w:0,h:0}),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=(0,j.useCallback)(()=>{let t=o.current;if(!t)return;let r=n.findIndex(t=>t.value===e);if(r<0)return;let i=s.current[r];if(!i)return;let a=my,c=t.getBoundingClientRect(),u=i.getBoundingClientRect(),f=FOe(i,t),p,m;if(f)p=f.x,m=f.y;else{let e=getComputedStyle(t),n=parseFloat(e.borderLeftWidth)||0,r=parseFloat(e.borderTopWidth)||0;p=u.left-c.left-n,m=u.top-c.top-r}l({x:p+a,y:m+a,w:Math.max(0,u.width-a*2),h:Math.max(0,u.height-a*2)}),d(!0)},[n,e]),h=(0,j.useRef)(m);return h.current=m,(0,j.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>m());return()=>cancelAnimationFrame(e)},[m]),(0,j.useEffect)(()=>{let e=requestAnimationFrame(()=>{requestAnimationFrame(()=>p(!0))});return()=>cancelAnimationFrame(e)},[]),(0,j.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{requestAnimationFrame(()=>h.current())},n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,z.jsxs)(`div`,{ref:o,className:fh(POe,`relative isolate flex w-full max-w-full flex-row items-center`,i),role:`group`,"aria-label":r,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,className:fh(hy,`motion-reduce:!transition-none motion-reduce:!duration-0`,f&&`transition-[transform,width,height] duration-300 [transition-timing-function:cubic-bezier(0.32,0.72,0,1)]`),style:{width:c.w,height:c.h,transform:`translate3d(${c.x}px, ${c.y}px, 0)`,opacity:u&&c.w>0?1:0}}),n.map((n,r)=>{let i=n.icon,o=e===n.value;return(0,z.jsxs)(`button`,{ref:e=>{s.current[r]=e},type:`button`,"aria-pressed":o,title:n.title??n.label,onClick:()=>t(n.value),className:fh(IOe,o?`text-fg`:`text-fg-subtle`,a),children:[i?(0,z.jsx)(i,{className:`block size-3 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,z.jsx)(`span`,{className:`min-w-0 shrink truncate leading-none`,children:n.label})]},n.value)})]})}function _y(){return v(`/api/config`)}var vy=null;async function LOe(){return vy||(vy=Ce(_y()).finally(()=>{vy=null}),vy)}function yy(e){let t=(0,fm.c)(6),n;t[0]===e?n=t[1]:(n=e?_y():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=y(r,LOe,i),o,s;return t[3]===e?(o=t[4],s=t[5]):(o=()=>{if(!e)return;let t=_y(),n=()=>{x(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},s=[e],t[3]=e,t[4]=o,t[5]=s),(0,j.useEffect)(o,s),a}function by(){return x(_y())}var xy=null;async function H(){return xy||(xy=ROe().finally(()=>{xy=null}),xy)}async function ROe(){let e=await Te(v(`/api/agents?locale=${encodeURIComponent(p())}`));if(e.ok){let t=await e.json();if(t.ok&&t.payload?.defaultId&&Array.isArray(t.payload.agents)){let e=t.payload.defaultId.trim().toLowerCase(),n=t.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));if(n.length>0)return{defaultId:e,items:n}}}let t=(await LOe()).payload?.config?.agents,n=(t?.defaultId??`main`).trim().toLowerCase(),r=(Array.isArray(t?.list)?t.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));return r.length===0?{defaultId:n,items:[{id:n}]}:{defaultId:n,items:r}}function zOe(e){return typeof e==`object`&&!!e&&`role`in e}function Sy(e){if(!e||typeof e!=`object`)return!1;let t=e.type;return t===`tool_use`||t===`tool_call`||t===`toolCall`}function Cy(e){return typeof e==`object`&&!!e}function BOe(e){return typeof e.id==`string`&&e.id.length>0?e.id:crypto.randomUUID()}function wy(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function VOe(e){return wy(e.args??e.arguments??e.input??e.function?.arguments)??{}}function Ty(e){if(typeof e==`string`){let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}return Date.now()}var Ey=3e5;function Dy(e,t){let n=new URLSearchParams({uri:e.trim()});return t?.trim()&&n.set(`sessionKey`,t.trim()),`/api/media/read?${n.toString()}`}function Oy(e){if(typeof e.content==`string`&&e.content.length>0)return e.content;if(typeof e.data==`string`&&e.data.length>0)return e.data}var ky=[`.txt`,`.md`,`.json`,`.xml`,`.html`,`.css`,`.js`,`.ts`,`.jsx`,`.tsx`,`.yml`,`.yaml`];function HOe(e){let t=e.mimeType?.toLowerCase()??``;if(t.startsWith(`text/`)||t===`application/json`||t===`application/xml`||t===`application/javascript`||t===`application/typescript`)return!0;let n=e.name?.toLowerCase()??``;return ky.some(e=>n.endsWith(e))}function UOe(e){if(e.extractedText!=null&&e.extractedText!==``)return e.extractedText;if(!HOe(e))return;let t=Oy(e);if(t)try{let e=Ay(t);return new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(e))}catch{return}}function WOe(e,t){let n=t.trim();if(n.startsWith(`data:`))return n;let r=n.replace(/\s/g,``);return`data:${e&&typeof e==`string`&&e.includes(`/`)?e:`application/octet-stream`};base64,${r}`}function GOe(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode(...i)}return btoa(n)}function Ay(e){if(e==null||e===``)throw Error(`Missing file data`);let t=e;if(e.startsWith(`data:`)){let n=e.match(/base64,(.+)/);n&&(t=n[1])}let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}function KOe(e){let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(1)} ${t[n]}`}function qOe(e){let t=(e.mimeType??``).toLowerCase(),n=t.split(`;`)[0]?.trim()??``,r=e.name?.toLowerCase()??``;return e.type===`image`||n.startsWith(`image/`)?`image`:n===`application/pdf`||t.includes(`application/pdf`)||r.endsWith(`.pdf`)?`pdf`:n===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||t.includes(`wordprocessingml`)||r.endsWith(`.docx`)?`docx`:n===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||t.includes(`presentationml`)||r.endsWith(`.pptx`)?`pptx`:[`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(n)||t.includes(`spreadsheetml`)||t.includes(`ms-excel`)||r.endsWith(`.xlsx`)||r.endsWith(`.xls`)?`excel`:[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.bmp`,`.svg`].some(e=>r.endsWith(e))?`image`:`text`}function jy(e){let t=e.toLowerCase();for(let[e,n]of[[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.bmp`,`image/bmp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.ico`,`image/x-icon`],[`.tif`,`image/tiff`],[`.tiff`,`image/tiff`],[`.avif`,`image/avif`],[`.jxl`,`image/jxl`]])if(t.endsWith(e))return n}function JOe(e,t){return(t?.startsWith(`text/`)??!1)||ky.some(t=>e.toLowerCase().endsWith(t))}function My(e){if(Array.isArray(e))return e.map(e=>YOe(e))}function YOe(e){if(!e||typeof e!=`object`)return{name:`file`,mimeType:`application/octet-stream`};let t=e,n=Ny(t.uri),r=XOe(t.name),i=ZOe(t.mimeType,r),a=typeof t.type==`string`?t.type:void 0,o=a===`photo`||a===`image`||i.startsWith(`image/`)?`image`:a===`voice`||a===`audio`||i.startsWith(`audio/`)?`voice`:a;return{id:typeof t.id==`string`?t.id:void 0,name:r,mimeType:i,type:o,size:typeof t.size==`number`?t.size:void 0,uri:n,bucket:typeof t.bucket==`string`?t.bucket:void 0,path:typeof t.path==`string`?t.path:void 0}}function Ny(e){return typeof e==`string`&&e.trim().startsWith(`media://`)?e.trim():void 0}function XOe(e){return typeof e==`string`&&e.trim().length>0?e.trim():`file`}function ZOe(e,t){if(typeof e==`string`&&e.trim().length>0){let t=e.trim();if(t.toLowerCase().split(`;`)[0]?.trim()!==`application/octet-stream`)return t}return jy(t)??`application/octet-stream`}function Py(e){let t=e.uri?.trim();return t?`uri:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function Fy(e){if(!e?.length)return;let t=[],n=new Set;for(let r of e){let e=Py(r);n.has(e)||(n.add(e),t.push(r))}return t.length?t:void 0}var QOe=`[Startup context loaded by runtime]`,$Oe=`...[additional startup memory truncated]...`,eke=`END_QUOTED_NOTES`;function tke(e){if(!e.includes(QOe))return e;let t=e.replace(/^\uFEFF/,``);if(!t.startsWith(QOe))return e;let n=-1,r=t.lastIndexOf(eke);if(r>=0)n=r+16;else{let e=t.indexOf($Oe);e>=0&&(n=e+43)}if(n<0){let n=t.slice(35),r=n.indexOf(`
|
|
14
14
|
|
|
15
15
|
`);return r>=0?n.slice(r+2).replace(/^\s+/,``):e}return t.slice(n).replace(/^\s+/,``)}function Iy(e){if(typeof e!=`string`||!e.includes(`## Skill:`))return e;let t=e.match(/## Skill:\s*([^\s\r\n]+)/);if(!t)return e;let n=t[1]??``;if(!n)return e;let r=[...e.matchAll(/\*\*Arguments\*\*:\s*([^\r\n]+)/g)],i=r.length>0?(r[r.length-1]?.[1]??``).trim():``;return i?`/skill:${n} ${i}`:`/skill:${n}`}function Ly(e){return e.includes(`<file path=`)?e.replace(/<file\s+path="[^"]*">\r?\n[\s\S]*?<\/file>(?:\r?\n)*/g,``).replace(/\n{3,}/g,`
|
|
16
16
|
|
|
@@ -228,7 +228,7 @@ ${s.join(`
|
|
|
228
228
|
${c.join(`
|
|
229
229
|
`)}${l}
|
|
230
230
|
</style>`,defs:``}}function vRe(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return a<=0?`M${hD(e)},${hD(t)} h${hD(n)} v${hD(r)} h${hD(-n)} Z`:[`M${hD(e)},${hD(t+a)}`,`Q${hD(e)},${hD(t)} ${hD(e+a)},${hD(t)}`,`L${hD(e+n-a)},${hD(t)}`,`Q${hD(e+n)},${hD(t)} ${hD(e+n)},${hD(t+a)}`,`L${hD(e+n)},${hD(t+r-a)}`,`Q${hD(e+n)},${hD(t+r)} ${hD(e+n-a)},${hD(t+r)}`,`L${hD(e+a)},${hD(t+r)}`,`Q${hD(e)},${hD(t+r)} ${hD(e)},${hD(t+r-a)}`,`Z`].join(` `)}function yRe(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return a<=0?`M${hD(e)},${hD(t)} h${hD(n)} v${hD(r)} h${hD(-n)} Z`:[`M${hD(e+a)},${hD(t)}`,`L${hD(e+n-a)},${hD(t)}`,`Q${hD(e+n)},${hD(t)} ${hD(e+n)},${hD(t+a)}`,`L${hD(e+n)},${hD(t+r-a)}`,`Q${hD(e+n)},${hD(t+r)} ${hD(e+n-a)},${hD(t+r)}`,`L${hD(e+a)},${hD(t+r)}`,`Q${hD(e)},${hD(t+r)} ${hD(e)},${hD(t+r-a)}`,`L${hD(e)},${hD(t+a)}`,`Q${hD(e)},${hD(t)} ${hD(e+a)},${hD(t)}`,`Z`].join(` `)}function dD(e){if(e.length===0)return``;if(e.length===1)return`M${hD(e[0].x)},${hD(e[0].y)}`;if(e.length===2)return`M${hD(e[0].x)},${hD(e[0].y)} L${hD(e[1].x)},${hD(e[1].y)}`;let t=e.length,n=[],r=[];for(let i=0;i<t-1;i++)n.push(e[i+1].x-e[i].x),r.push(n[i]===0?0:(e[i+1].y-e[i].y)/n[i]);let i=Array(t).fill(0);if(t>2){let e=Array(t).fill(0),a=Array(t).fill(0);for(let i=1;i<t-1;i++){let t=2*(n[i-1]+n[i]),o=3*(r[i]-r[i-1]);if(i===1)e[i]=n[i]/t,a[i]=o/t;else{let r=t-n[i-1]*e[i-1];e[i]=n[i]/r,a[i]=(o-n[i-1]*a[i-1])/r}}for(let n=t-2;n>=1;n--)i[n]=a[n]-e[n]*i[n+1]}let a=Array(t).fill(0);for(let e=0;e<t-1;e++)a[e]=r[e]-n[e]*(2*i[e]+i[e+1])/3;a[t-1]=r[t-2]+n[t-2]*i[t-2]/3;let o=`M${hD(e[0].x)},${hD(e[0].y)}`;for(let r=0;r<t-1;r++){let t=n[r]/3,i=e[r].x+t,s=e[r].y+a[r]*t,c=e[r+1].x-t,l=e[r+1].y-a[r+1]*t;o+=` C${hD(i)},${hD(s)} ${hD(c)},${hD(l)} ${hD(e[r+1].x)},${hD(e[r+1].y)}`}return o}function fD(e,t,n,r){let i=nE(n,uD.fontSize,600),a=Math.max(...r.map(e=>{let t=nE(e.legendLabel,uD.fontSize,uD.fontWeight),n=nE(e.text,uD.fontSize,uD.fontWeight);return t+10+n})),o=Math.max(i,a)+uD.padX*2,s=26+r.length*20+6,c=Math.max(uD.minY,t-uD.offsetY-s-uD.pointerSize),l=e-o/2,u=e,d=c+s,f=uD.pointerSize,p=`<polygon points="${hD(u-f)},${hD(d)} ${hD(u+f)},${hD(d)} ${hD(u)},${hD(d+f)}" class="xychart-tip xychart-tip-ptr"/>`,m=`<rect x="${hD(l)}" y="${hD(c)}" width="${hD(o)}" height="${s}" rx="${uD.rx}" class="xychart-tip xychart-tip-bg"/>`;m+=p;let h=c+6+20/2;m+=`<text x="${hD(e)}" y="${hD(h)}" text-anchor="middle" font-weight="600" font-size="${uD.fontSize}" dy="${sE}" class="xychart-tip xychart-tip-text">${gD(n)}</text>`;let g=l+uD.padX,_=l+o-uD.padX;for(let e of r)h+=20,m+=`<text x="${hD(g)}" y="${hD(h)}" text-anchor="start" font-size="${uD.fontSize}" font-weight="${uD.fontWeight}" dy="${sE}" class="xychart-tip xychart-tip-text">${gD(e.legendLabel)}</text>`,m+=`<text x="${hD(_)}" y="${hD(h)}" text-anchor="end" font-size="${uD.fontSize}" font-weight="${uD.fontWeight}" dy="${sE}" class="xychart-tip xychart-tip-text">${gD(e.text)}</text>`;return m}function pD(e,t,n){let r=nE(n,uD.fontSize,uD.fontWeight)+uD.padX*2,i=uD.height,a=Math.max(uD.minY,t-uD.offsetY-i-uD.pointerSize),o=e-r/2,s=e,c=a+i/2,l=e,u=a+i,d=uD.pointerSize,f=`<polygon points="${hD(l-d)},${hD(u)} ${hD(l+d)},${hD(u)} ${hD(l)},${hD(u+d)}" class="xychart-tip xychart-tip-ptr"/>`;return`<rect x="${hD(o)}" y="${hD(a)}" width="${hD(r)}" height="${i}" rx="${uD.rx}" class="xychart-tip xychart-tip-bg"/>`+f+`<text x="${hD(s)}" y="${hD(c)}" text-anchor="middle" dy="${sE}" class="xychart-tip xychart-tip-text">${gD(n)}</text>`}function mD(e){return Number.isInteger(e)?e.toLocaleString(`en-US`):e.toFixed(+(Math.abs(e)<10))}function hD(e){return String(Math.round(e*10)/10)}function gD(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function _D(e){let t=e.trim().split(/[\n;]/)[0]?.trim().toLowerCase()??``;return/^xychart(-beta)?\b/.test(t)?`xychart`:/^sequencediagram\s*$/.test(t)?`sequence`:/^classdiagram\s*$/.test(t)?`class`:/^erdiagram\s*$/.test(t)?`er`:`flowchart`}function vD(e){return{bg:e.bg??OT.bg,fg:e.fg??OT.fg,line:e.line,accent:e.accent,muted:e.muted,surface:e.surface,border:e.border}}function yD(e,t={}){e=ET(e);let n=vD(t),r=t.font??`Inter`,i=t.transparent??!1,a=_D(e),o=e.split(`
|
|
231
|
-
`).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`%%`));switch(a){case`sequence`:return RE(zLe(KIe(o),t),n,r,i);case`class`:return GE(UE(qIe(o),t),n,r,i);case`er`:return aRe(iRe(ZIe(o),t),n,r,i);case`xychart`:return gRe(pRe(tLe(o),t),n,r,i,t.interactive??!1);default:return CLe(SLe(RIe(e),t),n,r,i)}}function bRe(e){try{return{html:`<div class="markdown-mermaid" data-mermaid-diagram>${yD(e.trim(),{bg:`var(--color-surface-hover)`,fg:`var(--color-fg)`,accent:`var(--color-accent-fg)`,border:`var(--color-edge)`,transparent:!0})}</div>`,error:!1}}catch{return{html:`<div class="markdown-mermaid markdown-mermaid-fallback" data-mermaid-fallback><pre><code class="hljs language-mermaid">${bD(e)}</code></pre></div>`,error:!0}}}function bD(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function xD(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function SD(e){return e.replace(/<pre><code class="(?:hljs\s+)?language-mermaid">([\s\S]*?)<\/code><\/pre>/g,(e,t)=>bRe(xD(t)).html)}fw.use(FNe({emptyLangClass:`hljs`,langPrefix:`hljs language-`,highlight(e,t){let n=(t??``).trim()||`plaintext`,r=hT.getLanguage(n)?n:`plaintext`;return hT.highlight(e,{language:r}).value}}));var CD={gfm:!0,breaks:!1,async:!1};function xRe(e,t){return SD(fw.parse(e,{...CD,...t,async:!1}))}var wD=!1;function SRe(){wD||typeof window>`u`||(wD=!0,HMe.addHook(`afterSanitizeAttributes`,e=>{if(e.tagName!==`A`||!e.hasAttribute(`href`))return;let t=e.getAttribute(`href`)??``;try{let n=new URL(t,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`||n.origin===window.location.origin)return;e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)}catch{}}))}SRe();var TD=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,ED=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>`;function DD(e){return e.querySelector(`code`)?.textContent??e.textContent??``}function CRe(e){let t=e.querySelector(`code`);if(!t?.className)return`plaintext`;for(let e of t.className.split(/\s+/))if(e.startsWith(`language-`))return e.slice(9).trim()||`plaintext`;return`plaintext`}function OD(e,t){let n=document.createDocumentFragment(),r=document.createElement(`span`);r.className=`markdown-code-copy-inner`,r.innerHTML=e===`idle`?TD:ED;let i=document.createElement(`span`);return i.className=`markdown-code-copy-label`,i.textContent=e===`idle`?t.copy:t.copied,n.appendChild(r),n.appendChild(i),n}function kD(e){e.querySelectorAll(`[data-md-code-block]`).forEach(e=>{let t=e.querySelector(`:scope > pre`),n=e.parentNode;t&&n&&(n.insertBefore(t,e),e.remove())})}function wRe(e,t){let n=e.querySelectorAll(`.markdown-body pre`),r=[];for(let e of n){if(e.closest(`[data-md-code-block]`)||e.closest(`[data-mermaid-fallback]`))continue;let n=e.parentNode;if(!n)continue;let i=document.createElement(`div`);i.className=`markdown-code-block`,i.setAttribute(`data-md-code-block`,``);let a=document.createElement(`div`);a.className=`markdown-code-block-header`;let o=document.createElement(`span`);o.className=`markdown-code-block-lang`,o.textContent=CRe(e);let s=document.createElement(`button`);s.type=`button`,s.className=`markdown-code-copy-btn`,s.dataset.mdCodeCopy=``,s.title=t.copy,s.setAttribute(`aria-label`,t.copy),s.replaceChildren(OD(`idle`,t));let c=n=>{n.preventDefault(),n.stopPropagation(),Sh(DD(e)).then(e=>{!e||!s.isConnected||(s.replaceChildren(OD(`copied`,t)),s.title=t.copied,s.setAttribute(`aria-label`,t.copied),window.setTimeout(()=>{s.isConnected&&(s.replaceChildren(OD(`idle`,t)),s.title=t.copy,s.setAttribute(`aria-label`,t.copy))},2e3))})};s.addEventListener(`click`,c),a.appendChild(o),a.appendChild(s),i.appendChild(a),n.insertBefore(i,e),i.appendChild(e),r.push(()=>{s.removeEventListener(`click`,c);let t=e.parentElement;t?.matches(`[data-md-code-block]`)&&t.parentNode&&(t.parentNode.insertBefore(e,t),t.remove())})}return()=>{for(let e of r)e()}}function TRe(e){let t=(0,fm.c)(21),{content:n,compact:r,breaks:i,className:a,codeCopy:o}=e,s=r===void 0?!1:r,c=i===void 0?!1:i,l=o===void 0?!0:o,u=f(ERe),d;t[0]===u?d=t[1]:(d=h(u),t[0]=u,t[1]=d);let p=d.chat,m;t[2]!==p.codeBlockCopy||t[3]!==p.messageCopied?(m={copy:p.codeBlockCopy,copied:p.messageCopied},t[2]=p.codeBlockCopy,t[3]=p.messageCopied,t[4]=m):m=t[4];let g=m,_;bb0:{if(!n.trim()){_=``;break bb0}let e;if(t[5]!==c||t[6]!==n){let r=xRe(n,c?{breaks:!0}:void 0);e=HMe.sanitize(r,{USE_PROFILES:{html:!0,svg:!0},ADD_ATTR:`viewBox.xmlns.d.fill.stroke.transform.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.x.y.width.height.rx.ry.cx.cy.r.x1.y1.x2.y2.offset.stop-color.stop-opacity.points.text-anchor.dominant-baseline.font-size.font-family.font-weight.font-style.class.id.style.markerWidth.markerHeight.refX.refY.orient.markerUnits.text-decoration.opacity.clip-path.mask.filter.preserveAspectRatio.xmlns:xlink.xlink:href.xml:space`.split(`.`)}),t[5]=c,t[6]=n,t[7]=e}else e=t[7];_=e}let v=_,y=(0,j.useRef)(null),b,x;t[8]!==l||t[9]!==g||t[10]!==v?(b=()=>{let e=y.current;if(e&&(kD(e),!(!l||!v)))return wRe(e,g)},x=[l,v,g],t[8]=l,t[9]=g,t[10]=v,t[11]=b,t[12]=x):(b=t[11],x=t[12]),(0,j.useLayoutEffect)(b,x);let S=s?`markdown-compact`:``,C=a??``,w;t[13]!==C||t[14]!==S?(w=[`markdown-body`,S,C].filter(Boolean),t[13]=C,t[14]=S,t[15]=w):w=t[15];let T=w.join(` `),E;t[16]===v?E=t[17]:(E={__html:v},t[16]=v,t[17]=E);let D;return t[18]!==T||t[19]!==E?(D=(0,z.jsx)(`div`,{ref:y,children:(0,z.jsx)(`div`,{className:T,dangerouslySetInnerHTML:E})}),t[18]=T,t[19]=E,t[20]=D):D=t[20],D}function ERe(e){return e.language}var AD=(0,j.memo)(TRe);AD.displayName=`MarkdownView`;function DRe(e){let t=(0,fm.c)(15),{initialContent:n,onSave:r,isDark:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=()=>n,t[0]=n,t[1]=o);let[s,c]=(0,j.useState)(o),l;t[2]===r?l=t[3]:(l=e=>{r?.(e)},t[2]=r,t[3]=l);let u=RS(l,500),d;t[4]===u?d=t[5]:(d=e=>{c(e),u(e)},t[4]=u,t[5]=d);let f=d,p;t[6]!==f||t[7]!==n||t[8]!==a?(p=(0,z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,z.jsx)(YS,{initialContent:n,onChange:f,isDark:a})}),t[6]=f,t[7]=n,t[8]=a,t[9]=p):p=t[9];let m;t[10]===s?m=t[11]:(m=(0,z.jsx)(`div`,{className:`bg-surface min-w-0 flex-1 overflow-y-auto px-6 py-4`,children:(0,z.jsx)(AD,{content:s})}),t[10]=s,t[11]=m);let h;return t[12]!==p||t[13]!==m?(h=(0,z.jsxs)(`div`,{className:`flex h-full divide-x divide-edge`,children:[p,m]}),t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function jD(e){let t=(0,fm.c)(22),{message:n,downloadLabel:r,onDownload:i,openSystemLabel:a,onOpenWithSystemApp:o,canOpenWithSystemApp:s}=e,c=s===void 0?!0:s,l;t[0]!==c||t[1]!==o||t[2]!==a?(l=Gh()&&c&&typeof o==`function`&&typeof a==`string`&&a.length>0,t[0]=c,t[1]=o,t[2]=a,t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=fh(`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-hover/60 p-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge`),t[4]=d):d=t[4];let f;t[5]===n?f=t[6]:(f=(0,z.jsx)(`p`,{className:`min-w-0 text-xs leading-relaxed text-fg-muted`,children:n}),t[5]=n,t[6]=f);let p;t[7]!==o||t[8]!==a||t[9]!==u?(p=u?(0,z.jsxs)(`button`,{type:`button`,className:fh(`inline-flex items-center gap-1.5 rounded-md border border-edge bg-surface-panel px-3 py-1.5 text-xs font-medium text-fg shadow-sm dark:border-edge`,yh.transition,yh.press,yh.focusRingPanel),onClick:()=>void o?.(),children:[(0,z.jsx)(aa,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),a]}):null,t[7]=o,t[8]=a,t[9]=u,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=fh(`inline-flex items-center gap-1.5 rounded-md border border-accent bg-accent px-3 py-1.5 text-xs font-medium text-white shadow-sm`,yh.transition,yh.press,yh.focusRingPanel),t[11]=m):m=t[11];let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,z.jsx)(na,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[12]=h):h=t[12];let g;t[13]!==r||t[14]!==i?(g=(0,z.jsxs)(`button`,{type:`button`,className:m,onClick:i,children:[h,r]}),t[13]=r,t[14]=i,t[15]=g):g=t[15];let _;t[16]!==p||t[17]!==g?(_=(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[p,g]}),t[16]=p,t[17]=g,t[18]=_):_=t[18];let v;return t[19]!==f||t[20]!==_?(v=(0,z.jsxs)(`div`,{className:d,children:[f,_]}),t[19]=f,t[20]=_,t[21]=v):v=t[21],v}function MD(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}function ND(e){let t=(0,fm.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=MD(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(PD),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,z.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,z.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,z.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function PD(e){return(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function FD(e,t){return`\`\`\`${{".ts":`typescript`,".js":`javascript`,".json":`json`}[t]??`plaintext`}\n${e}\n\`\`\``}function ID(e){let t=(0,fm.c)(23),{layout:n,text:r,showTruncationBar:i,onDownload:a,downloadLabel:o,truncationMessage:s,truncatedCaption:c,slideLabel:l,emptySlideLabel:u,openSystemLabel:d,onOpenWithSystemApp:f,canOpenWithSystemApp:p}=e,m=n===`workspace`?`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,h=n===`workspace`?`min-h-0 flex-1 overflow-auto p-2`:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle p-4 dark:border-edge`,g;t[0]!==p||t[1]!==o||t[2]!==a||t[3]!==f||t[4]!==d||t[5]!==i||t[6]!==s?(g=i?(0,z.jsx)(jD,{message:s,downloadLabel:o,onDownload:a,openSystemLabel:d,onOpenWithSystemApp:f,canOpenWithSystemApp:p}):null,t[0]=p,t[1]=o,t[2]=a,t[3]=f,t[4]=d,t[5]=i,t[6]=s,t[7]=g):g=t[7];let _;t[8]!==i||t[9]!==c?(_=i?(0,z.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:c}):null,t[8]=i,t[9]=c,t[10]=_):_=t[10];let v;t[11]!==u||t[12]!==l||t[13]!==r?(v=(0,z.jsx)(ND,{text:r,slideLabel:l,emptySlideLabel:u}),t[11]=u,t[12]=l,t[13]=r,t[14]=v):v=t[14];let y;t[15]!==h||t[16]!==_||t[17]!==v?(y=(0,z.jsxs)(`div`,{className:h,children:[_,v]}),t[15]=h,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==m||t[20]!==g||t[21]!==y?(b=(0,z.jsxs)(`div`,{className:m,children:[g,y]}),t[19]=m,t[20]=g,t[21]=y,t[22]=b):b=t[22],b}function LD(e){let{context:t,language:n,resolvedTheme:r,fileKey:i,fileName:a,loading:o,loadError:s,previewKind:c,textContent:l,binaryBuffer:u,showExtractedText:d,extractedText:f,extractedTextTruncated:p,workspaceEditing:m,pptxText:g,pptxTruncated:_,pptxError:v,actions:y}=e,b=h(n),x=(0,j.useMemo)(()=>BS(a),[a]),S=x===`.md`,C=x===`.html`||x===`.htm`,w=(0,j.useRef)(null),{error:T,excelTruncated:E}=Hje({language:n,buffer:u,kind:c===`pdf`||c===`excel`||c===`docx`?c:null,fileKey:i,containerEl:w.current}),D=zje((0,j.useMemo)(()=>{if(!u||c!==`image`)return null;let e=jy(a)??`image/png`;return new Blob([u],{type:e})},[u,c,a])),O=!!y.onOpenWithSystemApp&&(y.canOpenWithSystemApp??!0)&&t===`workspace`,k=t===`workspace`?b.workspace.openElsewhereHint:b.chat.attachmentPreviewOpenElsewhereHint,A=b.chat.attachmentPreviewDownloadFull,ee=t===`workspace`?b.workspace.openSystemApp:void 0,te=e=>b.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),ne=(0,z.jsx)(jD,{message:k,downloadLabel:A,onDownload:y.onDownload,openSystemLabel:ee,onOpenWithSystemApp:y.onOpenWithSystemApp,canOpenWithSystemApp:O}),re=null;if(o&&c==null)re=(0,z.jsx)(`p`,{className:`px-4 py-6 text-sm text-fg-muted`,children:b.chat.loading});else if(s)re=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[ne,(0,z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:(t===`workspace`?b.workspace.loadError:b.chat.attachmentPreviewLoadError)+`: `+s})]});else if(t===`attachment`&&d&&c!==`image`){let e=f||b.chat.attachmentPreviewNoText,t=c===`pptx`&&e.length>3e5?e.slice(0,Ey):e,n=!!p||c===`pptx`&&e.length>3e5;re=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:[n&&c===`pptx`?(0,z.jsx)(jD,{message:b.chat.attachmentPreviewOpenElsewhereTruncated,downloadLabel:b.chat.attachmentPreviewDownloadFull,onDownload:y.onDownload}):null,(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-hover/40 p-4 dark:border-edge`,children:[n&&c===`pptx`?(0,z.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:b.chat.attachmentPreviewPptxTruncated}):null,(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted`,children:t})]})]})}else if(c===`binaryOnly`&&u)re=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:(0,z.jsx)(jD,{message:t===`workspace`?b.workspace.cannotPreviewType+` `+b.workspace.openElsewhereHint:b.chat.attachmentPreviewOpenElsewhereHint,downloadLabel:b.chat.attachmentPreviewDownloadFull,onDownload:y.onDownload,openSystemLabel:ee,onOpenWithSystemApp:y.onOpenWithSystemApp,canOpenWithSystemApp:O})});else if(u&&c===`image`&&D)re=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,children:(0,z.jsx)(`img`,{src:D,alt:``,className:t===`workspace`?`max-h-[min(100%,calc(100dvh-9rem))] w-auto max-w-full object-contain`:`max-h-full max-w-full object-contain`})});else if(u&&c===`pptx`)if(t===`attachment`){let e=f||b.chat.attachmentPreviewNoText,t=Ey,n=!!p||e.length>t;re=(0,z.jsx)(ID,{layout:`attachment`,text:e.length>t?e.slice(0,t):e,showTruncationBar:n,onDownload:y.onDownload,downloadLabel:A,truncationMessage:b.chat.attachmentPreviewOpenElsewhereTruncated,truncatedCaption:b.chat.attachmentPreviewPptxTruncated,slideLabel:te,emptySlideLabel:b.chat.attachmentPreviewPptxEmptySlide})}else re=v?(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[ne,(0,z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:(t===`workspace`?b.workspace.loadError:b.chat.attachmentPreviewLoadError)+`: `+v})]}):g==null?(0,z.jsx)(`p`,{className:`px-4 py-6 text-sm text-fg-muted`,children:b.chat.loading}):(0,z.jsx)(ID,{layout:`workspace`,text:g,showTruncationBar:!!_,onDownload:y.onDownload,downloadLabel:A,truncationMessage:b.chat.attachmentPreviewOpenElsewhereTruncated,truncatedCaption:b.chat.attachmentPreviewPptxTruncated,slideLabel:te,emptySlideLabel:b.chat.attachmentPreviewPptxEmptySlide,openSystemLabel:ee,onOpenWithSystemApp:y.onOpenWithSystemApp,canOpenWithSystemApp:O});else if(u&&(c===`pdf`||c===`docx`))re=T?(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[ne,(0,z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:(t===`workspace`?b.workspace.loadError:b.chat.attachmentPreviewLoadError)+`: `+T})]}):(0,z.jsx)(`div`,{ref:w,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`});else if(u&&c===`excel`)re=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:T?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 px-2`,children:[ne,(0,z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T})]}):(0,z.jsxs)(z.Fragment,{children:[E?(0,z.jsx)(jD,{message:b.chat.attachmentPreviewOpenElsewhereTruncated,downloadLabel:b.chat.attachmentPreviewDownloadFull,onDownload:y.onDownload,openSystemLabel:ee,onOpenWithSystemApp:y.onOpenWithSystemApp,canOpenWithSystemApp:O}):null,(0,z.jsx)(`div`,{ref:w,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`})]})});else if(l!==null&&c===`text`)if(t===`workspace`&&S&&m?.markdownEditMode)re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,z.jsx)(DRe,{initialContent:l,onSave:e=>void m?.onSaveMarkdown?.(e),isDark:(m?.isDark??r===`dark`)===!0},i)});else if(S)re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,z.jsx)(AD,{content:l})});else if(t===`workspace`&&C&&m?.htmlCodeMode)re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,z.jsx)(tMe,{initialContent:l,onChange:e=>m?.onHtmlChange?.(e),isDark:(m?.isDark??r===`dark`)===!0},i)});else if(C)re=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:(0,z.jsx)(`iframe`,{title:a,className:`min-h-0 w-full flex-1 rounded-lg border border-edge-subtle bg-white dark:border-edge dark:bg-[#1e1e1e]`,srcDoc:l,sandbox:`allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms allow-modals`})});else if(x===`.ts`||x===`.js`)re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,z.jsx)(AD,{content:FD(l,x)})});else if(x===`.json`){let e=l;try{e=JSON.stringify(JSON.parse(l),null,2)}catch{}re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,z.jsx)(AD,{content:FD(e,`.json`)})})}else re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-fg`,children:l})});return(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:re})}var RD=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),zD=`VisuallyHidden`,ORe=j.forwardRef((e,t)=>(0,z.jsx)(ne.span,{...e,ref:t,style:{...RD,...e.style}}));ORe.displayName=zD;var BD=ORe,[VD,kRe]=O(`Tooltip`,[r_]),HD=r_(),ARe=`TooltipProvider`,UD=700,jRe=`tooltip.open`,[MRe,NRe]=VD(ARe),PRe=e=>{let{__scopeTooltip:t,delayDuration:n=UD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=j.useRef(!0),s=j.useRef(!1),c=j.useRef(0);return j.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,z.jsx)(MRe,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:j.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:j.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};PRe.displayName=ARe;var WD=`Tooltip`,[FRe,GD]=VD(WD),IRe=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=NRe(WD,e.__scopeTooltip),l=HD(t),[u,d]=j.useState(null),f=le(),p=j.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=j.useRef(!1),[_,v]=ue({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(jRe))):c.onClose(),a?.(e)},caller:WD}),y=j.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=j.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return j.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,z.jsx)(l_,{...l,children:(0,z.jsx)(FRe,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:j.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:j.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};IRe.displayName=WD;var KD=`TooltipTrigger`,LRe=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=GD(KD,n),a=NRe(KD,n),o=HD(n),s=A(t,j.useRef(null),i.onTriggerChange),c=j.useRef(!1),l=j.useRef(!1),u=j.useCallback(()=>c.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,z.jsx)(u_,{asChild:!0,...o,children:(0,z.jsx)(ne.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:me(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:me(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:me(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:me(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:me(e.onBlur,i.onClose),onClick:me(e.onClick,i.onClose)})})});LRe.displayName=KD;var qD=`TooltipPortal`,[RRe,JD]=VD(qD,{forceMount:void 0}),zRe=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=GD(qD,t);return(0,z.jsx)(RRe,{scope:t,forceMount:n,children:(0,z.jsx)(ae,{present:n||a.open,children:(0,z.jsx)(k,{asChild:!0,container:i,children:r})})})};zRe.displayName=qD;var YD=`TooltipContent`,XD=j.forwardRef((e,t)=>{let n=JD(YD,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=GD(YD,e.__scopeTooltip);return(0,z.jsx)(ae,{present:r||o.open,children:o.disableHoverableContent?(0,z.jsx)(URe,{side:i,...a,ref:t}):(0,z.jsx)(ZD,{side:i,...a,ref:t})})}),ZD=j.forwardRef((e,t)=>{let n=GD(YD,e.__scopeTooltip),r=NRe(YD,e.__scopeTooltip),i=j.useRef(null),a=A(t,i),[o,s]=j.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=j.useCallback(()=>{s(null),d(!1)},[d]),p=j.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=qRe(r,KRe(r,n.getBoundingClientRect())),a=JRe(t.getBoundingClientRect());s(XRe([...i,...a])),d(!0)},[d]);return j.useEffect(()=>()=>f(),[f]),j.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),j.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!YRe(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,z.jsx)(URe,{...e,ref:a})}),[BRe,VRe]=VD(WD,{isInside:!1}),HRe=ie(`TooltipContent`),URe=j.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=GD(YD,n),l=HD(n),{onClose:u}=c;return j.useEffect(()=>(document.addEventListener(jRe,u),()=>document.removeEventListener(jRe,u)),[u]),j.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,z.jsx)(pe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,z.jsxs)(PDe,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,z.jsx)(HRe,{children:r}),(0,z.jsx)(BRe,{scope:n,isInside:!0,children:(0,z.jsx)(BD,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});XD.displayName=YD;var WRe=`TooltipArrow`,GRe=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=HD(n);return VRe(WRe,n).isInside?null:(0,z.jsx)(FDe,{...i,...r,ref:t})});GRe.displayName=WRe;function KRe(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function qRe(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function JRe(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function YRe(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function XRe(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),ZRe(t)}function ZRe(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var QD=PRe,$D=IRe,eO=LRe,tO=zRe,nO=XD,rO=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,QRe=`block w-full min-w-0 truncate rounded border border-transparent bg-surface-hover px-2 py-1.5 font-mono text-xs text-fg focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`,$Re=`inline-flex w-[5.25rem] shrink-0 items-center justify-center gap-1 px-2 py-1 text-xs`;function eze(e){let t=(0,fm.c)(38),{label:n,text:r,compact:i,labels:a,monospace:o}=e,s=o===void 0?!0:o,c=(0,j.useRef)(null),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),p;t[0]===r?p=t[1]:(p=async()=>{if(f(!1),await Sh(r)){u(!0),window.setTimeout(()=>u(!1),2e3);return}Ch(c.current),f(!0),window.setTimeout(()=>f(!1),2500)},t[0]=r,t[1]=p);let m=p,h=i&&`gap-0.5`,g;t[2]===h?g=t[3]:(g=fh(`flex min-w-0 flex-col gap-1`,h),t[2]=h,t[3]=g);let _;t[4]===n?_=t[5]:(_=n?(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}):null,t[4]=n,t[5]=_);let v=n??a.copy,y=!s&&`font-sans`,b;t[6]===y?b=t[7]:(b=fh(QRe,y),t[6]=y,t[7]=b);let x;t[8]!==v||t[9]!==b||t[10]!==r?(x=(0,z.jsx)(eO,{asChild:!0,children:(0,z.jsx)(`input`,{ref:c,readOnly:!0,type:`text`,value:r,"aria-label":v,className:b,onFocus:tze})}),t[8]=v,t[9]=b,t[10]=r,t[11]=x):x=t[11];let S;t[12]===r?S=t[13]:(S=(0,z.jsx)(tO,{children:(0,z.jsx)(nO,{side:`top`,sideOffset:6,collisionPadding:12,className:rO,children:(0,z.jsx)(`span`,{className:`break-all`,children:r})})}),t[12]=r,t[13]=S);let C;t[14]!==S||t[15]!==x?(C=(0,z.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,z.jsxs)($D,{children:[x,S]})}),t[14]=S,t[15]=x,t[16]=C):C=t[16];let w;t[17]===m?w=t[18]:(w=()=>void m(),t[17]=m,t[18]=w);let T;t[19]===l?T=t[20]:(T=l?(0,z.jsx)(ei,{className:`size-3.5 shrink-0`}):(0,z.jsx)(D,{className:`size-3.5 shrink-0`}),t[19]=l,t[20]=T);let E=l?a.copied:a.copy,O;t[21]===E?O=t[22]:(O=(0,z.jsx)(`span`,{className:`truncate`,children:E}),t[21]=E,t[22]=O);let k;t[23]!==w||t[24]!==T||t[25]!==O?(k=(0,z.jsxs)(gh,{type:`button`,variant:`secondary`,className:$Re,onClick:w,children:[T,O]}),t[23]=w,t[24]=T,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==C||t[28]!==k?(A=(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_5.25rem] items-center gap-2`,children:[C,k]}),t[27]=C,t[28]=k,t[29]=A):A=t[29];let ee;t[30]!==d||t[31]!==a.copyFailed?(ee=d?(0,z.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:a.copyFailed}):null,t[30]=d,t[31]=a.copyFailed,t[32]=ee):ee=t[32];let te;return t[33]!==A||t[34]!==ee||t[35]!==g||t[36]!==_?(te=(0,z.jsx)(QD,{delayDuration:300,children:(0,z.jsxs)(`div`,{className:g,children:[_,A,ee]})}),t[33]=A,t[34]=ee,t[35]=g,t[36]=_,t[37]=te):te=t[37],te}function tze(e){return e.currentTarget.select()}function nze(e){let t=(0,fm.c)(12),{rows:n,compact:r,labels:i}=e,a=r&&`gap-1.5`,o;t[0]===a?o=t[1]:(o=fh(`flex min-w-0 flex-col gap-2`,a),t[0]=a,t[1]=o);let s;if(t[2]!==r||t[3]!==i||t[4]!==n){let e;t[6]!==r||t[7]!==i?(e=e=>(0,z.jsx)(eze,{label:e.label,text:e.text,compact:r,labels:i},e.key),t[6]=r,t[7]=i,t[8]=e):e=t[8],s=n.map(e),t[2]=r,t[3]=i,t[4]=n,t[5]=s}else s=t[5];let c;return t[9]!==o||t[10]!==s?(c=(0,z.jsx)(`div`,{className:o,children:s}),t[9]=o,t[10]=s,t[11]=c):c=t[11],c}var rze=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),ize=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function aze(e,t,n,r){if(n===`public`){let n=[{key:`public`,label:r.publicUrlLabel,url:e}];return t&&n.push({key:`lan`,label:r.lanUrlLabel,url:t}),n}return n===`lan`?[{key:`lan`,label:r.lanUrlLabel,url:e}]:[{key:`local`,label:r.localUrlLabel,url:e}]}function oze(e){let t=(0,fm.c)(17),{shareUrl:n,lanUrl:r,reachability:i,compact:a}=e,o=f(cze),s;t[0]===o?s=t[1]:(s=h(o),t[0]=o,t[1]=s);let c=s.sharesSettings,l=r??null,u;t[2]!==i||t[3]!==n||t[4]!==c||t[5]!==l?(u=aze(n,l,i,c),t[2]=i,t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,p;t[7]!==c.copied||t[8]!==c.copy||t[9]!==c.copyFailed?(p={copy:c.copy,copied:c.copied,copyFailed:c.copyFailed},t[7]=c.copied,t[8]=c.copy,t[9]=c.copyFailed,t[10]=p):p=t[10];let m=p,g;t[11]===d?g=t[12]:(g=d.map(sze),t[11]=d,t[12]=g);let _;return t[13]!==a||t[14]!==m||t[15]!==g?(_=(0,z.jsx)(nze,{rows:g,compact:a,labels:m}),t[13]=a,t[14]=m,t[15]=g,t[16]=_):_=t[16],_}function sze(e){return{key:e.key,label:e.label,text:e.url}}function cze(e){return e.language}function lze(e,t){return(t===`zh`?rze:ize).format(new Date(e))}function iO(e){let t=(0,fm.c)(23),{reachability:n,reachabilityHint:r}=e,i=f(aO),a;t[0]===i?a=t[1]:(a=h(i),t[0]=i,t[1]=a);let o=a.sharesSettings;if(n===`public`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(so,{className:`size-3`}),t[2]=e):e=t[2];let n;return t[3]===o.reachPublic?n=t[4]:(n=(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400`,children:[e,o.reachPublic]}),t[3]=o.reachPublic,t[4]=n),n}if(n===`lan`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(ACe,{className:`size-3`}),t[5]=e):e=t[5];let n;t[6]===r?n=t[7]:(n=r?(0,z.jsxs)(`span`,{className:`text-fg-muted`,children:[` — `,r]}):null,t[6]=r,t[7]=n);let i;return t[8]!==o.reachLan||t[9]!==n?(i=(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400`,children:[e,o.reachLan,n]}),t[8]=o.reachLan,t[9]=n,t[10]=i):i=t[10],i}let s;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(OCe,{className:`size-3`}),t[11]=s):s=t[11];let c;t[12]===o.reachLocal?c=t[13]:(c=(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-subtle`,children:[s,o.reachLocal]}),t[12]=o.reachLocal,t[13]=c);let l=r??o.reachLocalHint,u;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(aa,{className:`size-3`}),t[14]=u):u=t[14];let d;t[15]===o.openTunnel?d=t[16]:(d=(0,z.jsxs)(mr,{to:`/settings/remote-access?tab=public`,className:`inline-flex items-center gap-0.5 text-accent hover:underline`,children:[o.openTunnel,u]}),t[15]=o.openTunnel,t[16]=d);let p;t[17]!==l||t[18]!==d?(p=(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,children:[l,` `,d]}),t[17]=l,t[18]=d,t[19]=p):p=t[19];let m;return t[20]!==c||t[21]!==p?(m=(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,p]}),t[20]=c,t[21]=p,t[22]=m):m=t[22],m}function aO(e){return e.language}function uze(e){let t=(0,fm.c)(24),{result:n}=e,r=f(dze),i;t[0]===r?i=t[1]:(i=h(r),t[0]=r,t[1]=i);let a=i.sharesSettings,o;t[2]===n.fileName?o=t[3]:(o=(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.fileName}),t[2]=n.fileName,t[3]=o);let s=a.expiresLabel,c;t[4]!==r||t[5]!==n.expiresAt?(c=lze(n.expiresAt,r),t[4]=r,t[5]=n.expiresAt,t[6]=c):c=t[6];let l;t[7]!==a.expiresLabel||t[8]!==c?(l=(0,z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s,`: `,c]}),t[7]=a.expiresLabel,t[8]=c,t[9]=l):l=t[9];let u;t[10]!==o||t[11]!==l?(u=(0,z.jsxs)(`div`,{children:[o,l]}),t[10]=o,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.lanUrl||t[14]!==n.reachability||t[15]!==n.shareUrl?(d=(0,z.jsx)(oze,{shareUrl:n.shareUrl,lanUrl:n.lanUrl,reachability:n.reachability}),t[13]=n.lanUrl,t[14]=n.reachability,t[15]=n.shareUrl,t[16]=d):d=t[16];let p;t[17]!==n.reachability||t[18]!==n.reachabilityHint?(p=(0,z.jsx)(iO,{reachability:n.reachability,reachabilityHint:n.reachabilityHint}),t[17]=n.reachability,t[18]=n.reachabilityHint,t[19]=p):p=t[19];let m;return t[20]!==u||t[21]!==d||t[22]!==p?(m=(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[u,d,p]}),t[20]=u,t[21]=d,t[22]=p,t[23]=m):m=t[23],m}function dze(e){return e.language}function oO(e){let t=(0,fm.c)(26),{open:n,onOpenChange:r,loading:i,error:a,result:o}=e,s=f(sO),c;t[0]===s?c=t[1]:(c=h(s),t[0]=s,t[1]=c);let l=c.sharesSettings,u;t[2]===s?u=t[3]:(u=h(s),t[2]=s,t[3]=u);let d=u,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,z.jsx)(ov,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=fh(`fixed left-1/2 top-1/2 z-[71] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`overflow-hidden rounded-lg border border-edge bg-surface-panel p-4 shadow-popover outline-none`),t[5]=m):m=t[5];let g;t[6]===l.shareCreated?g=t[7]:(g=(0,z.jsx)(cv,{className:`text-base font-semibold text-fg`,children:l.shareCreated}),t[6]=l.shareCreated,t[7]=g);let _;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,z.jsx)(rm,{className:`size-4`}),t[8]=_):_=t[8];let v;t[9]===l.cancel?v=t[10]:(v=(0,z.jsx)(uv,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,children:_})}),t[9]=l.cancel,t[10]=v);let y;t[11]!==g||t[12]!==v?(y=(0,z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[g,v]}),t[11]=g,t[12]=v,t[13]=y):y=t[13];let b;t[14]!==a||t[15]!==i||t[16]!==d||t[17]!==o?(b=i?(0,z.jsxs)(`p`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,z.jsx)(Ts,{className:`size-4 animate-spin`}),d.workspace.sharing]}):a?(0,z.jsx)(`p`,{className:`py-2 text-sm text-red-600 dark:text-red-400`,children:a}):o?(0,z.jsx)(uze,{result:o}):null,t[14]=a,t[15]=i,t[16]=d,t[17]=o,t[18]=b):b=t[18];let x;t[19]!==y||t[20]!==b?(x=(0,z.jsxs)(av,{children:[p,(0,z.jsxs)(sv,{className:m,children:[y,b]})]}),t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==r||t[23]!==n||t[24]!==x?(S=(0,z.jsx)(iv,{open:n,onOpenChange:r,children:x}),t[22]=r,t[23]=n,t[24]=x,t[25]=S):S=t[25],S}function sO(e){return e.language}async function fze(){return Ce(v(`/api/shares`))}async function cO(e){return Ce(v(`/api/shares`),{method:`POST`,body:JSON.stringify(e)})}async function lO(e){return Ce(v(`/api/shares/${e}`),{method:`DELETE`})}async function pze(){return Ce(v(`/api/shares`),{method:`DELETE`,body:JSON.stringify({expired:!0})})}async function uO(e,t){return Ce(v(`/api/shares/${e}`),{method:`PATCH`,body:JSON.stringify({extendTtlMs:t})})}function mze(){let[e,t]=(0,j.useState)(!1),[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(null),c=(0,j.useCallback)(async e=>{t(!0),r(!0),a(null),s(null);try{let t=await cO(e);return a(t.payload),t.payload}catch(e){return s(e instanceof Error?e.message:String(e)),null}finally{r(!1)}},[]),l=(0,j.useCallback)(()=>{a(null),s(null),r(!1)},[]);return{dialogOpen:e,loading:n,result:i,error:o,createShareLink:c,handleOpenChange:(0,j.useCallback)(e=>{t(e),e||l()},[l])}}function hze(e){return e.map(e=>({name:e.name,path:e.path,absolutePath:e.absolutePath,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function dO(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:dO(e.children,t,n)}:e)}function gze(e,t){let[n,r]=(0,j.useState)([]),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(null),c=(0,j.useRef)(new Set),l=e.trim(),u=t?.trim()??``,d=u,f=u?``:l,p=(0,j.useMemo)(()=>{if(d)return{sessionKey:d};if(f)return{agentId:f}},[d,f]);return{tree:n,loading:i,error:o,loadRoot:(0,j.useCallback)(async()=>{a(!0),s(null),c.current.clear();try{r(hze(await DS(``,p))),c.current.add(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[p]),loadChildren:(0,j.useCallback)(async e=>{if(!c.current.has(e)){c.current.add(e);try{let t=hze(await DS(e,p));r(n=>dO(n,e,t))}catch{c.current.delete(e)}}},[p]),reset:(0,j.useCallback)(()=>{r([]),s(null),c.current.clear()},[])}}var fO=l(e=>({agentId:``,setAgentId:t=>e({agentId:t})})),_ze=`xopc-web-workspace-panel-open`,pO=`xopc-web-workspace-panel-width-px`;function vze(){try{return globalThis.localStorage?.getItem(_ze)===`1`}catch{return!1}}function mO(e){try{globalThis.localStorage?.setItem(_ze,e?`1`:`0`)}catch{}}function yze(e){return Math.min(520,Math.max(200,Math.round(e)))}function hO(){try{let e=globalThis.localStorage?.getItem(pO);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?yze(t):320}catch{return 320}}function bze(e){try{globalThis.localStorage?.setItem(pO,String(e))}catch{}}var gO=l((e,t)=>({open:vze(),setOpen:t=>{e({open:t}),queueMicrotask(()=>mO(t))},toggleOpen:()=>{t().setOpen(!t().open)},widthPx:hO(),setWidthPx:t=>{let n=yze(t);e({widthPx:n}),queueMicrotask(()=>bze(n))}})),_O=l(e=>({path:null,setPath:t=>e({path:t})})),vO=(0,j.memo)(function(){let e=h(f(e=>e.language)),{pathname:t}=Hn(),{sessionKey:n}=Wn(),r=t.startsWith(`/chat`)&&n?decodeURIComponent(n):null,i=gO(e=>e.open),a=gO(e=>e.setOpen),o=gO(e=>e.widthPx),s=gO(e=>e.setWidthPx),[c,l]=(0,j.useState)(!1),u=_O(e=>e.path),d=_O(e=>e.setPath),p=fO(e=>e.agentId),{tree:m,loading:g,error:_,loadRoot:v,loadChildren:y,reset:b}=gze(p,r),x=r??p,S=r==null?p.trim()?{agentId:p.trim()}:void 0:{sessionKey:r},{dialogOpen:C,loading:w,result:T,error:E,createShareLink:D,handleOpenChange:O}=mze(),k=(0,j.useCallback)(e=>{if(!i)return;e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),l(!0);let n=e.clientX,r=gO.getState().widthPx,a=e.pointerId,o=e=>{s(r+(n-e.clientX))},c=()=>{try{t.releasePointerCapture(a)}catch{}l(!1),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[i,s]);(0,j.useEffect)(()=>{t.startsWith(`/chat`)||a(!1)},[t,a]),(0,j.useEffect)(()=>{if(!i){b(),d(null);return}d(null),v()},[i,x,v,b,d]),(0,j.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`Escape`&&(_O.getState().path||a(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[i,a]),(0,j.useEffect)(()=>{if(!i||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[i]);let A=(0,j.useCallback)(e=>{y(e)},[y]),ee=(0,j.useCallback)(async(t,n)=>{switch(t){case`preview`:if(n.isDirectory)return;d(n.path);break;case`download`:if(n.isDirectory)return;try{let e=VS(n.path);if(Yje(n.path)){let{contentBase64:t}=await kS(n.path,S);PS(e,Ay(t),jy(e)??`application/octet-stream`)}else{let{content:t}=await OS(n.path,S);Ije(e,t)}}catch{}break;case`copyPath`:try{await Sh(n.absolutePath??n.path)&&mS(`success`,e.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`share`:await D({path:n.path,...n.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...S});break;default:break}},[D,e.workspace.pathCopied,d,S]);return(0,z.jsxs)(z.Fragment,{children:[i?(0,z.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":e.closeMenu,onClick:()=>a(!1)}):null,(0,z.jsx)(`aside`,{id:`app-workspace-panel`,"aria-label":e.workspace.title,"aria-hidden":!i,className:fh(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:shadow-popover`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,`max-md:w-[min(20rem,92vw)]`,i?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,`motion-reduce:md:transition-none`,!i&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,i&&`app-workspace-panel-expanded-width md:shrink-0`,i&&c&&`workspace-panel-rail-resizing`),style:i?{"--workspace-panel-px":`${o}px`}:void 0,children:i?(0,z.jsxs)(`div`,{className:fh(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e.workspace.resizeHandleAria,onPointerDown:k,className:fh(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,c&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,Hh)}),(0,z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4 dark:border-edge`,children:[(0,z.jsx)(Na,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-base font-semibold leading-tight tracking-tight text-fg`,children:e.workspace.title}),(0,z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:e.cron.refresh,"aria-label":e.cron.refresh,disabled:g,onClick:()=>void v(),children:(0,z.jsx)(xu,{className:fh(`size-4`,g&&`animate-spin`),"aria-hidden":!0})}),(0,z.jsx)(gh,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":e.workspace.close,title:e.workspace.close,onClick:()=>a(!1),children:(0,z.jsx)(rm,{className:`size-4`,strokeWidth:1.75})})]}),_?(0,z.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[e.workspace.loadError,`: `,_]}):null,(0,z.jsx)(ES,{tree:m,selectedPath:u,onSelectFile:e=>d(e),onExpandDir:A,onAction:ee,actionLabels:{preview:e.workspace.preview,download:e.workspace.download,copyPath:e.workspace.copyPath,share:e.workspace.shareLink},emptyHint:e.workspace.emptyDir})]}):null}),(0,z.jsx)(oO,{open:C,onOpenChange:O,loading:w,error:E,result:T})]})}),xze=`(max-width: 1199px)`,Sze=`z-[58]`,yO=`z-[75]`,bO=`z-[76]`,xO=`z-[74]`,SO=`z-[77]`;function CO(){let e=(0,fm.c)(28),t=(0,j.useRef)(null),n=xe(OO),r=xe(DO),i=xe(EO),a=xe(TO),o=xe(wO),s=xe(q),c=f(Cze),l;e[0]===c?l=e[1]:(l=h(c),e[0]=c,e[1]=l);let u=l.token,d=!!s&&!i,p;e[2]!==d||e[3]!==o?(p=e=>{!e&&!d||e||o()},e[2]=d,e[3]=o,e[4]=p):p=e[4];let m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(ov,{className:fh(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,yO)}),e[5]=m):m=e[5];let g,_;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=fh(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,bO,`dark:border-edge`),_=e=>{e.preventDefault(),t.current?.focus()},e[6]=g,e[7]=_):(g=e[6],_=e[7]);let v;e[8]===u.title?v=e[9]:(v=(0,z.jsx)(cv,{className:`text-base font-semibold text-fg`,children:u.title}),e[8]=u.title,e[9]=v);let y;e[10]===u.description?y=e[11]:(y=(0,z.jsx)(lv,{className:`mt-1 text-sm text-fg-muted`,children:u.description}),e[10]=u.description,e[11]=y);let b;e[12]!==d||e[13]!==o||e[14]!==c?(b=d?(0,z.jsx)(gh,{type:`button`,variant:`ghost`,onClick:()=>o(),children:c===`zh`?`取消`:`Cancel`}):void 0,e[12]=d,e[13]=o,e[14]=c,e[15]=b):b=e[15];let x;e[16]!==r||e[17]!==a||e[18]!==b?(x=(0,z.jsx)(Mh,{className:`mt-4`,baseUrl:r,tokenInputRef:t,onSubmit:a,footerLeft:b}),e[16]=r,e[17]=a,e[18]=b,e[19]=x):x=e[19];let S;e[20]!==v||e[21]!==y||e[22]!==x?(S=(0,z.jsxs)(av,{children:[m,(0,z.jsxs)(sv,{className:g,onOpenAutoFocus:_,children:[v,y,x]})]}),e[20]=v,e[21]=y,e[22]=x,e[23]=S):S=e[23];let C;return e[24]!==n||e[25]!==p||e[26]!==S?(C=(0,z.jsx)(iv,{open:n,onOpenChange:p,children:S}),e[24]=n,e[25]=p,e[26]=S,e[27]=C):C=e[27],C}function Cze(e){return e.language}function q(e){return e.token}function wO(e){return e.closeTokenDialog}function TO(e){return e.setGatewayToken}function EO(e){return e.tokenExpired}function DO(e){return e.baseUrl}function OO(e){return e.tokenDialogOpen}var kO=`xopc:shell-prefs-changed`,AO={notifyEnabled:!0,notifySoundEnabled:!0};function wze(){return AO}function Tze(){typeof window>`u`||window.dispatchEvent(new CustomEvent(kO))}async function jO(){if(!Gh()||!window.electronAPI?.system)return AO;try{let e=await window.electronAPI.system.getBehavior();AO={notifyEnabled:e.notifyEnabled,notifySoundEnabled:e.notifySoundEnabled}}catch{}return AO}function MO(){try{let e=new AudioContext,t=e.createOscillator(),n=e.createGain();t.type=`sine`,t.frequency.value=880,n.gain.value=.07,t.connect(n),n.connect(e.destination),t.start(),t.stop(e.currentTime+.15),e.close()}catch{}}function NO(e){if(typeof Notification>`u`)return!1;let t=wze();if(!t.notifyEnabled&&!e.force||Notification.permission!==`granted`)return!1;let n=e.title.trim();if(!n||!e.force&&!e.urgent&&!document.hidden)return!1;try{let r=new Notification(n,{body:e.body?.trim()||void 0,tag:e.tag,silent:!t.notifySoundEnabled});return r.onclick=()=>{window.focus(),r.close()},t.notifySoundEnabled&&MO(),!0}catch{return!1}}async function Eze(e,t){if(typeof Notification>`u`)return`unsupported`;if(Gh()&&window.electronAPI?.system?.requestNotifications){let n=await window.electronAPI.system.requestNotifications();if(n.status!==`granted`)return n.outcome===`opened-settings`||n.status===`denied`?`denied`:`default`;if(Notification.permission==="default"){let e=await Notification.requestPermission();if(e!==`granted`)return e===`denied`?`denied`:`default`}else if(Notification.permission===`denied`)return`denied`;return AO={...AO,notifyEnabled:!0},NO({title:e,body:t,tag:`xopc-notify-test`,force:!0}),`enabled`}let n=Notification.permission;return n==="default"&&(n=await Notification.requestPermission()),n===`denied`?`denied`:n===`granted`?(AO={...AO,notifyEnabled:!0},NO({title:e,body:t,tag:`xopc-notify-test`,force:!0}),`enabled`):`default`}function Dze(){let e=(0,fm.c)(4),t=f(jze),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,j.useEffect)(kze,n);let r,i;return e[1]===t?(r=e[2],i=e[3]):(r=()=>{if(!Gh())return;let e=h(t).systemSettings.desktopNotify,n=Oze,r=t=>{let n=t.detail,r=n?.event;if(!r||r.type!==`error`)return;let i=typeof r.content==`string`?r.content.trim():``;NO({title:e.agentErrorTitle,body:i||e.agentErrorBody,tag:`xopc-agent-error-${n?.sessionKey??`unknown`}`,urgent:!0})};return window.addEventListener(Ee,n),window.addEventListener(`agent-stream-event`,r),()=>{window.removeEventListener(Ee,n),window.removeEventListener(`agent-stream-event`,r)}},i=[t],e[1]=t,e[2]=r,e[3]=i),(0,j.useEffect)(r,i),null}function Oze(e){let t=e.detail,n=typeof t?.title==`string`?t.title.trim():``;if(!n)return;let r=typeof t?.message==`string`?t.message.trim():void 0,i=t?.type===`error`||t?.type===`warning`;NO({title:n,body:r,tag:`xopc-toast-${t?.type??`info`}`,urgent:i})}function kze(){if(!Gh())return;jO();let e=Aze;return window.addEventListener(kO,e),()=>window.removeEventListener(kO,e)}function Aze(){jO()}function jze(e){return e.language}function Mze(){let e=(0,fm.c)(16),t=f(Nze),n;e[0]===t?n=e[1]:(n=h(t),e[0]=t,e[1]=n);let r=n.electron,[i,a]=(0,j.useState)(null),o,s;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{if(!Gh())return;let e=window.electronAPI?.gateway;if(e?.onExited)return e.onExited(e=>a(e))},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,j.useEffect)(o,s),!i)return null;let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=fh(`shrink-0 border-b border-danger/35 bg-danger/10 px-4 py-3 text-sm text-fg shadow-surface`),e[4]=c):c=e[4];let l;e[5]===r.gatewayExitTitle?l=e[6]:(l=(0,z.jsx)(`p`,{className:`font-semibold`,children:r.gatewayExitTitle}),e[5]=r.gatewayExitTitle,e[6]=l);let u;e[7]===r.gatewayExitBody?u=e[8]:(u=(0,z.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:r.gatewayExitBody}),e[7]=r.gatewayExitBody,e[8]=u);let d=i.code??`—`,p=i.signal??`—`,m;e[9]!==d||e[10]!==p?(m=(0,z.jsxs)(`p`,{className:`mt-2 font-mono text-xs text-fg-muted`,children:[`exit `,d,` · signal `,p]}),e[9]=d,e[10]=p,e[11]=m):m=e[11];let g;return e[12]!==l||e[13]!==u||e[14]!==m?(g=(0,z.jsxs)(`div`,{className:c,role:`alert`,children:[l,u,m]}),e[12]=l,e[13]=u,e[14]=m,e[15]=g):g=e[15],g}function Nze(e){return e.language}function Pze(){let e=(0,fm.c)(3),t=Un(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!Gh())return;let e=window.electronAPI;if(!e?.menu)return;let n=e.menu.onNavigate(e=>{t(e)}),r=e.menu.onTogglePalette(Fze);return()=>{n(),r()}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,j.useEffect)(n,r),null}function Fze(){window.dispatchEvent(new CustomEvent(`toggle-command-palette`))}var Ize=1500,Lze=9e4;function Rze(){let e=(0,fm.c)(16),t=f(Bze),n;e[0]===t?n=e[1]:(n=h(t),e[0]=t,e[1]=n);let r=n.updatePanel,[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(!1),c=(0,j.useRef)(0),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=c.current+=1;a(!0),s(!1),(async()=>{await new Promise(PO);let t=Date.now()+Lze;for(;e===c.current&&Date.now()<t;){try{if((await fetch(v(`/api/health`),{signal:AbortSignal.timeout(3e3)})).ok){window.location.reload();return}}catch{}await new Promise(zze)}e===c.current&&s(!0)})()},e[2]=l):l=e[2];let u=l,d,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=()=>u();return window.addEventListener(`gateway-restart-initiated`,e),()=>{c.current+=1,window.removeEventListener(`gateway-restart-initiated`,e)}},p=[u],e[3]=d,e[4]=p):(d=e[3],p=e[4]),(0,j.useEffect)(d,p);let m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{u()},e[5]=m):m=e[5];let g=m;if(!i)return null;let _=o?`border-red-500/20 bg-red-500/10 text-red-800 dark:text-red-200`:`border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-100`,y;e[6]===_?y=e[7]:(y=fh(`flex min-h-10 w-full items-center justify-center gap-2 border-b px-4 py-2 text-sm`,_),e[6]=_,e[7]=y);let b;e[8]!==r.restartPollRetry||e[9]!==r.restartPollTimeout||e[10]!==r.restartPolling||e[11]!==o?(b=o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{children:r.restartPollTimeout}),(0,z.jsx)(`button`,{type:`button`,onClick:g,className:`ml-2 rounded bg-accent px-2 py-0.5 text-xs font-medium text-white hover:bg-accent/90`,children:r.restartPollRetry})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ts,{className:`size-4 animate-spin`,"aria-hidden":!0}),(0,z.jsx)(`span`,{children:r.restartPolling})]}),e[8]=r.restartPollRetry,e[9]=r.restartPollTimeout,e[10]=r.restartPolling,e[11]=o,e[12]=b):b=e[12];let x;return e[13]!==y||e[14]!==b?(x=(0,z.jsx)(`div`,{className:y,children:b}),e[13]=y,e[14]=b,e[15]=x):x=e[15],x}function zze(e){return setTimeout(e,Ize)}function PO(e){return setTimeout(e,2e3)}function Bze(e){return e.language}async function FO(){return Ce(v(`/api/tunnel/pair/context`))}async function IO(){return Ce(v(`/api/tunnel/pair/enable-lan`),{method:`POST`,body:JSON.stringify({})})}async function LO(){return Ce(v(`/api/tunnel/status`))}async function RO(){await Ce(v(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function zO(){return Ce(v(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function BO(e){return Ce(v(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function VO(){return Ce(v(`/api/tunnel/qr`))}async function HO(){return Ce(v(`/api/tunnel/pair`),{method:`POST`,body:JSON.stringify({})})}async function UO(){let e=(await Ce(v(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function WO(e){await Ce(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}async function GO(){if(Gh()&&window.electronAPI?.gateway?.restart){let e=await window.electronAPI.gateway.restart();return e.ok&&e.token&&xe.getState().setGatewayToken(e.token),e}let e=await Ce(v(`/api/gateway/restart`),{method:`POST`,body:JSON.stringify({})});return e.ok===!1?{ok:!1,message:e.message??e.error??`Gateway restart failed`}:{ok:!0}}async function KO(e,t={}){let n=t.timeoutMs??9e4,r=t.intervalMs??500,i=Date.now()+n,a=async()=>{if(Date.now()>=i)return!1;try{if((await fetch(v(`/api/tunnel/pair/context`),{headers:{Authorization:`Bearer ${e}`}})).ok)return!0}catch{}return await new Promise(e=>setTimeout(e,r)),a()};return a()}async function qO(e={}){let t=e.timeoutMs??9e4,n=e.intervalMs??500,r=Date.now()+t,i=async()=>{if(Date.now()>=r)return null;try{let e=await FO();if(e.pairingReady)return e}catch{}return await new Promise(e=>setTimeout(e,n)),i()};return i()}function JO({reminder:e,compact:t}){let n=f(e=>e.language),r=h(n).updatePanel,{show:i,dismiss:a,electronQuitAndInstall:o,runNpmUpdate:s,npmUpdateRunning:c}=e,[l,u]=(0,j.useState)(!1),d=(0,j.useCallback)(async()=>{let e=h(n).updatePanel;u(!0);try{let t=await GO();if(t.ok){window.dispatchEvent(new Event(`gateway-restart-initiated`));return}De({type:`error`,title:e.updateErrorFailed,message:t.message??`Gateway restart failed`})}catch(t){De({type:`error`,title:e.updateErrorFailed,message:t instanceof Error?t.message:String(t)})}finally{u(!1)}},[n]),p=(0,j.useCallback)(async()=>{let e=h(n).updatePanel,t=await s();if(t.ok){De({type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail});return}De({type:`error`,title:t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed,message:t.message})},[s,n]);if(i.kind===`none`)return null;let m=`absolute right-2 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1 sm:right-3`;return i.kind===`electron-ready`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 px-10 py-2 text-sm sm:px-12`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:`flex max-w-[min(100%,48rem)] items-center justify-center gap-2 text-center`,children:[(0,z.jsx)(na,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`min-w-0`,children:r.reminderElectronReady.replace(`{{version}}`,i.version)})]}),(0,z.jsxs)(`div`,{className:m,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:o,className:`rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90`,children:[(0,z.jsx)(xu,{className:`mr-1 inline size-3`}),r.restartToUpdate]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,z.jsx)(rm,{className:`size-4`})})]})]}):i.kind===`electron-error`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-red-500/20 bg-red-500/10 px-10 py-2 text-sm text-fg sm:px-12`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:`flex max-w-[min(100%,52rem)] items-center justify-center gap-2 text-center`,children:[(0,z.jsx)(di,{className:`size-4 shrink-0 text-red-500 dark:text-red-400`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:r.reminderElectronUpdateError.replace(`{{detail}}`,i.message)})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:m,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,z.jsx)(rm,{className:`size-4`})})]}):i.kind===`electron-downloading`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 flex-col items-center justify-center gap-2 border-b border-edge bg-surface-secondary px-10 py-2 text-sm text-fg-muted sm:flex-row sm:gap-4 sm:px-12`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:`flex max-w-full items-center justify-center gap-2 text-center`,children:[(0,z.jsx)(na,{className:`size-4 shrink-0 animate-pulse`,"aria-hidden":!0}),(0,z.jsx)(`span`,{children:r.reminderDownloading.replace(`{{percent}}`,String(i.percent))})]}),(0,z.jsx)(`div`,{className:`h-1.5 w-full max-w-xs rounded-full bg-surface-tertiary sm:max-w-[12rem]`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${i.percent}%`}})}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:fh(m,`sm:right-2`),"aria-label":r.dismissAria,children:(0,z.jsx)(rm,{className:`size-4`})})]}):i.kind===`npm-restart-required`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-amber-500/25 bg-amber-500/10 py-2 text-sm`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,z.jsx)(`span`,{children:r.restartRequired.replace(`{{version}}`,i.version)}),(0,z.jsxs)(`button`,{type:`button`,onClick:d,disabled:l,className:`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[l?(0,z.jsx)(Ts,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(xu,{className:`size-3 shrink-0`,"aria-hidden":!0}),r.restartGateway]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:m,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,z.jsx)(rm,{className:`size-4`})})]}):i.kind===`npm`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:fh(`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`),children:[(0,z.jsxs)(`span`,{children:[r.reminderNpm.replace(`{{version}}`,i.version),i.channel&&i.channel!==`latest`?` (${i.channel})`:``]}),(0,z.jsxs)(`button`,{type:`button`,onClick:p,disabled:c,className:`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[c?(0,z.jsx)(Ts,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(xu,{className:`size-3 shrink-0`,"aria-hidden":!0}),c?r.updateRunning:r.updateNow]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:m,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,z.jsx)(rm,{className:`size-4`})})]}):null}function YO(e,t,n){let r=h(e),i=r.commandPalette.actions,a=r.commandPalette.groups.actions;return[{kind:`action`,id:`action:cron:create`,title:i.createCron,subtitle:i.createCronSubtitle,groupLabel:a,keywords:[`cron`,`schedule`,`job`,`timer`],run:()=>{n(),t(`/cron?action=create`)}},{kind:`action`,id:`action:cron:manage`,title:i.manageCron,subtitle:i.manageCronSubtitle,groupLabel:a,keywords:[`cron`,`schedule`,`tasks`],run:()=>{n(),t(`/cron`)}},{kind:`action`,id:`action:skills:manage`,title:i.manageSkills,subtitle:i.manageSkillsSubtitle,groupLabel:a,keywords:[`skills`,`skill`,`catalog`],run:()=>{n(),t(`/skills`)}},{kind:`action`,id:`action:skills:reload`,title:i.reloadSkills,subtitle:i.reloadSkillsSubtitle,groupLabel:a,keywords:[`skills`,`reload`,`refresh`],run:()=>{n(),w(async()=>{let{reloadSkills:e}=await Promise.resolve().then(()=>uk);return{reloadSkills:e}},void 0).then(({reloadSkills:e})=>e())}}]}function XO(e){return h(e).commandPalette.groups}function Vze(e){let t=XO(e);return{[t.navigate]:0,[t.quickSettings]:1,[t.extensions]:2,[t.sessions]:3,[t.files]:4,[t.commands]:5,[t.skills]:6,[t.actions]:7}}function Hze(e){let t=XO(e);return{[t.navigate]:12,[t.quickSettings]:12,[t.actions]:8,[t.extensions]:8,[t.sessions]:8,[t.files]:10,[t.commands]:6,[t.skills]:6}}function ZO(e,t){return Vze(e)[t]??10}function QO(e){return e.trim().toLowerCase()}function Uze(e,t){let n=QO(e),r=QO(t);if(!r)return 0;if(!n)return null;if(n===r)return 0;if(n.startsWith(r))return 1;let i=n.indexOf(r);return i>=0?2+Math.min(i,50)/100:null}function Wze(e,t){let n=t.trim();if(!n)return 0;let r=[{text:e.title,weight:1},{text:e.subtitle??``,weight:1.75}];for(let t of e.keywords??[])r.push({text:t,weight:1.25});let i=null;for(let e of r){let t=Uze(e.text,n);if(t===null)continue;let r=t*e.weight;i=i===null?r:Math.min(i,r)}if(i===null)return null;let a=e.kind===`route`?-.15:e.kind===`file`?-.1:e.kind===`session`?-.05:e.kind===`setting`||e.kind===`action`?-.02:0;return Math.max(0,i+a)}function Gze(e){return e.toSorted((e,t)=>e.rank===t.rank?e.groupLabel===t.groupLabel?e.title.localeCompare(t.title):e.groupLabel.localeCompare(t.groupLabel):e.rank-t.rank)}var Kze=new Set([`settingsTunnel`,`settingsShares`,`settingsHeartbeat`,`settingsGoals`,`settingsDreams`,`logs`]),qze=[`/settings/remote-access`,`/settings/tunnel`,`/settings/shares`,`/settings/heartbeat`,`/settings/goals`,`/settings/dreams`,`/settings/logs`,`/settings/apps`,`/settings/extensions/debug`,`/settings/ext/`];function $O(e,t){return t===`advanced`?!0:!Kze.has(e)}function ek(e,t){return t===`advanced`?!0:!qze.some(t=>e===t||e.startsWith(t))}var tk=`/channels`,Jze=[`telegram`,`weixin`,`feishu`];function Yze(e){return Jze.includes(e)}function nk(e,t){let n=`${tk}/${encodeURIComponent(e.trim().toLowerCase())}`;return t?.pairing?`${n}?pairing=1`:n}function Xze(e){return e?.trim().toLowerCase()||null}var rk=l(ge(e=>({mode:`simple`,setMode:t=>e({mode:t}),setShowAdvanced:t=>e({mode:t?`advanced`:`simple`})}),{name:`xopc-web-settings-mode`}));function Zze(){return rk(ik)}function ik(e){return e.mode===`advanced`}var ak=[`settingsAgentChat`,`settingsAgentGeneration`,`settingsAgentWorkspace`,`settingsAgentBrowser`,`settingsConnectors`,`settingsAgentRuntime`,`settingsAgentContext`,`settingsAgentMemory`,`settingsAgentTools`,`settingsAgentSkills`,`settingsAgentSystemPrompt`],ok={settingsAgentChat:[`model`,`fallback`,`role`,`strategy`],settingsAgentGeneration:[`temperature`,`sampling`,`thinking`,`reasoning`],settingsAgentWorkspace:[`workspace`,`directory`,`folder`,`attachments`],settingsAgentBrowser:[`browser`,`playwright`,`automation`],settingsConnectors:[`connector`,`mcp`,`integration`,`tools`],settingsAgentRuntime:[`limits`,`turn`,`timeout`,`tool`,`iterations`],settingsAgentContext:[`context`,`compaction`,`pruning`,`tokens`],settingsAgentMemory:[`memory`,`review`,`session`,`search`],settingsAgentTools:[`tools`,`web`,`extract`,`code`],settingsAgentSkills:[`skills`,`allowlist`,`marketplace`],settingsAgentSystemPrompt:[`system`,`prompt`,`instructions`]};function sk(e,t){let n=h(e).commandPalette.routes.agentDefaultsSubtitle;return ak.filter(e=>$O(e,t)).map(t=>({id:`route:settings:agent:${t}`,title:_(e,t),subtitle:n,path:Rh(t),keywords:[`agent`,`defaults`,`config`,...ok[t]??[]]}))}function ck(e,t){return e.filter(e=>ek(e.path.split(`?`)[0]??e.path,t))}function Qze(e){let t=h(e),n=t.commandPalette.routes,r=t.channelsSettings,i=rk.getState().mode;return ck([{id:`route:chat`,title:t.nav.chat,subtitle:n.chatSubtitle,path:`/chat`,keywords:[`chat`,`new`,`compose`,`assistant`]},{id:`route:agents`,title:t.nav.agents,subtitle:n.agentsSubtitle,path:`/agents`,keywords:[`agent`,`persona`,`switch`]},{id:`route:apps`,title:t.nav.apps,subtitle:n.appsSubtitle,path:`/apps`,keywords:[`extension`,`plugin`,`addon`]},{id:`route:sessions`,title:t.nav.sessions,subtitle:n.sessionsSubtitle,path:`/settings/sessions`,keywords:[`history`,`archive`,`pin`]},{id:`route:logs`,title:t.nav.logs,subtitle:n.logsSubtitle,path:`/settings/logs`,keywords:[`debug`,`errors`]},{id:`route:skills`,title:t.nav.skills,subtitle:n.skillsSubtitle,path:`/skills`,keywords:[`tools`,`catalog`]},{id:`route:channels`,title:t.nav.channels,subtitle:n.channelsSubtitle,path:`/channels`,keywords:[`telegram`,`weixin`,`feishu`,`channel`]},{id:`route:channels:telegram`,title:r.telegramTitle,subtitle:n.channelsSubtitle,path:nk(`telegram`),keywords:[`telegram`,`bot`,`channel`,`pairing`]},{id:`route:channels:weixin`,title:r.weixinTitle,subtitle:n.channelsSubtitle,path:nk(`weixin`),keywords:[`weixin`,`wechat`,`channel`,`qr`]},{id:`route:channels:feishu`,title:r.feishuTitle,subtitle:n.channelsSubtitle,path:nk(`feishu`),keywords:[`feishu`,`lark`,`channel`]},{id:`route:channels:telegram:pairing`,title:`${r.telegramTitle} — ${r.hubPairingButton}`,subtitle:n.channelsSubtitle,path:nk(`telegram`,{pairing:!0}),keywords:[`telegram`,`pairing`,`approve`,`dm`]},{id:`route:cron`,title:t.nav.cron,subtitle:n.cronSubtitle,path:`/cron`,keywords:[`schedule`,`jobs`,`tasks`,`history`,`scheduler`,`timezone`,`concurrency`,`cron`,`automation`]},{id:`route:settings:goals`,title:t.nav.settingsGoals,subtitle:n.goalsSettingsSubtitle,path:`/settings/goals`,keywords:[`goal`,`checklist`,`judge`,`/goal`,`automation`]},{id:`route:settings:dreams`,title:t.nav.settingsDreams,subtitle:n.dreamsSettingsSubtitle,path:`/settings/dreams`,keywords:[`dream`,`memory`,`consolidation`,`automation`]},{id:`route:settings`,title:t.nav.settings,subtitle:n.settingsSubtitle,path:`/settings/overview`,keywords:[`config`,`status`,`providers`,`models`,`agents`,`search`,`preferences`]},{id:`route:settings:credentials`,title:t.nav.settingsCredentials,subtitle:n.credentialsSubtitle,path:`/settings/credentials`,keywords:[`api`,`key`,`credentials`,`oauth`,`token`,`models`,`providers`]},{id:`route:settings:providers`,title:t.nav.settingsProviders,subtitle:n.providersSubtitle,path:`/settings/credentials?tab=providers`,keywords:[`api`,`key`,`openai`,`anthropic`,`google`]},{id:`route:settings:models`,title:t.nav.settingsModels,subtitle:n.modelsSubtitle,path:`/settings/credentials?tab=catalog`,keywords:[`gpt`,`claude`,`gemini`,`llm`]},{id:`route:settings:image-models`,title:t.nav.settingsImageModels,subtitle:n.imageModelsSubtitle,path:`/settings/credentials?tab=image-models`,keywords:[`image`,`vision`,`generate`,`picture`]},{id:`route:settings:voice`,title:t.nav.settingsVoice,subtitle:n.voiceSubtitle,path:`/settings/credentials?tab=voice`,keywords:[`tts`,`stt`,`speech`,`microphone`]},{id:`route:settings:search`,title:t.nav.settingsSearch,subtitle:n.searchSubtitle,path:`/settings/credentials?tab=search`,keywords:[`search`,`web`,`tavily`,`serper`,`brave`]},{id:`route:settings:gateway`,title:t.nav.settingsGateway,subtitle:n.gatewaySubtitle,path:`/settings/gateway`,keywords:[`server`,`port`,`auth`,`token`]},...sk(e,i)],i)}function $ze(e){_e.getState().setPreference(e)}function eBe(e){f.getState().setLanguage(e)}function tBe(e,t){let n=h(e),r=n.commandPalette.quickSettings,i=n.commandPalette.groups.quickSettings;return[{kind:`setting`,id:`setting:model`,title:r.switchModel,subtitle:r.switchModelSubtitle,groupLabel:i,keywords:[`model`,`gpt`,`claude`,`gemini`,`llm`],run:()=>t.openModelPalette()},{kind:`setting`,id:`setting:agent`,title:r.switchAgent,subtitle:r.switchAgentSubtitle,groupLabel:i,keywords:[`agent`,`persona`,`bot`],run:()=>t.openAgentPalette()},{kind:`setting`,id:`setting:theme:light`,title:r.themeLight,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`light`,`appearance`],run:()=>{$ze(`light`),t.closePalette()}},{kind:`setting`,id:`setting:theme:dark`,title:r.themeDark,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`dark`,`night`],run:()=>{$ze(`dark`),t.closePalette()}},{kind:`setting`,id:`setting:theme:system`,title:r.themeSystem,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`system`,`auto`],run:()=>{$ze(`system`),t.closePalette()}},{kind:`setting`,id:`setting:lang:en`,title:r.languageEn,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`english`,`language`,`locale`],run:()=>{eBe(`en`),t.closePalette()}},{kind:`setting`,id:`setting:lang:zh`,title:r.languageZh,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`chinese`,`中文`,`language`],run:()=>{eBe(`zh`),t.closePalette()}}]}function lk(e){let t=e===`zh`;return[{id:`field:gateway:port`,title:t?`网关端口`:`Gateway Port`,subtitle:t?`设置 HTTP 网关监听端口`:`HTTP gateway listen port`,path:`/settings/gateway`,keywords:[`port`,`listen`,`http`,`server`,`端口`]},{id:`field:gateway:host`,title:t?`网关绑定地址`:`Gateway Host`,subtitle:t?`设置绑定的网络接口`:`Network interface to bind`,path:`/settings/gateway`,keywords:[`host`,`bind`,`interface`,`localhost`,`地址`]},{id:`field:gateway:auth`,title:t?`网关认证令牌`:`Gateway Auth Token`,subtitle:t?`访问网关所需的 Bearer token`:`Bearer token for gateway access`,path:`/settings/gateway`,keywords:[`auth`,`token`,`bearer`,`password`,`security`,`认证`,`令牌`]},{id:`field:agent:model`,title:t?`默认模型`:`Default Model`,subtitle:t?`对话使用的 LLM 模型`:`LLM model for conversations`,path:`/settings/agent-defaults`,keywords:[`model`,`llm`,`gpt`,`claude`,`gemini`,`模型`]},{id:`field:agent:temperature`,title:t?`温度 (Temperature)`:`Temperature`,subtitle:t?`控制回复的随机性`:`Controls response randomness`,path:`/settings/agent-defaults?tab=generation`,keywords:[`temperature`,`sampling`,`randomness`,`creative`,`温度`,`随机`]},{id:`field:agent:maxTokens`,title:t?`最大输出 Tokens`:`Max Output Tokens`,subtitle:t?`单次回复的最大 token 数`:`Maximum tokens per response`,path:`/settings/agent-defaults?tab=generation`,keywords:[`max`,`tokens`,`output`,`length`,`limit`,`最大`]},{id:`field:agent:workspace`,title:t?`工作目录`:`Workspace Directory`,subtitle:t?`代理的默认工作目录`:`Default working directory for the agent`,path:`/settings/agent-defaults?tab=workspace`,keywords:[`workspace`,`directory`,`folder`,`path`,`cwd`,`工作目录`]},{id:`field:agent:browser`,title:t?`浏览器自动化`:`Browser automation`,subtitle:t?`启用 browser_use 工具`:`Enable browser_use tools`,path:`/settings/agent-browser`,keywords:[`browser`,`browser_use`,`automation`,`浏览器`]},{id:`field:agent:browser-extension`,title:t?`Chrome 扩展连接`:`Chrome extension bridge`,subtitle:t?`安装扩展并启动 WebSocket 桥接`:`Install extension and start the bridge`,path:`/settings/agent-browser?tab=extension`,keywords:[`extension`,`chrome`,`bridge`,`websocket`,`扩展`,`桥接`]},{id:`field:agent:browser-playwright`,title:t?`安装 Playwright Chromium`:`Install Playwright Chromium`,subtitle:t?`本地 Playwright 后端就绪检查`:`Local Playwright backend setup`,path:`/settings/agent-browser?tab=local`,keywords:[`playwright`,`chromium`,`install`,`local`,`安装`]},{id:`field:agent:browser-cloak`,title:t?`CloakBrowser 配置`:`CloakBrowser settings`,subtitle:t?`反指纹浏览器下载与高级选项`:`Stealth browser download and fingerprint options`,path:`/settings/agent-browser?tab=cloakbrowser`,keywords:[`cloak`,`cloakbrowser`,`fingerprint`,`stealth`,`反指纹`]},{id:`field:agent:browser-headless`,title:t?`浏览器无头模式`:`Browser headless mode`,subtitle:t?`隐藏浏览器窗口`:`Run without a visible window`,path:`/settings/agent-browser?focus=runtime`,keywords:[`headless`,`window`,`visible`,`无头`]},{id:`field:agent:browser-private-urls`,title:t?`允许内网 URL`:`Allow private URLs`,subtitle:t?`浏览器导航安全限制`:`Browser navigation security policy`,path:`/settings/agent-browser?focus=security`,keywords:[`private`,`internal`,`localhost`,`security`,`内网`,`安全`]},{id:`field:agent:turnLimit`,title:t?`轮次限制`:`Turn Limit`,subtitle:t?`单次会话最大对话轮次`:`Maximum turns per session run`,path:`/settings/agent-defaults?tab=runtime`,keywords:[`turn`,`limit`,`iterations`,`max`,`轮次`,`限制`]},{id:`field:agent:timeout`,title:t?`超时时间`:`Timeout`,subtitle:t?`单次工具调用的超时`:`Tool execution timeout`,path:`/settings/agent-defaults?tab=runtime`,keywords:[`timeout`,`duration`,`seconds`,`超时`]},{id:`field:agent:compaction`,title:t?`上下文压缩`:`Context Compaction`,subtitle:t?`长对话自动压缩策略`:`Auto-compact strategy for long conversations`,path:`/settings/agent-defaults?tab=context`,keywords:[`compaction`,`context`,`pruning`,`tokens`,`window`,`压缩`,`上下文`]},{id:`field:agent:memory`,title:t?`记忆设置`:`Memory Settings`,subtitle:t?`会话记忆与回顾配置`:`Session memory and review configuration`,path:`/settings/agent-defaults?tab=memory`,keywords:[`memory`,`review`,`session`,`recall`,`记忆`]},{id:`field:agent:systemPrompt`,title:t?`系统提示词`:`System Prompt`,subtitle:t?`自定义系统指令`:`Custom system instructions`,path:`/settings/agent-defaults?tab=system-prompt`,keywords:[`system`,`prompt`,`instructions`,`persona`,`系统提示词`,`指令`]},{id:`field:voice:sttProvider`,title:t?`STT 语音识别提供商`:`STT Provider`,subtitle:t?`语音转文字服务商`:`Speech-to-text service provider`,path:`/settings/credentials?tab=voice`,keywords:[`stt`,`speech`,`recognition`,`whisper`,`deepgram`,`语音识别`]},{id:`field:voice:ttsProvider`,title:t?`TTS 语音合成提供商`:`TTS Provider`,subtitle:t?`文字转语音服务商`:`Text-to-speech service provider`,path:`/settings/credentials?tab=voice`,keywords:[`tts`,`speech`,`synthesis`,`voice`,`elevenlabs`,`语音合成`]},{id:`field:search:engine`,title:t?`搜索引擎`:`Web Search Engine`,subtitle:t?`联网搜索使用的引擎`:`Engine for web search tool`,path:`/settings/credentials?tab=search`,keywords:[`search`,`engine`,`tavily`,`serper`,`brave`,`bing`,`搜索引擎`]},{id:`field:cron:enabled`,title:t?`定时任务开关`:`Cron Enabled`,subtitle:t?`启用/禁用定时调度器`:`Enable or disable the scheduler`,path:`/cron?tab=settings`,keywords:[`cron`,`enabled`,`scheduler`,`timer`,`定时`,`调度`]},{id:`field:cron:timezone`,title:t?`定时任务时区`:`Cron Timezone`,subtitle:t?`调度器使用的时区`:`Timezone for the scheduler`,path:`/cron?tab=settings`,keywords:[`timezone`,`tz`,`utc`,`cron`,`时区`]},{id:`field:channels:telegram`,title:`Telegram Bot Token`,subtitle:t?`配置 Telegram 频道连接`:`Configure Telegram channel connection`,path:`/settings/channels`,keywords:[`telegram`,`bot`,`token`,`channel`,`频道`]},{id:`field:channels:dmPolicy`,title:t?`私聊接入策略`:`DM Access Policy`,subtitle:t?`Telegram 私聊白名单/配对策略`:`Telegram DM allowlist/pairing policy`,path:`/settings/channels`,keywords:[`dm`,`policy`,`pairing`,`allowlist`,`access`,`私聊`,`策略`]},{id:`field:mcp:servers`,title:t?`MCP 服务器配置`:`MCP Servers`,subtitle:t?`外部 MCP 工具服务器列表`:`External MCP tool server registry`,path:`/settings/connectors`,keywords:[`mcp`,`server`,`tools`,`external`,`stdio`,`服务器`,`connector`]},{id:`field:heartbeat:interval`,title:t?`心跳间隔`:`Heartbeat Interval`,subtitle:t?`网关存活检测频率`:`Gateway keep-alive check frequency`,path:`/settings/heartbeat`,keywords:[`heartbeat`,`interval`,`keepalive`,`alive`,`心跳`]},{id:`field:tunnel:enabled`,title:t?`公网隧道`:`Public Tunnel`,subtitle:t?`FRP 远程访问隧道开关`:`FRP remote access tunnel toggle`,path:`/settings/remote-access`,keywords:[`tunnel`,`frp`,`remote`,`public`,`ngrok`,`隧道`,`远程`]}]}function nBe(e,t,n,r){return lk(e).map(e=>({kind:`setting`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:r,keywords:e.keywords,run:()=>{n(),t(e.path)}}))}var uk=t({deleteSkill:()=>mk,getMarketplaceCategories:()=>_k,getMarketplacePackageDetail:()=>yk,getMarketplaceProvider:()=>Sk,getMarketplaceProviders:()=>Ck,getMarketplaceSkills:()=>vk,getSkillMarkdown:()=>xk,getSkills:()=>fk,installMarketplaceSkill:()=>bk,patchSkillEnabled:()=>hk,reloadSkills:()=>rBe,uploadSkillZip:()=>pk});async function dk(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function fk(e){let t=await Te(v(`/api/skills${e&&e!==`en`?`?lang=${encodeURIComponent(e)}`:``}`),{cache:`no-store`});if(!t.ok)throw Error(await dk(t));let n=await t.json();if(!n.payload)throw Error(`Invalid response`);return n.payload}async function rBe(){let e=await Te(v(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await dk(e))}async function pk(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`);let r=xe.getState().token,i=new Headers;r&&i.set(`Authorization`,`Bearer ${r}`);let a=await fetch(v(`/api/skills/upload`),{method:`POST`,headers:i,body:n});a.status===401&&xe.getState().onUnauthorized();let o=await a.json().catch(()=>({}));if(!a.ok)throw Error(o.error||`HTTP ${a.status}`);if(!o.payload?.skillId)throw Error(`Invalid response`);return o.payload}async function mk(e){let t=await Te(v(`/api/skills/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(await dk(t))}async function hk(e,t){let n=await Te(v(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await dk(n))}function gk(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function _k(e){let t=new URLSearchParams;gk(t,e?.provider);let n=t.toString(),r=await Te(v(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await dk(r));let i=await r.json();if(!i.payload||!Array.isArray(i.payload.items))throw Error(`Invalid response`);return{items:i.payload.items}}async function vk(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),gk(t,e.provider);let n=t.toString(),r=await Te(v(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await dk(r));let i=await r.json();if(!i.payload?.items||!i.payload.meta)throw Error(`Invalid response`);return i.payload}async function yk(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;gk(r,t?.provider);let i=r.toString(),a=await Te(v(`/api/skills/marketplace/packages/${n}${i?`?${i}`:``}`),{cache:`no-store`});if(!a.ok)throw Error(await dk(a));let o=await a.json();if(!o.payload?.name)throw Error(`Invalid response`);return o.payload}async function bk(e){let t=await Te(v(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await dk(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function xk(e,t){let n=t?`?lang=${encodeURIComponent(t)}`:``,r=await Te(v(`/api/skills/${encodeURIComponent(e)}/content${n}`),{cache:`no-store`});if(!r.ok)throw Error(await dk(r));let i=(await r.json()).payload;if(!i||typeof i.name!=`string`||typeof i.description!=`string`||typeof i.bodyMarkdown!=`string`||typeof i.disableModelInvocation!=`boolean`||!i.metadata||typeof i.metadata!=`object`||typeof i.metadata.name!=`string`||typeof i.metadata.description!=`string`)throw Error(`Invalid response`);return i}async function Sk(){let e=await Te(v(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await dk(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function Ck(){let e=await Te(v(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await dk(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}var wk=`[a-zA-Z0-9](?:[a-zA-Z0-9._-]{0,62})`,iBe=RegExp(`\\/skill:(${wk})`,`g`);function Tk(){return new RegExp(iBe.source,`g`)}var Ek=RegExp(`(\\/skill:${wk})$`),aBe=RegExp(`(\\/skill:${wk})([ \\t\\f\\v]*)$`),oBe=RegExp(`^${wk}$`);function sBe(e){return oBe.test(e.trim())}var cBe=RegExp(`^\\/skill:(${wk})`),Dk=[],Ok=new Map;function kk(e){let t=new Set;for(let n of e??[]){n?.name&&t.add(n.name);for(let e of n.aliases??[])typeof e==`string`&&e.length>0&&t.add(e)}Dk=Array.from(t).toSorted((e,t)=>t.length-e.length).map(e=>({key:e})),Ok.clear()}function lBe(e,t){if(t>=e.length)return!0;let n=e[t];return!/[a-zA-Z0-9_-]/.test(n)}function uBe(e,t){return!(e[t]!==`/`||t>0&&!/\s/.test(e[t-1]))}function Ak(e,t){if(!uBe(e,t)||Dk.length===0)return null;let n=e.slice(t);if(n.startsWith(`/skill:`))return null;for(let{key:e}of Dk){let t=`/${e}`;if(n.startsWith(t)&&lBe(n,t.length))return{len:t.length,matchedKey:e}}return null}function jk(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==`/`){n+=1;continue}let r=e.slice(n).match(cBe);if(r?.[0]){n+=r[0].length;continue}let i=Ak(e,n);i?(t.push({start:n,end:n+i.len}),n+=i.len):n+=1}return t}function Mk(e){for(let t=e.length-1;t>=0;--t){if(e[t]!==`/`||e.startsWith(`/skill:`,t))continue;let n=Ak(e,t);if(n&&t+n.len===e.length)return!0}return!1}function dBe(e){if(!e.startsWith(`/`)||Dk.length===0||e.startsWith(`/skill:`))return!1;let t=Ak(e,0);return t?e.length===t.len||!/[a-zA-Z0-9_-]/.test(e[t.len]):!1}function fBe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Nk(e){let t=Ok.get(e);return t||(t=RegExp(`(${fBe(e)})([ \\t\\f\\v]*)$`),Ok.set(e,t)),t}function Pk(e){for(let{key:t}of Dk){let n=`/${t}`;if(!e.endsWith(n))continue;let r=e.length-n.length;if(Ak(e,r))return{tokenStart:r}}return null}function Fk(e){for(let{key:t}of Dk){let n=`/${t}`,r=e.match(Nk(n));if(!r)continue;let i=e.length-r[0].length;if(Ak(e,i))return{tokenStart:i}}return null}async function Ik(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function pBe(){let e=await Te(v(`/api/commands`));if(!e.ok)throw Error(await Ik(e));return(await e.json()).payload?.commands??[]}var Lk=6e4,Rk=null,mBe=0,zk=null,hBe=new Map,gBe=new Map,Bk=null,_Be;async function Vk(e=!1){return!e&&Rk&&Date.now()<mBe?(kk(Rk),Rk):zk||(zk=pBe().then(e=>(Rk=e,mBe=Date.now()+Lk,kk(e),e)).catch(e=>{throw kk([]),e}).finally(()=>{zk=null}),zk)}async function Hk(e,t=!1){let n=e??`en`,r=Date.now();return!t&&hBe.has(n)&&r<(gBe.get(n)??0)?hBe.get(n):Bk&&_Be===n?Bk:(_Be=n,Bk=fk(e).then(e=>(hBe.set(n,e),gBe.set(n,Date.now()+Lk),e)).finally(()=>{Bk=null,_Be=void 0}),Bk)}var Uk=`fill-chat-composer`;function Wk(e){window.dispatchEvent(new CustomEvent(Uk,{detail:{text:e}}))}function Gk(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var Kk=3e4,qk=null;function Jk(e){return e.trim()}function vBe(e){return e.map(e=>({name:e.name,relativePath:e.path,isDirectory:e.isDirectory}))}async function Yk(e,t){let n=t.sessionKey?.trim(),r=t.agentId?.trim(),i=t.limit??15,a=e.trim(),o=new URLSearchParams;if(o.set(`q`,a),o.set(`limit`,String(i)),n?o.set(`sessionKey`,n):r&&o.set(`agentId`,r),n&&a.length===0){let e=Jk(n),t=Date.now();if(qk&&qk.key===e&&t-qk.at<Kk)return qk.items}let s=vBe((await Ce(v(`/api/workspace/editor/files/search?${o.toString()}`))).payload.entries??[]);return n&&a.length===0&&(qk={key:Jk(n),at:Date.now(),items:s}),s}async function yBe(e,t){return DS(e,{sessionKey:t.sessionKey,agentId:t.agentId})}function Xk(e){let t=typeof e.profileDir==`string`?e.profileDir.trim():``,n=e.typedModels?.defaults??[],r=e.typedModels?.effective??n;return{...e,profileDir:t,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:e.skills??{defaults:[]},tools:e.tools??{defaultsDisable:[],entryDisable:[],effectiveDisable:[]},typedModels:{defaults:n,effective:r}}}async function bBe(){let e=(await Ce(v(`/api/agents?locale=${encodeURIComponent(p())}`))).payload;if(!e?.defaultId||!Array.isArray(e.agents))throw Error(`Invalid /api/agents response`);let t=Array.isArray(e.builtinToolIds)?e.builtinToolIds:[];return{defaultId:e.defaultId,agents:e.agents.map(Xk),builtinToolIds:t}}async function xBe(e){let{mutate:t}=await w(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([3,1,4]));await Promise.all([t(`settings-gateway-agents`,e,{revalidate:!1}),t(`setup-checklist-agents`,e,{revalidate:!1})])}async function SBe(e){let t=await Ce(v(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=typeof t.payload?.agentId==`string`?t.payload.agentId.trim():``,r=t.payload?.agents;if(!n||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid create agent response`);return{createdAgentId:n,defaultId:r.defaultId,agents:r.agents.map(Xk),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]}}async function CBe(e){let t=await Ce(v(`/api/agents/batch`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agents:e})}),n=Array.isArray(t.payload?.agentIds)?t.payload.agentIds.map(e=>String(e).trim()).filter(Boolean):[],r=t.payload?.agents;if(n.length===0||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid batch create agent response`);let i={defaultId:r.defaultId,agents:r.agents.map(Xk),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]};return await xBe(i),{createdAgentIds:n,...i}}async function wBe(e,t){let n=(await Ce(v(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).payload;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid update agent response`);return{defaultId:n.defaultId,agents:n.agents.map(Xk),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function TBe(e,t){let n=(await Ce(v(`/api/agents/${encodeURIComponent(e)}${t?`?purge=true`:``}`),{method:`DELETE`})).payload?.agents;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid delete agent response`);return{defaultId:n.defaultId,agents:n.agents.map(Xk),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}function Zk(e){if(!e||typeof e!=`object`||!(`bindings`in e))return[];let t=e.bindings;return Array.isArray(t)?t:[]}async function Qk(e){await Ce(v(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({bindings:e})}),by()}async function $k(){let e=(await Ce(v(`/api/skills`))).payload?.catalog;return Array.isArray(e)?e:[]}async function eA(e){let t=(await Ce(v(`/api/agents/${encodeURIComponent(e)}/files`))).payload,n=typeof t?.profileDir==`string`?t.profileDir.trim():``;if(!t?.files||!n)throw Error(`Invalid files list response`);return{agentId:t.agentId,profileDir:n,files:t.files}}async function EBe(e,t){let n=(await Ce(v(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid file content response`);return n}async function DBe(e,t,n){await Ce(v(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}function tA(e){let t=e.type.toLowerCase();return t===`image/png`||t===`image/jpeg`||t===`image/jpg`||t===`image/webp`?t===`image/jpg`?`image/jpeg`:t:null}function OBe(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=String(r.result??``),n=e.indexOf(`,`);t(n>=0?e.slice(n+1):``)},r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(e)})}async function nA(e,t){let n=tA(t);if(!n)throw Error(`unsupported_image_type`);if(t.size===0||t.size>512*1024)throw Error(`avatar_too_large`);let r=await OBe(t);if(!r)throw Error(`empty_file`);await Ce(v(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({base64:r,mimeType:n})})}async function rA(e){await Ce(v(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`DELETE`})}var iA=`main`;function aA(e,t){return e.name?.trim()||(e.id.trim().toLowerCase()===iA?t.defaultMainAgentName:e.id)}function oA(e,t){return e.description?.trim()||(e.id.trim().toLowerCase()===iA?t.defaultMainAgentDescription:``)}var kBe=500,sA=null,cA;function lA(e){cA=e,sA!==null&&clearTimeout(sA),sA=setTimeout(()=>{sA=null;let e=cA;cA=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},kBe)}function uA(){let{pathname:e}=Hn(),{sessionKey:t}=Wn();if(!e.startsWith(`/chat`)||!t)return;let n=decodeURIComponent(t);return n&&n!==`new`?n:void 0}function dA(e){switch(e.kind){case`extension`:return(0,z.jsx)(Kl,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`route`:return(0,z.jsx)(Na,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`session`:return(0,z.jsx)(Na,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`file`:return(0,z.jsx)(fa,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`command`:return(0,z.jsx)(Hf,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`skill`:return(0,z.jsx)(zd,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});case`setting`:return(0,z.jsx)(fd,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`action`:return(0,z.jsx)(im,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});default:return null}}function fA(e,t,n,r){if(r(),t.startsWith(`/chat`)){Wk(e);return}let i=e.match(/^\/skill:(\S+)\s*$/),a=e.match(/^\/(\S+)\s*$/);i?n(`/chat/new?skill=${encodeURIComponent(i[1])}`):a?n(`/chat/new?slash=${encodeURIComponent(a[1])}`):(n(`/chat/new`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Wk(e)})}))}function pA(e){let t=[];for(let n of e.uiExtensions){let r=n.ui?.contributions?.commands;if(Array.isArray(r))for(let i of r)!i||typeof i.id!=`string`||typeof i.title!=`string`||t.push({kind:`extension`,id:`ext:${n.id}:${i.id}`,title:i.title,subtitle:n.name,groupLabel:e.extensionsGroupLabel,keywords:[n.id,n.name,i.id],run:()=>{e.close(),i.opensPanel!==void 0&&i.opensPanel!==``?e.navigate(`/apps/${encodeURIComponent(n.id)}`):window.dispatchEvent(new CustomEvent(`extension-command`,{detail:{extensionId:n.id,commandId:i.id}}))}})}return t}function mA(e,t){switch(t.type){case`setQuery`:return{...e,query:t.value};case`setSelectedIndex`:{let n=typeof t.value==`function`?t.value(e.selectedIndex):t.value;return{...e,selectedIndex:n}}case`setLayer`:return{...e,paletteLayer:t.layer,query:``,selectedIndex:0};case`resetMain`:return{query:``,selectedIndex:0,paletteLayer:`main`}}}var ABe={query:``,selectedIndex:0,paletteLayer:`main`};async function hA(){let e=await Ce(v(`/api/registry`)),t=[];for(let n of e.payload?.providers??[])for(let e of n.models??[])e.available!==!1&&t.push({id:e.ref,title:e.name||e.ref,subtitle:e.ref});return t.sort((e,t)=>e.title.localeCompare(t.title)),t}async function jBe(e){let t=await bBe(),n=h(e).agentsSettings;return t.agents.map(e=>({id:e.id,title:aA(e,n),subtitle:e.id}))}function MBe({onClose:e}){let t=(0,j.useRef)(null),n=(0,j.useRef)(null),r=Un(),{pathname:i}=Hn(),a=f(e=>e.language),o=ey(),s=uA(),c=fO(e=>e.agentId),l=_O(e=>e.setPath),[u,d]=(0,j.useReducer)(mA,ABe),{query:p,selectedIndex:m,paletteLayer:g}=u,_=(0,j.useMemo)(()=>Qze(a),[a]),[y]=zS(p,120),b=(0,j.useCallback)(()=>{d({type:`setLayer`,layer:`models`})},[]),x=(0,j.useCallback)(()=>{d({type:`setLayer`,layer:`agents`})},[]),S=Tv(async()=>g===`models`?hA():g===`agents`?jBe(a):[],[g,a],{enabled:g===`models`||g===`agents`,initial:[],errorData:[]}),C=Tv(async()=>{let t=y.trim(),n=e,u=h(a).commandPalette.groups,d=_.map(e=>({kind:`route`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.navigate,keywords:[...e.keywords??[],e.path],run:()=>{n(),r(e.path)}})),f=tBe(a,{closePalette:n,openModelPalette:b,openAgentPalette:x}),p=YO(a,r,n),m=pA({query:t,close:n,navigate:r,uiExtensions:o,extensionsGroupLabel:u.extensions}),[g,v,S,C]=await Promise.all([Vk(),Hk(a),pb({search:t||void 0,limit:8,offset:0}).catch(()=>({items:[]})),(async()=>{let e=s?.trim(),n=c.trim();return!e&&!n?[]:await Yk(t,{sessionKey:e||void 0,agentId:e?void 0:n||void 0,limit:10}).catch(()=>[])})()]),w=g.map(e=>({kind:`command`,id:`cmd:${e.id}`,title:`/${e.name}`,subtitle:e.description,groupLabel:u.commands,keywords:[e.id,...e.aliases??[],e.category??``],run:()=>{fA(Gk(e),i,r,n)}})),T=v.catalog.flatMap(e=>!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,title:`/skill:${e.name}`,subtitle:e.description,groupLabel:u.skills,keywords:[e.source??``,`skill`],run:()=>{fA(`/skill:${e.name} `,i,r,n)}}]),E=(S.items??[]).map(e=>({kind:`session`,id:`session:${e.key}`,title:e.name?.trim()||e.key,subtitle:e.key,groupLabel:u.sessions,keywords:[e.key,...e.tags??[],e.sourceChannel??``],run:()=>{n(),r(`/chat/${encodeURIComponent(e.key)}`)}})),D=C.flatMap(e=>e.isDirectory?[]:[{kind:`file`,id:`file:${e.relativePath}`,title:e.name,subtitle:e.relativePath,groupLabel:u.files,keywords:[e.relativePath],run:()=>{n();let t=e.relativePath.replace(/\\/g,`/`).replace(/^\/+/,``),a=()=>l(t);if(i.startsWith(`/chat`)){a();return}r(`/chat`),window.setTimeout(()=>a(),0)}}]),O=nBe(a,r,n,u.navigate),k=[...d,...f,...p,...m,...O,...E,...D,...w,...T],A=[];for(let e of k){let n=Wze(e,t);n!==null&&A.push({...e,rank:n})}let ee=Hze(a),te=Gze(A),ne=[],re={};for(let e of te){let t=(re[e.groupLabel]??0)+1;if(!(t>(ee[e.groupLabel]??6))&&(re[e.groupLabel]=t,ne.push(e),ne.length>=36))break}return ne.sort((e,t)=>ZO(a,e.groupLabel)-ZO(a,t.groupLabel)||e.rank-t.rank||e.title.localeCompare(t.title)),ne},[y,_,o,r,s,c,i,l,a,b,x,e],{enabled:g===`main`,initial:[],errorData:[]}),w=C.data,T=C.loading,E=C.error,D=(0,j.useMemo)(()=>{let e=p.trim().toLowerCase(),t=S.data;return e?t.filter(t=>t.title.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.subtitle?.toLowerCase().includes(e)??!1)):t},[S.data,p]),O=`${g}|${p}|${String(D.length)}|${String(w.length)}`,k=(0,j.useRef)(O);if(k.current!==O){k.current=O;let e=g===`main`?Math.max(0,w.length-1):Math.max(0,D.length);m>e&&d({type:`setSelectedIndex`,value:e})}(0,j.useEffect)(()=>{let e=window.setTimeout(()=>t.current?.focus(),50);return()=>window.clearTimeout(e)},[]);let A=(0,j.useEffectEvent)(t=>{if(t.key===`Escape`){if(t.preventDefault(),g!==`main`){d({type:`resetMain`});return}e();return}let n=g===`main`?Math.max(0,w.length-1):Math.max(0,D.length);if(t.key===`ArrowDown`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.min(e+1,n)});return}if(t.key===`ArrowUp`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.max(0,e-1)});return}if(t.key===`Enter`){if(t.preventDefault(),g===`models`){if(m===0){d({type:`resetMain`});return}let t=D[m-1];if(!t)return;(async()=>{await Ce(v(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agents:{defaults:{model:t.id}}})}),by(),lA(),e(),d({type:`resetMain`})})();return}if(g===`agents`){if(m===0){d({type:`resetMain`});return}let t=D[m-1];if(!t)return;window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:t.id}})),e(),d({type:`resetMain`});return}let n=w[m];n&&n.run()}});(0,j.useEffect)(()=>{let e=e=>{A(e)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,j.useLayoutEffect)(()=>{let e=n.current;e&&e.querySelector(`[data-global-palette-index="${String(m)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[m,w,g,D.length]);let ee=a===`zh`?`返回`:`Back`;if(g===`models`||g===`agents`){let r=D,i=S.loading;return(0,z.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":a===`zh`?`选择模型或智能体`:`Model or agent picker`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,z.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,z.jsx)(`input`,{ref:t,type:`search`,value:p,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:g===`models`?a===`zh`?`搜索模型…`:`Search models…`:a===`zh`?`搜索智能体…`:`Search agents…`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,z.jsxs)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,"data-global-palette-index":0,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-fg-muted`,m===0?`bg-surface-hover`:`hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:0}),onClick:()=>d({type:`resetMain`}),children:[`← `,ee]})}),i?(0,z.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`加载中…`:`Loading…`}):r.length===0?(0,z.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`无结果`:`No results`}):r.map((t,n)=>{let r=n+1;return(0,z.jsx)(`li`,{children:(0,z.jsx)(`button`,{type:`button`,"data-global-palette-index":r,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,m===r?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:r}),onClick:()=>{g===`models`?(async()=>{await Ce(v(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agents:{defaults:{model:t.id}}})}),by(),lA(),e(),d({type:`resetMain`})})():(window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:t.id}})),e(),d({type:`resetMain`}))},children:(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:t.title}),t.subtitle?(0,z.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:t.subtitle}):null]})})},t.id)})]})]})})}let te=``;return(0,z.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Global search`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,z.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,z.jsx)(`input`,{ref:t,type:`search`,value:p,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:a===`zh`?`搜索…(会话 / 文件 / 设置 / 命令)`:`Search… (sessions, files, settings, commands)`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,z.jsx)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,"aria-activedescendant":w[m]?`global-hit-${w[m].id}`:void 0,children:w.length===0?(0,z.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:T?a===`zh`?`搜索中…`:`Searching…`:E?E instanceof Error?E.message:String(E):a===`zh`?`无结果`:`No results`}):w.map((e,t)=>{let n=e.groupLabel===te?``:e.groupLabel;return te=e.groupLabel,(0,z.jsxs)(`li`,{children:[n?(0,z.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:n}):null,(0,z.jsxs)(`button`,{id:`global-hit-${e.id}`,"data-global-palette-index":t,type:`button`,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,t===m?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:t}),onClick:()=>e.run(),children:[(0,z.jsx)(`span`,{className:`mt-0.5`,children:dA(e)}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.subtitle?(0,z.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.subtitle}):null]})]})]},e.id)})})]})})}function NBe(){let e=(0,fm.c)(7),[t,n]=(0,j.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),n(gA))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,j.useEffect)(r,i);let a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=()=>n(!0);return window.addEventListener(`open-command-palette`,e),()=>window.removeEventListener(`open-command-palette`,e)},o=[],e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,j.useEffect)(a,o);let s,c;if(e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=()=>n(PBe);return window.addEventListener(`toggle-command-palette`,e),()=>window.removeEventListener(`toggle-command-palette`,e)},c=[],e[4]=s,e[5]=c):(s=e[4],c=e[5]),(0,j.useEffect)(s,c),!t)return null;let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(MBe,{onClose:()=>n(!1)}),e[6]=l):l=e[6],l}function PBe(e){return!e}function gA(e){return!e}var _A=`meta+.`,FBe=l(ge(e=>({shortcut:_A,setShortcut:t=>e({shortcut:t})}),{name:`xopc-quick-capture-shortcut`})),IBe={cmd:`meta`,command:`meta`,ctrl:`control`,ctl:`control`,opt:`alt`,option:`alt`};function LBe(e){let t=e.toLowerCase().trim();return IBe[t]??t}function RBe(e,t){let n=t.split(`+`).map(LBe),r=new Set(n.filter(e=>[`meta`,`control`,`alt`,`shift`].includes(e))),i=n.find(e=>!r.has(e));return!i||r.has(`meta`)!==e.metaKey||r.has(`control`)!==e.ctrlKey||r.has(`alt`)!==e.altKey||r.has(`shift`)!==e.shiftKey?!1:e.key.toLowerCase()===i||e.code.toLowerCase()===i}var zBe=`xopc-attachment`,BBe=/^xopc-attachment:\/\/notes\/([^/]+)\/([^/?#]+)$/i;function VBe(e,t){return`${zBe}://notes/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function vA(e,t){let n=e.trim();if(!n)return null;let r=n.split(`?`)[0].match(BBe);if(!r)return null;let i=decodeURIComponent(r[1]),a=decodeURIComponent(r[2]);return t&&i!==t?null:{noteId:i,attachmentId:a}}function HBe(e,t){return`/api/notes/${encodeURIComponent(e)}/media/${encodeURIComponent(t)}`}function UBe(e,t){return VBe(e,t)}function yA(e){if(e<60)return`Voice · ${e}s`;let t=Math.floor(e/60),n=e%60;return`Voice · ${t}:${String(n).padStart(2,`0`)}`}async function bA(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:`HTTP ${e.status}`}async function WBe(e,t){let n=xe.getState().token,r=new Headers;n&&r.set(`Authorization`,`Bearer ${n}`);let i=await fetch(e,{method:`POST`,headers:r,body:t});if(i.status===401&&xe.getState().onUnauthorized(),!i.ok)throw Error(await bA(i));return i.json()}var xA=new Map,SA=``;function CA(e,t,n){return`${n}:${e}:${t}`}function GBe(){let e=xe.getState().token??``;if(e!==SA){for(let e of xA.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);xA.clear(),SA=e}}async function KBe(e,t){GBe();let n=CA(e,t,xe.getState().token??``),r=xA.get(n);return r||(r={blob:(async()=>{let n=await Te(v(HBe(e,t)));if(n.status===401&&xe.getState().onUnauthorized(),!n.ok)throw Error(`HTTP ${n.status}`);return n.blob()})(),objectUrl:null,refCount:0},xA.set(n,r)),r.blob}async function wA(e,t){GBe();let n=CA(e,t,xe.getState().token??``),r=xA.get(n);if(r||(r={blob:KBe(e,t),objectUrl:null,refCount:0},xA.set(n,r)),!r.objectUrl){let e=await r.blob;r.objectUrl=URL.createObjectURL(e)}return r.refCount+=1,r.objectUrl}function TA(e,t){GBe();let n=CA(e,t,xe.getState().token??``),r=xA.get(n);r&&(r.refCount=Math.max(0,r.refCount-1),r.refCount===0&&r.objectUrl&&(URL.revokeObjectURL(r.objectUrl),r.objectUrl=null,xA.delete(n)))}function EA(e){let t=(0,fm.c)(39),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({src:s,expectedNoteId:r,alt:c,className:n,onClick:i,onLoadFailed:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?``:c,u;t[8]!==r||t[9]!==s?(u=vA(s,r),t[8]=r,t[9]=s,t[10]=u):u=t[10];let d=u,[f,p]=(0,j.useState)(d?null:s),[m,h]=(0,j.useState)(!1),g,_;if(t[11]!==a||t[12]!==d||t[13]!==s?(g=()=>{if(h(!1),!d){p(s);return}let e=!1;return p(null),wA(d.noteId,d.attachmentId).then(t=>{e||p(t)}).catch(()=>{e||(h(!0),a?.())}),()=>{e=!0,TA(d.noteId,d.attachmentId)}},_=[s,d,a],t[11]=a,t[12]=d,t[13]=s,t[14]=g,t[15]=_):(g=t[14],_=t[15]),(0,j.useEffect)(g,_),m){let e;t[16]===n?e=t[17]:(e=fh(`flex items-center justify-center bg-surface-hover text-fg-muted`,n),t[16]=n,t[17]=e);let r=!l,i;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(Do,{className:`h-5 w-5`}),t[18]=i):i=t[18];let a;return t[19]!==e||t[20]!==r?(a=(0,z.jsx)(`div`,{className:e,"aria-hidden":r,children:i}),t[19]=e,t[20]=r,t[21]=a):a=t[21],a}if(!f){let e;t[22]===n?e=t[23]:(e=fh(`animate-pulse bg-surface-hover`,n),t[22]=n,t[23]=e);let r=!l,i;return t[24]!==e||t[25]!==r?(i=(0,z.jsx)(`div`,{className:e,"aria-hidden":r}),t[24]=e,t[25]=r,t[26]=i):i=t[26],i}let v;t[27]!==f||t[28]!==i?(v=i?()=>i(f):void 0,t[27]=f,t[28]=i,t[29]=v):v=t[29];let y;t[30]===a?y=t[31]:(y=()=>{h(!0),a?.()},t[30]=a,t[31]=y);let b;return t[32]!==l||t[33]!==n||t[34]!==f||t[35]!==o||t[36]!==v||t[37]!==y?(b=(0,z.jsx)(`img`,{...o,src:f,alt:l,className:n,onClick:v,onError:y}),t[32]=l,t[33]=n,t[34]=f,t[35]=o,t[36]=v,t[37]=y,t[38]=b):b=t[38],b}function DA(e){return e.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^)\s]+)/gi,`/api/notes/$1/media/$2`)}function qBe(e,t){let n=[];return e.querySelectorAll(`.markdown-body img`).forEach(e=>{let r=vA(e.getAttribute(`src`)??``,t);if(!r)return;let i=!1;wA(r.noteId,r.attachmentId).then(t=>{i||(e.src=t)}).catch(()=>{e.classList.add(`note-media-load-failed`)}),n.push(()=>{i=!0,TA(r.noteId,r.attachmentId)})}),e.querySelectorAll(`.markdown-body a`).forEach(e=>{let r=vA(e.getAttribute(`href`)??``,t);if(!r)return;let i=document.createElement(`audio`);i.controls=!0,i.className=`note-media-audio mt-2 w-full max-w-md`,e.replaceWith(i);let a=!1;wA(r.noteId,r.attachmentId).then(e=>{a||(i.src=e)}).catch(()=>{i.remove()}),n.push(()=>{a=!0,TA(r.noteId,r.attachmentId)})}),()=>{for(let e of n)e()}}function JBe(e){let t=(0,fm.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({content:n,noteId:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(0,j.useRef)(null),o;t[4]===r?o=t[5]:(o=()=>{let e=a.current;if(e)return qBe(e,r)},t[4]=r,t[5]=o);let s;t[6]!==n||t[7]!==r?(s=[n,r],t[6]=n,t[7]=r,t[8]=s):s=t[8],(0,j.useLayoutEffect)(o,s);let c;t[9]===n?c=t[10]:(c=DA(n),t[9]=n,t[10]=c);let l;return t[11]!==i||t[12]!==c?(l=(0,z.jsx)(`div`,{ref:a,children:(0,z.jsx)(AD,{content:c,...i})}),t[11]=i,t[12]=c,t[13]=l):l=t[13],l}async function YBe(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.kind&&t.set(`kind`,e.kind),e.tag&&t.set(`tag`,e.tag),e.pinned!==void 0&&t.set(`pinned`,String(e.pinned)),e.search&&t.set(`search`,e.search),e.limit&&t.set(`limit`,String(e.limit)),e.offset&&t.set(`offset`,String(e.offset)),e.sortBy&&t.set(`sortBy`,e.sortBy),e.sortOrder&&t.set(`sortOrder`,e.sortOrder);let n=t.toString();return Ce(v(`/api/notes${n?`?${n}`:``}`))}async function XBe(e,t=`web`){return(await Ce(v(`/api/notes/quick-capture`),{method:`POST`,body:JSON.stringify({text:e,channel:t})})).note}async function ZBe(e){let t=await Te(v(`/api/notes/${encodeURIComponent(e)}`));if(t.status===404)return null;let n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n.note??null}async function QBe(e,t){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).note}async function $Be(e){await Ce(v(`/api/notes/${encodeURIComponent(e)}`),{method:`DELETE`})}async function eVe(e){return Ce(v(`/api/notes/${encodeURIComponent(e)}/catalyze`),{method:`POST`})}async function tVe(e,t){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/catalysis-feedback`),{method:`POST`,body:JSON.stringify({feedback:t})})).note}async function OA(e){return Ce(v(`/api/notes/${encodeURIComponent(e)}/chat`),{method:`POST`})}async function nVe(e){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/threads`))).items}async function kA(e,t,n){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/append`),{method:`POST`,body:JSON.stringify({content:t,heading:n})})).note}async function rVe(e,t={}){return(await Ce(v(`/api/notes/task`),{method:`POST`,body:JSON.stringify({title:e,channel:`web`,priority:t.priority,sourceSessionKey:t.sourceSessionKey||void 0,sourceNoteId:t.sourceNoteId||void 0})})).note}async function AA(e,t){let n=new FormData;return n.append(`file`,t),(await WBe(v(`/api/notes/${encodeURIComponent(e)}/media`),n)).attachment}async function jA(e,t){let n=new FormData;return n.append(`file`,e),t?.text&&n.append(`text`,t.text),n.append(`channel`,t?.channel??`web`),t?.kind&&n.append(`kind`,t.kind),t?.duration!==void 0&&n.append(`duration`,String(t.duration)),(await WBe(v(`/api/notes`),n)).note}async function iVe(e,t=`web`){let n=await jA(e,{channel:t}),r=n.attachments?.find(e=>e.type===`image`)??n.attachments?.[0];if(!r)return n;let i=`})`;return n.text!==i&&(n=await QBe(n.id,{text:i})),n}async function aVe(e,t,n=`web`){let r=await jA(e,{channel:n,kind:`voice`,duration:t}),i=r.attachments?.find(e=>e.type===`audio`)??r.attachments?.[0];if(!i)return r;let a=`[${yA(t)}](${UBe(r.id,i.id)})`;return r.text!==a&&(r=await QBe(r.id,{text:a,kind:`voice`})),r}async function oVe(e){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/history`))).entries}async function sVe(e,t){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/history/${t}`))).snapshot}async function cVe(e,t){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/history/restore`),{method:`POST`,body:JSON.stringify({timestamp:t})})).note}function lVe(e){let t=(0,fm.c)(50),{onClose:n}=e,r=Un(),i=f(MA),a;t[0]===i?a=t[1]:(a=h(i),t[0]=i,t[1]=a);let o=a.notes,[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(!1),d=(0,j.useRef)(null),p,m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{let e=window.setTimeout(()=>d.current?.focus(),50);return()=>window.clearTimeout(e)},m=[],t[2]=p,t[3]=m):(p=t[2],m=t[3]),(0,j.useEffect)(p,m);let g;t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==s?(g=async e=>{let t=s.trim();if(!(!t||l)){u(!0);try{let i=await XBe(t,`web`);n(),e&&r(`/notes/${i.id}`)}catch{u(!1)}}},t[4]=r,t[5]=n,t[6]=l,t[7]=s,t[8]=g):g=t[8];let _=g,v;t[9]!==_||t[10]!==n?(v=e=>{if(e.key===`Escape`){e.preventDefault(),n();return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),_(!0);return}e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),_(!1))},t[9]=_,t[10]=n,t[11]=v):v=t[11];let y=v,b;t[12]===n?b=t[13]:(b=e=>{e.target===e.currentTarget&&n()},t[12]=n,t[13]=b);let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,z.jsx)(Df,{className:`h-4 w-4 text-accent`}),t[14]=x):x=t[14];let S;t[15]===o.quickCapturePlaceholder?S=t[16]:(S=(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[x,(0,z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.quickCapturePlaceholder})]}),t[15]=o.quickCapturePlaceholder,t[16]=S);let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>c(e.target.value),t[17]=C):C=t[17];let w;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(w={fieldSizing:`content`,minHeight:`6rem`,maxHeight:`40vh`},t[18]=w):w=t[18];let T;t[19]!==y||t[20]!==o.quickCapturePlaceholder||t[21]!==l||t[22]!==s?(T=(0,z.jsx)(`textarea`,{ref:d,value:s,onChange:C,onKeyDown:y,placeholder:o.quickCapturePlaceholder,disabled:l,rows:4,className:`resize-none border-none bg-transparent px-4 py-3 text-sm leading-relaxed text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:w}),t[19]=y,t[20]=o.quickCapturePlaceholder,t[21]=l,t[22]=s,t[23]=T):T=t[23];let E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,z.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Enter`}),t[24]=E):E=t[24];let D;t[25]===o.quickCaptureHintEnter?D=t[26]:(D=(0,z.jsxs)(`span`,{children:[E,` `,o.quickCaptureHintEnter]}),t[25]=o.quickCaptureHintEnter,t[26]=D);let O;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,z.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Shift+Enter`}),t[27]=O):O=t[27];let k;t[28]===o.quickCaptureHintShift?k=t[29]:(k=(0,z.jsxs)(`span`,{children:[O,` `,o.quickCaptureHintShift]}),t[28]=o.quickCaptureHintShift,t[29]=k);let A;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,z.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Esc`}),t[30]=A):A=t[30];let ee;t[31]===o.quickCaptureHintEsc?ee=t[32]:(ee=(0,z.jsxs)(`span`,{children:[A,` `,o.quickCaptureHintEsc]}),t[31]=o.quickCaptureHintEsc,t[32]=ee);let te;t[33]!==D||t[34]!==k||t[35]!==ee?(te=(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-[11px] text-fg-muted`,children:[D,k,ee]}),t[33]=D,t[34]=k,t[35]=ee,t[36]=te):te=t[36];let ne;t[37]===l?ne=t[38]:(ne=l&&(0,z.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-accent border-t-transparent`}),t[37]=l,t[38]=ne);let re;t[39]!==te||t[40]!==ne?(re=(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-4 py-2`,children:[te,ne]}),t[39]=te,t[40]=ne,t[41]=re):re=t[41];let ie;t[42]!==T||t[43]!==re||t[44]!==S?(ie=(0,z.jsxs)(`div`,{className:`flex w-full max-w-lg flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[S,T,re]}),t[42]=T,t[43]=re,t[44]=S,t[45]=ie):ie=t[45];let ae;return t[46]!==o.quickCapturePlaceholder||t[47]!==ie||t[48]!==b?(ae=(0,z.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":o.quickCapturePlaceholder,onMouseDown:b,children:ie}),t[46]=o.quickCapturePlaceholder,t[47]=ie,t[48]=b,t[49]=ae):ae=t[49],ae}function MA(e){return e.language}function NA(){let e=(0,fm.c)(8),[t,n]=(0,j.useState)(!1),r=xe(PA),i=FBe(dVe),a,o;e[0]!==i||e[1]!==r?(a=()=>{let e=e=>{RBe(e,i)&&(e.preventDefault(),r&&n(uVe))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},o=[i,r],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,j.useEffect)(a,o);let s,c;if(e[4]===r?(s=e[5],c=e[6]):(s=()=>{let e=()=>{r&&n(!0)};return window.addEventListener(`open-quick-capture`,e),()=>window.removeEventListener(`open-quick-capture`,e)},c=[r],e[4]=r,e[5]=s,e[6]=c),(0,j.useEffect)(s,c),!t)return null;let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(lVe,{onClose:()=>n(!1)}),e[7]=l):l=e[7],l}function uVe(e){return!e}function dVe(e){return e.shortcut}function PA(e){return e.token}var FA=class{_config;_callbacks;_eventSource;_shouldReconnect=!0;_reconnectCount=0;constructor(e,t){this._config=e,this._callbacks=t}get maxReconnectAttempts(){return this._config.maxReconnectAttempts??10}get autoReconnect(){return this._config.autoReconnect??!0}connect(){if(this._eventSource)return;let e=new URL(v(`/api/events`));this._config.token&&e.searchParams.set(`token`,this._config.token),this._eventSource=new EventSource(e.toString()),this._eventSource.onopen=()=>{this._reconnectCount=0},this._eventSource.addEventListener(`connected`,()=>{this._callbacks.onConnected()});for(let e of[`agent.stream`,`config.reload`,`channels.status`,`message.sent`,`session.updated`,`session.transcript_updated`,`session.created`,`dreaming.phase.start`,`dreaming.phase.end`])this._eventSource.addEventListener(e,t=>{this._callbacks.onEvent(e,t.data)});this._eventSource.onerror=()=>{this._eventSource?.readyState===EventSource.CLOSED?this._handlePermanentDisconnect():this._callbacks.onReconnecting()}}_handlePermanentDisconnect(){this._callbacks.onDisconnected(),!(!this._shouldReconnect||!this.autoReconnect)&&(this._reconnectCount++,this._reconnectCount>this.maxReconnectAttempts&&this._callbacks.onError(`Connection failed after max retries`))}disconnect(){this._shouldReconnect=!1,this._eventSource?.close(),this._eventSource=void 0}reconnect(){this._shouldReconnect=!0,this._reconnectCount=0,this.disconnect(),this._shouldReconnect=!0,setTimeout(()=>this.connect(),100)}};function IA(e,t){let n=t;try{n=JSON.parse(t)}catch{}if(e===`config.reload`){lA(n);return}let r=e.replace(/\./g,`-`);if(window.dispatchEvent(new CustomEvent(r,{detail:n})),e===`agent.stream`&&n&&typeof n==`object`&&n){let e=n;typeof e.sessionKey==`string`&&e.sessionKey.length>0&&window.dispatchEvent(new CustomEvent(`agent-stream-event`,{detail:{sessionKey:e.sessionKey,event:e.event===void 0?e:e.event}}))}}var LA=null;function RA(e){LA=e}function fVe(){LA?.reconnect()}var zA=l(()=>({connectionState:`idle`,error:null,reconnectAttempt:0}));function BA(e){zA.setState(e)}function pVe(e){let t=new FA({token:e,autoReconnect:!0,maxReconnectAttempts:10},{onConnected:()=>{BA({connectionState:`connected`,error:null,reconnectAttempt:0})},onReconnecting:()=>{BA({connectionState:`reconnecting`})},onDisconnected:()=>{BA({connectionState:`disconnected`})},onError:e=>{BA({connectionState:`error`,error:e})},onEvent:(e,t)=>{IA(e,t)}});return RA(t),BA({connectionState:`connecting`,error:null}),t.connect(),()=>{t.disconnect(),RA(null),BA({connectionState:`disconnected`,error:null})}}function VA(){RA(null),BA({connectionState:`disconnected`,error:null,reconnectAttempt:0})}function mVe(){let e=(0,fm.c)(3),t=xe(HA),n,r;e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!t){VA();return}return pVe(t)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,j.useEffect)(n,r)}function HA(e){return e.token}function hVe(){return mVe(),null}var UA=1e3,WA=1001,GA=1002,KA=1003,gVe=1004,_Ve=1005,qA=1006,vVe=1007,JA=1008,YA=1009,yVe=1010,XA=1011,ZA=1012,QA=1013,$A=1014,ej=1015,tj=1016,bVe=1017,xVe=1018,SVe=1020,CVe=35902,wVe=35899,nj=1021,rj=1022,ij=1023,aj=1026,oj=1027,sj=1028,cj=1029,lj=1030,uj=1031,dj=1033,TVe=33776,fj=33777,EVe=33778,DVe=33779,OVe=35840,kVe=35841,pj=35842,mj=35843,AVe=36196,hj=37492,jVe=37496,MVe=37488,NVe=37489,PVe=37490,FVe=37491,IVe=37808,gj=37809,_j=37810,vj=37811,yj=37812,bj=37813,xj=37814,Sj=37815,Cj=37816,LVe=37817,wj=37818,RVe=37819,zVe=37820,BVe=37821,Tj=36492,VVe=36494,Ej=36495,Dj=36283,HVe=36284,UVe=36285,Oj=36286,kj=2300,Aj=2301,jj=2302,WVe=2303,Mj=2400,Nj=2401,Pj=2402,GVe=3200,Fj=`srgb`,KVe=`srgb-linear`,Ij=`linear`,Lj=`srgb`,Rj=7680,zj=35044,Bj=2e3;function qVe(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function JVe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function J(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function YVe(){let e=J(`canvas`);return e.style.display=`block`,e}var Vj={},Hj=null;function XVe(...e){let t=`THREE.`+e.shift();Hj?Hj(`log`,t,...e):console.log(t,...e)}function Uj(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function Wj(...e){e=Uj(e);let t=`THREE.`+e.shift();if(Hj)Hj(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function Gj(...e){e=Uj(e);let t=`THREE.`+e.shift();if(Hj)Hj(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Kj(...e){let t=e.join(` `);t in Vj||(Vj[t]=!0,Wj(...e))}function qj(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var Jj={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Yj=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},Xj=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),Zj=Math.PI/180,Qj=180/Math.PI;function $j(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Xj[e&255]+Xj[e>>8&255]+Xj[e>>16&255]+Xj[e>>24&255]+`-`+Xj[t&255]+Xj[t>>8&255]+`-`+Xj[t>>16&15|64]+Xj[t>>24&255]+`-`+Xj[n&63|128]+Xj[n>>8&255]+`-`+Xj[n>>16&255]+Xj[n>>24&255]+Xj[r&255]+Xj[r>>8&255]+Xj[r>>16&255]+Xj[r>>24&255]).toLowerCase()}function eM(e,t,n){return Math.max(t,Math.min(n,e))}function tM(e,t){return(e%t+t)%t}function nM(e,t,n){return(1-n)*e+n*t}function rM(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function iM(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var aM=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=eM(this.x,e.x,t.x),this.y=eM(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=eM(this.x,e,t),this.y=eM(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eM(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(eM(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},oM=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:Wj(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(eM(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},sM=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ZVe.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ZVe.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=eM(this.x,e.x,t.x),this.y=eM(this.y,e.y,t.y),this.z=eM(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=eM(this.x,e,t),this.y=eM(this.y,e,t),this.z=eM(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eM(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return cM.copy(this).projectOnVector(e),this.sub(cM)}reflect(e){return this.sub(cM.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(eM(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},cM=new sM,ZVe=new oM,lM=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(uM.makeScale(e,t)),this}rotate(e){return this.premultiply(uM.makeRotation(-e)),this}translate(e,t){return this.premultiply(uM.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},uM=new lM,QVe=new lM().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dM=new lM().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function fM(){let e={enabled:!0,workingColorSpace:KVe,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Y(e.r),e.g=Y(e.g),e.b=Y(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=mM(e.r),e.g=mM(e.g),e.b=mM(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Ij:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Kj(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Kj(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[KVe]:{primaries:t,whitePoint:r,transfer:Ij,toXYZ:QVe,fromXYZ:dM,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Fj},outputColorSpaceConfig:{drawingBufferColorSpace:Fj}},[Fj]:{primaries:t,whitePoint:r,transfer:Lj,toXYZ:QVe,fromXYZ:dM,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Fj}}}),e}var pM=fM();function Y(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function mM(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var hM,$Ve=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{hM===void 0&&(hM=J(`canvas`)),hM.width=e.width,hM.height=e.height;let t=hM.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=hM}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=J(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Y(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Y(t[e]/255)*255):t[e]=Y(t[e]);return{data:t,width:e.width,height:e.height}}else return Wj(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},eHe=0,gM=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:eHe++}),this.uuid=$j(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(_M(r[t].image)):e.push(_M(r[t]))}else e=_M(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function _M(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?$Ve.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(Wj(`Texture: Unable to serialize Texture.`),{})}var tHe=0,vM=new sM,yM=class e extends Yj{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=WA,i=WA,a=qA,o=JA,s=ij,c=YA,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:tHe++}),this.uuid=$j(),this.name=``,this.source=new gM(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new aM(0,0),this.repeat=new aM(1,1),this.center=new aM(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new lM,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(vM).x}get height(){return this.source.getSize(vM).y}get depth(){return this.source.getSize(vM).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Wj(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Wj(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case UA:e.x-=Math.floor(e.x);break;case WA:e.x=e.x<0?0:1;break;case GA:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case UA:e.y-=Math.floor(e.y);break;case WA:e.y=e.y<0?0:1;break;case GA:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};yM.DEFAULT_IMAGE=null,yM.DEFAULT_MAPPING=300,yM.DEFAULT_ANISOTROPY=1;var bM=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=eM(this.x,e.x,t.x),this.y=eM(this.y,e.y,t.y),this.z=eM(this.z,e.z,t.z),this.w=eM(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=eM(this.x,e,t),this.y=eM(this.y,e,t),this.z=eM(this.z,e,t),this.w=eM(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eM(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},xM=class extends Yj{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qA,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new bM(0,0,e,t),this.scissorTest=!1,this.viewport=new bM(0,0,e,t),this.textures=[];let r=new yM({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:qA,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new gM(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this}dispose(){this.dispatchEvent({type:`dispose`})}},SM=class extends xM{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},CM=class extends yM{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=KA,this.minFilter=KA,this.wrapR=WA,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},nHe=class extends yM{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=KA,this.minFilter=KA,this.wrapR=WA,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},wM=class e{static{e.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/TM.setFromMatrixColumn(e,0).length(),i=1/TM.setFromMatrixColumn(e,1).length(),a=1/TM.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(rHe,e,iHe)}lookAt(e,t,n){let r=this.elements;return kM.subVectors(e,t),kM.lengthSq()===0&&(kM.z=1),kM.normalize(),DM.crossVectors(n,kM),DM.lengthSq()===0&&(Math.abs(n.z)===1?kM.x+=1e-4:kM.z+=1e-4,kM.normalize(),DM.crossVectors(n,kM)),DM.normalize(),OM.crossVectors(kM,DM),r[0]=DM.x,r[4]=OM.x,r[8]=kM.x,r[1]=DM.y,r[5]=OM.y,r[9]=kM.y,r[2]=DM.z,r[6]=OM.z,r[10]=kM.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],ee=r[10],te=r[14],ne=r[3],re=r[7],ie=r[11],ae=r[15];return i[0]=a*x+o*T+s*k+c*ne,i[4]=a*S+o*E+s*A+c*re,i[8]=a*C+o*D+s*ee+c*ie,i[12]=a*w+o*O+s*te+c*ae,i[1]=l*x+u*T+d*k+f*ne,i[5]=l*S+u*E+d*A+f*re,i[9]=l*C+u*D+d*ee+f*ie,i[13]=l*w+u*O+d*te+f*ae,i[2]=p*x+m*T+h*k+g*ne,i[6]=p*S+m*E+h*A+g*re,i[10]=p*C+m*D+h*ee+g*ie,i[14]=p*w+m*O+h*te+g*ae,i[3]=_*x+v*T+y*k+b*ne,i[7]=_*S+v*E+y*A+b*re,i[11]=_*C+v*D+y*ee+b*ie,i[15]=_*w+v*O+y*te+b*ae,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=TM.set(r[0],r[1],r[2]).length(),o=TM.set(r[4],r[5],r[6]).length(),s=TM.set(r[8],r[9],r[10]).length();i<0&&(a=-a),EM.copy(this);let c=1/a,l=1/o,u=1/s;return EM.elements[0]*=c,EM.elements[1]*=c,EM.elements[2]*=c,EM.elements[4]*=l,EM.elements[5]*=l,EM.elements[6]*=l,EM.elements[8]*=u,EM.elements[9]*=u,EM.elements[10]*=u,t.setFromRotationMatrix(EM),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=Bj,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Bj,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},TM=new sM,EM=new wM,rHe=new sM(0,0,0),iHe=new sM(1,1,1),DM=new sM,OM=new sM,kM=new sM,aHe=new wM,AM=new oM,jM=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(eM(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-eM(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(eM(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-eM(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(eM(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-eM(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:Wj(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return aHe.makeRotationFromQuaternion(e),this.setFromRotationMatrix(aHe,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return AM.setFromEuler(this),this.setFromQuaternion(AM,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};jM.DEFAULT_ORDER=`XYZ`;var MM=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},oHe=0,sHe=new sM,NM=new oM,PM=new wM,FM=new sM,IM=new sM,cHe=new sM,lHe=new oM,uHe=new sM(1,0,0),dHe=new sM(0,1,0),fHe=new sM(0,0,1),pHe={type:`added`},mHe={type:`removed`},LM={type:`childadded`,child:null},RM={type:`childremoved`,child:null},zM=class e extends Yj{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:oHe++}),this.uuid=$j(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new sM,n=new jM,r=new oM,i=new sM(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new wM},normalMatrix:{value:new lM}}),this.matrix=new wM,this.matrixWorld=new wM,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new MM,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return NM.setFromAxisAngle(e,t),this.quaternion.multiply(NM),this}rotateOnWorldAxis(e,t){return NM.setFromAxisAngle(e,t),this.quaternion.premultiply(NM),this}rotateX(e){return this.rotateOnAxis(uHe,e)}rotateY(e){return this.rotateOnAxis(dHe,e)}rotateZ(e){return this.rotateOnAxis(fHe,e)}translateOnAxis(e,t){return sHe.copy(e).applyQuaternion(this.quaternion),this.position.add(sHe.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(uHe,e)}translateY(e){return this.translateOnAxis(dHe,e)}translateZ(e){return this.translateOnAxis(fHe,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(PM.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?FM.copy(e):FM.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),IM.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?PM.lookAt(IM,FM,this.up):PM.lookAt(FM,IM,this.up),this.quaternion.setFromRotationMatrix(PM),r&&(PM.extractRotation(r.matrixWorld),NM.setFromRotationMatrix(PM),this.quaternion.premultiply(NM.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(Gj(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(pHe),LM.child=e,this.dispatchEvent(LM),LM.child=null):Gj(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(mHe),RM.child=e,this.dispatchEvent(RM),RM.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),PM.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),PM.multiply(e.parent.matrixWorld)),e.applyMatrix4(PM),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(pHe),LM.child=e,this.dispatchEvent(LM),LM.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(IM,e,cHe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(IM,lHe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};zM.DEFAULT_UP=new sM(0,1,0),zM.DEFAULT_MATRIX_AUTO_UPDATE=!0,zM.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var BM=class extends zM{constructor(){super(),this.isGroup=!0,this.type=`Group`}},VM={type:`move`},HM=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new BM,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new BM,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new sM,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new sM),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new BM,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new sM,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new sM,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(VM)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new BM;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},hHe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},UM={h:0,s:0,l:0},WM={h:0,s:0,l:0};function GM(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var KM=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Fj){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pM.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=pM.workingColorSpace){return this.r=e,this.g=t,this.b=n,pM.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=pM.workingColorSpace){if(e=tM(e,1),t=eM(t,0,1),n=eM(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=GM(i,r,e+1/3),this.g=GM(i,r,e),this.b=GM(i,r,e-1/3)}return pM.colorSpaceToWorking(this,r),this}setStyle(e,t=Fj){function n(t){t!==void 0&&parseFloat(t)<1&&Wj(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:Wj(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);Wj(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fj){let n=hHe[e.toLowerCase()];return n===void 0?Wj(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Y(e.r),this.g=Y(e.g),this.b=Y(e.b),this}copyLinearToSRGB(e){return this.r=mM(e.r),this.g=mM(e.g),this.b=mM(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fj){return pM.workingToColorSpace(qM.copy(this),e),Math.round(eM(qM.r*255,0,255))*65536+Math.round(eM(qM.g*255,0,255))*256+Math.round(eM(qM.b*255,0,255))}getHexString(e=Fj){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pM.workingColorSpace){pM.workingToColorSpace(qM.copy(this),t);let n=qM.r,r=qM.g,i=qM.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=pM.workingColorSpace){return pM.workingToColorSpace(qM.copy(this),t),e.r=qM.r,e.g=qM.g,e.b=qM.b,e}getStyle(e=Fj){pM.workingToColorSpace(qM.copy(this),e);let t=qM.r,n=qM.g,r=qM.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(UM),this.setHSL(UM.h+e,UM.s+t,UM.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(UM),e.getHSL(WM);let n=nM(UM.h,WM.h,t),r=nM(UM.s,WM.s,t),i=nM(UM.l,WM.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},qM=new KM;KM.NAMES=hHe;var gHe=class extends zM{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new jM,this.environmentIntensity=1,this.environmentRotation=new jM,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},JM=new sM,YM=new sM,_He=new sM,XM=new sM,ZM=new sM,QM=new sM,vHe=new sM,$M=new sM,eN=new sM,tN=new sM,yHe=new bM,bHe=new bM,nN=new bM,rN=class e{constructor(e=new sM,t=new sM,n=new sM){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),JM.subVectors(e,t),r.cross(JM);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){JM.subVectors(r,t),YM.subVectors(n,t),_He.subVectors(e,t);let a=JM.dot(JM),o=JM.dot(YM),s=JM.dot(_He),c=YM.dot(YM),l=YM.dot(_He),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,XM)===null?!1:XM.x>=0&&XM.y>=0&&XM.x+XM.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,XM)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,XM.x),s.addScaledVector(a,XM.y),s.addScaledVector(o,XM.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return yHe.setScalar(0),bHe.setScalar(0),nN.setScalar(0),yHe.fromBufferAttribute(e,t),bHe.fromBufferAttribute(e,n),nN.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(yHe,i.x),a.addScaledVector(bHe,i.y),a.addScaledVector(nN,i.z),a}static isFrontFacing(e,t,n,r){return JM.subVectors(n,t),YM.subVectors(e,t),JM.cross(YM).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return JM.subVectors(this.c,this.b),YM.subVectors(this.a,this.b),JM.cross(YM).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;ZM.subVectors(r,n),QM.subVectors(i,n),$M.subVectors(e,n);let s=ZM.dot($M),c=QM.dot($M);if(s<=0&&c<=0)return t.copy(n);eN.subVectors(e,r);let l=ZM.dot(eN),u=QM.dot(eN);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(ZM,a);tN.subVectors(e,i);let f=ZM.dot(tN),p=QM.dot(tN);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(QM,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return vHe.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(vHe,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(ZM,a).addScaledVector(QM,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},iN=class{constructor(e=new sM(1/0,1/0,1/0),t=new sM(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(oN.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(oN.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=oN.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,oN):oN.fromBufferAttribute(r,t),oN.applyMatrix4(e.matrixWorld),this.expandByPoint(oN);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),sN.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),sN.copy(e.boundingBox)),sN.applyMatrix4(e.matrixWorld),this.union(sN)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,oN),oN.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(mN),hN.subVectors(this.max,mN),cN.subVectors(e.a,mN),lN.subVectors(e.b,mN),uN.subVectors(e.c,mN),dN.subVectors(lN,cN),fN.subVectors(uN,lN),pN.subVectors(cN,uN);let t=[0,-dN.z,dN.y,0,-fN.z,fN.y,0,-pN.z,pN.y,dN.z,0,-dN.x,fN.z,0,-fN.x,pN.z,0,-pN.x,-dN.y,dN.x,0,-fN.y,fN.x,0,-pN.y,pN.x,0];return!xHe(t,cN,lN,uN,hN)||(t=[1,0,0,0,1,0,0,0,1],!xHe(t,cN,lN,uN,hN))?!1:(gN.crossVectors(dN,fN),t=[gN.x,gN.y,gN.z],xHe(t,cN,lN,uN,hN))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,oN).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(oN).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(aN[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),aN[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),aN[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),aN[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),aN[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),aN[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),aN[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),aN[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(aN),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},aN=[new sM,new sM,new sM,new sM,new sM,new sM,new sM,new sM],oN=new sM,sN=new iN,cN=new sM,lN=new sM,uN=new sM,dN=new sM,fN=new sM,pN=new sM,mN=new sM,hN=new sM,gN=new sM,_N=new sM;function xHe(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){_N.fromArray(e,a);let o=i.x*Math.abs(_N.x)+i.y*Math.abs(_N.y)+i.z*Math.abs(_N.z),s=t.dot(_N),c=n.dot(_N),l=r.dot(_N);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var vN=new sM,yN=new aM,bN=0,xN=class extends Yj{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:bN++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=zj,this.updateRanges=[],this.gpuType=ej,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)yN.fromBufferAttribute(this,t),yN.applyMatrix3(e),this.setXY(t,yN.x,yN.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)vN.fromBufferAttribute(this,t),vN.applyMatrix3(e),this.setXYZ(t,vN.x,vN.y,vN.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)vN.fromBufferAttribute(this,t),vN.applyMatrix4(e),this.setXYZ(t,vN.x,vN.y,vN.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)vN.fromBufferAttribute(this,t),vN.applyNormalMatrix(e),this.setXYZ(t,vN.x,vN.y,vN.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)vN.fromBufferAttribute(this,t),vN.transformDirection(e),this.setXYZ(t,vN.x,vN.y,vN.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=rM(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=iM(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=rM(t,this.array)),t}setX(e,t){return this.normalized&&(t=iM(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=rM(t,this.array)),t}setY(e,t){return this.normalized&&(t=iM(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=rM(t,this.array)),t}setZ(e,t){return this.normalized&&(t=iM(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=rM(t,this.array)),t}setW(e,t){return this.normalized&&(t=iM(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=iM(t,this.array),n=iM(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=iM(t,this.array),n=iM(n,this.array),r=iM(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=iM(t,this.array),n=iM(n,this.array),r=iM(r,this.array),i=iM(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:`dispose`})}},SN=class extends xN{constructor(e,t,n){super(new Uint16Array(e),t,n)}},CN=class extends xN{constructor(e,t,n){super(new Uint32Array(e),t,n)}},wN=class extends xN{constructor(e,t,n){super(new Float32Array(e),t,n)}},TN=new iN,EN=new sM,DN=new sM,ON=class{constructor(e=new sM,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?TN.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;EN.subVectors(e,this.center);let t=EN.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(EN,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(DN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(EN.copy(e.center).add(DN)),this.expandByPoint(EN.copy(e.center).sub(DN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},kN=0,AN=new wM,SHe=new zM,jN=new sM,MN=new iN,NN=new iN,PN=new sM,FN=class e extends Yj{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kN++}),this.uuid=$j(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(qVe(e)?CN:SN)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new lM().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return AN.makeRotationFromQuaternion(e),this.applyMatrix4(AN),this}rotateX(e){return AN.makeRotationX(e),this.applyMatrix4(AN),this}rotateY(e){return AN.makeRotationY(e),this.applyMatrix4(AN),this}rotateZ(e){return AN.makeRotationZ(e),this.applyMatrix4(AN),this}translate(e,t,n){return AN.makeTranslation(e,t,n),this.applyMatrix4(AN),this}scale(e,t,n){return AN.makeScale(e,t,n),this.applyMatrix4(AN),this}lookAt(e){return SHe.lookAt(e),SHe.updateMatrix(),this.applyMatrix4(SHe.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(jN).negate(),this.translate(jN.x,jN.y,jN.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new wN(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&Wj(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new iN);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Gj(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new sM(-1/0,-1/0,-1/0),new sM(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];MN.setFromBufferAttribute(n),this.morphTargetsRelative?(PN.addVectors(this.boundingBox.min,MN.min),this.boundingBox.expandByPoint(PN),PN.addVectors(this.boundingBox.max,MN.max),this.boundingBox.expandByPoint(PN)):(this.boundingBox.expandByPoint(MN.min),this.boundingBox.expandByPoint(MN.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Gj(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ON);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Gj(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new sM,1/0);return}if(e){let n=this.boundingSphere.center;if(MN.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];NN.setFromBufferAttribute(n),this.morphTargetsRelative?(PN.addVectors(MN.min,NN.min),MN.expandByPoint(PN),PN.addVectors(MN.max,NN.max),MN.expandByPoint(PN)):(MN.expandByPoint(NN.min),MN.expandByPoint(NN.max))}MN.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)PN.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(PN));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)PN.fromBufferAttribute(a,t),o&&(jN.fromBufferAttribute(e,t),PN.add(jN)),r=Math.max(r,n.distanceToSquared(PN))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Gj(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Gj(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new xN(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new sM,s[e]=new sM;let c=new sM,l=new sM,u=new sM,d=new aM,f=new aM,p=new aM,m=new sM,h=new sM;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new sM,y=new sM,b=new sM,x=new sM;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new xN(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new sM,i=new sM,a=new sM,o=new sM,s=new sM,c=new sM,l=new sM,u=new sM;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)PN.fromBufferAttribute(e,t),PN.normalize(),e.setXYZ(t,PN.x,PN.y,PN.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new xN(a,r,i)}if(this.index===null)return Wj(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},CHe=0,IN=class extends Yj{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:CHe++}),this.uuid=$j(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new KM(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Rj,this.stencilZFail=Rj,this.stencilZPass=Rj,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Wj(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Wj(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},LN=new sM,RN=new sM,zN=new sM,BN=new sM,VN=new sM,HN=new sM,UN=new sM,WN=class{constructor(e=new sM,t=new sM(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,LN)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=LN.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(LN.copy(this.origin).addScaledVector(this.direction,t),LN.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){RN.copy(e).add(t).multiplyScalar(.5),zN.copy(t).sub(e).normalize(),BN.copy(this.origin).sub(RN);let i=e.distanceTo(t)*.5,a=-this.direction.dot(zN),o=BN.dot(this.direction),s=-BN.dot(zN),c=BN.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(RN).addScaledVector(zN,d),f}intersectSphere(e,t){LN.subVectors(e.center,this.origin);let n=LN.dot(this.direction),r=LN.dot(LN)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,LN)!==null}intersectTriangle(e,t,n,r,i){VN.subVectors(t,e),HN.subVectors(n,e),UN.crossVectors(VN,HN);let a=this.direction.dot(UN),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;BN.subVectors(this.origin,e);let s=o*this.direction.dot(HN.crossVectors(BN,HN));if(s<0)return null;let c=o*this.direction.dot(VN.cross(BN));if(c<0||s+c>a)return null;let l=-o*BN.dot(UN);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},GN=class extends IN{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new KM(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jM,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},KN=new wM,qN=new WN,JN=new ON,YN=new sM,XN=new sM,ZN=new sM,QN=new sM,$N=new sM,eP=new sM,tP=new sM,nP=new sM,rP=class extends zM{constructor(e=new FN,t=new GN){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){eP.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&($N.fromBufferAttribute(s,e),a?eP.addScaledVector($N,r):eP.addScaledVector($N.sub(t),r))}t.add(eP)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),JN.copy(n.boundingSphere),JN.applyMatrix4(i),qN.copy(e.ray).recast(e.near),!(JN.containsPoint(qN.origin)===!1&&(qN.intersectSphere(JN,YN)===null||qN.origin.distanceToSquared(YN)>(e.far-e.near)**2))&&(KN.copy(i).invert(),qN.copy(e.ray).applyMatrix4(KN),!(n.boundingBox!==null&&qN.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,qN)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=aP(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=aP(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=aP(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=aP(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function iP(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;nP.copy(s),nP.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(nP);return l<n.near||l>n.far?null:{distance:l,point:nP.clone(),object:e}}function aP(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,XN),e.getVertexPosition(c,ZN),e.getVertexPosition(l,QN);let u=iP(e,t,n,r,XN,ZN,QN,tP);if(u){let e=new sM;rN.getBarycoord(tP,XN,ZN,QN,e),i&&(u.uv=rN.getInterpolatedAttribute(i,s,c,l,e,new aM)),a&&(u.uv1=rN.getInterpolatedAttribute(a,s,c,l,e,new aM)),o&&(u.normal=rN.getInterpolatedAttribute(o,s,c,l,e,new sM),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new sM,materialIndex:0};rN.getNormal(XN,ZN,QN,t.normal),u.face=t,u.barycoord=e}return u}var oP=class extends yM{constructor(e=null,t=1,n=1,r,i,a,o,s,c=KA,l=KA,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},sP=new sM,cP=new sM,wHe=new lM,lP=class{constructor(e=new sM(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=sP.subVectors(n,t).cross(cP.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(sP),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||wHe.getNormalMatrix(e),r=this.coplanarPoint(sP).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},uP=new ON,THe=new aM(.5,.5),dP=new sM,EHe=class{constructor(e=new lP,t=new lP,n=new lP,r=new lP,i=new lP,a=new lP){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Bj,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),uP.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),uP.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(uP)}intersectsSprite(e){return uP.center.set(0,0,0),uP.radius=.7071067811865476+THe.distanceTo(e.center),uP.applyMatrix4(e.matrixWorld),this.intersectsSphere(uP)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(dP.x=r.normal.x>0?e.max.x:e.min.x,dP.y=r.normal.y>0?e.max.y:e.min.y,dP.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(dP)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},fP=class extends IN{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new KM(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},pP=new sM,mP=new sM,hP=new wM,gP=new WN,_P=new ON,vP=new sM,yP=new sM,bP=class extends zM{constructor(e=new FN,t=new fP){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)pP.fromBufferAttribute(t,e-1),mP.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=pP.distanceTo(mP);e.setAttribute(`lineDistance`,new wN(n,1))}else Wj(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),_P.copy(n.boundingSphere),_P.applyMatrix4(r),_P.radius+=i,e.ray.intersectsSphere(_P)===!1)return;hP.copy(r).invert(),gP.copy(e.ray).applyMatrix4(hP);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=xP(this,e,gP,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=xP(this,e,gP,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=xP(this,e,gP,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=xP(this,e,gP,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function xP(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(pP.fromBufferAttribute(s,i),mP.fromBufferAttribute(s,a),n.distanceSqToSegment(pP,mP,vP,yP)>r)return;vP.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(vP);if(!(c<t.near||c>t.far))return{distance:c,point:yP.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var SP=new sM,DHe=new sM,CP=class extends bP{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)SP.fromBufferAttribute(t,e),DHe.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+SP.distanceTo(DHe);e.setAttribute(`lineDistance`,new wN(n,1))}else Wj(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},wP=class extends IN{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new KM(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},OHe=new wM,TP=new WN,EP=new ON,DP=new sM,OP=class extends zM{constructor(e=new FN,t=new wP){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),EP.copy(n.boundingSphere),EP.applyMatrix4(r),EP.radius+=i,e.ray.intersectsSphere(EP)===!1)return;OHe.copy(r).invert(),TP.copy(e.ray).applyMatrix4(OHe);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);DP.fromBufferAttribute(l,n),kP(DP,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)DP.fromBufferAttribute(l,a),kP(DP,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function kP(e,t,n,r,i,a,o){let s=TP.distanceSqToPoint(e);if(s<n){let n=new sM;TP.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var kHe=class extends yM{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},AP=class extends yM{constructor(e,t,n=$A,r,i,a,o=KA,s=KA,c,l=aj,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new gM(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},jP=class extends AP{constructor(e,t=$A,n=301,r,i,a=KA,o=KA,s,c=aj){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},MP=class extends yM{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},NP=class e extends FN{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new wN(c,3)),this.setAttribute(`normal`,new wN(l,3)),this.setAttribute(`uv`,new wN(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new sM;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},PP=class e extends FN{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new wN(p,3)),this.setAttribute(`normal`,new wN(m,3)),this.setAttribute(`uv`,new wN(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}};function FP(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(LP(i))i.isRenderTargetTexture?(Wj(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i))if(LP(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice();else t[n][r]=i}}return t}function IP(e){let t={};for(let n=0;n<e.length;n++){let r=FP(e[n]);for(let e in r)t[e]=r[e]}return t}function LP(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function RP(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function AHe(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:pM.workingColorSpace}var jHe={clone:FP,merge:IP},MHe=`void main() {
|
|
231
|
+
`).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`%%`));switch(a){case`sequence`:return RE(zLe(KIe(o),t),n,r,i);case`class`:return GE(UE(qIe(o),t),n,r,i);case`er`:return aRe(iRe(ZIe(o),t),n,r,i);case`xychart`:return gRe(pRe(tLe(o),t),n,r,i,t.interactive??!1);default:return CLe(SLe(RIe(e),t),n,r,i)}}function bRe(e){try{return{html:`<div class="markdown-mermaid" data-mermaid-diagram>${yD(e.trim(),{bg:`var(--color-surface-hover)`,fg:`var(--color-fg)`,accent:`var(--color-accent-fg)`,border:`var(--color-edge)`,transparent:!0})}</div>`,error:!1}}catch{return{html:`<div class="markdown-mermaid markdown-mermaid-fallback" data-mermaid-fallback><pre><code class="hljs language-mermaid">${bD(e)}</code></pre></div>`,error:!0}}}function bD(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function xD(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function SD(e){return e.replace(/<pre><code class="(?:hljs\s+)?language-mermaid">([\s\S]*?)<\/code><\/pre>/g,(e,t)=>bRe(xD(t)).html)}fw.use(FNe({emptyLangClass:`hljs`,langPrefix:`hljs language-`,highlight(e,t){let n=(t??``).trim()||`plaintext`,r=hT.getLanguage(n)?n:`plaintext`;return hT.highlight(e,{language:r}).value}}));var CD={gfm:!0,breaks:!1,async:!1};function xRe(e,t){return SD(fw.parse(e,{...CD,...t,async:!1}))}var wD=!1;function SRe(){wD||typeof window>`u`||(wD=!0,HMe.addHook(`afterSanitizeAttributes`,e=>{if(e.tagName!==`A`||!e.hasAttribute(`href`))return;let t=e.getAttribute(`href`)??``;try{let n=new URL(t,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`||n.origin===window.location.origin)return;e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)}catch{}}))}SRe();var TD=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,ED=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>`;function DD(e){return e.querySelector(`code`)?.textContent??e.textContent??``}function CRe(e){let t=e.querySelector(`code`);if(!t?.className)return`plaintext`;for(let e of t.className.split(/\s+/))if(e.startsWith(`language-`))return e.slice(9).trim()||`plaintext`;return`plaintext`}function OD(e,t){let n=document.createDocumentFragment(),r=document.createElement(`span`);r.className=`markdown-code-copy-inner`,r.innerHTML=e===`idle`?TD:ED;let i=document.createElement(`span`);return i.className=`markdown-code-copy-label`,i.textContent=e===`idle`?t.copy:t.copied,n.appendChild(r),n.appendChild(i),n}function kD(e){e.querySelectorAll(`[data-md-code-block]`).forEach(e=>{let t=e.querySelector(`:scope > pre`),n=e.parentNode;t&&n&&(n.insertBefore(t,e),e.remove())})}function wRe(e,t){let n=e.querySelectorAll(`.markdown-body pre`),r=[];for(let e of n){if(e.closest(`[data-md-code-block]`)||e.closest(`[data-mermaid-fallback]`))continue;let n=e.parentNode;if(!n)continue;let i=document.createElement(`div`);i.className=`markdown-code-block`,i.setAttribute(`data-md-code-block`,``);let a=document.createElement(`div`);a.className=`markdown-code-block-header`;let o=document.createElement(`span`);o.className=`markdown-code-block-lang`,o.textContent=CRe(e);let s=document.createElement(`button`);s.type=`button`,s.className=`markdown-code-copy-btn`,s.dataset.mdCodeCopy=``,s.title=t.copy,s.setAttribute(`aria-label`,t.copy),s.replaceChildren(OD(`idle`,t));let c=n=>{n.preventDefault(),n.stopPropagation(),Sh(DD(e)).then(e=>{!e||!s.isConnected||(s.replaceChildren(OD(`copied`,t)),s.title=t.copied,s.setAttribute(`aria-label`,t.copied),window.setTimeout(()=>{s.isConnected&&(s.replaceChildren(OD(`idle`,t)),s.title=t.copy,s.setAttribute(`aria-label`,t.copy))},2e3))})};s.addEventListener(`click`,c),a.appendChild(o),a.appendChild(s),i.appendChild(a),n.insertBefore(i,e),i.appendChild(e),r.push(()=>{s.removeEventListener(`click`,c);let t=e.parentElement;t?.matches(`[data-md-code-block]`)&&t.parentNode&&(t.parentNode.insertBefore(e,t),t.remove())})}return()=>{for(let e of r)e()}}function TRe(e){let t=(0,fm.c)(21),{content:n,compact:r,breaks:i,className:a,codeCopy:o}=e,s=r===void 0?!1:r,c=i===void 0?!1:i,l=o===void 0?!0:o,u=f(ERe),d;t[0]===u?d=t[1]:(d=h(u),t[0]=u,t[1]=d);let p=d.chat,m;t[2]!==p.codeBlockCopy||t[3]!==p.messageCopied?(m={copy:p.codeBlockCopy,copied:p.messageCopied},t[2]=p.codeBlockCopy,t[3]=p.messageCopied,t[4]=m):m=t[4];let g=m,_;bb0:{if(!n.trim()){_=``;break bb0}let e;if(t[5]!==c||t[6]!==n){let r=xRe(n,c?{breaks:!0}:void 0);e=HMe.sanitize(r,{USE_PROFILES:{html:!0,svg:!0},ADD_ATTR:`viewBox.xmlns.d.fill.stroke.transform.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.x.y.width.height.rx.ry.cx.cy.r.x1.y1.x2.y2.offset.stop-color.stop-opacity.points.text-anchor.dominant-baseline.font-size.font-family.font-weight.font-style.class.id.style.markerWidth.markerHeight.refX.refY.orient.markerUnits.text-decoration.opacity.clip-path.mask.filter.preserveAspectRatio.xmlns:xlink.xlink:href.xml:space`.split(`.`)}),t[5]=c,t[6]=n,t[7]=e}else e=t[7];_=e}let v=_,y=(0,j.useRef)(null),b,x;t[8]!==l||t[9]!==g||t[10]!==v?(b=()=>{let e=y.current;if(e&&(kD(e),!(!l||!v)))return wRe(e,g)},x=[l,v,g],t[8]=l,t[9]=g,t[10]=v,t[11]=b,t[12]=x):(b=t[11],x=t[12]),(0,j.useLayoutEffect)(b,x);let S=s?`markdown-compact`:``,C=a??``,w;t[13]!==C||t[14]!==S?(w=[`markdown-body`,S,C].filter(Boolean),t[13]=C,t[14]=S,t[15]=w):w=t[15];let T=w.join(` `),E;t[16]===v?E=t[17]:(E={__html:v},t[16]=v,t[17]=E);let D;return t[18]!==T||t[19]!==E?(D=(0,z.jsx)(`div`,{ref:y,children:(0,z.jsx)(`div`,{className:T,dangerouslySetInnerHTML:E})}),t[18]=T,t[19]=E,t[20]=D):D=t[20],D}function ERe(e){return e.language}var AD=(0,j.memo)(TRe);AD.displayName=`MarkdownView`;function DRe(e){let t=(0,fm.c)(15),{initialContent:n,onSave:r,isDark:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=()=>n,t[0]=n,t[1]=o);let[s,c]=(0,j.useState)(o),l;t[2]===r?l=t[3]:(l=e=>{r?.(e)},t[2]=r,t[3]=l);let u=RS(l,500),d;t[4]===u?d=t[5]:(d=e=>{c(e),u(e)},t[4]=u,t[5]=d);let f=d,p;t[6]!==f||t[7]!==n||t[8]!==a?(p=(0,z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,z.jsx)(YS,{initialContent:n,onChange:f,isDark:a})}),t[6]=f,t[7]=n,t[8]=a,t[9]=p):p=t[9];let m;t[10]===s?m=t[11]:(m=(0,z.jsx)(`div`,{className:`bg-surface min-w-0 flex-1 overflow-y-auto px-6 py-4`,children:(0,z.jsx)(AD,{content:s})}),t[10]=s,t[11]=m);let h;return t[12]!==p||t[13]!==m?(h=(0,z.jsxs)(`div`,{className:`flex h-full divide-x divide-edge`,children:[p,m]}),t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function jD(e){let t=(0,fm.c)(22),{message:n,downloadLabel:r,onDownload:i,openSystemLabel:a,onOpenWithSystemApp:o,canOpenWithSystemApp:s}=e,c=s===void 0?!0:s,l;t[0]!==c||t[1]!==o||t[2]!==a?(l=Gh()&&c&&typeof o==`function`&&typeof a==`string`&&a.length>0,t[0]=c,t[1]=o,t[2]=a,t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=fh(`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-hover/60 p-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge`),t[4]=d):d=t[4];let f;t[5]===n?f=t[6]:(f=(0,z.jsx)(`p`,{className:`min-w-0 text-xs leading-relaxed text-fg-muted`,children:n}),t[5]=n,t[6]=f);let p;t[7]!==o||t[8]!==a||t[9]!==u?(p=u?(0,z.jsxs)(`button`,{type:`button`,className:fh(`inline-flex items-center gap-1.5 rounded-md border border-edge bg-surface-panel px-3 py-1.5 text-xs font-medium text-fg shadow-sm dark:border-edge`,yh.transition,yh.press,yh.focusRingPanel),onClick:()=>void o?.(),children:[(0,z.jsx)(aa,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),a]}):null,t[7]=o,t[8]=a,t[9]=u,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=fh(`inline-flex items-center gap-1.5 rounded-md border border-accent bg-accent px-3 py-1.5 text-xs font-medium text-white shadow-sm`,yh.transition,yh.press,yh.focusRingPanel),t[11]=m):m=t[11];let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,z.jsx)(na,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[12]=h):h=t[12];let g;t[13]!==r||t[14]!==i?(g=(0,z.jsxs)(`button`,{type:`button`,className:m,onClick:i,children:[h,r]}),t[13]=r,t[14]=i,t[15]=g):g=t[15];let _;t[16]!==p||t[17]!==g?(_=(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[p,g]}),t[16]=p,t[17]=g,t[18]=_):_=t[18];let v;return t[19]!==f||t[20]!==_?(v=(0,z.jsxs)(`div`,{className:d,children:[f,_]}),t[19]=f,t[20]=_,t[21]=v):v=t[21],v}function MD(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}function ND(e){let t=(0,fm.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=MD(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(PD),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,z.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,z.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,z.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function PD(e){return(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function FD(e,t){return`\`\`\`${{".ts":`typescript`,".js":`javascript`,".json":`json`}[t]??`plaintext`}\n${e}\n\`\`\``}function ID(e){let t=(0,fm.c)(23),{layout:n,text:r,showTruncationBar:i,onDownload:a,downloadLabel:o,truncationMessage:s,truncatedCaption:c,slideLabel:l,emptySlideLabel:u,openSystemLabel:d,onOpenWithSystemApp:f,canOpenWithSystemApp:p}=e,m=n===`workspace`?`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,h=n===`workspace`?`min-h-0 flex-1 overflow-auto p-2`:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle p-4 dark:border-edge`,g;t[0]!==p||t[1]!==o||t[2]!==a||t[3]!==f||t[4]!==d||t[5]!==i||t[6]!==s?(g=i?(0,z.jsx)(jD,{message:s,downloadLabel:o,onDownload:a,openSystemLabel:d,onOpenWithSystemApp:f,canOpenWithSystemApp:p}):null,t[0]=p,t[1]=o,t[2]=a,t[3]=f,t[4]=d,t[5]=i,t[6]=s,t[7]=g):g=t[7];let _;t[8]!==i||t[9]!==c?(_=i?(0,z.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:c}):null,t[8]=i,t[9]=c,t[10]=_):_=t[10];let v;t[11]!==u||t[12]!==l||t[13]!==r?(v=(0,z.jsx)(ND,{text:r,slideLabel:l,emptySlideLabel:u}),t[11]=u,t[12]=l,t[13]=r,t[14]=v):v=t[14];let y;t[15]!==h||t[16]!==_||t[17]!==v?(y=(0,z.jsxs)(`div`,{className:h,children:[_,v]}),t[15]=h,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==m||t[20]!==g||t[21]!==y?(b=(0,z.jsxs)(`div`,{className:m,children:[g,y]}),t[19]=m,t[20]=g,t[21]=y,t[22]=b):b=t[22],b}function LD(e){let{context:t,language:n,resolvedTheme:r,fileKey:i,fileName:a,loading:o,loadError:s,previewKind:c,textContent:l,binaryBuffer:u,showExtractedText:d,extractedText:f,extractedTextTruncated:p,workspaceEditing:m,pptxText:g,pptxTruncated:_,pptxError:v,actions:y}=e,b=h(n),x=(0,j.useMemo)(()=>BS(a),[a]),S=x===`.md`,C=x===`.html`||x===`.htm`,w=(0,j.useRef)(null),{error:T,excelTruncated:E}=Hje({language:n,buffer:u,kind:c===`pdf`||c===`excel`||c===`docx`?c:null,fileKey:i,containerEl:w.current}),D=zje((0,j.useMemo)(()=>{if(!u||c!==`image`)return null;let e=jy(a)??`image/png`;return new Blob([u],{type:e})},[u,c,a])),O=!!y.onOpenWithSystemApp&&(y.canOpenWithSystemApp??!0)&&t===`workspace`,k=t===`workspace`?b.workspace.openElsewhereHint:b.chat.attachmentPreviewOpenElsewhereHint,A=b.chat.attachmentPreviewDownloadFull,ee=t===`workspace`?b.workspace.openSystemApp:void 0,te=e=>b.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),ne=(0,z.jsx)(jD,{message:k,downloadLabel:A,onDownload:y.onDownload,openSystemLabel:ee,onOpenWithSystemApp:y.onOpenWithSystemApp,canOpenWithSystemApp:O}),re=null;if(o&&c==null)re=(0,z.jsx)(`p`,{className:`px-4 py-6 text-sm text-fg-muted`,children:b.chat.loading});else if(s)re=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[ne,(0,z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:(t===`workspace`?b.workspace.loadError:b.chat.attachmentPreviewLoadError)+`: `+s})]});else if(t===`attachment`&&d&&c!==`image`){let e=f||b.chat.attachmentPreviewNoText,t=c===`pptx`&&e.length>3e5?e.slice(0,Ey):e,n=!!p||c===`pptx`&&e.length>3e5;re=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:[n&&c===`pptx`?(0,z.jsx)(jD,{message:b.chat.attachmentPreviewOpenElsewhereTruncated,downloadLabel:b.chat.attachmentPreviewDownloadFull,onDownload:y.onDownload}):null,(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-hover/40 p-4 dark:border-edge`,children:[n&&c===`pptx`?(0,z.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:b.chat.attachmentPreviewPptxTruncated}):null,(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted`,children:t})]})]})}else if(c===`binaryOnly`&&u)re=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:(0,z.jsx)(jD,{message:t===`workspace`?b.workspace.cannotPreviewType+` `+b.workspace.openElsewhereHint:b.chat.attachmentPreviewOpenElsewhereHint,downloadLabel:b.chat.attachmentPreviewDownloadFull,onDownload:y.onDownload,openSystemLabel:ee,onOpenWithSystemApp:y.onOpenWithSystemApp,canOpenWithSystemApp:O})});else if(u&&c===`image`&&D)re=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,children:(0,z.jsx)(`img`,{src:D,alt:``,className:t===`workspace`?`max-h-[min(100%,calc(100dvh-9rem))] w-auto max-w-full object-contain`:`max-h-full max-w-full object-contain`})});else if(u&&c===`pptx`)if(t===`attachment`){let e=f||b.chat.attachmentPreviewNoText,t=Ey,n=!!p||e.length>t;re=(0,z.jsx)(ID,{layout:`attachment`,text:e.length>t?e.slice(0,t):e,showTruncationBar:n,onDownload:y.onDownload,downloadLabel:A,truncationMessage:b.chat.attachmentPreviewOpenElsewhereTruncated,truncatedCaption:b.chat.attachmentPreviewPptxTruncated,slideLabel:te,emptySlideLabel:b.chat.attachmentPreviewPptxEmptySlide})}else re=v?(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[ne,(0,z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:(t===`workspace`?b.workspace.loadError:b.chat.attachmentPreviewLoadError)+`: `+v})]}):g==null?(0,z.jsx)(`p`,{className:`px-4 py-6 text-sm text-fg-muted`,children:b.chat.loading}):(0,z.jsx)(ID,{layout:`workspace`,text:g,showTruncationBar:!!_,onDownload:y.onDownload,downloadLabel:A,truncationMessage:b.chat.attachmentPreviewOpenElsewhereTruncated,truncatedCaption:b.chat.attachmentPreviewPptxTruncated,slideLabel:te,emptySlideLabel:b.chat.attachmentPreviewPptxEmptySlide,openSystemLabel:ee,onOpenWithSystemApp:y.onOpenWithSystemApp,canOpenWithSystemApp:O});else if(u&&(c===`pdf`||c===`docx`))re=T?(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[ne,(0,z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:(t===`workspace`?b.workspace.loadError:b.chat.attachmentPreviewLoadError)+`: `+T})]}):(0,z.jsx)(`div`,{ref:w,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`});else if(u&&c===`excel`)re=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:T?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 px-2`,children:[ne,(0,z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T})]}):(0,z.jsxs)(z.Fragment,{children:[E?(0,z.jsx)(jD,{message:b.chat.attachmentPreviewOpenElsewhereTruncated,downloadLabel:b.chat.attachmentPreviewDownloadFull,onDownload:y.onDownload,openSystemLabel:ee,onOpenWithSystemApp:y.onOpenWithSystemApp,canOpenWithSystemApp:O}):null,(0,z.jsx)(`div`,{ref:w,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`})]})});else if(l!==null&&c===`text`)if(t===`workspace`&&S&&m?.markdownEditMode)re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,z.jsx)(DRe,{initialContent:l,onSave:e=>void m?.onSaveMarkdown?.(e),isDark:(m?.isDark??r===`dark`)===!0},i)});else if(S)re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,z.jsx)(AD,{content:l})});else if(t===`workspace`&&C&&m?.htmlCodeMode)re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,z.jsx)(tMe,{initialContent:l,onChange:e=>m?.onHtmlChange?.(e),isDark:(m?.isDark??r===`dark`)===!0},i)});else if(C)re=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:(0,z.jsx)(`iframe`,{title:a,className:`min-h-0 w-full flex-1 rounded-lg border border-edge-subtle bg-white dark:border-edge dark:bg-[#1e1e1e]`,srcDoc:l,sandbox:`allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms allow-modals`})});else if(x===`.ts`||x===`.js`)re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,z.jsx)(AD,{content:FD(l,x)})});else if(x===`.json`){let e=l;try{e=JSON.stringify(JSON.parse(l),null,2)}catch{}re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,z.jsx)(AD,{content:FD(e,`.json`)})})}else re=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-fg`,children:l})});return(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:re})}var RD=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),zD=`VisuallyHidden`,ORe=j.forwardRef((e,t)=>(0,z.jsx)(ne.span,{...e,ref:t,style:{...RD,...e.style}}));ORe.displayName=zD;var BD=ORe,[VD,kRe]=O(`Tooltip`,[r_]),HD=r_(),ARe=`TooltipProvider`,UD=700,jRe=`tooltip.open`,[MRe,NRe]=VD(ARe),PRe=e=>{let{__scopeTooltip:t,delayDuration:n=UD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=j.useRef(!0),s=j.useRef(!1),c=j.useRef(0);return j.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,z.jsx)(MRe,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:j.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:j.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};PRe.displayName=ARe;var WD=`Tooltip`,[FRe,GD]=VD(WD),IRe=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=NRe(WD,e.__scopeTooltip),l=HD(t),[u,d]=j.useState(null),f=le(),p=j.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=j.useRef(!1),[_,v]=ue({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(jRe))):c.onClose(),a?.(e)},caller:WD}),y=j.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=j.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return j.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,z.jsx)(l_,{...l,children:(0,z.jsx)(FRe,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:j.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:j.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};IRe.displayName=WD;var KD=`TooltipTrigger`,LRe=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=GD(KD,n),a=NRe(KD,n),o=HD(n),s=A(t,j.useRef(null),i.onTriggerChange),c=j.useRef(!1),l=j.useRef(!1),u=j.useCallback(()=>c.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,z.jsx)(u_,{asChild:!0,...o,children:(0,z.jsx)(ne.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:me(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:me(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:me(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:me(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:me(e.onBlur,i.onClose),onClick:me(e.onClick,i.onClose)})})});LRe.displayName=KD;var qD=`TooltipPortal`,[RRe,JD]=VD(qD,{forceMount:void 0}),zRe=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=GD(qD,t);return(0,z.jsx)(RRe,{scope:t,forceMount:n,children:(0,z.jsx)(ae,{present:n||a.open,children:(0,z.jsx)(k,{asChild:!0,container:i,children:r})})})};zRe.displayName=qD;var YD=`TooltipContent`,XD=j.forwardRef((e,t)=>{let n=JD(YD,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=GD(YD,e.__scopeTooltip);return(0,z.jsx)(ae,{present:r||o.open,children:o.disableHoverableContent?(0,z.jsx)(URe,{side:i,...a,ref:t}):(0,z.jsx)(ZD,{side:i,...a,ref:t})})}),ZD=j.forwardRef((e,t)=>{let n=GD(YD,e.__scopeTooltip),r=NRe(YD,e.__scopeTooltip),i=j.useRef(null),a=A(t,i),[o,s]=j.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=j.useCallback(()=>{s(null),d(!1)},[d]),p=j.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=qRe(r,KRe(r,n.getBoundingClientRect())),a=JRe(t.getBoundingClientRect());s(XRe([...i,...a])),d(!0)},[d]);return j.useEffect(()=>()=>f(),[f]),j.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),j.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!YRe(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,z.jsx)(URe,{...e,ref:a})}),[BRe,VRe]=VD(WD,{isInside:!1}),HRe=ie(`TooltipContent`),URe=j.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=GD(YD,n),l=HD(n),{onClose:u}=c;return j.useEffect(()=>(document.addEventListener(jRe,u),()=>document.removeEventListener(jRe,u)),[u]),j.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,z.jsx)(pe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,z.jsxs)(PDe,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,z.jsx)(HRe,{children:r}),(0,z.jsx)(BRe,{scope:n,isInside:!0,children:(0,z.jsx)(BD,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});XD.displayName=YD;var WRe=`TooltipArrow`,GRe=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=HD(n);return VRe(WRe,n).isInside?null:(0,z.jsx)(FDe,{...i,...r,ref:t})});GRe.displayName=WRe;function KRe(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function qRe(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function JRe(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function YRe(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function XRe(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),ZRe(t)}function ZRe(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var QD=PRe,$D=IRe,eO=LRe,tO=zRe,nO=XD,rO=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,QRe=`block w-full min-w-0 truncate rounded border border-transparent bg-surface-hover px-2 py-1.5 font-mono text-xs text-fg focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`,$Re=`inline-flex w-[5.25rem] shrink-0 items-center justify-center gap-1 px-2 py-1 text-xs`;function eze(e){let t=(0,fm.c)(38),{label:n,text:r,compact:i,labels:a,monospace:o}=e,s=o===void 0?!0:o,c=(0,j.useRef)(null),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),p;t[0]===r?p=t[1]:(p=async()=>{if(f(!1),await Sh(r)){u(!0),window.setTimeout(()=>u(!1),2e3);return}Ch(c.current),f(!0),window.setTimeout(()=>f(!1),2500)},t[0]=r,t[1]=p);let m=p,h=i&&`gap-0.5`,g;t[2]===h?g=t[3]:(g=fh(`flex min-w-0 flex-col gap-1`,h),t[2]=h,t[3]=g);let _;t[4]===n?_=t[5]:(_=n?(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}):null,t[4]=n,t[5]=_);let v=n??a.copy,y=!s&&`font-sans`,b;t[6]===y?b=t[7]:(b=fh(QRe,y),t[6]=y,t[7]=b);let x;t[8]!==v||t[9]!==b||t[10]!==r?(x=(0,z.jsx)(eO,{asChild:!0,children:(0,z.jsx)(`input`,{ref:c,readOnly:!0,type:`text`,value:r,"aria-label":v,className:b,onFocus:tze})}),t[8]=v,t[9]=b,t[10]=r,t[11]=x):x=t[11];let S;t[12]===r?S=t[13]:(S=(0,z.jsx)(tO,{children:(0,z.jsx)(nO,{side:`top`,sideOffset:6,collisionPadding:12,className:rO,children:(0,z.jsx)(`span`,{className:`break-all`,children:r})})}),t[12]=r,t[13]=S);let C;t[14]!==S||t[15]!==x?(C=(0,z.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,z.jsxs)($D,{children:[x,S]})}),t[14]=S,t[15]=x,t[16]=C):C=t[16];let w;t[17]===m?w=t[18]:(w=()=>void m(),t[17]=m,t[18]=w);let T;t[19]===l?T=t[20]:(T=l?(0,z.jsx)(ei,{className:`size-3.5 shrink-0`}):(0,z.jsx)(D,{className:`size-3.5 shrink-0`}),t[19]=l,t[20]=T);let E=l?a.copied:a.copy,O;t[21]===E?O=t[22]:(O=(0,z.jsx)(`span`,{className:`truncate`,children:E}),t[21]=E,t[22]=O);let k;t[23]!==w||t[24]!==T||t[25]!==O?(k=(0,z.jsxs)(gh,{type:`button`,variant:`secondary`,className:$Re,onClick:w,children:[T,O]}),t[23]=w,t[24]=T,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==C||t[28]!==k?(A=(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_5.25rem] items-center gap-2`,children:[C,k]}),t[27]=C,t[28]=k,t[29]=A):A=t[29];let ee;t[30]!==d||t[31]!==a.copyFailed?(ee=d?(0,z.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:a.copyFailed}):null,t[30]=d,t[31]=a.copyFailed,t[32]=ee):ee=t[32];let te;return t[33]!==A||t[34]!==ee||t[35]!==g||t[36]!==_?(te=(0,z.jsx)(QD,{delayDuration:300,children:(0,z.jsxs)(`div`,{className:g,children:[_,A,ee]})}),t[33]=A,t[34]=ee,t[35]=g,t[36]=_,t[37]=te):te=t[37],te}function tze(e){return e.currentTarget.select()}function nze(e){let t=(0,fm.c)(12),{rows:n,compact:r,labels:i}=e,a=r&&`gap-1.5`,o;t[0]===a?o=t[1]:(o=fh(`flex min-w-0 flex-col gap-2`,a),t[0]=a,t[1]=o);let s;if(t[2]!==r||t[3]!==i||t[4]!==n){let e;t[6]!==r||t[7]!==i?(e=e=>(0,z.jsx)(eze,{label:e.label,text:e.text,compact:r,labels:i},e.key),t[6]=r,t[7]=i,t[8]=e):e=t[8],s=n.map(e),t[2]=r,t[3]=i,t[4]=n,t[5]=s}else s=t[5];let c;return t[9]!==o||t[10]!==s?(c=(0,z.jsx)(`div`,{className:o,children:s}),t[9]=o,t[10]=s,t[11]=c):c=t[11],c}var rze=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),ize=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function aze(e,t,n,r){if(n===`public`){let n=[{key:`public`,label:r.publicUrlLabel,url:e}];return t&&n.push({key:`lan`,label:r.lanUrlLabel,url:t}),n}return n===`lan`?[{key:`lan`,label:r.lanUrlLabel,url:e}]:[{key:`local`,label:r.localUrlLabel,url:e}]}function oze(e){let t=(0,fm.c)(17),{shareUrl:n,lanUrl:r,reachability:i,compact:a}=e,o=f(cze),s;t[0]===o?s=t[1]:(s=h(o),t[0]=o,t[1]=s);let c=s.sharesSettings,l=r??null,u;t[2]!==i||t[3]!==n||t[4]!==c||t[5]!==l?(u=aze(n,l,i,c),t[2]=i,t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,p;t[7]!==c.copied||t[8]!==c.copy||t[9]!==c.copyFailed?(p={copy:c.copy,copied:c.copied,copyFailed:c.copyFailed},t[7]=c.copied,t[8]=c.copy,t[9]=c.copyFailed,t[10]=p):p=t[10];let m=p,g;t[11]===d?g=t[12]:(g=d.map(sze),t[11]=d,t[12]=g);let _;return t[13]!==a||t[14]!==m||t[15]!==g?(_=(0,z.jsx)(nze,{rows:g,compact:a,labels:m}),t[13]=a,t[14]=m,t[15]=g,t[16]=_):_=t[16],_}function sze(e){return{key:e.key,label:e.label,text:e.url}}function cze(e){return e.language}function lze(e,t){return(t===`zh`?rze:ize).format(new Date(e))}function iO(e){let t=(0,fm.c)(23),{reachability:n,reachabilityHint:r}=e,i=f(aO),a;t[0]===i?a=t[1]:(a=h(i),t[0]=i,t[1]=a);let o=a.sharesSettings;if(n===`public`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(so,{className:`size-3`}),t[2]=e):e=t[2];let n;return t[3]===o.reachPublic?n=t[4]:(n=(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400`,children:[e,o.reachPublic]}),t[3]=o.reachPublic,t[4]=n),n}if(n===`lan`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(ACe,{className:`size-3`}),t[5]=e):e=t[5];let n;t[6]===r?n=t[7]:(n=r?(0,z.jsxs)(`span`,{className:`text-fg-muted`,children:[` — `,r]}):null,t[6]=r,t[7]=n);let i;return t[8]!==o.reachLan||t[9]!==n?(i=(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400`,children:[e,o.reachLan,n]}),t[8]=o.reachLan,t[9]=n,t[10]=i):i=t[10],i}let s;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(OCe,{className:`size-3`}),t[11]=s):s=t[11];let c;t[12]===o.reachLocal?c=t[13]:(c=(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-subtle`,children:[s,o.reachLocal]}),t[12]=o.reachLocal,t[13]=c);let l=r??o.reachLocalHint,u;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(aa,{className:`size-3`}),t[14]=u):u=t[14];let d;t[15]===o.openTunnel?d=t[16]:(d=(0,z.jsxs)(mr,{to:`/settings/remote-access?tab=public`,className:`inline-flex items-center gap-0.5 text-accent hover:underline`,children:[o.openTunnel,u]}),t[15]=o.openTunnel,t[16]=d);let p;t[17]!==l||t[18]!==d?(p=(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,children:[l,` `,d]}),t[17]=l,t[18]=d,t[19]=p):p=t[19];let m;return t[20]!==c||t[21]!==p?(m=(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,p]}),t[20]=c,t[21]=p,t[22]=m):m=t[22],m}function aO(e){return e.language}function uze(e){let t=(0,fm.c)(24),{result:n}=e,r=f(dze),i;t[0]===r?i=t[1]:(i=h(r),t[0]=r,t[1]=i);let a=i.sharesSettings,o;t[2]===n.fileName?o=t[3]:(o=(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.fileName}),t[2]=n.fileName,t[3]=o);let s=a.expiresLabel,c;t[4]!==r||t[5]!==n.expiresAt?(c=lze(n.expiresAt,r),t[4]=r,t[5]=n.expiresAt,t[6]=c):c=t[6];let l;t[7]!==a.expiresLabel||t[8]!==c?(l=(0,z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s,`: `,c]}),t[7]=a.expiresLabel,t[8]=c,t[9]=l):l=t[9];let u;t[10]!==o||t[11]!==l?(u=(0,z.jsxs)(`div`,{children:[o,l]}),t[10]=o,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.lanUrl||t[14]!==n.reachability||t[15]!==n.shareUrl?(d=(0,z.jsx)(oze,{shareUrl:n.shareUrl,lanUrl:n.lanUrl,reachability:n.reachability}),t[13]=n.lanUrl,t[14]=n.reachability,t[15]=n.shareUrl,t[16]=d):d=t[16];let p;t[17]!==n.reachability||t[18]!==n.reachabilityHint?(p=(0,z.jsx)(iO,{reachability:n.reachability,reachabilityHint:n.reachabilityHint}),t[17]=n.reachability,t[18]=n.reachabilityHint,t[19]=p):p=t[19];let m;return t[20]!==u||t[21]!==d||t[22]!==p?(m=(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[u,d,p]}),t[20]=u,t[21]=d,t[22]=p,t[23]=m):m=t[23],m}function dze(e){return e.language}function oO(e){let t=(0,fm.c)(26),{open:n,onOpenChange:r,loading:i,error:a,result:o}=e,s=f(sO),c;t[0]===s?c=t[1]:(c=h(s),t[0]=s,t[1]=c);let l=c.sharesSettings,u;t[2]===s?u=t[3]:(u=h(s),t[2]=s,t[3]=u);let d=u,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,z.jsx)(ov,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=fh(`fixed left-1/2 top-1/2 z-[71] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`overflow-hidden rounded-lg border border-edge bg-surface-panel p-4 shadow-popover outline-none`),t[5]=m):m=t[5];let g;t[6]===l.shareCreated?g=t[7]:(g=(0,z.jsx)(cv,{className:`text-base font-semibold text-fg`,children:l.shareCreated}),t[6]=l.shareCreated,t[7]=g);let _;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,z.jsx)(rm,{className:`size-4`}),t[8]=_):_=t[8];let v;t[9]===l.cancel?v=t[10]:(v=(0,z.jsx)(uv,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,children:_})}),t[9]=l.cancel,t[10]=v);let y;t[11]!==g||t[12]!==v?(y=(0,z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[g,v]}),t[11]=g,t[12]=v,t[13]=y):y=t[13];let b;t[14]!==a||t[15]!==i||t[16]!==d||t[17]!==o?(b=i?(0,z.jsxs)(`p`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,z.jsx)(Ts,{className:`size-4 animate-spin`}),d.workspace.sharing]}):a?(0,z.jsx)(`p`,{className:`py-2 text-sm text-red-600 dark:text-red-400`,children:a}):o?(0,z.jsx)(uze,{result:o}):null,t[14]=a,t[15]=i,t[16]=d,t[17]=o,t[18]=b):b=t[18];let x;t[19]!==y||t[20]!==b?(x=(0,z.jsxs)(av,{children:[p,(0,z.jsxs)(sv,{className:m,children:[y,b]})]}),t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==r||t[23]!==n||t[24]!==x?(S=(0,z.jsx)(iv,{open:n,onOpenChange:r,children:x}),t[22]=r,t[23]=n,t[24]=x,t[25]=S):S=t[25],S}function sO(e){return e.language}async function fze(){return Ce(v(`/api/shares`))}async function cO(e){return Ce(v(`/api/shares`),{method:`POST`,body:JSON.stringify(e)})}async function lO(e){return Ce(v(`/api/shares/${e}`),{method:`DELETE`})}async function pze(){return Ce(v(`/api/shares`),{method:`DELETE`,body:JSON.stringify({expired:!0})})}async function uO(e,t){return Ce(v(`/api/shares/${e}`),{method:`PATCH`,body:JSON.stringify({extendTtlMs:t})})}function mze(){let[e,t]=(0,j.useState)(!1),[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(null),c=(0,j.useCallback)(async e=>{t(!0),r(!0),a(null),s(null);try{let t=await cO(e);return a(t.payload),t.payload}catch(e){return s(e instanceof Error?e.message:String(e)),null}finally{r(!1)}},[]),l=(0,j.useCallback)(()=>{a(null),s(null),r(!1)},[]);return{dialogOpen:e,loading:n,result:i,error:o,createShareLink:c,handleOpenChange:(0,j.useCallback)(e=>{t(e),e||l()},[l])}}function hze(e){return e.map(e=>({name:e.name,path:e.path,absolutePath:e.absolutePath,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function dO(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:dO(e.children,t,n)}:e)}function gze(e,t){let[n,r]=(0,j.useState)([]),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(null),c=(0,j.useRef)(new Set),l=e.trim(),u=t?.trim()??``,d=u,f=u?``:l,p=(0,j.useMemo)(()=>{if(d)return{sessionKey:d};if(f)return{agentId:f}},[d,f]);return{tree:n,loading:i,error:o,loadRoot:(0,j.useCallback)(async()=>{a(!0),s(null),c.current.clear();try{r(hze(await DS(``,p))),c.current.add(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[p]),loadChildren:(0,j.useCallback)(async e=>{if(!c.current.has(e)){c.current.add(e);try{let t=hze(await DS(e,p));r(n=>dO(n,e,t))}catch{c.current.delete(e)}}},[p]),reset:(0,j.useCallback)(()=>{r([]),s(null),c.current.clear()},[])}}var fO=l(e=>({agentId:``,setAgentId:t=>e({agentId:t})})),_ze=`xopc-web-workspace-panel-open`,pO=`xopc-web-workspace-panel-width-px`;function vze(){try{return globalThis.localStorage?.getItem(_ze)===`1`}catch{return!1}}function mO(e){try{globalThis.localStorage?.setItem(_ze,e?`1`:`0`)}catch{}}function yze(e){return Math.min(520,Math.max(200,Math.round(e)))}function hO(){try{let e=globalThis.localStorage?.getItem(pO);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?yze(t):320}catch{return 320}}function bze(e){try{globalThis.localStorage?.setItem(pO,String(e))}catch{}}var gO=l((e,t)=>({open:vze(),setOpen:t=>{e({open:t}),queueMicrotask(()=>mO(t))},toggleOpen:()=>{t().setOpen(!t().open)},widthPx:hO(),setWidthPx:t=>{let n=yze(t);e({widthPx:n}),queueMicrotask(()=>bze(n))}})),_O=l(e=>({path:null,setPath:t=>e({path:t})})),vO=(0,j.memo)(function(){let e=h(f(e=>e.language)),{pathname:t}=Hn(),{sessionKey:n}=Wn(),r=t.startsWith(`/chat`)&&n?decodeURIComponent(n):null,i=gO(e=>e.open),a=gO(e=>e.setOpen),o=gO(e=>e.widthPx),s=gO(e=>e.setWidthPx),[c,l]=(0,j.useState)(!1),u=_O(e=>e.path),d=_O(e=>e.setPath),p=fO(e=>e.agentId),{tree:m,loading:g,error:_,loadRoot:v,loadChildren:y,reset:b}=gze(p,r),x=r??p,S=r==null?p.trim()?{agentId:p.trim()}:void 0:{sessionKey:r},{dialogOpen:C,loading:w,result:T,error:E,createShareLink:D,handleOpenChange:O}=mze(),k=(0,j.useCallback)(e=>{if(!i)return;e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),l(!0);let n=e.clientX,r=gO.getState().widthPx,a=e.pointerId,o=e=>{s(r+(n-e.clientX))},c=()=>{try{t.releasePointerCapture(a)}catch{}l(!1),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[i,s]);(0,j.useEffect)(()=>{t.startsWith(`/chat`)||a(!1)},[t,a]),(0,j.useEffect)(()=>{if(!i){b(),d(null);return}d(null),v()},[i,x,v,b,d]),(0,j.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`Escape`&&(_O.getState().path||a(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[i,a]),(0,j.useEffect)(()=>{if(!i||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[i]);let A=(0,j.useCallback)(e=>{y(e)},[y]),ee=(0,j.useCallback)(async(t,n)=>{switch(t){case`preview`:if(n.isDirectory)return;d(n.path);break;case`download`:if(n.isDirectory)return;try{let e=VS(n.path);if(Yje(n.path)){let{contentBase64:t}=await kS(n.path,S);PS(e,Ay(t),jy(e)??`application/octet-stream`)}else{let{content:t}=await OS(n.path,S);Ije(e,t)}}catch{}break;case`copyPath`:try{await Sh(n.absolutePath??n.path)&&mS(`success`,e.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`share`:await D({path:n.path,...n.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...S});break;default:break}},[D,e.workspace.pathCopied,d,S]);return(0,z.jsxs)(z.Fragment,{children:[i?(0,z.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":e.closeMenu,onClick:()=>a(!1)}):null,(0,z.jsx)(`aside`,{id:`app-workspace-panel`,"aria-label":e.workspace.title,"aria-hidden":!i,className:fh(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:shadow-popover`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,`max-md:w-[min(20rem,92vw)]`,i?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,`motion-reduce:md:transition-none`,!i&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,i&&`app-workspace-panel-expanded-width md:shrink-0`,i&&c&&`workspace-panel-rail-resizing`),style:i?{"--workspace-panel-px":`${o}px`}:void 0,children:i?(0,z.jsxs)(`div`,{className:fh(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e.workspace.resizeHandleAria,onPointerDown:k,className:fh(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,c&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,Hh)}),(0,z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4 dark:border-edge`,children:[(0,z.jsx)(Na,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-base font-semibold leading-tight tracking-tight text-fg`,children:e.workspace.title}),(0,z.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:e.cron.refresh,"aria-label":e.cron.refresh,disabled:g,onClick:()=>void v(),children:(0,z.jsx)(xu,{className:fh(`size-4`,g&&`animate-spin`),"aria-hidden":!0})}),(0,z.jsx)(gh,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":e.workspace.close,title:e.workspace.close,onClick:()=>a(!1),children:(0,z.jsx)(rm,{className:`size-4`,strokeWidth:1.75})})]}),_?(0,z.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[e.workspace.loadError,`: `,_]}):null,(0,z.jsx)(ES,{tree:m,selectedPath:u,onSelectFile:e=>d(e),onExpandDir:A,onAction:ee,actionLabels:{preview:e.workspace.preview,download:e.workspace.download,copyPath:e.workspace.copyPath,share:e.workspace.shareLink},emptyHint:e.workspace.emptyDir})]}):null}),(0,z.jsx)(oO,{open:C,onOpenChange:O,loading:w,error:E,result:T})]})}),xze=`(max-width: 1199px)`,Sze=`z-[58]`,yO=`z-[75]`,bO=`z-[76]`,xO=`z-[74]`,SO=`z-[77]`;function CO(){let e=(0,fm.c)(28),t=(0,j.useRef)(null),n=xe(OO),r=xe(DO),i=xe(EO),a=xe(TO),o=xe(wO),s=xe(q),c=f(Cze),l;e[0]===c?l=e[1]:(l=h(c),e[0]=c,e[1]=l);let u=l.token,d=!!s&&!i,p;e[2]!==d||e[3]!==o?(p=e=>{!e&&!d||e||o()},e[2]=d,e[3]=o,e[4]=p):p=e[4];let m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(ov,{className:fh(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,yO)}),e[5]=m):m=e[5];let g,_;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=fh(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,bO,`dark:border-edge`),_=e=>{e.preventDefault(),t.current?.focus()},e[6]=g,e[7]=_):(g=e[6],_=e[7]);let v;e[8]===u.title?v=e[9]:(v=(0,z.jsx)(cv,{className:`text-base font-semibold text-fg`,children:u.title}),e[8]=u.title,e[9]=v);let y;e[10]===u.description?y=e[11]:(y=(0,z.jsx)(lv,{className:`mt-1 text-sm text-fg-muted`,children:u.description}),e[10]=u.description,e[11]=y);let b;e[12]!==d||e[13]!==o||e[14]!==c?(b=d?(0,z.jsx)(gh,{type:`button`,variant:`ghost`,onClick:()=>o(),children:c===`zh`?`取消`:`Cancel`}):void 0,e[12]=d,e[13]=o,e[14]=c,e[15]=b):b=e[15];let x;e[16]!==r||e[17]!==a||e[18]!==b?(x=(0,z.jsx)(Mh,{className:`mt-4`,baseUrl:r,tokenInputRef:t,onSubmit:a,footerLeft:b}),e[16]=r,e[17]=a,e[18]=b,e[19]=x):x=e[19];let S;e[20]!==v||e[21]!==y||e[22]!==x?(S=(0,z.jsxs)(av,{children:[m,(0,z.jsxs)(sv,{className:g,onOpenAutoFocus:_,children:[v,y,x]})]}),e[20]=v,e[21]=y,e[22]=x,e[23]=S):S=e[23];let C;return e[24]!==n||e[25]!==p||e[26]!==S?(C=(0,z.jsx)(iv,{open:n,onOpenChange:p,children:S}),e[24]=n,e[25]=p,e[26]=S,e[27]=C):C=e[27],C}function Cze(e){return e.language}function q(e){return e.token}function wO(e){return e.closeTokenDialog}function TO(e){return e.setGatewayToken}function EO(e){return e.tokenExpired}function DO(e){return e.baseUrl}function OO(e){return e.tokenDialogOpen}var kO=`xopc:shell-prefs-changed`,AO={notifyEnabled:!0,notifySoundEnabled:!0};function wze(){return AO}function Tze(){typeof window>`u`||window.dispatchEvent(new CustomEvent(kO))}async function jO(){if(!Gh()||!window.electronAPI?.system)return AO;try{let e=await window.electronAPI.system.getBehavior();AO={notifyEnabled:e.notifyEnabled,notifySoundEnabled:e.notifySoundEnabled}}catch{}return AO}function MO(){try{let e=new AudioContext,t=e.createOscillator(),n=e.createGain();t.type=`sine`,t.frequency.value=880,n.gain.value=.07,t.connect(n),n.connect(e.destination),t.start(),t.stop(e.currentTime+.15),e.close()}catch{}}function NO(e){if(typeof Notification>`u`)return!1;let t=wze();if(!t.notifyEnabled&&!e.force||Notification.permission!==`granted`)return!1;let n=e.title.trim();if(!n||!e.force&&!e.urgent&&!document.hidden)return!1;try{let r=new Notification(n,{body:e.body?.trim()||void 0,tag:e.tag,silent:!t.notifySoundEnabled});return r.onclick=()=>{window.focus(),r.close()},t.notifySoundEnabled&&MO(),!0}catch{return!1}}async function Eze(e,t){if(typeof Notification>`u`)return`unsupported`;if(Gh()&&window.electronAPI?.system?.requestNotifications){let n=await window.electronAPI.system.requestNotifications();if(n.status!==`granted`)return n.outcome===`opened-settings`||n.status===`denied`?`denied`:`default`;if(Notification.permission==="default"){let e=await Notification.requestPermission();if(e!==`granted`)return e===`denied`?`denied`:`default`}else if(Notification.permission===`denied`)return`denied`;return AO={...AO,notifyEnabled:!0},NO({title:e,body:t,tag:`xopc-notify-test`,force:!0}),`enabled`}let n=Notification.permission;return n==="default"&&(n=await Notification.requestPermission()),n===`denied`?`denied`:n===`granted`?(AO={...AO,notifyEnabled:!0},NO({title:e,body:t,tag:`xopc-notify-test`,force:!0}),`enabled`):`default`}function Dze(){let e=(0,fm.c)(4),t=f(jze),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,j.useEffect)(kze,n);let r,i;return e[1]===t?(r=e[2],i=e[3]):(r=()=>{if(!Gh())return;let e=h(t).systemSettings.desktopNotify,n=Oze,r=t=>{let n=t.detail,r=n?.event;if(!r||r.type!==`error`)return;let i=typeof r.content==`string`?r.content.trim():``;NO({title:e.agentErrorTitle,body:i||e.agentErrorBody,tag:`xopc-agent-error-${n?.sessionKey??`unknown`}`,urgent:!0})};return window.addEventListener(Ee,n),window.addEventListener(`agent-stream-event`,r),()=>{window.removeEventListener(Ee,n),window.removeEventListener(`agent-stream-event`,r)}},i=[t],e[1]=t,e[2]=r,e[3]=i),(0,j.useEffect)(r,i),null}function Oze(e){let t=e.detail,n=typeof t?.title==`string`?t.title.trim():``;if(!n)return;let r=typeof t?.message==`string`?t.message.trim():void 0,i=t?.type===`error`||t?.type===`warning`;NO({title:n,body:r,tag:`xopc-toast-${t?.type??`info`}`,urgent:i})}function kze(){if(!Gh())return;jO();let e=Aze;return window.addEventListener(kO,e),()=>window.removeEventListener(kO,e)}function Aze(){jO()}function jze(e){return e.language}function Mze(){let e=(0,fm.c)(16),t=f(Nze),n;e[0]===t?n=e[1]:(n=h(t),e[0]=t,e[1]=n);let r=n.electron,[i,a]=(0,j.useState)(null),o,s;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{if(!Gh())return;let e=window.electronAPI?.gateway;if(e?.onExited)return e.onExited(e=>a(e))},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,j.useEffect)(o,s),!i)return null;let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=fh(`shrink-0 border-b border-danger/35 bg-danger/10 px-4 py-3 text-sm text-fg shadow-surface`),e[4]=c):c=e[4];let l;e[5]===r.gatewayExitTitle?l=e[6]:(l=(0,z.jsx)(`p`,{className:`font-semibold`,children:r.gatewayExitTitle}),e[5]=r.gatewayExitTitle,e[6]=l);let u;e[7]===r.gatewayExitBody?u=e[8]:(u=(0,z.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:r.gatewayExitBody}),e[7]=r.gatewayExitBody,e[8]=u);let d=i.code??`—`,p=i.signal??`—`,m;e[9]!==d||e[10]!==p?(m=(0,z.jsxs)(`p`,{className:`mt-2 font-mono text-xs text-fg-muted`,children:[`exit `,d,` · signal `,p]}),e[9]=d,e[10]=p,e[11]=m):m=e[11];let g;return e[12]!==l||e[13]!==u||e[14]!==m?(g=(0,z.jsxs)(`div`,{className:c,role:`alert`,children:[l,u,m]}),e[12]=l,e[13]=u,e[14]=m,e[15]=g):g=e[15],g}function Nze(e){return e.language}function Pze(){let e=(0,fm.c)(3),t=Un(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!Gh())return;let e=window.electronAPI;if(!e?.menu)return;let n=e.menu.onNavigate(e=>{t(e)}),r=e.menu.onTogglePalette(Fze);return()=>{n(),r()}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,j.useEffect)(n,r),null}function Fze(){window.dispatchEvent(new CustomEvent(`toggle-command-palette`))}var Ize=1500,Lze=9e4;function Rze(){let e=(0,fm.c)(16),t=f(Bze),n;e[0]===t?n=e[1]:(n=h(t),e[0]=t,e[1]=n);let r=n.updatePanel,[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(!1),c=(0,j.useRef)(0),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=c.current+=1;a(!0),s(!1),(async()=>{await new Promise(PO);let t=Date.now()+Lze;for(;e===c.current&&Date.now()<t;){try{if((await fetch(v(`/api/health`),{signal:AbortSignal.timeout(3e3)})).ok){window.location.reload();return}}catch{}await new Promise(zze)}e===c.current&&s(!0)})()},e[2]=l):l=e[2];let u=l,d,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=()=>u();return window.addEventListener(`gateway-restart-initiated`,e),()=>{c.current+=1,window.removeEventListener(`gateway-restart-initiated`,e)}},p=[u],e[3]=d,e[4]=p):(d=e[3],p=e[4]),(0,j.useEffect)(d,p);let m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{u()},e[5]=m):m=e[5];let g=m;if(!i)return null;let _=o?`border-red-500/20 bg-red-500/10 text-red-800 dark:text-red-200`:`border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-100`,y;e[6]===_?y=e[7]:(y=fh(`flex min-h-10 w-full items-center justify-center gap-2 border-b px-4 py-2 text-sm`,_),e[6]=_,e[7]=y);let b;e[8]!==r.restartPollRetry||e[9]!==r.restartPollTimeout||e[10]!==r.restartPolling||e[11]!==o?(b=o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{children:r.restartPollTimeout}),(0,z.jsx)(`button`,{type:`button`,onClick:g,className:`ml-2 rounded bg-accent px-2 py-0.5 text-xs font-medium text-white hover:bg-accent/90`,children:r.restartPollRetry})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ts,{className:`size-4 animate-spin`,"aria-hidden":!0}),(0,z.jsx)(`span`,{children:r.restartPolling})]}),e[8]=r.restartPollRetry,e[9]=r.restartPollTimeout,e[10]=r.restartPolling,e[11]=o,e[12]=b):b=e[12];let x;return e[13]!==y||e[14]!==b?(x=(0,z.jsx)(`div`,{className:y,children:b}),e[13]=y,e[14]=b,e[15]=x):x=e[15],x}function zze(e){return setTimeout(e,Ize)}function PO(e){return setTimeout(e,2e3)}function Bze(e){return e.language}async function FO(){return Ce(v(`/api/tunnel/pair/context`))}async function IO(){return Ce(v(`/api/tunnel/pair/enable-lan`),{method:`POST`,body:JSON.stringify({})})}async function LO(){return Ce(v(`/api/tunnel/status`))}async function RO(){await Ce(v(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function zO(){return Ce(v(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function BO(e){return Ce(v(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function VO(){return Ce(v(`/api/tunnel/qr`))}async function HO(){return Ce(v(`/api/tunnel/pair`),{method:`POST`,body:JSON.stringify({})})}async function UO(){let e=(await Ce(v(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function WO(e){await Ce(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}async function GO(){if(Gh()&&window.electronAPI?.gateway?.restart){let e=await window.electronAPI.gateway.restart();return e.ok&&e.token&&xe.getState().setGatewayToken(e.token),e}let e=await Ce(v(`/api/gateway/restart`),{method:`POST`,body:JSON.stringify({})});return e.ok===!1?{ok:!1,message:e.message??e.error??`Gateway restart failed`}:{ok:!0}}async function KO(e,t={}){let n=t.timeoutMs??9e4,r=t.intervalMs??500,i=Date.now()+n,a=async()=>{if(Date.now()>=i)return!1;try{if((await fetch(v(`/api/tunnel/pair/context`),{headers:{Authorization:`Bearer ${e}`}})).ok)return!0}catch{}return await new Promise(e=>setTimeout(e,r)),a()};return a()}async function qO(e={}){let t=e.timeoutMs??9e4,n=e.intervalMs??500,r=Date.now()+t,i=async()=>{if(Date.now()>=r)return null;try{let e=await FO();if(e.pairingReady)return e}catch{}return await new Promise(e=>setTimeout(e,n)),i()};return i()}function JO({reminder:e,compact:t}){let n=f(e=>e.language),r=h(n).updatePanel,{show:i,dismiss:a,electronQuitAndInstall:o,runNpmUpdate:s,npmUpdateRunning:c}=e,[l,u]=(0,j.useState)(!1),d=(0,j.useCallback)(async()=>{let e=h(n).updatePanel;u(!0);try{let t=await GO();if(t.ok){window.dispatchEvent(new Event(`gateway-restart-initiated`));return}De({type:`error`,title:e.updateErrorFailed,message:t.message??`Gateway restart failed`})}catch(t){De({type:`error`,title:e.updateErrorFailed,message:t instanceof Error?t.message:String(t)})}finally{u(!1)}},[n]),p=(0,j.useCallback)(async()=>{let e=h(n).updatePanel,t=await s();if(t.ok){De({type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail});return}De({type:`error`,title:t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed,message:t.message})},[s,n]);if(i.kind===`none`)return null;let m=`absolute right-2 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1 sm:right-3`;return i.kind===`electron-ready`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 px-10 py-2 text-sm sm:px-12`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:`flex max-w-[min(100%,48rem)] items-center justify-center gap-2 text-center`,children:[(0,z.jsx)(na,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`min-w-0`,children:r.reminderElectronReady.replace(`{{version}}`,i.version)})]}),(0,z.jsxs)(`div`,{className:m,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:o,className:`rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90`,children:[(0,z.jsx)(xu,{className:`mr-1 inline size-3`}),r.restartToUpdate]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,z.jsx)(rm,{className:`size-4`})})]})]}):i.kind===`electron-error`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-red-500/20 bg-red-500/10 px-10 py-2 text-sm text-fg sm:px-12`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:`flex max-w-[min(100%,52rem)] items-center justify-center gap-2 text-center`,children:[(0,z.jsx)(di,{className:`size-4 shrink-0 text-red-500 dark:text-red-400`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:r.reminderElectronUpdateError.replace(`{{detail}}`,i.message)})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:m,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,z.jsx)(rm,{className:`size-4`})})]}):i.kind===`electron-downloading`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 flex-col items-center justify-center gap-2 border-b border-edge bg-surface-secondary px-10 py-2 text-sm text-fg-muted sm:flex-row sm:gap-4 sm:px-12`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:`flex max-w-full items-center justify-center gap-2 text-center`,children:[(0,z.jsx)(na,{className:`size-4 shrink-0 animate-pulse`,"aria-hidden":!0}),(0,z.jsx)(`span`,{children:r.reminderDownloading.replace(`{{percent}}`,String(i.percent))})]}),(0,z.jsx)(`div`,{className:`h-1.5 w-full max-w-xs rounded-full bg-surface-tertiary sm:max-w-[12rem]`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${i.percent}%`}})}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:fh(m,`sm:right-2`),"aria-label":r.dismissAria,children:(0,z.jsx)(rm,{className:`size-4`})})]}):i.kind===`npm-restart-required`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-amber-500/25 bg-amber-500/10 py-2 text-sm`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,z.jsx)(`span`,{children:r.restartRequired.replace(`{{version}}`,i.version)}),(0,z.jsxs)(`button`,{type:`button`,onClick:d,disabled:l,className:`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[l?(0,z.jsx)(Ts,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(xu,{className:`size-3 shrink-0`,"aria-hidden":!0}),r.restartGateway]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:m,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,z.jsx)(rm,{className:`size-4`})})]}):i.kind===`npm`?(0,z.jsxs)(`div`,{className:fh(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm`,t&&`text-xs`),children:[(0,z.jsxs)(`div`,{className:fh(`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`),children:[(0,z.jsxs)(`span`,{children:[r.reminderNpm.replace(`{{version}}`,i.version),i.channel&&i.channel!==`latest`?` (${i.channel})`:``]}),(0,z.jsxs)(`button`,{type:`button`,onClick:p,disabled:c,className:`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[c?(0,z.jsx)(Ts,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(xu,{className:`size-3 shrink-0`,"aria-hidden":!0}),c?r.updateRunning:r.updateNow]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:m,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,z.jsx)(rm,{className:`size-4`})})]}):null}function YO(e,t,n){let r=h(e),i=r.commandPalette.actions,a=r.commandPalette.groups.actions;return[{kind:`action`,id:`action:cron:create`,title:i.createCron,subtitle:i.createCronSubtitle,groupLabel:a,keywords:[`cron`,`schedule`,`job`,`timer`],run:()=>{n(),t(`/cron?action=create`)}},{kind:`action`,id:`action:cron:manage`,title:i.manageCron,subtitle:i.manageCronSubtitle,groupLabel:a,keywords:[`cron`,`schedule`,`tasks`],run:()=>{n(),t(`/cron`)}},{kind:`action`,id:`action:skills:manage`,title:i.manageSkills,subtitle:i.manageSkillsSubtitle,groupLabel:a,keywords:[`skills`,`skill`,`catalog`],run:()=>{n(),t(`/skills`)}},{kind:`action`,id:`action:skills:reload`,title:i.reloadSkills,subtitle:i.reloadSkillsSubtitle,groupLabel:a,keywords:[`skills`,`reload`,`refresh`],run:()=>{n(),w(async()=>{let{reloadSkills:e}=await Promise.resolve().then(()=>uk);return{reloadSkills:e}},void 0).then(({reloadSkills:e})=>e())}}]}function XO(e){return h(e).commandPalette.groups}function Vze(e){let t=XO(e);return{[t.navigate]:0,[t.quickSettings]:1,[t.extensions]:2,[t.sessions]:3,[t.files]:4,[t.commands]:5,[t.skills]:6,[t.actions]:7}}function Hze(e){let t=XO(e);return{[t.navigate]:12,[t.quickSettings]:12,[t.actions]:8,[t.extensions]:8,[t.sessions]:8,[t.files]:10,[t.commands]:6,[t.skills]:6}}function ZO(e,t){return Vze(e)[t]??10}function QO(e){return e.trim().toLowerCase()}function Uze(e,t){let n=QO(e),r=QO(t);if(!r)return 0;if(!n)return null;if(n===r)return 0;if(n.startsWith(r))return 1;let i=n.indexOf(r);return i>=0?2+Math.min(i,50)/100:null}function Wze(e,t){let n=t.trim();if(!n)return 0;let r=[{text:e.title,weight:1},{text:e.subtitle??``,weight:1.75}];for(let t of e.keywords??[])r.push({text:t,weight:1.25});let i=null;for(let e of r){let t=Uze(e.text,n);if(t===null)continue;let r=t*e.weight;i=i===null?r:Math.min(i,r)}if(i===null)return null;let a=e.kind===`route`?-.15:e.kind===`file`?-.1:e.kind===`session`?-.05:e.kind===`setting`||e.kind===`action`?-.02:0;return Math.max(0,i+a)}function Gze(e){return e.toSorted((e,t)=>e.rank===t.rank?e.groupLabel===t.groupLabel?e.title.localeCompare(t.title):e.groupLabel.localeCompare(t.groupLabel):e.rank-t.rank)}var Kze=new Set([`settingsTunnel`,`settingsShares`,`settingsHeartbeat`,`settingsGoals`,`settingsDreams`,`logs`]),qze=[`/settings/remote-access`,`/settings/tunnel`,`/settings/shares`,`/settings/heartbeat`,`/settings/goals`,`/settings/dreams`,`/settings/logs`,`/settings/apps`,`/settings/extensions/debug`,`/settings/ext/`];function $O(e,t){return t===`advanced`?!0:!Kze.has(e)}function ek(e,t){return t===`advanced`?!0:!qze.some(t=>e===t||e.startsWith(t))}var tk=`/channels`,Jze=[`telegram`,`weixin`,`feishu`];function Yze(e){return Jze.includes(e)}function nk(e,t){let n=`${tk}/${encodeURIComponent(e.trim().toLowerCase())}`;return t?.pairing?`${n}?pairing=1`:n}function Xze(e){return e?.trim().toLowerCase()||null}var rk=l(ge(e=>({mode:`simple`,setMode:t=>e({mode:t}),setShowAdvanced:t=>e({mode:t?`advanced`:`simple`})}),{name:`xopc-web-settings-mode`}));function Zze(){return rk(ik)}function ik(e){return e.mode===`advanced`}var ak=[`settingsAgentChat`,`settingsAgentGeneration`,`settingsAgentWorkspace`,`settingsAgentBrowser`,`settingsConnectors`,`settingsAgentRuntime`,`settingsAgentContext`,`settingsAgentMemory`,`settingsAgentTools`,`settingsAgentSkills`,`settingsAgentSystemPrompt`],ok={settingsAgentChat:[`model`,`fallback`,`role`,`strategy`],settingsAgentGeneration:[`temperature`,`sampling`,`thinking`,`reasoning`],settingsAgentWorkspace:[`workspace`,`directory`,`folder`,`attachments`],settingsAgentBrowser:[`browser`,`playwright`,`automation`],settingsConnectors:[`connector`,`mcp`,`integration`,`tools`],settingsAgentRuntime:[`limits`,`turn`,`timeout`,`tool`,`iterations`],settingsAgentContext:[`context`,`compaction`,`pruning`,`tokens`],settingsAgentMemory:[`memory`,`review`,`session`,`search`],settingsAgentTools:[`tools`,`web`,`extract`,`code`],settingsAgentSkills:[`skills`,`allowlist`,`marketplace`],settingsAgentSystemPrompt:[`system`,`prompt`,`instructions`]};function sk(e,t){let n=h(e).commandPalette.routes.agentDefaultsSubtitle;return ak.filter(e=>$O(e,t)).map(t=>({id:`route:settings:agent:${t}`,title:_(e,t),subtitle:n,path:Rh(t),keywords:[`agent`,`defaults`,`config`,...ok[t]??[]]}))}function ck(e,t){return e.filter(e=>ek(e.path.split(`?`)[0]??e.path,t))}function Qze(e){let t=h(e),n=t.commandPalette.routes,r=t.channelsSettings,i=rk.getState().mode;return ck([{id:`route:chat`,title:t.nav.chat,subtitle:n.chatSubtitle,path:`/chat`,keywords:[`chat`,`new`,`compose`,`assistant`]},{id:`route:agents`,title:t.nav.agents,subtitle:n.agentsSubtitle,path:`/agents`,keywords:[`agent`,`persona`,`switch`]},{id:`route:apps`,title:t.nav.apps,subtitle:n.appsSubtitle,path:`/apps`,keywords:[`extension`,`plugin`,`addon`]},{id:`route:sessions`,title:t.nav.sessions,subtitle:n.sessionsSubtitle,path:`/settings/sessions`,keywords:[`history`,`archive`,`pin`]},{id:`route:logs`,title:t.nav.logs,subtitle:n.logsSubtitle,path:`/settings/logs`,keywords:[`debug`,`errors`]},{id:`route:skills`,title:t.nav.skills,subtitle:n.skillsSubtitle,path:`/skills`,keywords:[`tools`,`catalog`]},{id:`route:channels`,title:t.nav.channels,subtitle:n.channelsSubtitle,path:`/channels`,keywords:[`telegram`,`weixin`,`feishu`,`channel`]},{id:`route:channels:telegram`,title:r.telegramTitle,subtitle:n.channelsSubtitle,path:nk(`telegram`),keywords:[`telegram`,`bot`,`channel`,`pairing`]},{id:`route:channels:weixin`,title:r.weixinTitle,subtitle:n.channelsSubtitle,path:nk(`weixin`),keywords:[`weixin`,`wechat`,`channel`,`qr`]},{id:`route:channels:feishu`,title:r.feishuTitle,subtitle:n.channelsSubtitle,path:nk(`feishu`),keywords:[`feishu`,`lark`,`channel`]},{id:`route:channels:telegram:pairing`,title:`${r.telegramTitle} — ${r.hubPairingButton}`,subtitle:n.channelsSubtitle,path:nk(`telegram`,{pairing:!0}),keywords:[`telegram`,`pairing`,`approve`,`dm`]},{id:`route:cron`,title:t.nav.cron,subtitle:n.cronSubtitle,path:`/cron`,keywords:[`schedule`,`jobs`,`tasks`,`history`,`scheduler`,`timezone`,`concurrency`,`cron`,`automation`]},{id:`route:settings:goals`,title:t.nav.settingsGoals,subtitle:n.goalsSettingsSubtitle,path:`/settings/goals`,keywords:[`goal`,`checklist`,`judge`,`/goal`,`automation`]},{id:`route:settings:dreams`,title:t.nav.settingsDreams,subtitle:n.dreamsSettingsSubtitle,path:`/settings/dreams`,keywords:[`dream`,`memory`,`consolidation`,`automation`]},{id:`route:settings`,title:t.nav.settings,subtitle:n.settingsSubtitle,path:`/settings/overview`,keywords:[`config`,`status`,`providers`,`models`,`agents`,`search`,`preferences`]},{id:`route:settings:credentials`,title:t.nav.settingsCredentials,subtitle:n.credentialsSubtitle,path:`/settings/credentials`,keywords:[`api`,`key`,`credentials`,`oauth`,`token`,`models`,`providers`]},{id:`route:settings:providers`,title:t.nav.settingsProviders,subtitle:n.providersSubtitle,path:`/settings/credentials?tab=providers`,keywords:[`api`,`key`,`openai`,`anthropic`,`google`]},{id:`route:settings:models`,title:t.nav.settingsModels,subtitle:n.modelsSubtitle,path:`/settings/credentials?tab=catalog`,keywords:[`gpt`,`claude`,`gemini`,`llm`]},{id:`route:settings:image-models`,title:t.nav.settingsImageModels,subtitle:n.imageModelsSubtitle,path:`/settings/credentials?tab=image-models`,keywords:[`image`,`vision`,`generate`,`picture`]},{id:`route:settings:voice`,title:t.nav.settingsVoice,subtitle:n.voiceSubtitle,path:`/settings/credentials?tab=voice`,keywords:[`tts`,`stt`,`speech`,`microphone`]},{id:`route:settings:search`,title:t.nav.settingsSearch,subtitle:n.searchSubtitle,path:`/settings/credentials?tab=search`,keywords:[`search`,`web`,`tavily`,`serper`,`brave`]},{id:`route:settings:gateway`,title:t.nav.settingsGateway,subtitle:n.gatewaySubtitle,path:`/settings/gateway`,keywords:[`server`,`port`,`auth`,`token`]},...sk(e,i)],i)}function $ze(e){_e.getState().setPreference(e)}function eBe(e){f.getState().setLanguage(e)}function tBe(e,t){let n=h(e),r=n.commandPalette.quickSettings,i=n.commandPalette.groups.quickSettings;return[{kind:`setting`,id:`setting:model`,title:r.switchModel,subtitle:r.switchModelSubtitle,groupLabel:i,keywords:[`model`,`gpt`,`claude`,`gemini`,`llm`],run:()=>t.openModelPalette()},{kind:`setting`,id:`setting:agent`,title:r.switchAgent,subtitle:r.switchAgentSubtitle,groupLabel:i,keywords:[`agent`,`persona`,`bot`],run:()=>t.openAgentPalette()},{kind:`setting`,id:`setting:theme:light`,title:r.themeLight,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`light`,`appearance`],run:()=>{$ze(`light`),t.closePalette()}},{kind:`setting`,id:`setting:theme:dark`,title:r.themeDark,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`dark`,`night`],run:()=>{$ze(`dark`),t.closePalette()}},{kind:`setting`,id:`setting:theme:system`,title:r.themeSystem,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`system`,`auto`],run:()=>{$ze(`system`),t.closePalette()}},{kind:`setting`,id:`setting:lang:en`,title:r.languageEn,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`english`,`language`,`locale`],run:()=>{eBe(`en`),t.closePalette()}},{kind:`setting`,id:`setting:lang:zh`,title:r.languageZh,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`chinese`,`中文`,`language`],run:()=>{eBe(`zh`),t.closePalette()}}]}function lk(e){let t=e===`zh`;return[{id:`field:gateway:port`,title:t?`网关端口`:`Gateway Port`,subtitle:t?`设置 HTTP 网关监听端口`:`HTTP gateway listen port`,path:`/settings/gateway`,keywords:[`port`,`listen`,`http`,`server`,`端口`]},{id:`field:gateway:host`,title:t?`网关绑定地址`:`Gateway Host`,subtitle:t?`设置绑定的网络接口`:`Network interface to bind`,path:`/settings/gateway`,keywords:[`host`,`bind`,`interface`,`localhost`,`地址`]},{id:`field:gateway:auth`,title:t?`网关认证令牌`:`Gateway Auth Token`,subtitle:t?`访问网关所需的 Bearer token`:`Bearer token for gateway access`,path:`/settings/gateway`,keywords:[`auth`,`token`,`bearer`,`password`,`security`,`认证`,`令牌`]},{id:`field:agent:model`,title:t?`默认模型`:`Default Model`,subtitle:t?`对话使用的 LLM 模型`:`LLM model for conversations`,path:`/settings/agent-defaults`,keywords:[`model`,`llm`,`gpt`,`claude`,`gemini`,`模型`]},{id:`field:agent:temperature`,title:t?`温度 (Temperature)`:`Temperature`,subtitle:t?`控制回复的随机性`:`Controls response randomness`,path:`/settings/agent-defaults?tab=generation`,keywords:[`temperature`,`sampling`,`randomness`,`creative`,`温度`,`随机`]},{id:`field:agent:maxTokens`,title:t?`最大输出 Tokens`:`Max Output Tokens`,subtitle:t?`单次回复的最大 token 数`:`Maximum tokens per response`,path:`/settings/agent-defaults?tab=generation`,keywords:[`max`,`tokens`,`output`,`length`,`limit`,`最大`]},{id:`field:agent:workspace`,title:t?`工作目录`:`Workspace Directory`,subtitle:t?`代理的默认工作目录`:`Default working directory for the agent`,path:`/settings/agent-defaults?tab=workspace`,keywords:[`workspace`,`directory`,`folder`,`path`,`cwd`,`工作目录`]},{id:`field:agent:browser`,title:t?`浏览器自动化`:`Browser automation`,subtitle:t?`启用 browser_use 工具`:`Enable browser_use tools`,path:`/settings/agent-browser`,keywords:[`browser`,`browser_use`,`automation`,`浏览器`]},{id:`field:agent:browser-extension`,title:t?`Chrome 扩展连接`:`Chrome extension bridge`,subtitle:t?`安装扩展并启动 WebSocket 桥接`:`Install extension and start the bridge`,path:`/settings/agent-browser?tab=extension`,keywords:[`extension`,`chrome`,`bridge`,`websocket`,`扩展`,`桥接`]},{id:`field:agent:browser-playwright`,title:t?`安装 Playwright Chromium`:`Install Playwright Chromium`,subtitle:t?`本地 Playwright 后端就绪检查`:`Local Playwright backend setup`,path:`/settings/agent-browser?tab=local`,keywords:[`playwright`,`chromium`,`install`,`local`,`安装`]},{id:`field:agent:browser-cloak`,title:t?`CloakBrowser 配置`:`CloakBrowser settings`,subtitle:t?`反指纹浏览器下载与高级选项`:`Stealth browser download and fingerprint options`,path:`/settings/agent-browser?tab=cloakbrowser`,keywords:[`cloak`,`cloakbrowser`,`fingerprint`,`stealth`,`反指纹`]},{id:`field:agent:browser-headless`,title:t?`浏览器无头模式`:`Browser headless mode`,subtitle:t?`隐藏浏览器窗口`:`Run without a visible window`,path:`/settings/agent-browser?focus=runtime`,keywords:[`headless`,`window`,`visible`,`无头`]},{id:`field:agent:browser-private-urls`,title:t?`允许内网 URL`:`Allow private URLs`,subtitle:t?`浏览器导航安全限制`:`Browser navigation security policy`,path:`/settings/agent-browser?focus=security`,keywords:[`private`,`internal`,`localhost`,`security`,`内网`,`安全`]},{id:`field:agent:turnLimit`,title:t?`轮次限制`:`Turn Limit`,subtitle:t?`单次会话最大对话轮次`:`Maximum turns per session run`,path:`/settings/agent-defaults?tab=runtime`,keywords:[`turn`,`limit`,`iterations`,`max`,`轮次`,`限制`]},{id:`field:agent:timeout`,title:t?`超时时间`:`Timeout`,subtitle:t?`单次工具调用的超时`:`Tool execution timeout`,path:`/settings/agent-defaults?tab=runtime`,keywords:[`timeout`,`duration`,`seconds`,`超时`]},{id:`field:agent:compaction`,title:t?`上下文压缩`:`Context Compaction`,subtitle:t?`长对话自动压缩策略`:`Auto-compact strategy for long conversations`,path:`/settings/agent-defaults?tab=context`,keywords:[`compaction`,`context`,`pruning`,`tokens`,`window`,`压缩`,`上下文`]},{id:`field:agent:memory`,title:t?`记忆设置`:`Memory Settings`,subtitle:t?`会话记忆与回顾配置`:`Session memory and review configuration`,path:`/settings/agent-defaults?tab=memory`,keywords:[`memory`,`review`,`session`,`recall`,`记忆`]},{id:`field:agent:systemPrompt`,title:t?`系统提示词`:`System Prompt`,subtitle:t?`自定义系统指令`:`Custom system instructions`,path:`/settings/agent-defaults?tab=system-prompt`,keywords:[`system`,`prompt`,`instructions`,`persona`,`系统提示词`,`指令`]},{id:`field:voice:sttProvider`,title:t?`STT 语音识别提供商`:`STT Provider`,subtitle:t?`语音转文字服务商`:`Speech-to-text service provider`,path:`/settings/credentials?tab=voice`,keywords:[`stt`,`speech`,`recognition`,`whisper`,`deepgram`,`语音识别`]},{id:`field:voice:ttsProvider`,title:t?`TTS 语音合成提供商`:`TTS Provider`,subtitle:t?`文字转语音服务商`:`Text-to-speech service provider`,path:`/settings/credentials?tab=voice`,keywords:[`tts`,`speech`,`synthesis`,`voice`,`elevenlabs`,`语音合成`]},{id:`field:search:engine`,title:t?`搜索引擎`:`Web Search Engine`,subtitle:t?`联网搜索使用的引擎`:`Engine for web search tool`,path:`/settings/credentials?tab=search`,keywords:[`search`,`engine`,`tavily`,`serper`,`brave`,`bing`,`搜索引擎`]},{id:`field:cron:enabled`,title:t?`定时任务开关`:`Cron Enabled`,subtitle:t?`启用/禁用定时调度器`:`Enable or disable the scheduler`,path:`/cron?tab=settings`,keywords:[`cron`,`enabled`,`scheduler`,`timer`,`定时`,`调度`]},{id:`field:cron:timezone`,title:t?`定时任务时区`:`Cron Timezone`,subtitle:t?`调度器使用的时区`:`Timezone for the scheduler`,path:`/cron?tab=settings`,keywords:[`timezone`,`tz`,`utc`,`cron`,`时区`]},{id:`field:channels:telegram`,title:`Telegram Bot Token`,subtitle:t?`配置 Telegram 频道连接`:`Configure Telegram channel connection`,path:`/settings/channels`,keywords:[`telegram`,`bot`,`token`,`channel`,`频道`]},{id:`field:channels:dmPolicy`,title:t?`私聊接入策略`:`DM Access Policy`,subtitle:t?`Telegram 私聊白名单/配对策略`:`Telegram DM allowlist/pairing policy`,path:`/settings/channels`,keywords:[`dm`,`policy`,`pairing`,`allowlist`,`access`,`私聊`,`策略`]},{id:`field:mcp:servers`,title:t?`MCP 服务器配置`:`MCP Servers`,subtitle:t?`外部 MCP 工具服务器列表`:`External MCP tool server registry`,path:`/settings/connectors`,keywords:[`mcp`,`server`,`tools`,`external`,`stdio`,`服务器`,`connector`]},{id:`field:heartbeat:interval`,title:t?`心跳间隔`:`Heartbeat Interval`,subtitle:t?`网关存活检测频率`:`Gateway keep-alive check frequency`,path:`/settings/heartbeat`,keywords:[`heartbeat`,`interval`,`keepalive`,`alive`,`心跳`]},{id:`field:tunnel:enabled`,title:t?`公网隧道`:`Public Tunnel`,subtitle:t?`FRP 远程访问隧道开关`:`FRP remote access tunnel toggle`,path:`/settings/remote-access`,keywords:[`tunnel`,`frp`,`remote`,`public`,`ngrok`,`隧道`,`远程`]}]}function nBe(e,t,n,r){return lk(e).map(e=>({kind:`setting`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:r,keywords:e.keywords,run:()=>{n(),t(e.path)}}))}var uk=t({deleteSkill:()=>mk,getMarketplaceCategories:()=>_k,getMarketplacePackageDetail:()=>yk,getMarketplaceProvider:()=>Sk,getMarketplaceProviders:()=>Ck,getMarketplaceSkills:()=>vk,getSkillMarkdown:()=>xk,getSkills:()=>fk,installMarketplaceSkill:()=>bk,patchSkillEnabled:()=>hk,reloadSkills:()=>rBe,uploadSkillZip:()=>pk});async function dk(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function fk(e){let t=await Te(v(`/api/skills${e&&e!==`en`?`?lang=${encodeURIComponent(e)}`:``}`),{cache:`no-store`});if(!t.ok)throw Error(await dk(t));let n=await t.json();if(!n.payload)throw Error(`Invalid response`);return n.payload}async function rBe(){let e=await Te(v(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await dk(e))}async function pk(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`);let r=xe.getState().token,i=new Headers;r&&i.set(`Authorization`,`Bearer ${r}`);let a=await fetch(v(`/api/skills/upload`),{method:`POST`,headers:i,body:n});a.status===401&&xe.getState().onUnauthorized();let o=await a.json().catch(()=>({}));if(!a.ok)throw Error(o.error||`HTTP ${a.status}`);if(!o.payload?.skillId)throw Error(`Invalid response`);return o.payload}async function mk(e){let t=await Te(v(`/api/skills/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(await dk(t))}async function hk(e,t){let n=await Te(v(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await dk(n))}function gk(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function _k(e){let t=new URLSearchParams;gk(t,e?.provider);let n=t.toString(),r=await Te(v(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await dk(r));let i=await r.json();if(!i.payload||!Array.isArray(i.payload.items))throw Error(`Invalid response`);return{items:i.payload.items}}async function vk(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),gk(t,e.provider);let n=t.toString(),r=await Te(v(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await dk(r));let i=await r.json();if(!i.payload?.items||!i.payload.meta)throw Error(`Invalid response`);return i.payload}async function yk(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;gk(r,t?.provider);let i=r.toString(),a=await Te(v(`/api/skills/marketplace/packages/${n}${i?`?${i}`:``}`),{cache:`no-store`});if(!a.ok)throw Error(await dk(a));let o=await a.json();if(!o.payload?.name)throw Error(`Invalid response`);return o.payload}async function bk(e){let t=await Te(v(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await dk(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function xk(e,t){let n=t?`?lang=${encodeURIComponent(t)}`:``,r=await Te(v(`/api/skills/${encodeURIComponent(e)}/content${n}`),{cache:`no-store`});if(!r.ok)throw Error(await dk(r));let i=(await r.json()).payload;if(!i||typeof i.name!=`string`||typeof i.description!=`string`||typeof i.bodyMarkdown!=`string`||typeof i.disableModelInvocation!=`boolean`||!i.metadata||typeof i.metadata!=`object`||typeof i.metadata.name!=`string`||typeof i.metadata.description!=`string`)throw Error(`Invalid response`);return i}async function Sk(){let e=await Te(v(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await dk(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function Ck(){let e=await Te(v(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await dk(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}var wk=`[a-zA-Z0-9](?:[a-zA-Z0-9._-]{0,62})`,iBe=RegExp(`\\/skill:(${wk})`,`g`);function Tk(){return new RegExp(iBe.source,`g`)}var Ek=RegExp(`(\\/skill:${wk})$`),aBe=RegExp(`(\\/skill:${wk})([ \\t\\f\\v]*)$`),oBe=RegExp(`^${wk}$`);function sBe(e){return oBe.test(e.trim())}var cBe=RegExp(`^\\/skill:(${wk})`),Dk=[],Ok=new Map;function kk(e){let t=new Set;for(let n of e??[]){n?.name&&t.add(n.name);for(let e of n.aliases??[])typeof e==`string`&&e.length>0&&t.add(e)}Dk=Array.from(t).toSorted((e,t)=>t.length-e.length).map(e=>({key:e})),Ok.clear()}function lBe(e,t){if(t>=e.length)return!0;let n=e[t];return!/[a-zA-Z0-9_-]/.test(n)}function uBe(e,t){return!(e[t]!==`/`||t>0&&!/\s/.test(e[t-1]))}function Ak(e,t){if(!uBe(e,t)||Dk.length===0)return null;let n=e.slice(t);if(n.startsWith(`/skill:`))return null;for(let{key:e}of Dk){let t=`/${e}`;if(n.startsWith(t)&&lBe(n,t.length))return{len:t.length,matchedKey:e}}return null}function jk(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==`/`){n+=1;continue}let r=e.slice(n).match(cBe);if(r?.[0]){n+=r[0].length;continue}let i=Ak(e,n);i?(t.push({start:n,end:n+i.len}),n+=i.len):n+=1}return t}function Mk(e){for(let t=e.length-1;t>=0;--t){if(e[t]!==`/`||e.startsWith(`/skill:`,t))continue;let n=Ak(e,t);if(n&&t+n.len===e.length)return!0}return!1}function dBe(e){if(!e.startsWith(`/`)||Dk.length===0||e.startsWith(`/skill:`))return!1;let t=Ak(e,0);return t?e.length===t.len||!/[a-zA-Z0-9_-]/.test(e[t.len]):!1}function fBe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Nk(e){let t=Ok.get(e);return t||(t=RegExp(`(${fBe(e)})([ \\t\\f\\v]*)$`),Ok.set(e,t)),t}function Pk(e){for(let{key:t}of Dk){let n=`/${t}`;if(!e.endsWith(n))continue;let r=e.length-n.length;if(Ak(e,r))return{tokenStart:r}}return null}function Fk(e){for(let{key:t}of Dk){let n=`/${t}`,r=e.match(Nk(n));if(!r)continue;let i=e.length-r[0].length;if(Ak(e,i))return{tokenStart:i}}return null}async function Ik(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function pBe(){let e=await Te(v(`/api/commands`));if(!e.ok)throw Error(await Ik(e));return(await e.json()).payload?.commands??[]}var Lk=6e4,Rk=null,mBe=0,zk=null,hBe=new Map,gBe=new Map,Bk=null,_Be;async function Vk(e=!1){return!e&&Rk&&Date.now()<mBe?(kk(Rk),Rk):zk||(zk=pBe().then(e=>(Rk=e,mBe=Date.now()+Lk,kk(e),e)).catch(e=>{throw kk([]),e}).finally(()=>{zk=null}),zk)}async function Hk(e,t=!1){let n=e??`en`,r=Date.now();return!t&&hBe.has(n)&&r<(gBe.get(n)??0)?hBe.get(n):Bk&&_Be===n?Bk:(_Be=n,Bk=fk(e).then(e=>(hBe.set(n,e),gBe.set(n,Date.now()+Lk),e)).finally(()=>{Bk=null,_Be=void 0}),Bk)}var Uk=`fill-chat-composer`;function Wk(e){window.dispatchEvent(new CustomEvent(Uk,{detail:{text:e}}))}function Gk(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var Kk=3e4,qk=null;function Jk(e){return e.trim()}function vBe(e){return e.map(e=>({name:e.name,relativePath:e.path,isDirectory:e.isDirectory}))}async function Yk(e,t){let n=t.sessionKey?.trim(),r=t.agentId?.trim(),i=t.limit??15,a=e.trim(),o=new URLSearchParams;if(o.set(`q`,a),o.set(`limit`,String(i)),n?o.set(`sessionKey`,n):r&&o.set(`agentId`,r),n&&a.length===0){let e=Jk(n),t=Date.now();if(qk&&qk.key===e&&t-qk.at<Kk)return qk.items}let s=vBe((await Ce(v(`/api/workspace/editor/files/search?${o.toString()}`))).payload.entries??[]);return n&&a.length===0&&(qk={key:Jk(n),at:Date.now(),items:s}),s}async function yBe(e,t){return DS(e,{sessionKey:t.sessionKey,agentId:t.agentId})}function Xk(e){let t=typeof e.profileDir==`string`?e.profileDir.trim():``,n=e.typedModels?.defaults??[],r=e.typedModels?.effective??n;return{...e,profileDir:t,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:e.skills??{defaults:[]},tools:e.tools??{defaultsDisable:[],entryDisable:[],effectiveDisable:[]},typedModels:{defaults:n,effective:r}}}async function bBe(){let e=(await Ce(v(`/api/agents?locale=${encodeURIComponent(p())}`))).payload;if(!e?.defaultId||!Array.isArray(e.agents))throw Error(`Invalid /api/agents response`);let t=Array.isArray(e.builtinToolIds)?e.builtinToolIds:[];return{defaultId:e.defaultId,agents:e.agents.map(Xk),builtinToolIds:t}}async function xBe(e){let{mutate:t}=await w(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([3,1,4]));await Promise.all([t(`settings-gateway-agents`,e,{revalidate:!1}),t(`setup-checklist-agents`,e,{revalidate:!1})])}async function SBe(e){let t=await Ce(v(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=typeof t.payload?.agentId==`string`?t.payload.agentId.trim():``,r=t.payload?.agents;if(!n||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid create agent response`);return{createdAgentId:n,defaultId:r.defaultId,agents:r.agents.map(Xk),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]}}async function CBe(e){let t=await Ce(v(`/api/agents/batch`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agents:e})}),n=Array.isArray(t.payload?.agentIds)?t.payload.agentIds.map(e=>String(e).trim()).filter(Boolean):[],r=t.payload?.agents;if(n.length===0||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid batch create agent response`);let i={defaultId:r.defaultId,agents:r.agents.map(Xk),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]};return await xBe(i),{createdAgentIds:n,...i}}async function wBe(e,t){let n=(await Ce(v(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).payload;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid update agent response`);return{defaultId:n.defaultId,agents:n.agents.map(Xk),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function TBe(e,t){let n=(await Ce(v(`/api/agents/${encodeURIComponent(e)}${t?`?purge=true`:``}`),{method:`DELETE`})).payload?.agents;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid delete agent response`);return{defaultId:n.defaultId,agents:n.agents.map(Xk),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}function Zk(e){if(!e||typeof e!=`object`||!(`bindings`in e))return[];let t=e.bindings;return Array.isArray(t)?t:[]}async function Qk(e){await Ce(v(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({bindings:e})}),by()}async function $k(){let e=(await Ce(v(`/api/skills`))).payload?.catalog;return Array.isArray(e)?e:[]}async function eA(e){let t=(await Ce(v(`/api/agents/${encodeURIComponent(e)}/files`))).payload,n=typeof t?.profileDir==`string`?t.profileDir.trim():``;if(!t?.files||!n)throw Error(`Invalid files list response`);return{agentId:t.agentId,profileDir:n,files:t.files}}async function EBe(e,t){let n=(await Ce(v(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid file content response`);return n}async function DBe(e,t,n){await Ce(v(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}function tA(e){let t=e.type.toLowerCase();return t===`image/png`||t===`image/jpeg`||t===`image/jpg`||t===`image/webp`?t===`image/jpg`?`image/jpeg`:t:null}function OBe(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=String(r.result??``),n=e.indexOf(`,`);t(n>=0?e.slice(n+1):``)},r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(e)})}async function nA(e,t){let n=tA(t);if(!n)throw Error(`unsupported_image_type`);if(t.size===0||t.size>512*1024)throw Error(`avatar_too_large`);let r=await OBe(t);if(!r)throw Error(`empty_file`);await Ce(v(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({base64:r,mimeType:n})})}async function rA(e){await Ce(v(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`DELETE`})}var iA=`main`;function aA(e,t){return e.name?.trim()||(e.id.trim().toLowerCase()===iA?t.defaultMainAgentName:e.id)}function oA(e,t){return e.description?.trim()||(e.id.trim().toLowerCase()===iA?t.defaultMainAgentDescription:``)}var kBe=500,sA=null,cA;function lA(e){cA=e,sA!==null&&clearTimeout(sA),sA=setTimeout(()=>{sA=null;let e=cA;cA=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},kBe)}function uA(){let{pathname:e}=Hn(),{sessionKey:t}=Wn();if(!e.startsWith(`/chat`)||!t)return;let n=decodeURIComponent(t);return n&&n!==`new`?n:void 0}function dA(e){switch(e.kind){case`extension`:return(0,z.jsx)(Kl,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`route`:return(0,z.jsx)(Na,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`session`:return(0,z.jsx)(Na,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`file`:return(0,z.jsx)(fa,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`command`:return(0,z.jsx)(Hf,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`skill`:return(0,z.jsx)(zd,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});case`setting`:return(0,z.jsx)(fd,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`action`:return(0,z.jsx)(im,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});default:return null}}function fA(e,t,n,r){if(r(),t.startsWith(`/chat`)){Wk(e);return}let i=e.match(/^\/skill:(\S+)\s*$/),a=e.match(/^\/(\S+)\s*$/);i?n(`/chat/new?skill=${encodeURIComponent(i[1])}`):a?n(`/chat/new?slash=${encodeURIComponent(a[1])}`):(n(`/chat/new`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Wk(e)})}))}function pA(e){let t=[];for(let n of e.uiExtensions){let r=n.ui?.contributions?.commands;if(Array.isArray(r))for(let i of r)!i||typeof i.id!=`string`||typeof i.title!=`string`||t.push({kind:`extension`,id:`ext:${n.id}:${i.id}`,title:i.title,subtitle:n.name,groupLabel:e.extensionsGroupLabel,keywords:[n.id,n.name,i.id],run:()=>{e.close(),i.opensPanel!==void 0&&i.opensPanel!==``?e.navigate(`/apps/${encodeURIComponent(n.id)}`):window.dispatchEvent(new CustomEvent(`extension-command`,{detail:{extensionId:n.id,commandId:i.id}}))}})}return t}function mA(e,t){switch(t.type){case`setQuery`:return{...e,query:t.value};case`setSelectedIndex`:{let n=typeof t.value==`function`?t.value(e.selectedIndex):t.value;return{...e,selectedIndex:n}}case`setLayer`:return{...e,paletteLayer:t.layer,query:``,selectedIndex:0};case`resetMain`:return{query:``,selectedIndex:0,paletteLayer:`main`}}}var ABe={query:``,selectedIndex:0,paletteLayer:`main`};async function hA(){let e=await Ce(v(`/api/registry`)),t=[];for(let n of e.payload?.providers??[])for(let e of n.models??[])e.available!==!1&&t.push({id:e.ref,title:e.name||e.ref,subtitle:e.ref});return t.sort((e,t)=>e.title.localeCompare(t.title)),t}async function jBe(e){let t=await bBe(),n=h(e).agentsSettings;return t.agents.map(e=>({id:e.id,title:aA(e,n),subtitle:e.id}))}function MBe({onClose:e}){let t=(0,j.useRef)(null),n=(0,j.useRef)(null),r=Un(),{pathname:i}=Hn(),a=f(e=>e.language),o=ey(),s=uA(),c=fO(e=>e.agentId),l=_O(e=>e.setPath),[u,d]=(0,j.useReducer)(mA,ABe),{query:p,selectedIndex:m,paletteLayer:g}=u,_=(0,j.useMemo)(()=>Qze(a),[a]),[y]=zS(p,120),b=(0,j.useCallback)(()=>{d({type:`setLayer`,layer:`models`})},[]),x=(0,j.useCallback)(()=>{d({type:`setLayer`,layer:`agents`})},[]),S=Tv(async()=>g===`models`?hA():g===`agents`?jBe(a):[],[g,a],{enabled:g===`models`||g===`agents`,initial:[],errorData:[]}),C=Tv(async()=>{let t=y.trim(),n=e,u=h(a).commandPalette.groups,d=_.map(e=>({kind:`route`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.navigate,keywords:[...e.keywords??[],e.path],run:()=>{n(),r(e.path)}})),f=tBe(a,{closePalette:n,openModelPalette:b,openAgentPalette:x}),p=YO(a,r,n),m=pA({query:t,close:n,navigate:r,uiExtensions:o,extensionsGroupLabel:u.extensions}),[g,v,S,C]=await Promise.all([Vk(),Hk(a),pb({search:t||void 0,limit:8,offset:0}).catch(()=>({items:[]})),(async()=>{let e=s?.trim(),n=c.trim();return!e&&!n?[]:await Yk(t,{sessionKey:e||void 0,agentId:e?void 0:n||void 0,limit:10}).catch(()=>[])})()]),w=g.map(e=>({kind:`command`,id:`cmd:${e.id}`,title:`/${e.name}`,subtitle:e.description,groupLabel:u.commands,keywords:[e.id,...e.aliases??[],e.category??``],run:()=>{fA(Gk(e),i,r,n)}})),T=v.catalog.flatMap(e=>!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,title:`/skill:${e.name}`,subtitle:e.description,groupLabel:u.skills,keywords:[e.source??``,`skill`],run:()=>{fA(`/skill:${e.name} `,i,r,n)}}]),E=(S.items??[]).map(e=>({kind:`session`,id:`session:${e.key}`,title:e.name?.trim()||e.key,subtitle:e.key,groupLabel:u.sessions,keywords:[e.key,...e.tags??[],e.sourceChannel??``],run:()=>{n(),r(`/chat/${encodeURIComponent(e.key)}`)}})),D=C.flatMap(e=>e.isDirectory?[]:[{kind:`file`,id:`file:${e.relativePath}`,title:e.name,subtitle:e.relativePath,groupLabel:u.files,keywords:[e.relativePath],run:()=>{n();let t=e.relativePath.replace(/\\/g,`/`).replace(/^\/+/,``),a=()=>l(t);if(i.startsWith(`/chat`)){a();return}r(`/chat`),window.setTimeout(()=>a(),0)}}]),O=nBe(a,r,n,u.navigate),k=[...d,...f,...p,...m,...O,...E,...D,...w,...T],A=[];for(let e of k){let n=Wze(e,t);n!==null&&A.push({...e,rank:n})}let ee=Hze(a),te=Gze(A),ne=[],re={};for(let e of te){let t=(re[e.groupLabel]??0)+1;if(!(t>(ee[e.groupLabel]??6))&&(re[e.groupLabel]=t,ne.push(e),ne.length>=36))break}return ne.sort((e,t)=>ZO(a,e.groupLabel)-ZO(a,t.groupLabel)||e.rank-t.rank||e.title.localeCompare(t.title)),ne},[y,_,o,r,s,c,i,l,a,b,x,e],{enabled:g===`main`,initial:[],errorData:[]}),w=C.data,T=C.loading,E=C.error,D=(0,j.useMemo)(()=>{let e=p.trim().toLowerCase(),t=S.data;return e?t.filter(t=>t.title.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.subtitle?.toLowerCase().includes(e)??!1)):t},[S.data,p]),O=`${g}|${p}|${String(D.length)}|${String(w.length)}`,k=(0,j.useRef)(O);if(k.current!==O){k.current=O;let e=g===`main`?Math.max(0,w.length-1):Math.max(0,D.length);m>e&&d({type:`setSelectedIndex`,value:e})}(0,j.useEffect)(()=>{let e=window.setTimeout(()=>t.current?.focus(),50);return()=>window.clearTimeout(e)},[]);let A=(0,j.useEffectEvent)(t=>{if(t.key===`Escape`){if(t.preventDefault(),g!==`main`){d({type:`resetMain`});return}e();return}let n=g===`main`?Math.max(0,w.length-1):Math.max(0,D.length);if(t.key===`ArrowDown`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.min(e+1,n)});return}if(t.key===`ArrowUp`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.max(0,e-1)});return}if(t.key===`Enter`){if(t.preventDefault(),g===`models`){if(m===0){d({type:`resetMain`});return}let t=D[m-1];if(!t)return;(async()=>{await Ce(v(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agents:{defaults:{model:t.id}}})}),by(),lA(),e(),d({type:`resetMain`})})();return}if(g===`agents`){if(m===0){d({type:`resetMain`});return}let t=D[m-1];if(!t)return;window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:t.id}})),e(),d({type:`resetMain`});return}let n=w[m];n&&n.run()}});(0,j.useEffect)(()=>{let e=e=>{A(e)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,j.useLayoutEffect)(()=>{let e=n.current;e&&e.querySelector(`[data-global-palette-index="${String(m)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[m,w,g,D.length]);let ee=a===`zh`?`返回`:`Back`;if(g===`models`||g===`agents`){let r=D,i=S.loading;return(0,z.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":a===`zh`?`选择模型或智能体`:`Model or agent picker`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,z.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,z.jsx)(`input`,{ref:t,type:`search`,value:p,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:g===`models`?a===`zh`?`搜索模型…`:`Search models…`:a===`zh`?`搜索智能体…`:`Search agents…`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,z.jsxs)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,"data-global-palette-index":0,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-fg-muted`,m===0?`bg-surface-hover`:`hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:0}),onClick:()=>d({type:`resetMain`}),children:[`← `,ee]})}),i?(0,z.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`加载中…`:`Loading…`}):r.length===0?(0,z.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`无结果`:`No results`}):r.map((t,n)=>{let r=n+1;return(0,z.jsx)(`li`,{children:(0,z.jsx)(`button`,{type:`button`,"data-global-palette-index":r,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,m===r?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:r}),onClick:()=>{g===`models`?(async()=>{await Ce(v(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agents:{defaults:{model:t.id}}})}),by(),lA(),e(),d({type:`resetMain`})})():(window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:t.id}})),e(),d({type:`resetMain`}))},children:(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:t.title}),t.subtitle?(0,z.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:t.subtitle}):null]})})},t.id)})]})]})})}let te=``;return(0,z.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Global search`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,z.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,z.jsx)(`input`,{ref:t,type:`search`,value:p,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:a===`zh`?`搜索…(会话 / 文件 / 设置 / 命令)`:`Search… (sessions, files, settings, commands)`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,z.jsx)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,"aria-activedescendant":w[m]?`global-hit-${w[m].id}`:void 0,children:w.length===0?(0,z.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:T?a===`zh`?`搜索中…`:`Searching…`:E?E instanceof Error?E.message:String(E):a===`zh`?`无结果`:`No results`}):w.map((e,t)=>{let n=e.groupLabel===te?``:e.groupLabel;return te=e.groupLabel,(0,z.jsxs)(`li`,{children:[n?(0,z.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:n}):null,(0,z.jsxs)(`button`,{id:`global-hit-${e.id}`,"data-global-palette-index":t,type:`button`,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,t===m?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:t}),onClick:()=>e.run(),children:[(0,z.jsx)(`span`,{className:`mt-0.5`,children:dA(e)}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.subtitle?(0,z.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.subtitle}):null]})]})]},e.id)})})]})})}function NBe(){let e=(0,fm.c)(7),[t,n]=(0,j.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),n(gA))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,j.useEffect)(r,i);let a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=()=>n(!0);return window.addEventListener(`open-command-palette`,e),()=>window.removeEventListener(`open-command-palette`,e)},o=[],e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,j.useEffect)(a,o);let s,c;if(e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=()=>n(PBe);return window.addEventListener(`toggle-command-palette`,e),()=>window.removeEventListener(`toggle-command-palette`,e)},c=[],e[4]=s,e[5]=c):(s=e[4],c=e[5]),(0,j.useEffect)(s,c),!t)return null;let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(MBe,{onClose:()=>n(!1)}),e[6]=l):l=e[6],l}function PBe(e){return!e}function gA(e){return!e}var _A=`meta+.`,FBe=l(ge(e=>({shortcut:_A,setShortcut:t=>e({shortcut:t})}),{name:`xopc-quick-capture-shortcut`})),IBe={cmd:`meta`,command:`meta`,ctrl:`control`,ctl:`control`,opt:`alt`,option:`alt`};function LBe(e){let t=e.toLowerCase().trim();return IBe[t]??t}function RBe(e,t){let n=t.split(`+`).map(LBe),r=new Set(n.filter(e=>[`meta`,`control`,`alt`,`shift`].includes(e))),i=n.find(e=>!r.has(e));return!i||r.has(`meta`)!==e.metaKey||r.has(`control`)!==e.ctrlKey||r.has(`alt`)!==e.altKey||r.has(`shift`)!==e.shiftKey?!1:e.key.toLowerCase()===i||e.code.toLowerCase()===i}var zBe=`xopc-attachment`,BBe=/^xopc-attachment:\/\/notes\/([^/]+)\/([^/?#]+)$/i;function VBe(e,t){return`${zBe}://notes/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function vA(e,t){let n=e.trim();if(!n)return null;let r=n.split(`?`)[0].match(BBe);if(!r)return null;let i=decodeURIComponent(r[1]),a=decodeURIComponent(r[2]);return t&&i!==t?null:{noteId:i,attachmentId:a}}function HBe(e,t){return`/api/notes/${encodeURIComponent(e)}/media/${encodeURIComponent(t)}`}function UBe(e,t){return VBe(e,t)}function yA(e){if(e<60)return`Voice · ${e}s`;let t=Math.floor(e/60),n=e%60;return`Voice · ${t}:${String(n).padStart(2,`0`)}`}async function bA(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:`HTTP ${e.status}`}async function WBe(e,t){let n=xe.getState().token,r=new Headers;n&&r.set(`Authorization`,`Bearer ${n}`);let i=await fetch(e,{method:`POST`,headers:r,body:t});if(i.status===401&&xe.getState().onUnauthorized(),!i.ok)throw Error(await bA(i));return i.json()}var xA=new Map,SA=``;function CA(e,t,n){return`${n}:${e}:${t}`}function GBe(){let e=xe.getState().token??``;if(e!==SA){for(let e of xA.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);xA.clear(),SA=e}}async function KBe(e,t){GBe();let n=CA(e,t,xe.getState().token??``),r=xA.get(n);return r||(r={blob:(async()=>{let n=await Te(v(HBe(e,t)));if(n.status===401&&xe.getState().onUnauthorized(),!n.ok)throw Error(`HTTP ${n.status}`);return n.blob()})(),objectUrl:null,refCount:0},xA.set(n,r)),r.blob}async function wA(e,t){GBe();let n=CA(e,t,xe.getState().token??``),r=xA.get(n);if(r||(r={blob:KBe(e,t),objectUrl:null,refCount:0},xA.set(n,r)),!r.objectUrl){let e=await r.blob;r.objectUrl=URL.createObjectURL(e)}return r.refCount+=1,r.objectUrl}function TA(e,t){GBe();let n=CA(e,t,xe.getState().token??``),r=xA.get(n);r&&(r.refCount=Math.max(0,r.refCount-1),r.refCount===0&&r.objectUrl&&(URL.revokeObjectURL(r.objectUrl),r.objectUrl=null,xA.delete(n)))}function EA(e){let t=(0,fm.c)(39),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({src:s,expectedNoteId:r,alt:c,className:n,onClick:i,onLoadFailed:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?``:c,u;t[8]!==r||t[9]!==s?(u=vA(s,r),t[8]=r,t[9]=s,t[10]=u):u=t[10];let d=u,[f,p]=(0,j.useState)(d?null:s),[m,h]=(0,j.useState)(!1),g,_;if(t[11]!==a||t[12]!==d||t[13]!==s?(g=()=>{if(h(!1),!d){p(s);return}let e=!1;return p(null),wA(d.noteId,d.attachmentId).then(t=>{e||p(t)}).catch(()=>{e||(h(!0),a?.())}),()=>{e=!0,TA(d.noteId,d.attachmentId)}},_=[s,d,a],t[11]=a,t[12]=d,t[13]=s,t[14]=g,t[15]=_):(g=t[14],_=t[15]),(0,j.useEffect)(g,_),m){let e;t[16]===n?e=t[17]:(e=fh(`flex items-center justify-center bg-surface-hover text-fg-muted`,n),t[16]=n,t[17]=e);let r=!l,i;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(Do,{className:`h-5 w-5`}),t[18]=i):i=t[18];let a;return t[19]!==e||t[20]!==r?(a=(0,z.jsx)(`div`,{className:e,"aria-hidden":r,children:i}),t[19]=e,t[20]=r,t[21]=a):a=t[21],a}if(!f){let e;t[22]===n?e=t[23]:(e=fh(`animate-pulse bg-surface-hover`,n),t[22]=n,t[23]=e);let r=!l,i;return t[24]!==e||t[25]!==r?(i=(0,z.jsx)(`div`,{className:e,"aria-hidden":r}),t[24]=e,t[25]=r,t[26]=i):i=t[26],i}let v;t[27]!==f||t[28]!==i?(v=i?()=>i(f):void 0,t[27]=f,t[28]=i,t[29]=v):v=t[29];let y;t[30]===a?y=t[31]:(y=()=>{h(!0),a?.()},t[30]=a,t[31]=y);let b;return t[32]!==l||t[33]!==n||t[34]!==f||t[35]!==o||t[36]!==v||t[37]!==y?(b=(0,z.jsx)(`img`,{...o,src:f,alt:l,className:n,onClick:v,onError:y}),t[32]=l,t[33]=n,t[34]=f,t[35]=o,t[36]=v,t[37]=y,t[38]=b):b=t[38],b}function DA(e){return e.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^)\s]+)/gi,`/api/notes/$1/media/$2`)}function qBe(e,t){let n=[];return e.querySelectorAll(`.markdown-body img`).forEach(e=>{let r=vA(e.getAttribute(`src`)??``,t);if(!r)return;let i=!1;wA(r.noteId,r.attachmentId).then(t=>{i||(e.src=t)}).catch(()=>{e.classList.add(`note-media-load-failed`)}),n.push(()=>{i=!0,TA(r.noteId,r.attachmentId)})}),e.querySelectorAll(`.markdown-body a`).forEach(e=>{let r=vA(e.getAttribute(`href`)??``,t);if(!r)return;let i=document.createElement(`audio`);i.controls=!0,i.className=`note-media-audio mt-2 w-full max-w-md`,e.replaceWith(i);let a=!1;wA(r.noteId,r.attachmentId).then(e=>{a||(i.src=e)}).catch(()=>{i.remove()}),n.push(()=>{a=!0,TA(r.noteId,r.attachmentId)})}),()=>{for(let e of n)e()}}function JBe(e){let t=(0,fm.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({content:n,noteId:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(0,j.useRef)(null),o;t[4]===r?o=t[5]:(o=()=>{let e=a.current;if(e)return qBe(e,r)},t[4]=r,t[5]=o);let s;t[6]!==n||t[7]!==r?(s=[n,r],t[6]=n,t[7]=r,t[8]=s):s=t[8],(0,j.useLayoutEffect)(o,s);let c;t[9]===n?c=t[10]:(c=DA(n),t[9]=n,t[10]=c);let l;return t[11]!==i||t[12]!==c?(l=(0,z.jsx)(`div`,{ref:a,children:(0,z.jsx)(AD,{content:c,...i})}),t[11]=i,t[12]=c,t[13]=l):l=t[13],l}async function YBe(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.kind&&t.set(`kind`,e.kind),e.tag&&t.set(`tag`,e.tag),e.pinned!==void 0&&t.set(`pinned`,String(e.pinned)),e.search&&t.set(`search`,e.search),e.limit&&t.set(`limit`,String(e.limit)),e.offset&&t.set(`offset`,String(e.offset)),e.sortBy&&t.set(`sortBy`,e.sortBy),e.sortOrder&&t.set(`sortOrder`,e.sortOrder);let n=t.toString();return Ce(v(`/api/notes${n?`?${n}`:``}`))}async function XBe(e,t=`web`){return(await Ce(v(`/api/notes/quick-capture`),{method:`POST`,body:JSON.stringify({text:e,channel:t})})).note}async function ZBe(e){let t=await Te(v(`/api/notes/${encodeURIComponent(e)}`));if(t.status===404)return null;let n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n.note??null}async function QBe(e,t){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).note}async function $Be(e){await Ce(v(`/api/notes/${encodeURIComponent(e)}`),{method:`DELETE`})}async function eVe(e){return Ce(v(`/api/notes/${encodeURIComponent(e)}/catalyze`),{method:`POST`})}async function tVe(e,t){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/catalysis-feedback`),{method:`POST`,body:JSON.stringify({feedback:t})})).note}async function OA(e){return Ce(v(`/api/notes/${encodeURIComponent(e)}/chat`),{method:`POST`})}async function nVe(e){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/threads`))).items}async function kA(e,t,n){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/append`),{method:`POST`,body:JSON.stringify({content:t,heading:n})})).note}async function rVe(e,t={}){return(await Ce(v(`/api/notes/task`),{method:`POST`,body:JSON.stringify({title:e,channel:`web`,priority:t.priority,sourceSessionKey:t.sourceSessionKey||void 0,sourceNoteId:t.sourceNoteId||void 0})})).note}async function AA(e,t){let n=new FormData;return n.append(`file`,t),(await WBe(v(`/api/notes/${encodeURIComponent(e)}/media`),n)).attachment}async function jA(e,t){let n=new FormData;return n.append(`file`,e),t?.markdown&&n.append(`markdown`,t.markdown),n.append(`channel`,t?.channel??`web`),t?.kind&&n.append(`kind`,t.kind),t?.duration!==void 0&&n.append(`duration`,String(t.duration)),(await WBe(v(`/api/notes`),n)).note}async function iVe(e,t=`web`){let n=await jA(e,{channel:t}),r=n.attachments?.find(e=>e.type===`image`)??n.attachments?.[0];if(!r)return n;let i=`})`;return n.markdown!==i&&(n=await QBe(n.id,{markdown:i})),n}async function aVe(e,t,n=`web`){let r=await jA(e,{channel:n,kind:`voice`,duration:t}),i=r.attachments?.find(e=>e.type===`audio`)??r.attachments?.[0];if(!i)return r;let a=`[${yA(t)}](${UBe(r.id,i.id)})`;return r.markdown!==a&&(r=await QBe(r.id,{markdown:a,kind:`voice`})),r}async function oVe(e){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/history`))).entries}async function sVe(e,t){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/history/${t}`))).snapshot}async function cVe(e,t){return(await Ce(v(`/api/notes/${encodeURIComponent(e)}/history/restore`),{method:`POST`,body:JSON.stringify({timestamp:t})})).note}function lVe(e){let t=(0,fm.c)(50),{onClose:n}=e,r=Un(),i=f(MA),a;t[0]===i?a=t[1]:(a=h(i),t[0]=i,t[1]=a);let o=a.notes,[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(!1),d=(0,j.useRef)(null),p,m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{let e=window.setTimeout(()=>d.current?.focus(),50);return()=>window.clearTimeout(e)},m=[],t[2]=p,t[3]=m):(p=t[2],m=t[3]),(0,j.useEffect)(p,m);let g;t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==s?(g=async e=>{let t=s.trim();if(!(!t||l)){u(!0);try{let i=await XBe(t,`web`);n(),e&&r(`/notes/${i.id}`)}catch{u(!1)}}},t[4]=r,t[5]=n,t[6]=l,t[7]=s,t[8]=g):g=t[8];let _=g,v;t[9]!==_||t[10]!==n?(v=e=>{if(e.key===`Escape`){e.preventDefault(),n();return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),_(!0);return}e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),_(!1))},t[9]=_,t[10]=n,t[11]=v):v=t[11];let y=v,b;t[12]===n?b=t[13]:(b=e=>{e.target===e.currentTarget&&n()},t[12]=n,t[13]=b);let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,z.jsx)(Df,{className:`h-4 w-4 text-accent`}),t[14]=x):x=t[14];let S;t[15]===o.quickCapturePlaceholder?S=t[16]:(S=(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[x,(0,z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.quickCapturePlaceholder})]}),t[15]=o.quickCapturePlaceholder,t[16]=S);let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>c(e.target.value),t[17]=C):C=t[17];let w;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(w={fieldSizing:`content`,minHeight:`6rem`,maxHeight:`40vh`},t[18]=w):w=t[18];let T;t[19]!==y||t[20]!==o.quickCapturePlaceholder||t[21]!==l||t[22]!==s?(T=(0,z.jsx)(`textarea`,{ref:d,value:s,onChange:C,onKeyDown:y,placeholder:o.quickCapturePlaceholder,disabled:l,rows:4,className:`resize-none border-none bg-transparent px-4 py-3 text-sm leading-relaxed text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:w}),t[19]=y,t[20]=o.quickCapturePlaceholder,t[21]=l,t[22]=s,t[23]=T):T=t[23];let E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,z.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Enter`}),t[24]=E):E=t[24];let D;t[25]===o.quickCaptureHintEnter?D=t[26]:(D=(0,z.jsxs)(`span`,{children:[E,` `,o.quickCaptureHintEnter]}),t[25]=o.quickCaptureHintEnter,t[26]=D);let O;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,z.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Shift+Enter`}),t[27]=O):O=t[27];let k;t[28]===o.quickCaptureHintShift?k=t[29]:(k=(0,z.jsxs)(`span`,{children:[O,` `,o.quickCaptureHintShift]}),t[28]=o.quickCaptureHintShift,t[29]=k);let A;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,z.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Esc`}),t[30]=A):A=t[30];let ee;t[31]===o.quickCaptureHintEsc?ee=t[32]:(ee=(0,z.jsxs)(`span`,{children:[A,` `,o.quickCaptureHintEsc]}),t[31]=o.quickCaptureHintEsc,t[32]=ee);let te;t[33]!==D||t[34]!==k||t[35]!==ee?(te=(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-[11px] text-fg-muted`,children:[D,k,ee]}),t[33]=D,t[34]=k,t[35]=ee,t[36]=te):te=t[36];let ne;t[37]===l?ne=t[38]:(ne=l&&(0,z.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-accent border-t-transparent`}),t[37]=l,t[38]=ne);let re;t[39]!==te||t[40]!==ne?(re=(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-4 py-2`,children:[te,ne]}),t[39]=te,t[40]=ne,t[41]=re):re=t[41];let ie;t[42]!==T||t[43]!==re||t[44]!==S?(ie=(0,z.jsxs)(`div`,{className:`flex w-full max-w-lg flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[S,T,re]}),t[42]=T,t[43]=re,t[44]=S,t[45]=ie):ie=t[45];let ae;return t[46]!==o.quickCapturePlaceholder||t[47]!==ie||t[48]!==b?(ae=(0,z.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":o.quickCapturePlaceholder,onMouseDown:b,children:ie}),t[46]=o.quickCapturePlaceholder,t[47]=ie,t[48]=b,t[49]=ae):ae=t[49],ae}function MA(e){return e.language}function NA(){let e=(0,fm.c)(8),[t,n]=(0,j.useState)(!1),r=xe(PA),i=FBe(dVe),a,o;e[0]!==i||e[1]!==r?(a=()=>{let e=e=>{RBe(e,i)&&(e.preventDefault(),r&&n(uVe))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},o=[i,r],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,j.useEffect)(a,o);let s,c;if(e[4]===r?(s=e[5],c=e[6]):(s=()=>{let e=()=>{r&&n(!0)};return window.addEventListener(`open-quick-capture`,e),()=>window.removeEventListener(`open-quick-capture`,e)},c=[r],e[4]=r,e[5]=s,e[6]=c),(0,j.useEffect)(s,c),!t)return null;let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(lVe,{onClose:()=>n(!1)}),e[7]=l):l=e[7],l}function uVe(e){return!e}function dVe(e){return e.shortcut}function PA(e){return e.token}var FA=class{_config;_callbacks;_eventSource;_shouldReconnect=!0;_reconnectCount=0;constructor(e,t){this._config=e,this._callbacks=t}get maxReconnectAttempts(){return this._config.maxReconnectAttempts??10}get autoReconnect(){return this._config.autoReconnect??!0}connect(){if(this._eventSource)return;let e=new URL(v(`/api/events`));this._config.token&&e.searchParams.set(`token`,this._config.token),this._eventSource=new EventSource(e.toString()),this._eventSource.onopen=()=>{this._reconnectCount=0},this._eventSource.addEventListener(`connected`,()=>{this._callbacks.onConnected()});for(let e of[`agent.stream`,`config.reload`,`channels.status`,`message.sent`,`session.updated`,`session.transcript_updated`,`session.created`,`dreaming.phase.start`,`dreaming.phase.end`])this._eventSource.addEventListener(e,t=>{this._callbacks.onEvent(e,t.data)});this._eventSource.onerror=()=>{this._eventSource?.readyState===EventSource.CLOSED?this._handlePermanentDisconnect():this._callbacks.onReconnecting()}}_handlePermanentDisconnect(){this._callbacks.onDisconnected(),!(!this._shouldReconnect||!this.autoReconnect)&&(this._reconnectCount++,this._reconnectCount>this.maxReconnectAttempts&&this._callbacks.onError(`Connection failed after max retries`))}disconnect(){this._shouldReconnect=!1,this._eventSource?.close(),this._eventSource=void 0}reconnect(){this._shouldReconnect=!0,this._reconnectCount=0,this.disconnect(),this._shouldReconnect=!0,setTimeout(()=>this.connect(),100)}};function IA(e,t){let n=t;try{n=JSON.parse(t)}catch{}if(e===`config.reload`){lA(n);return}let r=e.replace(/\./g,`-`);if(window.dispatchEvent(new CustomEvent(r,{detail:n})),e===`agent.stream`&&n&&typeof n==`object`&&n){let e=n;typeof e.sessionKey==`string`&&e.sessionKey.length>0&&window.dispatchEvent(new CustomEvent(`agent-stream-event`,{detail:{sessionKey:e.sessionKey,event:e.event===void 0?e:e.event}}))}}var LA=null;function RA(e){LA=e}function fVe(){LA?.reconnect()}var zA=l(()=>({connectionState:`idle`,error:null,reconnectAttempt:0}));function BA(e){zA.setState(e)}function pVe(e){let t=new FA({token:e,autoReconnect:!0,maxReconnectAttempts:10},{onConnected:()=>{BA({connectionState:`connected`,error:null,reconnectAttempt:0})},onReconnecting:()=>{BA({connectionState:`reconnecting`})},onDisconnected:()=>{BA({connectionState:`disconnected`})},onError:e=>{BA({connectionState:`error`,error:e})},onEvent:(e,t)=>{IA(e,t)}});return RA(t),BA({connectionState:`connecting`,error:null}),t.connect(),()=>{t.disconnect(),RA(null),BA({connectionState:`disconnected`,error:null})}}function VA(){RA(null),BA({connectionState:`disconnected`,error:null,reconnectAttempt:0})}function mVe(){let e=(0,fm.c)(3),t=xe(HA),n,r;e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!t){VA();return}return pVe(t)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,j.useEffect)(n,r)}function HA(e){return e.token}function hVe(){return mVe(),null}var UA=1e3,WA=1001,GA=1002,KA=1003,gVe=1004,_Ve=1005,qA=1006,vVe=1007,JA=1008,YA=1009,yVe=1010,XA=1011,ZA=1012,QA=1013,$A=1014,ej=1015,tj=1016,bVe=1017,xVe=1018,SVe=1020,CVe=35902,wVe=35899,nj=1021,rj=1022,ij=1023,aj=1026,oj=1027,sj=1028,cj=1029,lj=1030,uj=1031,dj=1033,TVe=33776,fj=33777,EVe=33778,DVe=33779,OVe=35840,kVe=35841,pj=35842,mj=35843,AVe=36196,hj=37492,jVe=37496,MVe=37488,NVe=37489,PVe=37490,FVe=37491,IVe=37808,gj=37809,_j=37810,vj=37811,yj=37812,bj=37813,xj=37814,Sj=37815,Cj=37816,LVe=37817,wj=37818,RVe=37819,zVe=37820,BVe=37821,Tj=36492,VVe=36494,Ej=36495,Dj=36283,HVe=36284,UVe=36285,Oj=36286,kj=2300,Aj=2301,jj=2302,WVe=2303,Mj=2400,Nj=2401,Pj=2402,GVe=3200,Fj=`srgb`,KVe=`srgb-linear`,Ij=`linear`,Lj=`srgb`,Rj=7680,zj=35044,Bj=2e3;function qVe(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function JVe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function J(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function YVe(){let e=J(`canvas`);return e.style.display=`block`,e}var Vj={},Hj=null;function XVe(...e){let t=`THREE.`+e.shift();Hj?Hj(`log`,t,...e):console.log(t,...e)}function Uj(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function Wj(...e){e=Uj(e);let t=`THREE.`+e.shift();if(Hj)Hj(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function Gj(...e){e=Uj(e);let t=`THREE.`+e.shift();if(Hj)Hj(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Kj(...e){let t=e.join(` `);t in Vj||(Vj[t]=!0,Wj(...e))}function qj(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var Jj={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Yj=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},Xj=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),Zj=Math.PI/180,Qj=180/Math.PI;function $j(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Xj[e&255]+Xj[e>>8&255]+Xj[e>>16&255]+Xj[e>>24&255]+`-`+Xj[t&255]+Xj[t>>8&255]+`-`+Xj[t>>16&15|64]+Xj[t>>24&255]+`-`+Xj[n&63|128]+Xj[n>>8&255]+`-`+Xj[n>>16&255]+Xj[n>>24&255]+Xj[r&255]+Xj[r>>8&255]+Xj[r>>16&255]+Xj[r>>24&255]).toLowerCase()}function eM(e,t,n){return Math.max(t,Math.min(n,e))}function tM(e,t){return(e%t+t)%t}function nM(e,t,n){return(1-n)*e+n*t}function rM(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function iM(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var aM=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=eM(this.x,e.x,t.x),this.y=eM(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=eM(this.x,e,t),this.y=eM(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eM(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(eM(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},oM=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:Wj(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(eM(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},sM=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ZVe.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ZVe.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=eM(this.x,e.x,t.x),this.y=eM(this.y,e.y,t.y),this.z=eM(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=eM(this.x,e,t),this.y=eM(this.y,e,t),this.z=eM(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eM(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return cM.copy(this).projectOnVector(e),this.sub(cM)}reflect(e){return this.sub(cM.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(eM(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},cM=new sM,ZVe=new oM,lM=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(uM.makeScale(e,t)),this}rotate(e){return this.premultiply(uM.makeRotation(-e)),this}translate(e,t){return this.premultiply(uM.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},uM=new lM,QVe=new lM().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dM=new lM().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function fM(){let e={enabled:!0,workingColorSpace:KVe,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Y(e.r),e.g=Y(e.g),e.b=Y(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=mM(e.r),e.g=mM(e.g),e.b=mM(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Ij:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Kj(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Kj(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[KVe]:{primaries:t,whitePoint:r,transfer:Ij,toXYZ:QVe,fromXYZ:dM,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Fj},outputColorSpaceConfig:{drawingBufferColorSpace:Fj}},[Fj]:{primaries:t,whitePoint:r,transfer:Lj,toXYZ:QVe,fromXYZ:dM,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Fj}}}),e}var pM=fM();function Y(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function mM(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var hM,$Ve=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{hM===void 0&&(hM=J(`canvas`)),hM.width=e.width,hM.height=e.height;let t=hM.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=hM}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=J(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Y(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Y(t[e]/255)*255):t[e]=Y(t[e]);return{data:t,width:e.width,height:e.height}}else return Wj(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},eHe=0,gM=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:eHe++}),this.uuid=$j(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(_M(r[t].image)):e.push(_M(r[t]))}else e=_M(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function _M(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?$Ve.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(Wj(`Texture: Unable to serialize Texture.`),{})}var tHe=0,vM=new sM,yM=class e extends Yj{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=WA,i=WA,a=qA,o=JA,s=ij,c=YA,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:tHe++}),this.uuid=$j(),this.name=``,this.source=new gM(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new aM(0,0),this.repeat=new aM(1,1),this.center=new aM(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new lM,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(vM).x}get height(){return this.source.getSize(vM).y}get depth(){return this.source.getSize(vM).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Wj(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Wj(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case UA:e.x-=Math.floor(e.x);break;case WA:e.x=e.x<0?0:1;break;case GA:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case UA:e.y-=Math.floor(e.y);break;case WA:e.y=e.y<0?0:1;break;case GA:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};yM.DEFAULT_IMAGE=null,yM.DEFAULT_MAPPING=300,yM.DEFAULT_ANISOTROPY=1;var bM=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=eM(this.x,e.x,t.x),this.y=eM(this.y,e.y,t.y),this.z=eM(this.z,e.z,t.z),this.w=eM(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=eM(this.x,e,t),this.y=eM(this.y,e,t),this.z=eM(this.z,e,t),this.w=eM(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(eM(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},xM=class extends Yj{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qA,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new bM(0,0,e,t),this.scissorTest=!1,this.viewport=new bM(0,0,e,t),this.textures=[];let r=new yM({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:qA,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new gM(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this}dispose(){this.dispatchEvent({type:`dispose`})}},SM=class extends xM{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},CM=class extends yM{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=KA,this.minFilter=KA,this.wrapR=WA,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},nHe=class extends yM{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=KA,this.minFilter=KA,this.wrapR=WA,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},wM=class e{static{e.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/TM.setFromMatrixColumn(e,0).length(),i=1/TM.setFromMatrixColumn(e,1).length(),a=1/TM.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(rHe,e,iHe)}lookAt(e,t,n){let r=this.elements;return kM.subVectors(e,t),kM.lengthSq()===0&&(kM.z=1),kM.normalize(),DM.crossVectors(n,kM),DM.lengthSq()===0&&(Math.abs(n.z)===1?kM.x+=1e-4:kM.z+=1e-4,kM.normalize(),DM.crossVectors(n,kM)),DM.normalize(),OM.crossVectors(kM,DM),r[0]=DM.x,r[4]=OM.x,r[8]=kM.x,r[1]=DM.y,r[5]=OM.y,r[9]=kM.y,r[2]=DM.z,r[6]=OM.z,r[10]=kM.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],ee=r[10],te=r[14],ne=r[3],re=r[7],ie=r[11],ae=r[15];return i[0]=a*x+o*T+s*k+c*ne,i[4]=a*S+o*E+s*A+c*re,i[8]=a*C+o*D+s*ee+c*ie,i[12]=a*w+o*O+s*te+c*ae,i[1]=l*x+u*T+d*k+f*ne,i[5]=l*S+u*E+d*A+f*re,i[9]=l*C+u*D+d*ee+f*ie,i[13]=l*w+u*O+d*te+f*ae,i[2]=p*x+m*T+h*k+g*ne,i[6]=p*S+m*E+h*A+g*re,i[10]=p*C+m*D+h*ee+g*ie,i[14]=p*w+m*O+h*te+g*ae,i[3]=_*x+v*T+y*k+b*ne,i[7]=_*S+v*E+y*A+b*re,i[11]=_*C+v*D+y*ee+b*ie,i[15]=_*w+v*O+y*te+b*ae,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=TM.set(r[0],r[1],r[2]).length(),o=TM.set(r[4],r[5],r[6]).length(),s=TM.set(r[8],r[9],r[10]).length();i<0&&(a=-a),EM.copy(this);let c=1/a,l=1/o,u=1/s;return EM.elements[0]*=c,EM.elements[1]*=c,EM.elements[2]*=c,EM.elements[4]*=l,EM.elements[5]*=l,EM.elements[6]*=l,EM.elements[8]*=u,EM.elements[9]*=u,EM.elements[10]*=u,t.setFromRotationMatrix(EM),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=Bj,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Bj,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},TM=new sM,EM=new wM,rHe=new sM(0,0,0),iHe=new sM(1,1,1),DM=new sM,OM=new sM,kM=new sM,aHe=new wM,AM=new oM,jM=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(eM(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-eM(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(eM(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-eM(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(eM(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-eM(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:Wj(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return aHe.makeRotationFromQuaternion(e),this.setFromRotationMatrix(aHe,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return AM.setFromEuler(this),this.setFromQuaternion(AM,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};jM.DEFAULT_ORDER=`XYZ`;var MM=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},oHe=0,sHe=new sM,NM=new oM,PM=new wM,FM=new sM,IM=new sM,cHe=new sM,lHe=new oM,uHe=new sM(1,0,0),dHe=new sM(0,1,0),fHe=new sM(0,0,1),pHe={type:`added`},mHe={type:`removed`},LM={type:`childadded`,child:null},RM={type:`childremoved`,child:null},zM=class e extends Yj{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:oHe++}),this.uuid=$j(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new sM,n=new jM,r=new oM,i=new sM(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new wM},normalMatrix:{value:new lM}}),this.matrix=new wM,this.matrixWorld=new wM,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new MM,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return NM.setFromAxisAngle(e,t),this.quaternion.multiply(NM),this}rotateOnWorldAxis(e,t){return NM.setFromAxisAngle(e,t),this.quaternion.premultiply(NM),this}rotateX(e){return this.rotateOnAxis(uHe,e)}rotateY(e){return this.rotateOnAxis(dHe,e)}rotateZ(e){return this.rotateOnAxis(fHe,e)}translateOnAxis(e,t){return sHe.copy(e).applyQuaternion(this.quaternion),this.position.add(sHe.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(uHe,e)}translateY(e){return this.translateOnAxis(dHe,e)}translateZ(e){return this.translateOnAxis(fHe,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(PM.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?FM.copy(e):FM.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),IM.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?PM.lookAt(IM,FM,this.up):PM.lookAt(FM,IM,this.up),this.quaternion.setFromRotationMatrix(PM),r&&(PM.extractRotation(r.matrixWorld),NM.setFromRotationMatrix(PM),this.quaternion.premultiply(NM.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(Gj(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(pHe),LM.child=e,this.dispatchEvent(LM),LM.child=null):Gj(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(mHe),RM.child=e,this.dispatchEvent(RM),RM.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),PM.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),PM.multiply(e.parent.matrixWorld)),e.applyMatrix4(PM),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(pHe),LM.child=e,this.dispatchEvent(LM),LM.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(IM,e,cHe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(IM,lHe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};zM.DEFAULT_UP=new sM(0,1,0),zM.DEFAULT_MATRIX_AUTO_UPDATE=!0,zM.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var BM=class extends zM{constructor(){super(),this.isGroup=!0,this.type=`Group`}},VM={type:`move`},HM=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new BM,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new BM,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new sM,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new sM),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new BM,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new sM,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new sM,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(VM)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new BM;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},hHe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},UM={h:0,s:0,l:0},WM={h:0,s:0,l:0};function GM(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var KM=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Fj){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pM.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=pM.workingColorSpace){return this.r=e,this.g=t,this.b=n,pM.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=pM.workingColorSpace){if(e=tM(e,1),t=eM(t,0,1),n=eM(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=GM(i,r,e+1/3),this.g=GM(i,r,e),this.b=GM(i,r,e-1/3)}return pM.colorSpaceToWorking(this,r),this}setStyle(e,t=Fj){function n(t){t!==void 0&&parseFloat(t)<1&&Wj(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:Wj(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);Wj(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fj){let n=hHe[e.toLowerCase()];return n===void 0?Wj(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Y(e.r),this.g=Y(e.g),this.b=Y(e.b),this}copyLinearToSRGB(e){return this.r=mM(e.r),this.g=mM(e.g),this.b=mM(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fj){return pM.workingToColorSpace(qM.copy(this),e),Math.round(eM(qM.r*255,0,255))*65536+Math.round(eM(qM.g*255,0,255))*256+Math.round(eM(qM.b*255,0,255))}getHexString(e=Fj){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pM.workingColorSpace){pM.workingToColorSpace(qM.copy(this),t);let n=qM.r,r=qM.g,i=qM.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=pM.workingColorSpace){return pM.workingToColorSpace(qM.copy(this),t),e.r=qM.r,e.g=qM.g,e.b=qM.b,e}getStyle(e=Fj){pM.workingToColorSpace(qM.copy(this),e);let t=qM.r,n=qM.g,r=qM.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(UM),this.setHSL(UM.h+e,UM.s+t,UM.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(UM),e.getHSL(WM);let n=nM(UM.h,WM.h,t),r=nM(UM.s,WM.s,t),i=nM(UM.l,WM.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},qM=new KM;KM.NAMES=hHe;var gHe=class extends zM{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new jM,this.environmentIntensity=1,this.environmentRotation=new jM,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},JM=new sM,YM=new sM,_He=new sM,XM=new sM,ZM=new sM,QM=new sM,vHe=new sM,$M=new sM,eN=new sM,tN=new sM,yHe=new bM,bHe=new bM,nN=new bM,rN=class e{constructor(e=new sM,t=new sM,n=new sM){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),JM.subVectors(e,t),r.cross(JM);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){JM.subVectors(r,t),YM.subVectors(n,t),_He.subVectors(e,t);let a=JM.dot(JM),o=JM.dot(YM),s=JM.dot(_He),c=YM.dot(YM),l=YM.dot(_He),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,XM)===null?!1:XM.x>=0&&XM.y>=0&&XM.x+XM.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,XM)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,XM.x),s.addScaledVector(a,XM.y),s.addScaledVector(o,XM.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return yHe.setScalar(0),bHe.setScalar(0),nN.setScalar(0),yHe.fromBufferAttribute(e,t),bHe.fromBufferAttribute(e,n),nN.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(yHe,i.x),a.addScaledVector(bHe,i.y),a.addScaledVector(nN,i.z),a}static isFrontFacing(e,t,n,r){return JM.subVectors(n,t),YM.subVectors(e,t),JM.cross(YM).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return JM.subVectors(this.c,this.b),YM.subVectors(this.a,this.b),JM.cross(YM).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;ZM.subVectors(r,n),QM.subVectors(i,n),$M.subVectors(e,n);let s=ZM.dot($M),c=QM.dot($M);if(s<=0&&c<=0)return t.copy(n);eN.subVectors(e,r);let l=ZM.dot(eN),u=QM.dot(eN);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(ZM,a);tN.subVectors(e,i);let f=ZM.dot(tN),p=QM.dot(tN);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(QM,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return vHe.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(vHe,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(ZM,a).addScaledVector(QM,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},iN=class{constructor(e=new sM(1/0,1/0,1/0),t=new sM(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(oN.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(oN.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=oN.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,oN):oN.fromBufferAttribute(r,t),oN.applyMatrix4(e.matrixWorld),this.expandByPoint(oN);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),sN.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),sN.copy(e.boundingBox)),sN.applyMatrix4(e.matrixWorld),this.union(sN)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,oN),oN.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(mN),hN.subVectors(this.max,mN),cN.subVectors(e.a,mN),lN.subVectors(e.b,mN),uN.subVectors(e.c,mN),dN.subVectors(lN,cN),fN.subVectors(uN,lN),pN.subVectors(cN,uN);let t=[0,-dN.z,dN.y,0,-fN.z,fN.y,0,-pN.z,pN.y,dN.z,0,-dN.x,fN.z,0,-fN.x,pN.z,0,-pN.x,-dN.y,dN.x,0,-fN.y,fN.x,0,-pN.y,pN.x,0];return!xHe(t,cN,lN,uN,hN)||(t=[1,0,0,0,1,0,0,0,1],!xHe(t,cN,lN,uN,hN))?!1:(gN.crossVectors(dN,fN),t=[gN.x,gN.y,gN.z],xHe(t,cN,lN,uN,hN))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,oN).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(oN).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(aN[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),aN[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),aN[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),aN[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),aN[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),aN[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),aN[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),aN[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(aN),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},aN=[new sM,new sM,new sM,new sM,new sM,new sM,new sM,new sM],oN=new sM,sN=new iN,cN=new sM,lN=new sM,uN=new sM,dN=new sM,fN=new sM,pN=new sM,mN=new sM,hN=new sM,gN=new sM,_N=new sM;function xHe(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){_N.fromArray(e,a);let o=i.x*Math.abs(_N.x)+i.y*Math.abs(_N.y)+i.z*Math.abs(_N.z),s=t.dot(_N),c=n.dot(_N),l=r.dot(_N);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var vN=new sM,yN=new aM,bN=0,xN=class extends Yj{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:bN++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=zj,this.updateRanges=[],this.gpuType=ej,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)yN.fromBufferAttribute(this,t),yN.applyMatrix3(e),this.setXY(t,yN.x,yN.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)vN.fromBufferAttribute(this,t),vN.applyMatrix3(e),this.setXYZ(t,vN.x,vN.y,vN.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)vN.fromBufferAttribute(this,t),vN.applyMatrix4(e),this.setXYZ(t,vN.x,vN.y,vN.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)vN.fromBufferAttribute(this,t),vN.applyNormalMatrix(e),this.setXYZ(t,vN.x,vN.y,vN.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)vN.fromBufferAttribute(this,t),vN.transformDirection(e),this.setXYZ(t,vN.x,vN.y,vN.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=rM(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=iM(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=rM(t,this.array)),t}setX(e,t){return this.normalized&&(t=iM(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=rM(t,this.array)),t}setY(e,t){return this.normalized&&(t=iM(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=rM(t,this.array)),t}setZ(e,t){return this.normalized&&(t=iM(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=rM(t,this.array)),t}setW(e,t){return this.normalized&&(t=iM(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=iM(t,this.array),n=iM(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=iM(t,this.array),n=iM(n,this.array),r=iM(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=iM(t,this.array),n=iM(n,this.array),r=iM(r,this.array),i=iM(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:`dispose`})}},SN=class extends xN{constructor(e,t,n){super(new Uint16Array(e),t,n)}},CN=class extends xN{constructor(e,t,n){super(new Uint32Array(e),t,n)}},wN=class extends xN{constructor(e,t,n){super(new Float32Array(e),t,n)}},TN=new iN,EN=new sM,DN=new sM,ON=class{constructor(e=new sM,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?TN.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;EN.subVectors(e,this.center);let t=EN.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(EN,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(DN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(EN.copy(e.center).add(DN)),this.expandByPoint(EN.copy(e.center).sub(DN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},kN=0,AN=new wM,SHe=new zM,jN=new sM,MN=new iN,NN=new iN,PN=new sM,FN=class e extends Yj{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kN++}),this.uuid=$j(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(qVe(e)?CN:SN)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new lM().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return AN.makeRotationFromQuaternion(e),this.applyMatrix4(AN),this}rotateX(e){return AN.makeRotationX(e),this.applyMatrix4(AN),this}rotateY(e){return AN.makeRotationY(e),this.applyMatrix4(AN),this}rotateZ(e){return AN.makeRotationZ(e),this.applyMatrix4(AN),this}translate(e,t,n){return AN.makeTranslation(e,t,n),this.applyMatrix4(AN),this}scale(e,t,n){return AN.makeScale(e,t,n),this.applyMatrix4(AN),this}lookAt(e){return SHe.lookAt(e),SHe.updateMatrix(),this.applyMatrix4(SHe.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(jN).negate(),this.translate(jN.x,jN.y,jN.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new wN(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&Wj(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new iN);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Gj(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new sM(-1/0,-1/0,-1/0),new sM(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];MN.setFromBufferAttribute(n),this.morphTargetsRelative?(PN.addVectors(this.boundingBox.min,MN.min),this.boundingBox.expandByPoint(PN),PN.addVectors(this.boundingBox.max,MN.max),this.boundingBox.expandByPoint(PN)):(this.boundingBox.expandByPoint(MN.min),this.boundingBox.expandByPoint(MN.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Gj(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ON);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Gj(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new sM,1/0);return}if(e){let n=this.boundingSphere.center;if(MN.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];NN.setFromBufferAttribute(n),this.morphTargetsRelative?(PN.addVectors(MN.min,NN.min),MN.expandByPoint(PN),PN.addVectors(MN.max,NN.max),MN.expandByPoint(PN)):(MN.expandByPoint(NN.min),MN.expandByPoint(NN.max))}MN.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)PN.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(PN));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)PN.fromBufferAttribute(a,t),o&&(jN.fromBufferAttribute(e,t),PN.add(jN)),r=Math.max(r,n.distanceToSquared(PN))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Gj(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Gj(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new xN(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new sM,s[e]=new sM;let c=new sM,l=new sM,u=new sM,d=new aM,f=new aM,p=new aM,m=new sM,h=new sM;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new sM,y=new sM,b=new sM,x=new sM;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new xN(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new sM,i=new sM,a=new sM,o=new sM,s=new sM,c=new sM,l=new sM,u=new sM;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)PN.fromBufferAttribute(e,t),PN.normalize(),e.setXYZ(t,PN.x,PN.y,PN.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new xN(a,r,i)}if(this.index===null)return Wj(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},CHe=0,IN=class extends Yj{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:CHe++}),this.uuid=$j(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new KM(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Rj,this.stencilZFail=Rj,this.stencilZPass=Rj,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Wj(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Wj(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},LN=new sM,RN=new sM,zN=new sM,BN=new sM,VN=new sM,HN=new sM,UN=new sM,WN=class{constructor(e=new sM,t=new sM(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,LN)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=LN.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(LN.copy(this.origin).addScaledVector(this.direction,t),LN.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){RN.copy(e).add(t).multiplyScalar(.5),zN.copy(t).sub(e).normalize(),BN.copy(this.origin).sub(RN);let i=e.distanceTo(t)*.5,a=-this.direction.dot(zN),o=BN.dot(this.direction),s=-BN.dot(zN),c=BN.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(RN).addScaledVector(zN,d),f}intersectSphere(e,t){LN.subVectors(e.center,this.origin);let n=LN.dot(this.direction),r=LN.dot(LN)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,LN)!==null}intersectTriangle(e,t,n,r,i){VN.subVectors(t,e),HN.subVectors(n,e),UN.crossVectors(VN,HN);let a=this.direction.dot(UN),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;BN.subVectors(this.origin,e);let s=o*this.direction.dot(HN.crossVectors(BN,HN));if(s<0)return null;let c=o*this.direction.dot(VN.cross(BN));if(c<0||s+c>a)return null;let l=-o*BN.dot(UN);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},GN=class extends IN{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new KM(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jM,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},KN=new wM,qN=new WN,JN=new ON,YN=new sM,XN=new sM,ZN=new sM,QN=new sM,$N=new sM,eP=new sM,tP=new sM,nP=new sM,rP=class extends zM{constructor(e=new FN,t=new GN){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){eP.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&($N.fromBufferAttribute(s,e),a?eP.addScaledVector($N,r):eP.addScaledVector($N.sub(t),r))}t.add(eP)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),JN.copy(n.boundingSphere),JN.applyMatrix4(i),qN.copy(e.ray).recast(e.near),!(JN.containsPoint(qN.origin)===!1&&(qN.intersectSphere(JN,YN)===null||qN.origin.distanceToSquared(YN)>(e.far-e.near)**2))&&(KN.copy(i).invert(),qN.copy(e.ray).applyMatrix4(KN),!(n.boundingBox!==null&&qN.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,qN)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=aP(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=aP(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=aP(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=aP(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function iP(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;nP.copy(s),nP.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(nP);return l<n.near||l>n.far?null:{distance:l,point:nP.clone(),object:e}}function aP(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,XN),e.getVertexPosition(c,ZN),e.getVertexPosition(l,QN);let u=iP(e,t,n,r,XN,ZN,QN,tP);if(u){let e=new sM;rN.getBarycoord(tP,XN,ZN,QN,e),i&&(u.uv=rN.getInterpolatedAttribute(i,s,c,l,e,new aM)),a&&(u.uv1=rN.getInterpolatedAttribute(a,s,c,l,e,new aM)),o&&(u.normal=rN.getInterpolatedAttribute(o,s,c,l,e,new sM),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new sM,materialIndex:0};rN.getNormal(XN,ZN,QN,t.normal),u.face=t,u.barycoord=e}return u}var oP=class extends yM{constructor(e=null,t=1,n=1,r,i,a,o,s,c=KA,l=KA,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},sP=new sM,cP=new sM,wHe=new lM,lP=class{constructor(e=new sM(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=sP.subVectors(n,t).cross(cP.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(sP),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||wHe.getNormalMatrix(e),r=this.coplanarPoint(sP).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},uP=new ON,THe=new aM(.5,.5),dP=new sM,EHe=class{constructor(e=new lP,t=new lP,n=new lP,r=new lP,i=new lP,a=new lP){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Bj,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),uP.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),uP.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(uP)}intersectsSprite(e){return uP.center.set(0,0,0),uP.radius=.7071067811865476+THe.distanceTo(e.center),uP.applyMatrix4(e.matrixWorld),this.intersectsSphere(uP)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(dP.x=r.normal.x>0?e.max.x:e.min.x,dP.y=r.normal.y>0?e.max.y:e.min.y,dP.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(dP)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},fP=class extends IN{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new KM(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},pP=new sM,mP=new sM,hP=new wM,gP=new WN,_P=new ON,vP=new sM,yP=new sM,bP=class extends zM{constructor(e=new FN,t=new fP){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)pP.fromBufferAttribute(t,e-1),mP.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=pP.distanceTo(mP);e.setAttribute(`lineDistance`,new wN(n,1))}else Wj(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),_P.copy(n.boundingSphere),_P.applyMatrix4(r),_P.radius+=i,e.ray.intersectsSphere(_P)===!1)return;hP.copy(r).invert(),gP.copy(e.ray).applyMatrix4(hP);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=xP(this,e,gP,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=xP(this,e,gP,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=xP(this,e,gP,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=xP(this,e,gP,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function xP(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(pP.fromBufferAttribute(s,i),mP.fromBufferAttribute(s,a),n.distanceSqToSegment(pP,mP,vP,yP)>r)return;vP.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(vP);if(!(c<t.near||c>t.far))return{distance:c,point:yP.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var SP=new sM,DHe=new sM,CP=class extends bP{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)SP.fromBufferAttribute(t,e),DHe.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+SP.distanceTo(DHe);e.setAttribute(`lineDistance`,new wN(n,1))}else Wj(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},wP=class extends IN{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new KM(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},OHe=new wM,TP=new WN,EP=new ON,DP=new sM,OP=class extends zM{constructor(e=new FN,t=new wP){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),EP.copy(n.boundingSphere),EP.applyMatrix4(r),EP.radius+=i,e.ray.intersectsSphere(EP)===!1)return;OHe.copy(r).invert(),TP.copy(e.ray).applyMatrix4(OHe);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);DP.fromBufferAttribute(l,n),kP(DP,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)DP.fromBufferAttribute(l,a),kP(DP,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function kP(e,t,n,r,i,a,o){let s=TP.distanceSqToPoint(e);if(s<n){let n=new sM;TP.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var kHe=class extends yM{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},AP=class extends yM{constructor(e,t,n=$A,r,i,a,o=KA,s=KA,c,l=aj,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new gM(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},jP=class extends AP{constructor(e,t=$A,n=301,r,i,a=KA,o=KA,s,c=aj){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},MP=class extends yM{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},NP=class e extends FN{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new wN(c,3)),this.setAttribute(`normal`,new wN(l,3)),this.setAttribute(`uv`,new wN(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new sM;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},PP=class e extends FN{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new wN(p,3)),this.setAttribute(`normal`,new wN(m,3)),this.setAttribute(`uv`,new wN(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}};function FP(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(LP(i))i.isRenderTargetTexture?(Wj(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i))if(LP(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice();else t[n][r]=i}}return t}function IP(e){let t={};for(let n=0;n<e.length;n++){let r=FP(e[n]);for(let e in r)t[e]=r[e]}return t}function LP(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function RP(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function AHe(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:pM.workingColorSpace}var jHe={clone:FP,merge:IP},MHe=`void main() {
|
|
232
232
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
233
233
|
}`,NHe=`void main() {
|
|
234
234
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -4837,4 +4837,4 @@ void main() {
|
|
|
4837
4837
|
`)})]}):null,c?.trim()?(0,z.jsxs)(`section`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:d.scriptHeading}),(0,z.jsx)(`pre`,{className:`max-h-60 min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/35`,children:c})]}):null,ee?null:(0,z.jsx)(`div`,{className:`text-xs text-fg-disabled`,children:d.noExtraDetails})]}):null,t[53]=ee,t[54]=ae,t[55]=C,t[56]=E,t[57]=k,t[58]=le,t[59]=se,t[60]=d,t[61]=_,t[62]=u,t[63]=re,t[64]=T,t[65]=c,t[66]=l,t[67]=O,t[68]=h,t[69]=x,t[70]=Te):Te=t[70];let Ee;return t[71]!==ye||t[72]!==we||t[73]!==Te||t[74]!==p?(Ee=(0,z.jsxs)(`div`,{className:ye,role:`group`,"aria-label":p,children:[we,Te]}),t[71]=ye,t[72]=we,t[73]=Te,t[74]=p,t[75]=Ee):Ee=t[75],Ee}),OZe={parse_error:(0,z.jsx)(Gc,{className:`size-4 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0}),aborted:(0,z.jsx)(xi,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),timeout:(0,z.jsx)(ep,{className:`size-4 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),runtime_error:(0,z.jsx)(fp,{className:`size-4 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0})};function eV(e){return!e}function tV(e){return!e}function kZe(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`text-fg-disabled`,children:`•`}),(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]},e)}var AZe=(0,j.memo)(function(e){let t=(0,fm.c)(49),{rollup:n,isCurrent:r,labels:i,selectedAgentId:a,onSelectAgent:o}=e,[s,c]=(0,j.useState)(r||n.running>0||n.errored>0||n.skipped>0||!n.complete),l,u;t[0]===r?(l=t[1],u=t[2]):(l=()=>{r&&c(!0)},u=[r],t[0]=r,t[1]=l,t[2]=u),(0,j.useEffect)(l,u);let d=n.agents.length,f;t[3]!==n.complete||t[4]!==n.running?(f=n.running>0?(0,z.jsx)(Ts,{className:`size-3.5 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}):n.complete?(0,z.jsx)(E,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,z.jsx)(Si,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[3]=n.complete,t[4]=n.running,t[5]=f):f=t[5];let p=f,m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>c(nV),t[6]=m):m=t[6];let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=fh(`flex w-full min-w-0 items-center gap-2 rounded-md px-1 py-1 text-left`,`text-sm font-medium text-fg`,`hover:bg-surface-hover`,yh.transition,yh.focusRingPanel),t[7]=h):h=t[7];let g=s&&`rotate-90`,_;t[8]===g?_=t[9]:(_=fh(`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150`,g),t[8]=g,t[9]=_);let v;t[10]===_?v=t[11]:(v=(0,z.jsx)(ai,{className:_,"aria-hidden":!0}),t[10]=_,t[11]=v);let y;t[12]===n.title?y=t[13]:(y=(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.title}),t[12]=n.title,t[13]=y);let b;t[14]!==i||t[15]!==n.done||t[16]!==d?(b=i.countTpl(n.done,d),t[14]=i,t[15]=n.done,t[16]=d,t[17]=b):b=t[17];let x;t[18]===b?x=t[19]:(x=(0,z.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:b}),t[18]=b,t[19]=x);let S;t[20]!==i||t[21]!==n.running?(S=n.running>0?(0,z.jsx)(`span`,{className:`text-accent-fg`,children:i.runningTag(n.running)}):null,t[20]=i,t[21]=n.running,t[22]=S):S=t[22];let C;t[23]!==i||t[24]!==n.errored?(C=n.errored>0?(0,z.jsx)(`span`,{className:`text-rose-600 dark:text-rose-400`,children:i.errorsTag(n.errored)}):null,t[23]=i,t[24]=n.errored,t[25]=C):C=t[25];let w;t[26]!==i||t[27]!==n.skipped?(w=n.skipped>0?(0,z.jsx)(`span`,{children:i.skippedTag(n.skipped)}):null,t[26]=i,t[27]=n.skipped,t[28]=w):w=t[28];let T;t[29]!==S||t[30]!==C||t[31]!==w?(T=(0,z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-disabled`,children:[S,C,w]}),t[29]=S,t[30]=C,t[31]=w,t[32]=T):T=t[32];let D;t[33]!==s||t[34]!==p||t[35]!==x||t[36]!==T||t[37]!==v||t[38]!==y?(D=(0,z.jsxs)(`button`,{type:`button`,onClick:m,"aria-expanded":s,className:h,children:[v,p,y,x,T]}),t[33]=s,t[34]=p,t[35]=x,t[36]=T,t[37]=v,t[38]=y,t[39]=D):D=t[39];let O;t[40]!==i||t[41]!==o||t[42]!==s||t[43]!==n.agents||t[44]!==a?(O=s?(0,z.jsxs)(`div`,{className:`ml-4 mt-0.5 space-y-0.5 border-l border-edge-subtle pl-2`,children:[n.agents.map(e=>(0,z.jsx)(QB,{agent:e,labels:i,selected:a===e.id,onSelect:o},e.id)),n.agents.length===0?(0,z.jsx)(`div`,{className:`px-1.5 py-0.5 text-xs text-fg-disabled`,children:`…`}):null]}):null,t[40]=i,t[41]=o,t[42]=s,t[43]=n.agents,t[44]=a,t[45]=O):O=t[45];let k;return t[46]!==D||t[47]!==O?(k=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[46]=D,t[47]=O,t[48]=k):k=t[48],k});function nV(e){return!e}function jZe(e){let t=(0,fm.c)(44),{snapshot:n,labels:r,logsExpanded:i,onToggleLogs:a,selectedAgentId:o,onSelectAgent:s}=e,c;t[0]===n.agents?c=t[1]:(c=n.agents.filter(FZe),t[0]=n.agents,t[1]=c);let l=c,u;t[2]===n.agents?u=t[3]:(u=n.agents.filter(PZe),t[2]=n.agents,t[3]=u);let d=u,f;t[4]===n.agents?f=t[5]:(f=n.agents.filter(NZe),t[4]=n.agents,t[5]=f);let p=f,m;t[6]===n.agents?m=t[7]:(m=n.agents.filter(MZe),t[6]=n.agents,t[7]=m);let h=m,g;t[8]!==r.phase||t[9]!==r.runningAgentsHeading||t[10]!==s||t[11]!==l||t[12]!==o?(g=(0,z.jsx)(rV,{heading:r.runningAgentsHeading,agents:l,labels:r.phase,selectedAgentId:o,onSelectAgent:s}),t[8]=r.phase,t[9]=r.runningAgentsHeading,t[10]=s,t[11]=l,t[12]=o,t[13]=g):g=t[13];let _;t[14]!==d||t[15]!==r.failedAgentsHeading||t[16]!==r.phase||t[17]!==s||t[18]!==o?(_=(0,z.jsx)(rV,{heading:r.failedAgentsHeading,agents:d,labels:r.phase,selectedAgentId:o,onSelectAgent:s}),t[14]=d,t[15]=r.failedAgentsHeading,t[16]=r.phase,t[17]=s,t[18]=o,t[19]=_):_=t[19];let v;t[20]!==p||t[21]!==r.completedAgentsHeading||t[22]!==r.phase||t[23]!==s||t[24]!==o?(v=(0,z.jsx)(rV,{heading:r.completedAgentsHeading,agents:p,labels:r.phase,selectedAgentId:o,onSelectAgent:s}),t[20]=p,t[21]=r.completedAgentsHeading,t[22]=r.phase,t[23]=s,t[24]=o,t[25]=v):v=t[25];let y;t[26]!==r.phase||t[27]!==r.queuedAgentsHeading||t[28]!==s||t[29]!==h||t[30]!==o?(y=(0,z.jsx)(rV,{heading:r.queuedAgentsHeading,agents:h,labels:r.phase,selectedAgentId:o,onSelectAgent:s}),t[26]=r.phase,t[27]=r.queuedAgentsHeading,t[28]=s,t[29]=h,t[30]=o,t[31]=y):y=t[31];let b;t[32]!==r.recentLogsHeading||t[33]!==r.showAllLogs||t[34]!==i||t[35]!==a||t[36]!==n.logs?(b=(0,z.jsx)(IZe,{recentLogs:n.logs,recentLogsHeading:r.recentLogsHeading,showAllLogsLabel:r.showAllLogs,logsExpanded:i,onToggleLogs:a}),t[32]=r.recentLogsHeading,t[33]=r.showAllLogs,t[34]=i,t[35]=a,t[36]=n.logs,t[37]=b):b=t[37];let x;return t[38]!==g||t[39]!==_||t[40]!==v||t[41]!==y||t[42]!==b?(x=(0,z.jsxs)(`div`,{className:`space-y-3`,children:[g,_,v,y,b]}),t[38]=g,t[39]=_,t[40]=v,t[41]=y,t[42]=b,t[43]=x):x=t[43],x}function MZe(e){return e.status===`queued`}function NZe(e){return e.status===`done`}function PZe(e){return e.status===`error`||e.status===`skipped`}function FZe(e){return e.status===`running`}function rV(e){let t=(0,fm.c)(16),{heading:n,agents:r,labels:i,selectedAgentId:a,onSelectAgent:o}=e;if(r.length===0)return null;let s;t[0]===n?s=t[1]:(s=(0,z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=s);let c;if(t[2]!==r||t[3]!==i||t[4]!==o||t[5]!==a){let e;t[7]!==i||t[8]!==o||t[9]!==a?(e=e=>(0,z.jsx)(QB,{agent:e,labels:i,selected:a===e.id,onSelect:o},e.id),t[7]=i,t[8]=o,t[9]=a,t[10]=e):e=t[10],c=r.map(e),t[2]=r,t[3]=i,t[4]=o,t[5]=a,t[6]=c}else c=t[6];let l;t[11]===c?l=t[12]:(l=(0,z.jsx)(`div`,{className:`space-y-0.5`,children:c}),t[11]=c,t[12]=l);let u;return t[13]!==s||t[14]!==l?(u=(0,z.jsxs)(`section`,{className:`min-w-0`,children:[s,l]}),t[13]=s,t[14]=l,t[15]=u):u=t[15],u}function IZe(e){let t=(0,fm.c)(19),{recentLogs:n,recentLogsHeading:r,showAllLogsLabel:i,logsExpanded:a,onToggleLogs:o}=e,s;t[0]!==a||t[1]!==n?(s=a||n.length<=2?n:n.slice(-2),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===r?l=t[4]:(l=(0,z.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r}),t[3]=r,t[4]=l);let u;t[5]!==o||t[6]!==n.length||t[7]!==i?(u=n.length>2?(0,z.jsx)(`button`,{type:`button`,onClick:o,className:`text-[10px] text-accent-fg hover:underline`,children:i}):null,t[5]=o,t[6]=n.length,t[7]=i,t[8]=u):u=t[8];let d;t[9]!==l||t[10]!==u?(d=(0,z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f;t[12]===c?f=t[13]:(f=c.map(LZe),t[12]=c,t[13]=f);let p;t[14]===f?p=t[15]:(p=(0,z.jsx)(`div`,{className:`space-y-0.5`,children:f}),t[14]=f,t[15]=p);let m;return t[16]!==d||t[17]!==p?(m=(0,z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2`,children:[d,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18],m}function LZe(e){return(0,z.jsx)(`div`,{className:`break-words font-mono text-xs text-fg-subtle`,children:e},e)}function RZe(e){let t=(0,fm.c)(29),{rollup:n,currentPhase:r,labels:i,recentLogs:a,recentLogsHeading:o,showAllLogsLabel:s,logsExpanded:c,onToggleLogs:l,selectedAgentId:u,onSelectAgent:d}=e,f;t[0]!==c||t[1]!==a?(f=c||a.length<=2?a:a.slice(-2),t[0]=c,t[1]=a,t[2]=f):f=t[2];let p=f,m;if(t[3]!==r||t[4]!==i||t[5]!==d||t[6]!==n.phases||t[7]!==u){let e;t[9]!==r||t[10]!==i||t[11]!==d||t[12]!==u?(e=e=>(0,z.jsx)(AZe,{rollup:e,isCurrent:e.title===r,labels:i,selectedAgentId:u,onSelectAgent:d},e.title),t[9]=r,t[10]=i,t[11]=d,t[12]=u,t[13]=e):e=t[13],m=n.phases.map(e),t[3]=r,t[4]=i,t[5]=d,t[6]=n.phases,t[7]=u,t[8]=m}else m=t[8];let h;t[14]!==i||t[15]!==d||t[16]!==n.unphased||t[17]!==u?(h=n.unphased?(0,z.jsx)(AZe,{rollup:n.unphased,isCurrent:!1,labels:i,selectedAgentId:u,onSelectAgent:d}):null,t[14]=i,t[15]=d,t[16]=n.unphased,t[17]=u,t[18]=h):h=t[18];let g;t[19]!==l||t[20]!==a.length||t[21]!==o||t[22]!==s||t[23]!==p?(g=a.length>0?(0,z.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:o}),a.length>2?(0,z.jsx)(`button`,{type:`button`,onClick:l,className:`text-[10px] text-accent-fg hover:underline`,children:s}):null]}),(0,z.jsx)(`div`,{className:`space-y-0.5`,children:p.map(zZe)})]}):null,t[19]=l,t[20]=a.length,t[21]=o,t[22]=s,t[23]=p,t[24]=g):g=t[24];let _;return t[25]!==m||t[26]!==h||t[27]!==g?(_=(0,z.jsxs)(`div`,{className:`space-y-1`,children:[m,h,g]}),t[25]=m,t[26]=h,t[27]=g,t[28]=_):_=t[28],_}function zZe(e){return(0,z.jsx)(`div`,{className:`break-words font-mono text-xs text-fg-subtle`,children:e},e)}var iV=5,BZe=(0,j.memo)(function(e){let t=(0,fm.c)(69),{result:n,labels:r}=e;if(n==null){let e;return t[0]===r.emptyResult?e=t[1]:(e=(0,z.jsx)(`div`,{className:`text-sm text-fg-disabled`,children:r.emptyResult}),t[0]=r.emptyResult,t[1]=e),e}if(typeof n!=`object`){let e;return t[2]!==r.rawHeading||t[3]!==n?(e=(0,z.jsx)(sV,{value:n,heading:r.rawHeading}),t[2]=r.rawHeading,t[3]=n,t[4]=e):e=t[4],e}let i=n,a;if(t[5]!==r||t[6]!==i.actions||t[7]!==i.checklist||t[8]!==i.conclusion||t[9]!==i.decision||t[10]!==i.executiveSummary||t[11]!==i.findings||t[12]!==i.nextSteps||t[13]!==i.openQuestions||t[14]!==i.recommendations||t[15]!==i.summary||t[16]!==i.topFindings||t[17]!==i.topRisks){if(a=[],typeof i.executiveSummary==`string`&&i.executiveSummary.trim()){let e;t[19]!==r.executiveSummaryHeading||t[20]!==i.executiveSummary?(e=(0,z.jsx)(VZe,{heading:r.executiveSummaryHeading,text:i.executiveSummary},`exec`),t[19]=r.executiveSummaryHeading,t[20]=i.executiveSummary,t[21]=e):e=t[21],a.push(e)}else if(typeof i.summary==`string`&&i.summary.trim()){let e;t[22]!==r.summaryHeading||t[23]!==i.summary?(e=(0,z.jsx)(VZe,{heading:r.summaryHeading,text:i.summary},`sum`),t[22]=r.summaryHeading,t[23]=i.summary,t[24]=e):e=t[24],a.push(e)}let e;t[25]!==i.conclusion||t[26]!==i.decision?(e=KZe(i.conclusion,i.decision),t[25]=i.conclusion,t[26]=i.decision,t[27]=e):e=t[27];let n=e;if(n){let e;t[28]!==n||t[29]!==r.conclusionHeading?(e=(0,z.jsx)(VZe,{heading:r.conclusionHeading,text:n},`conclusion`),t[28]=n,t[29]=r.conclusionHeading,t[30]=e):e=t[30],a.push(e)}let o;t[31]!==i.actions||t[32]!==i.recommendations?(o=cV(i.recommendations)??cV(i.actions),t[31]=i.actions,t[32]=i.recommendations,t[33]=o):o=t[33];let s=o;if(s&&s.length>0){let e;t[34]!==r.moreSuffix||t[35]!==r.recommendationsHeading||t[36]!==s?(e=(0,z.jsx)(aV,{heading:r.recommendationsHeading,items:s,moreSuffix:r.moreSuffix},`recommendations`),t[34]=r.moreSuffix,t[35]=r.recommendationsHeading,t[36]=s,t[37]=e):e=t[37],a.push(e)}let c;t[38]===i.nextSteps?c=t[39]:(c=cV(i.nextSteps),t[38]=i.nextSteps,t[39]=c);let l=c;if(l&&l.length>0){let e;t[40]!==r.moreSuffix||t[41]!==r.nextStepsHeading||t[42]!==l?(e=(0,z.jsx)(aV,{heading:r.nextStepsHeading,items:l,moreSuffix:r.moreSuffix},`nextSteps`),t[40]=r.moreSuffix,t[41]=r.nextStepsHeading,t[42]=l,t[43]=e):e=t[43],a.push(e)}let u;t[44]===i.checklist?u=t[45]:(u=cV(i.checklist),t[44]=i.checklist,t[45]=u);let d=u;if(d&&d.length>0){let e;t[46]!==d||t[47]!==r.checklistHeading||t[48]!==r.moreSuffix?(e=(0,z.jsx)(aV,{heading:r.checklistHeading,items:d,moreSuffix:r.moreSuffix},`checklist`),t[46]=d,t[47]=r.checklistHeading,t[48]=r.moreSuffix,t[49]=e):e=t[49],a.push(e)}let f=GZe(i.topFindings)??GZe(i.findings);f&&f.length>0&&a.push((0,z.jsx)(oV,{items:f,heading:r.topFindingsHeading(f.length),moreSuffix:r.moreSuffix},`findings`));let p=GZe(i.topRisks);p&&p.length>0&&a.push((0,z.jsx)(oV,{items:p,heading:r.topRisksHeading(p.length),moreSuffix:r.moreSuffix},`risks`));let m=cV(i.openQuestions);if(m&&m.length>0){let e;t[50]===r.openQuestionsHeading?e=t[51]:(e=(0,z.jsx)(`summary`,{className:`cursor-pointer select-none text-[10px] font-medium uppercase tracking-wide text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:r.openQuestionsHeading}),t[50]=r.openQuestionsHeading,t[51]=e);let n=(0,z.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-sm text-fg-muted`,children:[m.slice(0,iV).map(lV),m.length>iV?(0,z.jsx)(`li`,{className:`pl-4 text-xs text-fg-disabled`,children:r.moreSuffix(m.length-iV)}):null]}),i;t[52]!==e||t[53]!==n?(i=(0,z.jsxs)(`details`,{className:`group min-w-0`,children:[e,n]},`oq`),t[52]=e,t[53]=n,t[54]=i):i=t[54],a.push(i)}t[5]=r,t[6]=i.actions,t[7]=i.checklist,t[8]=i.conclusion,t[9]=i.decision,t[10]=i.executiveSummary,t[11]=i.findings,t[12]=i.nextSteps,t[13]=i.openQuestions,t[14]=i.recommendations,t[15]=i.summary,t[16]=i.topFindings,t[17]=i.topRisks,t[18]=a}else a=t[18];if(a.length===0){let e;return t[55]!==r.rawHeading||t[56]!==n?(e=(0,z.jsx)(sV,{value:n,heading:r.rawHeading}),t[55]=r.rawHeading,t[56]=n,t[57]=e):e=t[57],e}let o;t[58]===r.rawHeading?o=t[59]:(o=(0,z.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:r.rawHeading}),t[58]=r.rawHeading,t[59]=o);let s;t[60]!==r.rawHeading||t[61]!==n?(s=(0,z.jsx)(sV,{value:n,heading:r.rawHeading,hideHeading:!0}),t[60]=r.rawHeading,t[61]=n,t[62]=s):s=t[62];let c;t[63]!==o||t[64]!==s?(c=(0,z.jsxs)(`details`,{className:`group`,children:[o,s]}),t[63]=o,t[64]=s,t[65]=c):c=t[65];let l;return t[66]!==a||t[67]!==c?(l=(0,z.jsxs)(`div`,{className:`space-y-3`,children:[a,c]}),t[66]=a,t[67]=c,t[68]=l):l=t[68],l});function VZe(e){let t=(0,fm.c)(7),{heading:n,text:r}=e,i;t[0]===n?i=t[1]:(i=(0,z.jsx)(`summary`,{className:`cursor-pointer select-none text-[10px] font-medium uppercase tracking-wide text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,z.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsxs)(`details`,{className:`group min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function aV(e){let t=(0,fm.c)(21),{heading:n,items:r,moreSuffix:i}=e,a,o,s,c,l;t[0]!==n||t[1]!==r?(l=r.slice(0,iV),s=`group min-w-0`,t[7]===n?c=t[8]:(c=(0,z.jsx)(`summary`,{className:`cursor-pointer select-none text-[10px] font-medium uppercase tracking-wide text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:n}),t[7]=n,t[8]=c),a=`mt-1 space-y-0.5 text-sm text-fg-muted`,o=l.map(HZe),t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):(a=t[2],o=t[3],s=t[4],c=t[5],l=t[6]);let u;t[9]!==r.length||t[10]!==i||t[11]!==l.length?(u=r.length>l.length?(0,z.jsx)(`li`,{className:`pl-4 text-xs text-fg-disabled`,children:i(r.length-l.length)}):null,t[9]=r.length,t[10]=i,t[11]=l.length,t[12]=u):u=t[12];let d;t[13]!==a||t[14]!==o||t[15]!==u?(d=(0,z.jsxs)(`ul`,{className:a,children:[o,u]}),t[13]=a,t[14]=o,t[15]=u,t[16]=d):d=t[16];let f;return t[17]!==s||t[18]!==c||t[19]!==d?(f=(0,z.jsxs)(`details`,{className:s,children:[c,d]}),t[17]=s,t[18]=c,t[19]=d,t[20]=f):f=t[20],f}function HZe(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`text-fg-disabled`,children:`•`}),(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]},e)}function oV(e){let t=(0,fm.c)(21),{items:n,heading:r,moreSuffix:i}=e,a,o,s,c,l;t[0]!==r||t[1]!==n?(l=n.slice(0,iV),s=`group min-w-0`,t[7]===r?c=t[8]:(c=(0,z.jsx)(`summary`,{className:`cursor-pointer select-none text-[10px] font-medium uppercase tracking-wide text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:r}),t[7]=r,t[8]=c),a=`mt-1 space-y-1`,o=l.map(UZe),t[0]=r,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):(a=t[2],o=t[3],s=t[4],c=t[5],l=t[6]);let u;t[9]!==a||t[10]!==o?(u=(0,z.jsx)(`ul`,{className:a,children:o}),t[9]=a,t[10]=o,t[11]=u):u=t[11];let d;t[12]!==n.length||t[13]!==i||t[14]!==l.length?(d=n.length>l.length?(0,z.jsx)(`div`,{className:`mt-1 pl-1 text-xs text-fg-disabled`,children:i(n.length-l.length)}):null,t[12]=n.length,t[13]=i,t[14]=l.length,t[15]=d):d=t[15];let f;return t[16]!==s||t[17]!==c||t[18]!==u||t[19]!==d?(f=(0,z.jsxs)(`details`,{className:s,children:[c,u,d]}),t[16]=s,t[17]=c,t[18]=u,t[19]=d,t[20]=f):f=t[20],f}function UZe(e){return(0,z.jsx)(WZe,{item:e},`${e.file??``}:${e.line??``}:${e.title??e.reason??e.fix??``}`)}function WZe(e){let t=(0,fm.c)(21),{item:n}=e,r=YB(n.severity),i=r===`high`?`bg-rose-500/15 text-rose-700 dark:text-rose-300`:r===`med`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`,a=n.file?n.line===void 0?n.file:`${n.file}:${n.line}`:n.source??``,o=n.dimension??n.lens??``,s;t[0]!==n.severity||t[1]!==i?(s=n.severity?(0,z.jsx)(`span`,{className:fh(`mt-0.5 shrink-0 rounded px-1.5 py-px text-[10px] font-medium uppercase`,i),children:String(n.severity).slice(0,4)}):(0,z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-disabled`,children:`•`}),t[0]=n.severity,t[1]=i,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=o?(0,z.jsx)(`span`,{className:`mr-1.5 text-xs text-fg-subtle`,children:o}):null,t[3]=o,t[4]=c);let l=n.title??n.reason??`(no title)`,u;t[5]===l?u=t[6]:(u=(0,z.jsx)(`span`,{className:`text-fg`,children:l}),t[5]=l,t[6]=u);let d;t[7]!==c||t[8]!==u?(d=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[c,u]}),t[7]=c,t[8]=u,t[9]=d):d=t[9];let f;t[10]===a?f=t[11]:(f=a?(0,z.jsx)(`div`,{className:`truncate font-mono text-xs text-fg-subtle`,title:a,children:a}):null,t[10]=a,t[11]=f);let p;t[12]===n.fix?p=t[13]:(p=n.fix?(0,z.jsxs)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:[`↳ `,n.fix]}):null,t[12]=n.fix,t[13]=p);let m;t[14]!==d||t[15]!==f||t[16]!==p?(m=(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[d,f,p]}),t[14]=d,t[15]=f,t[16]=p,t[17]=m):m=t[17];let h;return t[18]!==s||t[19]!==m?(h=(0,z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[s,m]}),t[18]=s,t[19]=m,t[20]=h):h=t[20],h}function sV(e){let t=(0,fm.c)(10),{value:n,heading:r,hideHeading:i}=e,a;try{let e;t[0]===n?e=t[1]:(e=JSON.stringify(n,null,2),t[0]=n,t[1]=e),a=e}catch{a=String(n)}let o;t[2]!==r||t[3]!==i?(o=i?null:(0,z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r}),t[2]=r,t[3]=i,t[4]=o):o=t[4];let s;t[5]===a?s=t[6]:(s=(0,z.jsx)(`pre`,{className:`max-h-72 min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/35`,children:a}),t[5]=a,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function GZe(e){return Array.isArray(e)&&e.length>0?e:null}function cV(e){if(!Array.isArray(e))return null;let t=e.filter(e=>typeof e==`string`&&e.trim().length>0);return t.length>0?t:null}function KZe(...e){for(let t of e)if(typeof t==`string`&&t.trim())return t;return null}function lV(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`text-fg-disabled`,children:`•`}),(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]},e)}var uV=(0,j.memo)(function({block:e,startedAt:t,sessionKey:n,onAbort:r,onSendChatMessage:i,labels:a,className:o}){let s=uZe(e),c=(0,j.useMemo)(()=>lZe(e),[e]),l=Un(),u=s===`failed`?hZe(e):null,d=s===`failed`?GB(e):``,[f,p]=(0,j.useState)(!1);(0,j.useEffect)(()=>{s===`completed`&&p(!0),(s===`running`||s===`failed`)&&p(!1)},[s]);let[m,h]=(0,j.useState)(!1),[g,_]=(0,j.useState)(null),[v,y]=(0,j.useState)(null),[b,x]=(0,j.useState)(!1),S=(0,j.useMemo)(()=>g==null||!c?null:c.agents.find(e=>e.id===g)??null,[g,c]),C=(0,j.useCallback)(e=>{_(e.id)},[]),w=(0,j.useCallback)(()=>{_(null)},[]),[,T]=(0,j.useState)(0);(0,j.useEffect)(()=>{if(s!==`running`)return;let e=window.setInterval(()=>T(e=>e+1),1e3);return()=>window.clearInterval(e)},[s]);let E=(0,j.useMemo)(()=>s===`running`?t?qB(Date.now()-t):``:c?.durationMs==null?``:qB(c.durationMs),[s,t,c?.durationMs]),[O,k]=(0,j.useState)(!1),A=(0,j.useCallback)(async()=>{c&&await Sh(typeof c.result==`string`?c.result:JZe(c.result))&&(k(!0),window.setTimeout(()=>k(!1),1500))},[c]),[ee,te]=(0,j.useState)(!1),[ne,re]=(0,j.useState)(``),ie=(0,j.useRef)(null);(0,j.useEffect)(()=>{ee&&(ne||re(c?.name??``),window.setTimeout(()=>ie.current?.focus(),0))},[ee,ne,c?.name]);let ae=(0,j.useCallback)(()=>{let e=ne.trim();!e||!i||(i(`/workflow save ${e}`),te(!1))},[ne,i]),oe=(0,j.useCallback)(()=>{let e=c?.name?.trim();e&&l(`/workflows?tab=catalog&def=${encodeURIComponent(e)}`)},[l,c?.name]);if(dZe(e)||s===`completed`&&!c){let t=u??hZe(e),r=fZe(e),i=qZe(e),s=r.snapshot,c=g==null||!s?null:s.agents.find(e=>e.id===g)??null;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($B,{kind:t,reason:r.headline||d||`workflow failed`,detailLines:r.detailLines,logs:r.logs,failedAgents:r.failedAgents,snapshot:s,scriptPreview:i,selectedAgentId:g,onSelectAgent:C,labels:a.error,className:o}),(0,z.jsx)(XB,{open:g!=null&&c!=null,agent:c,snapshot:s,sessionKey:n,pinnedAgentId:v,onPinAgent:y,onClose:w,labels:a.drawer})]})}let se=c?.agentCount??0,ce=c?.doneCount??0,le=c?gZe(c):{phases:[],unphased:null},ue=s===`running`&&c?a.currentProgressTpl(c.currentPhase,c.runningCount,c.doneCount,c.agentCount):void 0,de=(0,z.jsxs)(z.Fragment,{children:[s===`running`&&r?(0,z.jsx)(`button`,{type:`button`,onClick:r,className:fh(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-rose-600 dark:hover:text-rose-400`,yh.transition,yh.focusRingPanel),"aria-label":a.cancel,title:a.cancel,children:(0,z.jsx)(bi,{className:`size-4`})}):null,s===`completed`&&c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,onClick:A,className:fh(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yh.transition,yh.focusRingPanel),"aria-label":O?a.copyDoneAria:a.copyAria,title:O?a.copyDoneAria:a.copyAria,children:O?(0,z.jsx)(ei,{className:`size-4 text-emerald-600 dark:text-emerald-400`}):(0,z.jsx)(D,{className:`size-4`})}),i?(0,z.jsx)(`button`,{type:`button`,onClick:()=>te(e=>!e),className:fh(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yh.transition,yh.focusRingPanel),"aria-label":a.saveAria,title:a.saveTitle,children:(0,z.jsx)(zu,{className:`size-4`})}):null,c?.name?(0,z.jsx)(`button`,{type:`button`,onClick:oe,className:fh(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yh.transition,yh.focusRingPanel),"aria-label":a.openInWorkflowsAria,title:a.openInWorkflowsTitle,children:(0,z.jsx)(no,{className:`size-4`})}):null,(0,z.jsx)(`button`,{type:`button`,className:fh(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yh.transition,yh.focusRingPanel,`invisible`),"aria-label":a.moreAria,title:a.moreAria,children:(0,z.jsx)(ra,{className:`size-4`})})]}):null]});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:fh(`min-w-0 rounded-xl border border-edge bg-surface-panel shadow-surface`,o),role:`group`,"aria-label":c?`Workflow ${c.name}`:`Workflow`,children:[(0,z.jsx)(TZe,{name:c?.name??e.name,description:c?.description,status:s,doneCount:ce,totalCount:se,durationText:E,metaText:ue,collapsed:f,onToggleCollapsed:()=>p(e=>!e),actions:de,labels:a.header}),ee&&s===`completed`?(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 border-b border-edge-subtle px-3 py-2`,children:[(0,z.jsx)(`input`,{ref:ie,type:`text`,value:ne,onChange:e=>re(e.target.value),onKeyDown:e=>{e.key===`Enter`?ae():e.key===`Escape`&&te(!1)},placeholder:a.savePlaceholder,className:fh(`min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-2 py-1 text-sm text-fg`,`placeholder:text-fg-disabled`,yh.focusRingPanel)}),(0,z.jsx)(`button`,{type:`button`,onClick:ae,disabled:!ne.trim(),className:fh(`inline-flex h-7 items-center rounded-md bg-accent px-2.5 text-xs font-medium text-fg-onAccent`,`hover:bg-accent-hover`,yh.transition,yh.focusRingPanel,yh.disabled),children:a.saveSubmit}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>te(!1),className:fh(`inline-flex h-7 items-center rounded-md px-2 text-xs text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yh.transition,yh.focusRingPanel),children:a.saveCancel})]}):null,f?null:(0,z.jsxs)(`div`,{className:`space-y-3 px-3 py-2.5`,children:[s===`completed`&&c?(0,z.jsx)(BZe,{result:c.result,labels:a.result}):null,s===`running`&&c?(0,z.jsx)(jZe,{snapshot:c,labels:a,logsExpanded:b,onToggleLogs:()=>x(e=>!e),selectedAgentId:g,onSelectAgent:C}):null,s===`running`&&!c?(0,z.jsxs)(`div`,{className:`py-1 text-sm text-fg-subtle`,children:[(0,z.jsx)(`span`,{className:`inline-block size-2 animate-pulse rounded-full bg-accent align-middle`}),(0,z.jsx)(`span`,{className:`ml-2 align-middle`,children:a.viewSubagentsHeading})]}):null,s===`completed`&&c&&(le.phases.length>0||le.unphased)?(0,z.jsxs)(`details`,{className:`group`,open:m,onToggle:e=>h(e.target.open),children:[(0,z.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:a.viewSubagentsHeading}),(0,z.jsx)(`div`,{className:`mt-2`,children:(0,z.jsx)(RZe,{rollup:le,currentPhase:void 0,labels:a.phase,recentLogs:[],recentLogsHeading:a.recentLogsHeading,showAllLogsLabel:a.showAllLogs,logsExpanded:!1,onToggleLogs:()=>{},selectedAgentId:g,onSelectAgent:C})})]}):null]})]}),(0,z.jsx)(XB,{open:g!=null&&S!=null,agent:S,snapshot:c,sessionKey:n,pinnedAgentId:v,onPinAgent:y,onClose:w,labels:a.drawer})]})});function qZe(e){if(!e.input||typeof e.input!=`object`)return;let t=e.input;if(typeof t.script==`string`&&t.script.trim())return t.script.split(`
|
|
4838
4838
|
`).slice(0,80).join(`
|
|
4839
4839
|
`)}function JZe(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function dV(e){return e===`zh`?$Ze():QZe()}function YZe(){return QZe()}function XZe(){return{close:`Close`,statusQueued:`Queued`,statusRunning:`Running`,statusDone:`Completed`,statusError:`Failed`,statusSkipped:`Skipped`,workedFor:e=>`Worked for ${e}`,statusHeading:`Status`,phaseHeading:`Phase`,elapsedHeading:`Elapsed`,currentStepHeading:`Current step`,executionHeading:`Execution process`,promptHeading:`Prompt`,stepsHeading:`Steps`,outputHeading:`Output`,logsHeading:`Workflow logs`,pin:`Pin`,pinned:`Pinned`,runningPlaceholder:`Waiting for subagent steps…`,resizeLabel:`Resize drawer`,stream:{heading:`Live output`,empty:`No streamed output yet`}}}function ZZe(){return{close:`关闭`,statusQueued:`排队中`,statusRunning:`运行中`,statusDone:`已完成`,statusError:`失败`,statusSkipped:`已跳过`,workedFor:e=>`已运行 ${e}`,statusHeading:`状态`,phaseHeading:`阶段`,elapsedHeading:`耗时`,currentStepHeading:`当前步骤`,executionHeading:`执行过程`,promptHeading:`输入`,stepsHeading:`步骤`,outputHeading:`输出`,logsHeading:`工作流日志`,pin:`固定`,pinned:`已固定`,runningPlaceholder:`等待子 agent 步骤…`,resizeLabel:`调整抽屉宽度`,stream:{heading:`实时输出`,empty:`暂无流式输出`}}}function QZe(){return{header:{collapse:`Collapse`,expand:`Expand`,runningMeta:(e,t)=>t?`${e} · ${t}`:`${e}`,completedMeta:(e,t)=>t?`✓ ${e} · ${t}`:`✓ ${e}`,failedMeta:`failed`},phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} running`,errorsTag:e=>`· ${e} errors`,skippedTag:e=>`· ${e} skipped`,showPrompt:`Show prompt`,hidePrompt:`Hide prompt`,promptHeading:`Prompt`,resultPreviewHeading:`Result`,errorHeading:`Error`,emptyPreview:`(no preview)`,agentNumber:e=>`#${e}`,queued:`Queued`,running:`Running…`,openDetail:`View agent details`},drawer:XZe(),result:{topFindingsHeading:e=>`Top findings (${e})`,topRisksHeading:e=>`Top risks (${e})`,executiveSummaryHeading:`Executive summary`,summaryHeading:`Summary`,openQuestionsHeading:`Open questions`,conclusionHeading:`Conclusion`,recommendationsHeading:`Recommendations`,nextStepsHeading:`Next steps`,checklistHeading:`Checklist`,moreSuffix:e=>`${e} more…`,rawHeading:`View raw result`,emptyResult:`(no result)`},error:{titleParse:`Workflow parse error`,titleAbort:`Workflow aborted`,titleTimeout:`Workflow timed out`,titleRuntime:`Workflow failed`,expand:`Expand details`,collapse:`Collapse details`,expandHint:`Click to see error details`,detailsHeading:`Failure reason`,impactHeading:`Impact`,recoveryHeading:`Recommended actions`,recoveryActions:{parse_error:[`Check the workflow script syntax.`,`Make sure workflow fields use the expected snake_case shape.`],aborted:[`The run was stopped. Start it again if you still need the result.`],timeout:[`Retry the workflow.`,`If it times out again, reduce concurrency or check model/API availability.`],runtime_error:[`Review the failed agent first.`,`Use the completed agent results if they are still relevant.`,`Copy the error details if you want to continue diagnosis.`]},logsHeading:`Technical logs`,failedAgentsHeading:`Agent execution status`,executedAgentsHeading:`Agent execution status`,progressHeading:`Execution process`,scriptHeading:`Submitted script`,noExtraDetails:`No additional details recorded.`,copyReason:`Copy`,copyReasonDone:`Copied`,impactTpl:(e,t,n)=>`${e}/${t} agents completed · ${n} need attention`,phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} running`,errorsTag:e=>`· ${e} errors`,skippedTag:e=>`· ${e} skipped`,showPrompt:`Show prompt`,hidePrompt:`Hide prompt`,promptHeading:`Prompt`,resultPreviewHeading:`Result`,errorHeading:`Error`,emptyPreview:`(no preview)`,agentNumber:e=>`#${e}`,queued:`Queued`,running:`Running…`,openDetail:`View agent details`}},cancel:`Cancel workflow`,saveAria:`Save workflow…`,saveTitle:`Save this workflow under a name (~/.xopc/workflows/)`,savePlaceholder:`snake_case_name`,saveSubmit:`Save`,saveCancel:`Cancel`,saveDispatched:`Saved`,copyAria:`Copy result`,copyDoneAria:`Copied`,moreAria:`More actions`,openInWorkflowsAria:`Open in Workflows`,openInWorkflowsTitle:`Open this workflow in the Workflows center`,viewSubagentsHeading:`View agents`,runningProgressHeading:`Current progress`,runningAgentsHeading:`Running agents`,completedAgentsHeading:`Completed agents`,queuedAgentsHeading:`Queued agents`,failedAgentsHeading:`Needs attention`,currentProgressTpl:(e,t,n,r)=>`${e?`Phase: ${e}`:`Workflow is running`} · ${t} running · ${n}/${r} completed`,recentLogsHeading:`Recent updates`,showAllLogs:`Show all`}}function $Ze(){return{header:{collapse:`收起`,expand:`展开`,runningMeta:(e,t)=>t?`${e} · ${t}`:`${e}`,completedMeta:(e,t)=>t?`✓ ${e} · ${t}`:`✓ ${e}`,failedMeta:`失败`},phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} 运行中`,errorsTag:e=>`· ${e} 失败`,skippedTag:e=>`· ${e} 已跳过`,showPrompt:`查看 prompt`,hidePrompt:`收起 prompt`,promptHeading:`Prompt`,resultPreviewHeading:`结果预览`,errorHeading:`错误`,emptyPreview:`(暂无预览)`,agentNumber:e=>`#${e}`,queued:`排队中`,running:`运行中…`,openDetail:`查看 agent 详情`},drawer:ZZe(),result:{topFindingsHeading:e=>`主要发现(${e})`,topRisksHeading:e=>`主要风险(${e})`,executiveSummaryHeading:`摘要`,summaryHeading:`总结`,openQuestionsHeading:`待解决的问题`,conclusionHeading:`结论`,recommendationsHeading:`处理建议`,nextStepsHeading:`建议下一步`,checklistHeading:`检查清单`,moreSuffix:e=>`还有 ${e} 条…`,rawHeading:`查看原始结果`,emptyResult:`(无结果)`},error:{titleParse:`工作流解析失败`,titleAbort:`工作流已中止`,titleTimeout:`工作流超时`,titleRuntime:`工作流执行失败`,expand:`展开详情`,collapse:`收起详情`,expandHint:`点击查看错误详情`,detailsHeading:`失败原因`,impactHeading:`影响范围`,recoveryHeading:`建议处理`,recoveryActions:{parse_error:[`检查工作流脚本语法。`,`确认工作流字段使用预期的 snake_case 格式。`],aborted:[`本次执行已停止。如仍需要结果,可以重新运行。`],timeout:[`重新运行工作流。`,`如果仍然超时,建议降低并发或检查模型/API 可用性。`],runtime_error:[`优先查看失败智能体。`,`已完成智能体的结果仍可按需参考。`,`需要继续诊断时,可以复制错误详情。`]},logsHeading:`技术日志`,failedAgentsHeading:`智能体执行状态`,executedAgentsHeading:`智能体执行状态`,progressHeading:`执行过程`,scriptHeading:`提交的脚本`,noExtraDetails:`没有更多诊断信息。`,copyReason:`复制`,copyReasonDone:`已复制`,impactTpl:(e,t,n)=>`已完成 ${e}/${t} 个智能体 · ${n} 个需要关注`,phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} 运行中`,errorsTag:e=>`· ${e} 失败`,skippedTag:e=>`· ${e} 已跳过`,showPrompt:`查看 prompt`,hidePrompt:`收起 prompt`,promptHeading:`Prompt`,resultPreviewHeading:`结果预览`,errorHeading:`错误`,emptyPreview:`(暂无预览)`,agentNumber:e=>`#${e}`,queued:`排队中`,running:`运行中…`,openDetail:`查看 agent 详情`}},cancel:`取消工作流`,saveAria:`保存工作流…`,saveTitle:`把这个工作流保存到 ~/.xopc/workflows/`,savePlaceholder:`snake_case 名字`,saveSubmit:`保存`,saveCancel:`取消`,saveDispatched:`已保存`,copyAria:`复制结果`,copyDoneAria:`已复制`,moreAria:`更多操作`,openInWorkflowsAria:`在工作流中心打开`,openInWorkflowsTitle:`在工作流中心查看此工作流`,viewSubagentsHeading:`查看智能体`,runningProgressHeading:`当前进展`,runningAgentsHeading:`正在运行`,completedAgentsHeading:`已完成`,queuedAgentsHeading:`排队中`,failedAgentsHeading:`需要关注`,currentProgressTpl:(e,t,n,r)=>`${e?`正在执行 ${e}`:`工作流正在执行`} · ${t} 个运行中 · 已完成 ${n}/${r}`,recentLogsHeading:`最近更新`,showAllLogs:`显示全部`}}function eQe(e,t){switch(e.code){case`provider_setup_required`:return{title:t.providerSetupRequiredTitle,body:t.providerSetupRequiredBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.providerSetupRequiredCta,deepLink:`/settings/credentials`};case`provider_auth_invalid`:return{title:t.agentRunErrorAuthInvalidTitle,body:t.agentRunErrorAuthInvalidBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.agentRunErrorCtaProviders,deepLink:`/settings/credentials`};case`rate_limit`:return{title:t.agentRunErrorRateLimitTitle,body:t.agentRunErrorRateLimitBody};case`timeout`:return{title:t.agentRunErrorTimeoutTitle,body:t.agentRunErrorTimeoutBody};case`billing`:return{title:t.agentRunErrorBillingTitle,body:t.agentRunErrorBillingBody};case`send_failed`:return{title:t.agentRunErrorSendFailedTitle,body:t.agentRunErrorSendFailedBody};default:return{title:t.agentRunErrorUnknownTitle,body:t.agentRunErrorUnknownBody}}}function tQe(e){let t=(0,fm.c)(4),{code:n}=e;switch(n){case`provider_setup_required`:case`provider_auth_invalid`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(Uo,{className:`size-4`,strokeWidth:1.75}),t[0]=e):e=t[0],e}case`rate_limit`:case`timeout`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(ki,{className:`size-4`,strokeWidth:1.75}),t[1]=e):e=t[1],e}case`billing`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(lCe,{className:`size-4`,strokeWidth:1.75}),t[2]=e):e=t[2],e}default:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(di,{className:`size-4`,strokeWidth:1.75}),t[3]=e):e=t[3],e}}}function nQe(e){return e===`provider_setup_required`||e===`provider_auth_invalid`||e===`rate_limit`||e===`timeout`||e===`billing`?`amber`:`red`}function rQe(e){let t=(0,fm.c)(44),{payload:n}=e,r=Un(),i=f(fV),a,o;t[0]!==i||t[1]!==n?(a=h(i).chat,o=eQe(n,a),t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c=nQe(n.code),l=c===`amber`?`border-amber-300/60 bg-amber-50/70 dark:border-amber-500/30 dark:bg-amber-500/10`:`border-red-300/60 bg-red-50/70 dark:border-red-500/30 dark:bg-red-500/10`,u=c===`amber`?`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`:`bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300`,d=c===`amber`?`text-amber-900 dark:text-amber-100`:`text-red-900 dark:text-red-100`,p=c===`amber`?`text-amber-900/85 dark:text-amber-100/80`:`text-red-900/85 dark:text-red-100/80`,m=c===`amber`?`text-amber-800/80 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`:`text-red-800/80 hover:text-red-900 dark:text-red-200/80 dark:hover:text-red-100`,g=c===`amber`?`bg-amber-100/60 text-amber-900 dark:bg-amber-500/15 dark:text-amber-100`:`bg-red-100/60 text-red-900 dark:bg-red-500/15 dark:text-red-100`,_=c===`amber`?`bg-amber-600 text-white hover:bg-amber-700 dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`:`bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:text-red-950 dark:hover:bg-red-400`,v;t[4]===l?v=t[5]:(v=fh(`flex flex-col gap-2 rounded-xl border px-3 py-3`,l),t[4]=l,t[5]=v);let y;t[6]===u?y=t[7]:(y=fh(`flex size-8 shrink-0 items-center justify-center rounded-lg`,u),t[6]=u,t[7]=y);let b;t[8]===n.code?b=t[9]:(b=(0,z.jsx)(tQe,{code:n.code}),t[8]=n.code,t[9]=b);let x;t[10]!==y||t[11]!==b?(x=(0,z.jsx)(`span`,{className:y,"aria-hidden":!0,children:b}),t[10]=y,t[11]=b,t[12]=x):x=t[12];let S;t[13]===d?S=t[14]:(S=fh(`text-sm font-semibold`,d),t[13]=d,t[14]=S);let C;t[15]!==s.title||t[16]!==S?(C=(0,z.jsx)(`h3`,{className:S,children:s.title}),t[15]=s.title,t[16]=S,t[17]=C):C=t[17];let w;t[18]===p?w=t[19]:(w=fh(`mt-1 text-xs leading-relaxed`,p),t[18]=p,t[19]=w);let T;t[20]!==s.body||t[21]!==w?(T=(0,z.jsx)(`p`,{className:w,children:s.body}),t[20]=s.body,t[21]=w,t[22]=T):T=t[22];let E;t[23]!==C||t[24]!==T?(E=(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,T]}),t[23]=C,t[24]=T,t[25]=E):E=t[25];let D;t[26]!==E||t[27]!==x?(D=(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[x,E]}),t[26]=E,t[27]=x,t[28]=D):D=t[28];let O;t[29]!==s.cta||t[30]!==s.deepLink||t[31]!==_||t[32]!==r?(O=s.cta&&s.deepLink?(0,z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,z.jsx)(`button`,{type:`button`,className:fh(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`,_),onClick:()=>r(s.deepLink),children:s.cta})}):null,t[29]=s.cta,t[30]=s.deepLink,t[31]=_,t[32]=r,t[33]=O):O=t[33];let k;t[34]!==m||t[35]!==g||t[36]!==a||t[37]!==n.message?(k=n.message?(0,z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,z.jsx)(`summary`,{className:fh(`cursor-pointer select-none underline-offset-2`,m),children:a.agentRunErrorDetailToggle}),(0,z.jsx)(`pre`,{className:fh(`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md p-2 font-mono text-[11px] [overflow-wrap:anywhere]`,g),children:n.message})]}):null,t[34]=m,t[35]=g,t[36]=a,t[37]=n.message,t[38]=k):k=t[38];let A;return t[39]!==D||t[40]!==O||t[41]!==k||t[42]!==v?(A=(0,z.jsxs)(`section`,{role:`alert`,"aria-live":`polite`,className:v,children:[D,O,k]}),t[39]=D,t[40]=O,t[41]=k,t[42]=v,t[43]=A):A=t[43],A}function fV(e){return e.language}function iQe(e){let t=(0,fm.c)(8),{errorText:n}=e,r;t[0]===n?r=t[1]:(r=Yy(n),t[0]=n,t[1]=r);let i=r;if(!i)return null;let a;t[2]===i?a=t[3]:(a=Xy(i),t[2]=i,t[3]=a);let o=a;if(o){let e;return t[4]===o?e=t[5]:(e=(0,z.jsx)(`div`,{className:`mb-4`,children:(0,z.jsx)(aQe,{payload:o})}),t[4]=o,t[5]=e),e}let s;return t[6]===i?s=t[7]:(s=(0,z.jsx)(`div`,{className:`mb-4`,children:(0,z.jsx)(rQe,{payload:i})}),t[6]=i,t[7]=s),s}function aQe(e){let t=(0,fm.c)(28),{payload:n}=e,r=Un(),i=f(oQe),a,o;t[0]!==i||t[1]!==n.provider?(a=h(i).chat,o=a.providerSetupRequiredBody.replace(`{{provider}}`,n.provider),t[0]=i,t[1]=n.provider,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=fh(`flex flex-col gap-2 rounded-xl border border-amber-300/60 bg-amber-50/70 px-3 py-3`,`dark:border-amber-500/30 dark:bg-amber-500/10`),t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=fh(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`),t[5]=l):l=t[5];let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`span`,{className:l,"aria-hidden":!0,children:(0,z.jsx)(Uo,{className:`size-4`,strokeWidth:1.75})}),t[6]=u):u=t[6];let d;t[7]===a.providerSetupRequiredTitle?d=t[8]:(d=(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:a.providerSetupRequiredTitle}),t[7]=a.providerSetupRequiredTitle,t[8]=d);let p;t[9]===s?p=t[10]:(p=(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900/85 dark:text-amber-100/80`,children:s}),t[9]=s,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[u,(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[d,p]})]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=fh(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium`,`bg-amber-600 text-white hover:bg-amber-700`,`dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`),t[14]=g):g=t[14];let _;t[15]!==r||t[16]!==n.deepLink?(_=()=>r(n.deepLink),t[15]=r,t[16]=n.deepLink,t[17]=_):_=t[17];let v;t[18]!==a.providerSetupRequiredCta||t[19]!==_?(v=(0,z.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,z.jsx)(`button`,{type:`button`,className:g,onClick:_,children:a.providerSetupRequiredCta})}),t[18]=a.providerSetupRequiredCta,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==a.providerSetupRequiredDetailToggle||t[22]!==n.message?(y=n.message?(0,z.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer select-none text-amber-800/80 underline-offset-2 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`,children:a.providerSetupRequiredDetailToggle}),(0,z.jsx)(`pre`,{className:`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-amber-100/60 p-2 font-mono text-[11px] text-amber-900 dark:bg-amber-500/15 dark:text-amber-100 [overflow-wrap:anywhere]`,children:n.message})]}):null,t[21]=a.providerSetupRequiredDetailToggle,t[22]=n.message,t[23]=y):y=t[23];let b;return t[24]!==v||t[25]!==y||t[26]!==m?(b=(0,z.jsxs)(`section`,{role:`status`,"aria-live":`polite`,className:c,children:[m,v,y]}),t[24]=v,t[25]=y,t[26]=m,t[27]=b):b=t[27],b}function oQe(e){return e.language}var sQe=/^No API key found for (\S+)/i;function cQe(e){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);return e.kind!==`provider_setup_required`||typeof e.provider!=`string`||!e.provider||typeof e.deepLink!=`string`||!e.deepLink.startsWith(`/settings/`)?null:{kind:`provider_setup_required`,provider:e.provider,deepLink:e.deepLink,message:typeof e.message==`string`?e.message:void 0}}catch{return null}let n=sQe.exec(t);return n?{kind:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/credentials`,message:t}:null}function lQe(e,t,n,r,i,a){if(e.type===`text`){if(n)return(0,z.jsx)(`div`,{className:`min-w-0`,children:(0,z.jsx)(RB,{text:lke(tke(e.text??``))})},t);let r=cQe(e.text??``);return r?(0,z.jsx)(`div`,{className:`min-w-0`,children:(0,z.jsx)(aQe,{payload:r})},t):(0,z.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,z.jsx)(AD,{content:e.text,compact:!0})},t)}if(e.type===`image`&&e.source?.data){let n=a??0;return i?(0,z.jsx)(`button`,{type:`button`,className:fh(`inline-block max-w-full rounded-lg p-0 text-left`,yh.press,yh.focusRingPanel,`cursor-pointer`),onClick:()=>i(e,n),title:r,"aria-label":r,children:(0,z.jsx)(`img`,{src:e.source.data,className:`max-h-48 max-w-64 rounded-lg align-top object-contain`,alt:``})},t):(0,z.jsx)(`img`,{src:e.source.data,className:`max-h-48 max-w-64 rounded-lg object-contain`,alt:``},t)}return null}function pV(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t.type===`text`&&(t.text??``).length>0)return!0}return!1}function uQe(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=u??{},p=f.labels??YZe(),m=0,h=0;for(;m<e.length;){let u=e[m];if(u.type===`tool_use`&&cZe(u)){d.push((0,z.jsx)(uV,{block:u,startedAt:f.getStartedAt?.(u),sessionKey:l,onAbort:f.onAbort,onSendChatMessage:f.onSendChatMessage,labels:p},`workflow-${u.id??m}`)),m++;continue}if(u.type===`thinking`||u.type===`tool_use`){let s=m;for(;m<e.length;){let t=e[m];if(t.type===`thinking`){m++;continue}if(t.type===`tool_use`&&!cZe(t)){m++;continue}break}let c=e.slice(s,m);if(c.length>0){let u=!t&&pV(e,m);d.push((0,z.jsx)(X,{blocks:c,toolLabels:r,stepLabels:i,clusterLabels:a,cardLabels:o,sessionKey:l,isMessageStreaming:!t&&n,finalAnswerStarted:u},`steps-${s}`))}}else{let e=u.type===`image`?h++:0,n=lQe(u,`block-${m}`,t,s,c,u.type===`image`?e:m);n&&d.push(n),m++}}return d}function dQe(e){let t=(0,fm.c)(28),{open:n,title:r,description:i,confirmLabel:a,cancelLabel:o,destructive:s,onConfirm:c,onCancel:l}=e,u;t[0]===l?u=t[1]:(u=e=>{e||l()},t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,z.jsx)(ov,{className:fh(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,yO)}),t[2]=d):d=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=fh(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,bO,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[3]=f):f=t[3];let p;t[4]===r?p=t[5]:(p=(0,z.jsx)(cv,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=p);let m;t[6]===i?m=t[7]:(m=(0,z.jsx)(lv,{className:`mt-2 max-h-[min(50vh,16rem)] overflow-y-auto text-sm text-fg-muted whitespace-pre-wrap break-all`,children:i}),t[6]=i,t[7]=m);let h;t[8]!==o||t[9]!==l?(h=(0,z.jsx)(gh,{type:`button`,variant:`secondary`,onClick:l,children:o}),t[8]=o,t[9]=l,t[10]=h):h=t[10];let g=s&&`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,_;t[11]===g?_=t[12]:(_=fh(g),t[11]=g,t[12]=_);let v;t[13]!==a||t[14]!==c||t[15]!==_?(v=(0,z.jsx)(gh,{type:`button`,variant:`secondary`,className:_,onClick:c,children:a}),t[13]=a,t[14]=c,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==h||t[18]!==v?(y=(0,z.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[h,v]}),t[17]=h,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==y||t[21]!==p||t[22]!==m?(b=(0,z.jsxs)(av,{children:[d,(0,z.jsxs)(sv,{className:f,children:[p,m,y]})]}),t[20]=y,t[21]=p,t[22]=m,t[23]=b):b=t[23];let x;return t[24]!==n||t[25]!==u||t[26]!==b?(x=(0,z.jsx)(iv,{open:n,onOpenChange:u,children:b}),t[24]=n,t[25]=u,t[26]=b,t[27]=x):x=t[27],x}function fQe(e){return e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}var mV=fh(`inline-flex size-9 shrink-0 items-center justify-center rounded-lg`,`text-fg-muted transition-colors transition-transform duration-150 ease-out`,`hover:bg-surface-hover hover:text-fg active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,yh.disabled),hV=fh(`inline-flex h-8 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-xs text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg active:scale-[0.98]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,yh.disabled),pQe=(0,j.memo)(function(e){let t=(0,fm.c)(221),{message:n,authToken:r,sessionKey:i,isStreaming:a,progress:o,reasoningLevel:s,messageIndex:c,onDeleteRound:l,onRetryUserMessageRound:u,userMessageCanRetry:d,deleteRoundDisabled:p,onAbortCurrentTurn:m,onSendUserMessage:g,onSaveAssistantToSourceNote:_,onExtractAssistantTask:v}=e,y=s===void 0?`stream`:s,b=d===void 0?!1:d,x=p===void 0?!1:p,S=f(gV),C;t[0]===S?C=t[1]:(C=h(S),t[0]=S,t[1]=C);let w=C,T=n.role===`user`,E=n.role===`assistant`,O=T?w.chat.you:E?w.chat.assistant:w.chat.tool,k;t[2]!==w.chat.noOutput||t[3]!==w.chat.toolInput||t[4]!==w.chat.toolOutput?(k={input:w.chat.toolInput,output:w.chat.toolOutput,noOutput:w.chat.noOutput},t[2]=w.chat.noOutput,t[3]=w.chat.toolInput,t[4]=w.chat.toolOutput,t[5]=k):k=t[5];let A=k,ee;t[6]!==w.chat.stepDetails||t[7]!==w.chat.stepEditFile||t[8]!==w.chat.stepFetchUrl||t[9]!==w.chat.stepListDirectory||t[10]!==w.chat.stepOpenUrl||t[11]!==w.chat.stepReadFile||t[12]!==w.chat.stepRunCommand||t[13]!==w.chat.stepSearchedWeb||t[14]!==w.chat.stepUnknownTool||t[15]!==w.chat.stepWriteFile||t[16]!==w.chat.thoughts||t[17]!==w.chat.thoughtsStreaming||t[18]!==w.chat.viewSteps_one||t[19]!==w.chat.viewSteps_other?(ee={thoughts:w.chat.thoughts,thoughtsStreaming:w.chat.thoughtsStreaming,viewSteps_one:w.chat.viewSteps_one,viewSteps_other:w.chat.viewSteps_other,searchedWeb:w.chat.stepSearchedWeb,readFile:w.chat.stepReadFile,stepDetails:w.chat.stepDetails,runCommand:w.chat.stepRunCommand,listDirectory:w.chat.stepListDirectory,writeFile:w.chat.stepWriteFile,editFile:w.chat.stepEditFile,openUrl:w.chat.stepOpenUrl,fetchUrl:w.chat.stepFetchUrl,unknownTool:w.chat.stepUnknownTool},t[6]=w.chat.stepDetails,t[7]=w.chat.stepEditFile,t[8]=w.chat.stepFetchUrl,t[9]=w.chat.stepListDirectory,t[10]=w.chat.stepOpenUrl,t[11]=w.chat.stepReadFile,t[12]=w.chat.stepRunCommand,t[13]=w.chat.stepSearchedWeb,t[14]=w.chat.stepUnknownTool,t[15]=w.chat.stepWriteFile,t[16]=w.chat.thoughts,t[17]=w.chat.thoughtsStreaming,t[18]=w.chat.viewSteps_one,t[19]=w.chat.viewSteps_other,t[20]=ee):ee=t[20];let te=ee,ne;t[21]!==w.chat.stepsClusterJoin||t[22]!==w.chat.stepsClusterJoinFinal||t[23]!==w.chat.stepsClusterMoreSuffix?(ne={join:w.chat.stepsClusterJoin,joinFinal:w.chat.stepsClusterJoinFinal,moreSuffix:w.chat.stepsClusterMoreSuffix},t[21]=w.chat.stepsClusterJoin,t[22]=w.chat.stepsClusterJoinFinal,t[23]=w.chat.stepsClusterMoreSuffix,t[24]=ne):ne=t[24];let re;t[25]!==w.chat.stepsClusterDone||t[26]!==w.chat.stepsClusterIng||t[27]!==ne?(re={done:w.chat.stepsClusterDone,ing:w.chat.stepsClusterIng,join:ne},t[25]=w.chat.stepsClusterDone,t[26]=w.chat.stepsClusterIng,t[27]=ne,t[28]=re):re=t[28];let ie=re,ae=w.chat.toolCard,oe=y===`off`,se;bb0:{if(!oe){let e;t[29]===n.content?e=t[30]:(e=n.content??[],t[29]=n.content,t[30]=e),se=e;break bb0}let e;t[31]===n.content?e=t[32]:(e=n.content??[],t[31]=n.content,t[32]=e);let r;t[33]===e?r=t[34]:(r=e.filter(mQe),t[33]=e,t[34]=r),se=r}let ce=se,le;bb1:{if(!T&&!E){le=ce;break bb1}let e;t[35]===ce?e=t[36]:(e=ce??[],t[35]=ce,t[36]=e);let n;t[37]===e?n=t[38]:(n=e.filter(hQe),t[37]=e,t[38]=n),le=n}let ue=le,de;t[39]!==E||t[40]!==n.content?(de=E?XYe(n.content):[],t[39]=E,t[40]=n.content,t[41]=de):de=t[41];let fe=de,pe;t[42]!==E||t[43]!==n.content?(pe=E?(n.content??[]).filter(gQe):[],t[42]=E,t[43]=n.content,t[44]=pe):pe=t[44];let me=pe,he;t[45]!==me||t[46]!==E?(he=E?QYe(me):[],t[45]=me,t[46]=E,t[47]=he):he=t[47];let ge=he,_e=E&&(fe.length>0||ge.length>0),ve;bb2:{if(E){let e;t[48]!==fe||t[49]!==n.attachments?(e=YYe(n.attachments,fe),t[48]=fe,t[49]=n.attachments,t[50]=e):e=t[50],ve=e;break bb2}ve=n.attachments}let ye=ve,be=oe&&o?.stage===`thinking`?null:o,xe;t[51]!==n.content||t[52]!==oe?(xe=oe?!1:!!n.content?.some(_Qe),t[51]=n.content,t[52]=oe,t[53]=xe):xe=t[53];let Se=xe,Ce=!!n.timestamp||!!be?.message||a&&!Se,we;t[54]!==E||t[55]!==n.content?(we=E?$Ye(n.content??[]):``,t[54]=E,t[55]=n.content,t[56]=we):we=t[56];let Te=we,Ee;t[57]!==Te||t[58]!==E||t[59]!==n.content?(Ee=E&&Te?tXe(n.content??[]):``,t[57]=Te,t[58]=E,t[59]=n.content,t[60]=Ee):Ee=t[60];let De=Ee,Oe;bb3:{if(!T){Oe=``;break bb3}let e;t[61]===n.content?e=t[62]:(e=Zy(n.content),t[61]=n.content,t[62]=e),Oe=e}let ke=Oe,[Ae,je]=(0,j.useState)(null),[Me,Ne]=(0,j.useState)(null),[Pe,Fe]=(0,j.useState)(null),[Ie,Le]=(0,j.useState)(!1),[Re,ze]=(0,j.useState)(null),Be;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(e,t)=>{let n=ZYe(e,t);n&&ze(n)},t[63]=Be):Be=t[63];let Ve=Be,He;t[64]===De?He=t[65]:(He=()=>{De&&Sh(De).then(e=>{e&&(je(`plain`),window.setTimeout(()=>je(vQe),2e3))})},t[64]=De,t[65]=He);let Ue=He,We;t[66]===Te?We=t[67]:(We=()=>{Te&&Sh(Te).then(e=>{e&&(je(`markdown`),window.setTimeout(()=>je(yQe),2e3))})},t[66]=Te,t[67]=We);let Ge=We,Ke;t[68]!==Pe||t[69]!==Te||t[70]!==_?(Ke=()=>{!Te||!_||Pe||(Fe(`save-note`),Promise.resolve(_(Te)).then(()=>{Ne(`save-note`),window.setTimeout(()=>Ne(_V),2e3)}).finally(()=>Fe(null)))},t[68]=Pe,t[69]=Te,t[70]=_,t[71]=Ke):Ke=t[71];let qe=Ke,Je;t[72]!==Pe||t[73]!==Te||t[74]!==De||t[75]!==v?(Je=()=>{!De&&!Te||!v||Pe||(Fe(`extract-task`),Promise.resolve(v(De||Te)).then(()=>{Ne(`extract-task`),window.setTimeout(()=>Ne(vV),2e3)}).finally(()=>Fe(null)))},t[72]=Pe,t[73]=Te,t[74]=De,t[75]=v,t[76]=Je):Je=t[76];let Ye=Je,Xe;t[77]===ke?Xe=t[78]:(Xe=()=>{ke&&Sh(ke).then(e=>{e&&(je(`user`),window.setTimeout(()=>je(yV),2e3))})},t[77]=ke,t[78]=Xe);let Ze=Xe,Qe;t[79]!==c||t[80]!==l?(Qe=()=>{c==null||!l||Le(!0)},t[79]=c,t[80]=l,t[81]=Qe):Qe=t[81];let $e=Qe,et;t[82]!==c||t[83]!==l?(et=()=>{c==null||!l||(l(c),Le(!1))},t[82]=c,t[83]=l,t[84]=et):et=t[84];let tt=et,nt;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(nt=()=>{Le(!1)},t[85]=nt):nt=t[85];let rt=nt,it;if(t[86]!==n||t[87]!==oe){bb4:{let e=aYe(n);if(oe){it=e.filter(bQe);break bb4}it=e}t[86]=n,t[87]=oe,t[88]=it}else it=t[88];let at=it,ot=x||!b,st=T?`justify-end`:`justify-start`,ct;t[89]===st?ct=t[90]:(ct=fh(`group/msg flex w-full min-w-0`,st),t[89]=st,t[90]=ct);let lt=T?`flex w-full flex-col items-end`:`w-full`,ut;t[91]===lt?ut=t[92]:(ut=fh(`min-w-0 max-w-[min(85%,var(--max-width-chat))]`,lt),t[91]=lt,t[92]=ut);let dt;t[93]===O?dt=t[94]:(dt=(0,z.jsx)(`span`,{className:`sr-only`,children:O}),t[93]=O,t[94]=dt);let ft;t[95]!==a||t[96]!==T||t[97]!==w.chat.thinkingLabel||t[98]!==n.timestamp||t[99]!==be||t[100]!==Ce||t[101]!==Se?(ft=T&&Ce?(0,z.jsxs)(`div`,{className:`mb-2 flex w-full min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-0.5 text-xs`,children:[n.timestamp?(0,z.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:fQe(n.timestamp)}):null,be?.message?(0,z.jsx)(`span`,{className:`text-fg-subtle`,title:be.detail??``,children:be.message}):null,a&&!Se&&!be?.message?(0,z.jsx)(`span`,{className:`text-fg-subtle`,children:w.chat.thinkingLabel}):null]}):null,t[95]=a,t[96]=T,t[97]=w.chat.thinkingLabel,t[98]=n.timestamp,t[99]=be,t[100]=Ce,t[101]=Se,t[102]=ft):ft=t[102];let pt;t[103]!==a||t[104]!==T||t[105]!==w.chat.thinkingLabel||t[106]!==n.timestamp||t[107]!==be||t[108]!==Ce||t[109]!==Se?(pt=!T&&Ce?(0,z.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[n.timestamp?(0,z.jsx)(`time`,{suppressHydrationWarning:!0,className:`tabular-nums`,dateTime:new Date(n.timestamp).toISOString(),children:fQe(n.timestamp)}):null,be?.message?(0,z.jsx)(`span`,{className:`text-fg-subtle`,title:be.detail??``,children:be.message}):null,a&&!Se&&!be?.message?(0,z.jsx)(`span`,{className:`text-fg-subtle`,children:w.chat.thinkingLabel}):null]}):null,t[103]=a,t[104]=T,t[105]=w.chat.thinkingLabel,t[106]=n.timestamp,t[107]=be,t[108]=Ce,t[109]=Se,t[110]=pt):pt=t[110];let mt=T?`ltr`:void 0,ht=T&&`w-fit max-w-full rounded-xl border border-edge-subtle/70 bg-surface-hover/90 px-4 py-3 text-left shadow-sm dark:border-edge-subtle dark:bg-surface-hover/50`,gt;t[111]===ht?gt=t[112]:(gt=fh(`min-w-0 text-sm leading-relaxed text-fg`,ht),t[111]=ht,t[112]=gt);let _t;t[113]!==ae||t[114]!==ie||t[115]!==ue||t[116]!==E||t[117]!==a||t[118]!==T||t[119]!==S||t[120]!==w.chat.attachmentPreviewImage||t[121]!==m||t[122]!==g||t[123]!==i||t[124]!==te||t[125]!==A?(_t=(ue?.length??0)>0?(0,z.jsxs)(z.Fragment,{children:[uQe(ue,T,E&&a,A,te,ie,ae,w.chat.attachmentPreviewImage,Ve,i,{labels:dV(S),onAbort:E&&a?m:void 0,onSendChatMessage:g}),a?(0,z.jsx)(`span`,{className:`inline-block h-3 w-0.5 animate-pulse bg-accent align-middle`}):null]}):a?(0,z.jsx)(`span`,{className:`inline-block h-3 w-0.5 animate-pulse bg-accent`}):null,t[113]=ae,t[114]=ie,t[115]=ue,t[116]=E,t[117]=a,t[118]=T,t[119]=S,t[120]=w.chat.attachmentPreviewImage,t[121]=m,t[122]=g,t[123]=i,t[124]=te,t[125]=A,t[126]=_t):_t=t[126];let vt;t[127]!==E||t[128]!==at?(vt=E&&at.length>0?(0,z.jsx)(vYe,{blocks:at}):null,t[127]=E,t[128]=at,t[129]=vt):vt=t[129];let yt;t[130]!==ge||t[131]!==fe||t[132]!==r||t[133]!==w.chat.messageArtifactsHeading||t[134]!==i||t[135]!==_e?(yt=_e?(0,z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle/60 bg-surface-elevated/20 px-3 py-2.5`,role:`group`,"aria-label":w.chat.messageArtifactsHeading,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:w.chat.messageArtifactsHeading}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[fe.length>0?(0,z.jsx)(Gz,{paths:fe,sessionKey:i}):null,ge.length>0?(0,z.jsx)(hYe,{attachments:ge,authToken:r,sessionKey:i,layout:`assistant`}):null]})]}):null,t[130]=ge,t[131]=fe,t[132]=r,t[133]=w.chat.messageArtifactsHeading,t[134]=i,t[135]=_e,t[136]=yt):yt=t[136];let bt;t[137]!==ye||t[138]!==r||t[139]!==T||t[140]!==i||t[141]!==ke?(bt=ye?.length?T?(0,z.jsx)(hYe,{attachments:ye,authToken:r,sessionKey:i,layout:`user`,centerUserVoiceRow:ke.length===0}):(0,z.jsx)(hYe,{attachments:ye,authToken:r,sessionKey:i,layout:`assistant`}):null,t[137]=ye,t[138]=r,t[139]=T,t[140]=i,t[141]=ke,t[142]=bt):bt=t[142];let xt;t[143]!==_t||t[144]!==vt||t[145]!==yt||t[146]!==bt?(xt=(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[_t,vt,yt,bt]}),t[143]=_t,t[144]=vt,t[145]=yt,t[146]=bt,t[147]=xt):xt=t[147];let St;t[148]!==mt||t[149]!==gt||t[150]!==xt?(St=(0,z.jsx)(`div`,{dir:mt,className:gt,children:xt}),t[148]=mt,t[149]=gt,t[150]=xt,t[151]=St):St=t[151];let Ct;t[152]!==Ae||t[153]!==x||t[154]!==Ze||t[155]!==a||t[156]!==T||t[157]!==w.chat.messageCopied||t[158]!==w.chat.userMessageActionsWait||t[159]!==w.chat.userMessageCopy||t[160]!==w.chat.userMessageDelete||t[161]!==w.chat.userMessageEdit||t[162]!==w.chat.userMessageRetry||t[163]!==w.chat.userMessageRetryDisabledHint||t[164]!==c||t[165]!==l||t[166]!==u||t[167]!==$e||t[168]!==ot||t[169]!==ke||t[170]!==b?(Ct=T&&!a?(0,z.jsx)(`div`,{className:`mt-1.5 flex h-8 w-full min-w-0 shrink-0 justify-end`,children:(0,z.jsxs)(`div`,{className:fh(`flex h-full max-w-full items-center justify-end gap-0.5 sm:gap-2`,`pointer-events-none opacity-0 transition-opacity duration-150 ease-out`,`group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`),children:[u&&c!=null?(0,z.jsxs)(`button`,{type:`button`,className:fh(hV,ot&&`opacity-40`),onClick:()=>u(c),disabled:ot,title:x?w.chat.userMessageActionsWait:b?w.chat.userMessageRetry:w.chat.userMessageRetryDisabledHint,"aria-label":w.chat.userMessageRetry,children:[(0,z.jsx)(xu,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:w.chat.userMessageRetry})]}):null,(0,z.jsx)(`button`,{type:`button`,className:fh(hV,`size-8 px-0`),onClick:()=>Wk(ke),disabled:!ke,title:w.chat.userMessageEdit,"aria-label":w.chat.userMessageEdit,children:(0,z.jsx)(Tl,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,className:fh(hV,`size-8 px-0`),onClick:Ze,disabled:!ke,title:Ae===`user`?w.chat.messageCopied:w.chat.userMessageCopy,"aria-label":Ae===`user`?w.chat.messageCopied:w.chat.userMessageCopy,children:Ae===`user`?(0,z.jsx)(ei,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(D,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),l&&c!=null&&!x?(0,z.jsx)(`button`,{type:`button`,className:fh(hV,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:$e,title:w.chat.userMessageDelete,"aria-label":w.chat.userMessageDelete,children:(0,z.jsx)(sp,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]})}):null,t[152]=Ae,t[153]=x,t[154]=Ze,t[155]=a,t[156]=T,t[157]=w.chat.messageCopied,t[158]=w.chat.userMessageActionsWait,t[159]=w.chat.userMessageCopy,t[160]=w.chat.userMessageDelete,t[161]=w.chat.userMessageEdit,t[162]=w.chat.userMessageRetry,t[163]=w.chat.userMessageRetryDisabledHint,t[164]=c,t[165]=l,t[166]=u,t[167]=$e,t[168]=ot,t[169]=ke,t[170]=b,t[171]=Ct):Ct=t[171];let wt;t[172]!==Pe||t[173]!==Me||t[174]!==Ae||t[175]!==Te||t[176]!==De||t[177]!==Ge||t[178]!==Ue||t[179]!==Ye||t[180]!==qe||t[181]!==E||t[182]!==w.chat.messageCopied||t[183]!==w.chat.messageCopyMarkdown||t[184]!==w.chat.messageCopyPlainText||t[185]!==w.chat.messageExtractTask||t[186]!==w.chat.messageSaveToNote||t[187]!==w.chat.messageSavedToNote||t[188]!==w.chat.messageTaskExtracted||t[189]!==v||t[190]!==_?(wt=E&&Te?(0,z.jsxs)(`div`,{className:`mt-2 flex shrink-0 flex-wrap items-center gap-2 overflow-visible`,children:[(0,z.jsx)(`button`,{type:`button`,className:mV,onClick:Ue,disabled:!De,title:Ae===`plain`?w.chat.messageCopied:w.chat.messageCopyPlainText,"aria-label":Ae===`plain`?w.chat.messageCopied:w.chat.messageCopyPlainText,children:Ae===`plain`?(0,z.jsx)(ei,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(D,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,className:mV,onClick:Ge,title:Ae===`markdown`?w.chat.messageCopied:w.chat.messageCopyMarkdown,"aria-label":Ae===`markdown`?w.chat.messageCopied:w.chat.messageCopyMarkdown,children:Ae===`markdown`?(0,z.jsx)(ei,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(Sfe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),_?(0,z.jsx)(`button`,{type:`button`,className:mV,onClick:qe,disabled:!Te||Pe!==null,title:Me===`save-note`?w.chat.messageSavedToNote:w.chat.messageSaveToNote,"aria-label":Me===`save-note`?w.chat.messageSavedToNote:w.chat.messageSaveToNote,children:Me===`save-note`?(0,z.jsx)(ei,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(la,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null,v?(0,z.jsx)(`button`,{type:`button`,className:mV,onClick:Ye,disabled:!De&&!Te||Pe!==null,title:Me===`extract-task`?w.chat.messageTaskExtracted:w.chat.messageExtractTask,"aria-label":Me===`extract-task`?w.chat.messageTaskExtracted:w.chat.messageExtractTask,children:Me===`extract-task`?(0,z.jsx)(ei,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(xs,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null]}):null,t[172]=Pe,t[173]=Me,t[174]=Ae,t[175]=Te,t[176]=De,t[177]=Ge,t[178]=Ue,t[179]=Ye,t[180]=qe,t[181]=E,t[182]=w.chat.messageCopied,t[183]=w.chat.messageCopyMarkdown,t[184]=w.chat.messageCopyPlainText,t[185]=w.chat.messageExtractTask,t[186]=w.chat.messageSaveToNote,t[187]=w.chat.messageSavedToNote,t[188]=w.chat.messageTaskExtracted,t[189]=v,t[190]=_,t[191]=wt):wt=t[191];let Tt;t[192]!==ut||t[193]!==dt||t[194]!==ft||t[195]!==pt||t[196]!==St||t[197]!==Ct||t[198]!==wt?(Tt=(0,z.jsxs)(`div`,{className:ut,children:[dt,ft,pt,St,Ct,wt]}),t[192]=ut,t[193]=dt,t[194]=ft,t[195]=pt,t[196]=St,t[197]=Ct,t[198]=wt,t[199]=Tt):Tt=t[199];let Et;t[200]!==tt||t[201]!==Ie||t[202]!==T||t[203]!==w.chat.userMessageDeleteCancel||t[204]!==w.chat.userMessageDeleteConfirm||t[205]!==w.chat.userMessageDeleteConfirmTitle||t[206]!==w.chat.userMessageDeleteOk||t[207]!==c||t[208]!==l?(Et=T&&l&&c!=null?(0,z.jsx)(dQe,{open:Ie,title:w.chat.userMessageDeleteConfirmTitle,description:w.chat.userMessageDeleteConfirm,confirmLabel:w.chat.userMessageDeleteOk,cancelLabel:w.chat.userMessageDeleteCancel,destructive:!0,onConfirm:tt,onCancel:rt}):null,t[200]=tt,t[201]=Ie,t[202]=T,t[203]=w.chat.userMessageDeleteCancel,t[204]=w.chat.userMessageDeleteConfirm,t[205]=w.chat.userMessageDeleteConfirmTitle,t[206]=w.chat.userMessageDeleteOk,t[207]=c,t[208]=l,t[209]=Et):Et=t[209];let Dt=Re!==null,Ot;t[210]===Symbol.for(`react.memo_cache_sentinel`)?(Ot=()=>ze(null),t[210]=Ot):Ot=t[210];let kt;t[211]!==r||t[212]!==Re||t[213]!==i||t[214]!==Dt?(kt=(0,z.jsx)(Cz,{open:Dt,attachment:Re,authToken:r,sessionKey:i,onClose:Ot}),t[211]=r,t[212]=Re,t[213]=i,t[214]=Dt,t[215]=kt):kt=t[215];let At;return t[216]!==ct||t[217]!==Tt||t[218]!==Et||t[219]!==kt?(At=(0,z.jsxs)(`article`,{className:ct,children:[Tt,Et,kt]}),t[216]=ct,t[217]=Tt,t[218]=Et,t[219]=kt,t[220]=At):At=t[220],At});function gV(e){return e.language}function mQe(e){return e.type!==`thinking`}function hQe(e){return e.type!==`image`}function gQe(e){return e.type===`image`&&!!e.source?.data}function _Qe(e){return e.type===`thinking`&&e.streaming}function vQe(e){return e===`plain`?null:e}function yQe(e){return e===`markdown`?null:e}function _V(e){return e===`save-note`?null:e}function vV(e){return e===`extract-task`?null:e}function yV(e){return e===`user`?null:e}function bQe(e){return e.type!==`thinking`}function xQe(e,t){return`${e.timestamp??`n`}-${t}`}var bV=(0,j.memo)(function(e){let t=(0,fm.c)(32),{messages:n,authToken:r,sessionKey:i,streaming:a,progress:o,reasoningLevel:s,registerListContentRef:c,onPickWelcomePrompt:l,welcomeOverlay:u,onDeleteRound:d,onRetryUserMessageRound:p,deleteRoundDisabled:m,onAbortCurrentTurn:g,onSendUserMessage:_,onSaveAssistantToSourceNote:v,onExtractAssistantTask:y}=e,b=f(SQe),x;t[0]===b?x=t[1]:(x=h(b),t[0]=b,t[1]=x);let S=x;if(n.length===0&&!a){if(u){let e;return t[2]===u?e=t[3]:(e=(0,z.jsx)(`div`,{className:`flex w-full flex-col items-center pb-6 pt-4`,children:u}),t[2]=u,t[3]=e),e}if(l&&S.chat.welcomeSpotlight){let e;return t[4]!==S.chat||t[5]!==l?(e=(0,z.jsx)(`div`,{className:`pb-1.5`,children:(0,z.jsx)(iYe,{chat:S.chat,onPickPrompt:l})}),t[4]=S.chat,t[5]=l,t[6]=e):e=t[6],e}let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`div`,{className:`text-4xl`,"aria-hidden":!0,children:`🤖`}),t[7]=e):e=t[7];let n;t[8]===S.chat.welcomeTitle?n=t[9]:(n=(0,z.jsx)(`div`,{className:`text-xl font-semibold tracking-tight text-fg`,children:S.chat.welcomeTitle}),t[8]=S.chat.welcomeTitle,t[9]=n);let r;t[10]===S.chat.welcomeDescription?r=t[11]:(r=(0,z.jsx)(`div`,{className:`max-w-sm text-sm leading-relaxed text-fg-muted`,children:S.chat.welcomeDescription}),t[10]=S.chat.welcomeDescription,t[11]=r);let i;return t[12]!==n||t[13]!==r?(i=(0,z.jsx)(`div`,{className:`flex flex-col gap-10 pb-8`,children:(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-20 text-center`,children:[e,n,r]})}),t[12]=n,t[13]=r,t[14]=i):i=t[14],i}let C;t[15]!==r||t[16]!==m||t[17]!==n||t[18]!==g||t[19]!==d||t[20]!==y||t[21]!==p||t[22]!==v||t[23]!==_||t[24]!==o||t[25]!==s||t[26]!==i||t[27]!==a?(C=n.map((e,t)=>{let c=t===n.length-1,l=!!(a&&c&&e.role===`assistant`);return(0,z.jsx)(pQe,{message:e,authToken:r,sessionKey:i,isStreaming:l,progress:l?o:null,reasoningLevel:s,messageIndex:t,onDeleteRound:d,onRetryUserMessageRound:p,userMessageCanRetry:!!p&&uke(n,t),deleteRoundDisabled:m,onAbortCurrentTurn:g,onSendUserMessage:_,onSaveAssistantToSourceNote:v,onExtractAssistantTask:y},xQe(e,t))}),t[15]=r,t[16]=m,t[17]=n,t[18]=g,t[19]=d,t[20]=y,t[21]=p,t[22]=v,t[23]=_,t[24]=o,t[25]=s,t[26]=i,t[27]=a,t[28]=C):C=t[28];let w;return t[29]!==c||t[30]!==C?(w=(0,z.jsx)(`div`,{ref:c,className:`flex w-full min-w-0 flex-col gap-10 pb-8`,children:C}),t[29]=c,t[30]=C,t[31]=w):w=t[31],w});function SQe(e){return e.language}var xV=(0,j.memo)(function(e){let t=(0,fm.c)(7),{visible:n,onClick:r}=e,i=f(CQe),a;t[0]===i?a=t[1]:(a=h(i),t[0]=i,t[1]=a);let o=a;if(!n)return null;let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=fh(`fixed bottom-[calc(11rem+env(safe-area-inset-bottom,0px))] right-6 z-20 flex size-11 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-subtle shadow-float`,`hover:bg-surface-hover hover:text-fg dark:border-edge dark:shadow-none md:right-10`,yh.transition,yh.press,yh.focusRingPanel),t[2]=s):s=t[2];let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,z.jsx)(ri,{className:`size-6`,"aria-hidden":!0}),t[3]=c):c=t[3];let l;return t[4]!==o.chat.scrollToBottom||t[5]!==r?(l=(0,z.jsx)(`button`,{type:`button`,className:s,onClick:r,title:o.chat.scrollToBottom,"aria-label":o.chat.scrollToBottom,children:c}),t[4]=o.chat.scrollToBottom,t[5]=r,t[6]=l):l=t[6],l});function CQe(e){return e.language}function SV(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function wQe(e,t=48){return SV(e)<=t}function TQe(e){e.scrollTop=e.scrollHeight}function EQe(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function CV({hasToken:e,showSessionLoading:t,sessionKey:n,sending:r,chatMessages:i,hasMore:a,loadingMore:o,loadMoreMessages:s}){let c=(0,j.useRef)(null),l=(0,j.useRef)(null),u=(0,j.useRef)(!0),d=(0,j.useRef)(!1),f=(0,j.useRef)(null),p=(0,j.useRef)(null),[m,h]=(0,j.useState)(!0),g=(0,j.useRef)(!0),_=(0,j.useRef)(!1),v=(0,j.useRef)(0),y=(0,j.useRef)({first:void 0,len:0,scrollHeight:0}),b=(0,j.useCallback)(e=>{u.current=e,h(t=>t===e?t:e)},[]),x=(0,j.useCallback)(e=>{let t=c.current;if(t&&!(!e?.force&&!u.current)){if(e?.force&&b(!0),d.current=!0,e?.smooth){t.scrollTo({top:t.scrollHeight,behavior:`smooth`});return}TQe(t)}},[b]),S=(0,j.useCallback)(()=>{u.current&&(p.current!=null&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{p.current=null,x()}))},[x]),C=(0,j.useCallback)(()=>{b(!1)},[b]),w=(0,j.useCallback)(e=>{if(l.current===e||(f.current?.disconnect(),f.current=null,l.current=e,!e))return;let t=new ResizeObserver(()=>{S()});t.observe(e),f.current=t},[S]);(0,j.useEffect)(()=>()=>{f.current?.disconnect(),p.current!=null&&cancelAnimationFrame(p.current)},[]);let T=(0,j.useCallback)(()=>{let e=c.current;if(!e)return;if(d.current){d.current=!1;return}let t=wQe(e);b(t),e.scrollTop<100&&!t&&a&&!o&&s()},[b,a,o,s]),E=(0,j.useCallback)((e=!0)=>{x({force:!0,smooth:e})},[x]);(0,j.useLayoutEffect)(()=>{if(e){if(t){g.current=!0;return}g.current===!0&&(g.current=!1,b(!0),x({force:!0}))}},[t,e,b,x]),(0,j.useLayoutEffect)(()=>{!e||t||(y.current={first:void 0,len:0,scrollHeight:0},v.current=0,b(!0),x({force:!0}))},[n,e,t,b,x]);let D=e&&r&&!_.current&&!t;return(0,j.useLayoutEffect)(()=>{_.current=r,D&&(b(!0),x({force:!0}))},[D,r,b,x]),(0,j.useLayoutEffect)(()=>{if(t)return;let e=i.length,n=v.current;v.current=e,e>n&&u.current&&x()},[i.length,t,x]),(0,j.useLayoutEffect)(()=>{let e=c.current;if(!e||t)return;let n=y.current,r=i[0],a=i.length,o=e.scrollHeight;a>n.len&&n.len>0&&r!==void 0&&r!==n.first&&n.scrollHeight>0&&(e.scrollTop+=o-n.scrollHeight),y.current={first:r,len:a,scrollHeight:o}},[i,t]),(0,j.useLayoutEffect)(()=>{if(!e||t)return;let n=c.current;if(!n)return;let r=e=>{Math.abs(e.deltaY)<Math.abs(e.deltaX)||Math.abs(e.deltaY)<.25||EQe(e)&&C()},i=0,a=e=>{e.touches.length===1&&(i=e.touches[0].clientY)},o=e=>{if(e.touches.length!==1)return;let t=e.touches[0].clientY,n=t-i;i=t,n>2&&C()},s=e=>{if(e.button!==0)return;let t=n.offsetWidth-n.clientWidth;if(t<=0)return;let r=n.getBoundingClientRect();e.clientX>=r.right-t&&C()};return n.addEventListener(`wheel`,r,{passive:!0}),n.addEventListener(`pointerdown`,s),n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchmove`,o,{passive:!0}),()=>{n.removeEventListener(`wheel`,r),n.removeEventListener(`pointerdown`,s),n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchmove`,o)}},[e,t,C]),{scrollRef:c,atBottom:m,registerListContentRef:w,scrollToBottom:E,onScroll:T}}function wV(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function DQe(e){let t=String(e.streamSessionKey??``).trim(),n=wV(e.routeSessionKey);return!t||!n?!1:t===n}function OQe(e){let t=wV(e.routeSessionKey);return t?e.cacheSessionKey===t:!1}function kQe(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=wV(e.routeSessionKey);return n?n===t:!1}function AQe(e,t){return e?`new`:t??null}function jQe(e){return!e.viewSessionKey||e.sessionKey!==e.viewSessionKey?[]:e.streamingMsg?[...e.messages,e.streamingMsg]:e.messages}function MQe(e){e()}function TV(e){return e===`on`||e===`stream`||e===`off`?e:`stream`}function NQe(e,t){let n=String(e??``).trim();n&&qb.getState().patchSessionMeta(n,{model:t.model,thinkingLevel:t.thinkingLevel||`medium`,reasoningLevel:TV(t.reasoningLevel??void 0)})}function PQe(e){e.sendingRef.current=!1,e.streamingRef.current=!1}var FQe=`xopc.chat.clarifyPrompt:v1:`;function EV(e){return`${FQe}${encodeURIComponent(e.trim())}`}function DV(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function IQe(e){if(!DV(e))return null;let t=e.requestId,n=e.question;if(typeof t!=`string`||!t.trim()||typeof n!=`string`||!n.trim())return null;let r=Array.isArray(e.choices)?e.choices.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,i=typeof e.default==`string`&&e.default.trim()?e.default.trim():void 0;return{requestId:t.trim(),question:n.trim(),choices:r&&r.length>=2?r:void 0,default:i}}function LQe(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return null;try{let e=localStorage.getItem(EV(t));if(!e)return null;let n=JSON.parse(e);return DV(n)?IQe(n.prompt??n):null}catch{return null}}function OV(e,t){let n=e?.trim();if(!(!n||typeof localStorage>`u`))try{localStorage.setItem(EV(n),JSON.stringify({v:1,prompt:t}))}catch{}}function kV(e){let t=e?.trim();if(!(!t||typeof localStorage>`u`))try{localStorage.removeItem(EV(t))}catch{}}var RQe=`xopc.chat.followUpQueue:v2:`;function AV(e){return`${RQe}${encodeURIComponent(e.trim())}`}function zQe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function BQe(e){if(!zQe(e))return null;let t=e.type;if(typeof t!=`string`||!t.trim())return null;let n={type:t.trim()};return typeof e.mimeType==`string`&&(n.mimeType=e.mimeType),typeof e.name==`string`&&(n.name=e.name),typeof e.size==`number`&&Number.isFinite(e.size)&&(n.size=e.size),typeof e.uri==`string`&&(n.uri=e.uri),typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&(n.durationSeconds=e.durationSeconds),n}function VQe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!zQe(n))continue;let e=n.id,r=n.text;if(typeof e!=`string`||!e.trim()||typeof r!=`string`)continue;let i={id:e.trim(),text:r};if(typeof n.thinkingLevel==`string`&&n.thinkingLevel.trim()&&(i.thinkingLevel=n.thinkingLevel.trim()),Array.isArray(n.attachments)){let e=n.attachments.flatMap(e=>{let t=BQe(e);return t?[t]:[]});e.length&&(i.attachments=e)}if(t.push(i),t.length>=50)break}return t}function jV(e){return{editingId:e.editingId,pending:e.pending.map(e=>({...e,attachments:e.attachments?.map(e=>{let{data:t,...n}=e;return n})}))}}function HQe(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return null;try{let e=localStorage.getItem(AV(t));if(!e)return null;let n=JSON.parse(e);if(!zQe(n))return null;let r=VQe(n.pending),i=n.editingId===null?null:typeof n.editingId==`string`&&n.editingId.trim()?n.editingId.trim():null;return r.length===0&&i==null?null:{pending:r,editingId:i}}catch{return null}}function MV(e,t){let n=e?.trim();if(!n||typeof localStorage>`u`)return;let r=jV(t);if(r.pending.length===0&&r.editingId==null){UQe(n);return}try{localStorage.setItem(AV(n),JSON.stringify({v:2,...r}))}catch{}}function UQe(e){let t=e?.trim();if(!(!t||typeof localStorage>`u`))try{localStorage.removeItem(AV(t))}catch{}}function WQe(e){let{sessionKey:t,decodedKey:n,sessionKeyRef:r,activeStreamSessionKeyRef:i,sendingRef:a,streamingRef:o,modelSupportsThinking:s,thinkingLevel:c,shouldApplyStreamUpdate:l,sendMessageRef:u}=e,[d,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null),_=(0,j.useRef)(null),[y,b]=(0,j.useState)([]),x=(0,j.useRef)([]),[S,C]=(0,j.useState)(null),[w,T]=(0,j.useState)(null),E=(0,j.useRef)(null),[D,O]=(0,j.useState)(null),k=(0,j.useRef)(void 0),A=(0,j.useRef)(null);_.current=d,x.current=y,E.current=w,(0,j.useLayoutEffect)(()=>{let e=k.current;e!=null&&e!==n&&(MV(e,{pending:structuredClone(x.current),editingId:E.current}),_.current!=null&&OV(e,_.current),C(null)),k.current=n;let r=A.current;if(r!=null&&r!==t&&(MV(r,{pending:structuredClone(x.current),editingId:E.current}),_.current!=null&&OV(r,_.current)),A.current=t,!t&&!n){(x.current.length>0||E.current!==null||D!==null)&&(x.current=[],b([]),T(null),O(null)),_.current!=null&&(f(null),g(null));return}let i=t&&n&&t===n?t:null;if(i!=null&&i!==D){let e=HQe(i),t=e?structuredClone(e.pending):[];x.current=t,b(t),T(e?.editingId??null),f(LQe(i)),g(null),O(i)}t!=null&&t!==n&&_.current!=null&&(OV(t,_.current),f(null),g(null))},[t,n,D]),(0,j.useEffect)(()=>{let e=t!=null&&n!=null&&t!==n?t:t??n??null;if(!e)return;let i=window.setTimeout(()=>{r.current===e&&MV(e,{pending:structuredClone(x.current),editingId:E.current})},280);return()=>window.clearTimeout(i)},[t,n,y,w,r]);let ee=(0,j.useCallback)(()=>{g(null),f(null)},[]),te=(0,j.useCallback)(e=>{let t=String(e??``).trim();t&&(kV(t),r.current===t&&(g(null),f(null)))},[r]),ne=(0,j.useCallback)(()=>{let e=r.current;e&&kV(e),g(null),f(null)},[r]),re=(0,j.useCallback)(()=>{let e=r.current;e&&UQe(e),x.current=[],b([]),T(null),O(e)},[r]),ie=(0,j.useCallback)(()=>{let e=r.current;e&&(UQe(e),kV(e)),x.current=[],b([]),g(null),f(null),T(null),O(e)},[r]),ae=(0,j.useCallback)(e=>{te(e)},[te]),oe=(0,j.useCallback)(e=>t=>{OV(e,t),l(e)&&(a.current=!1,o.current=!1,qb.getState().setSessionFlags(e,{sending:!1,streaming:!1}),qb.getState().setSessionProgress(e,null),g(null),f(t))},[l,a,o]),se=(0,j.useCallback)(async e=>{let t=r.current;if(e!=null&&e!==t)return;let n=t;if(!n)return;let s=x.current;for(;s.length>0&&!s[0].text.trim()&&!s[0].attachments?.length;)s=s.slice(1);if(s.length===0){x.current=[],b([]);return}s.length!==x.current.length&&(x.current=s,b(s));let[c,...l]=s,d=c.text?.trim()??``,f=c.attachments;!d&&!f?.length||i.current===n&&(a.current||o.current)||(E.current===c.id&&T(null),x.current=l,b(l),await u.current(c.text,c.attachments,c.thinkingLevel))},[u,r,i,a,o]),ce=(0,j.useEffectEvent)(e=>{se(e)});return(0,j.useEffect)(()=>{if(!t||t!==n||d||y.length===0||a.current||o.current)return;let e=y[0];if(!e||!e.text.trim()&&!e.attachments?.length)return;let i=window.setTimeout(()=>{r.current===t&&(a.current||o.current||_.current||ce(t))},72);return()=>window.clearTimeout(i)},[t,n,d,y,a,o,r]),{clarifyPrompt:d,clarifySubmitting:p,clarifySubmitError:h,clarifyPromptRef:_,pendingFollowUps:y,pendingFollowUpsRef:x,steeringFollowUpId:S,editingFollowUpId:w,addPendingFollowUp:(0,j.useCallback)((e,t)=>{let n=e.trim();if(!n&&!t?.length||x.current.length>=10)return;let r=s?c:`off`,i={id:crypto.randomUUID(),text:n||e,attachments:t?.length?t:void 0,thinkingLevel:r};b(e=>{let t=[...e,i];return x.current=t,t})},[s,c]),beginEditFollowUp:(0,j.useCallback)(e=>{T(e)},[]),cancelEditFollowUp:(0,j.useCallback)(()=>{T(null)},[]),commitEditFollowUp:(0,j.useCallback)((e,t,n,r)=>{let i=t.trim(),a=x.current,o=a.findIndex(t=>t.id===e);if(o<0){T(null);return}if(!i&&!n?.length){let t=a.filter(t=>t.id!==e);x.current=t,b(t),T(null);return}let l=[...a],u=s?r??c:`off`;l[o]={...l[o],text:i||t,attachments:n?.length?n:void 0,thinkingLevel:u},x.current=l,b(l),T(null)},[s,c]),removePendingFollowUp:(0,j.useCallback)(e=>{E.current===e&&T(null),b(t=>{let n=t.filter(t=>t.id!==e);return x.current=n,n})},[]),movePendingFollowUp:(0,j.useCallback)((e,t)=>{b(n=>{let r=n.findIndex(t=>t.id===e);if(r<0)return n;let i=t===`up`?r-1:r+1;if(i<0||i>=n.length)return n;let a=[...n];return[a[r],a[i]]=[a[i],a[r]],x.current=a,a})},[]),reorderPendingFollowUp:(0,j.useCallback)((e,t)=>{b(n=>{if(e<0||e>=n.length||t<0||t>=n.length)return n;let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),x.current=r,r})},[]),steerPendingFollowUp:(0,j.useCallback)(async e=>{let t=r.current;if(!t)return;let n=x.current.find(t=>t.id===e);if(!(!n?.text.trim()||n.attachments?.length)){C(e);try{(await Te(v(`/api/agent/steer`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:t,message:n.text.trim()})})).ok&&(b(t=>{let n=t.filter(t=>t.id!==e);return x.current=n,n}),E.current===e&&T(null))}catch{}finally{C(null)}}},[r]),submitClarifyAnswer:(0,j.useCallback)(async e=>{let t=_.current;if(t){m(!0),g(null);try{let n=await Te(v(`/api/clarify/${encodeURIComponent(t.requestId)}`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answer:e})});if(!n.ok){g((await n.json().catch(()=>({}))).error?.message??n.statusText??`Clarify failed`);return}let i=r.current;i&&kV(i),f(null),g(null)}finally{m(!1)}}},[r]),cancelClarifyAnswer:(0,j.useCallback)(async()=>{let e=_.current;if(e){m(!0),g(null);try{let t=await Te(v(`/api/clarify/${encodeURIComponent(e.requestId)}`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skip:!0})});if(!t.ok){g((await t.json().catch(()=>({}))).error?.message??t.statusText??`Clarify failed`);return}let n=r.current;n&&kV(n),f(null),g(null)}finally{m(!1)}}},[r]),clearVisibleClarify:ee,dismissClarify:ne,dismissClarifyForSession:te,clearPendingFollowUps:re,dismissClarifyAndClearPending:ie,onClarifyToolEnd:ae,makeOnClarifyRequest:oe,flushSteeringQueue:se}}function GQe(e){let{navigate:t,sessionKeyRef:n,sessionKey:r,isNewRoute:i,locationState:a}=e,o=xe(e=>e.token),{data:s,mutate:c}=y(o?[`gateway-chat-agents`,o]:null,H,{revalidateOnFocus:!1});(0,j.useEffect)(()=>{let e=()=>void c();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[c]);let[l,u]=(0,j.useState)(()=>Ike()),d=(0,j.useRef)(s??null),f=(0,j.useRef)(Ike());(0,j.useEffect)(()=>{d.current=s??null},[s]),(0,j.useEffect)(()=>{f.current=l},[l]),(0,j.useEffect)(()=>{if(!s)return;let e=new Set(s.items.map(e=>e.id));u(t=>t==null||t===``||!e.has(t)?s.defaultId:t)},[s]);let p=(0,j.useCallback)(()=>{let e=n.current,t=e?pS(e):null;if(t)return t;let r=d.current,i=(f.current??``).trim().toLowerCase();if(!r)return i||void 0;let a=new Set(r.items.map(e=>e.id));return i&&a.has(i)?i:r.defaultId},[n]),m=(0,j.useCallback)(e=>{let r=e.trim().toLowerCase();u(r);try{globalThis.localStorage?.setItem(kb,r)}catch{}let i=n.current;(i?pS(i):null)!==r&&t(`/chat/new`,{replace:!1})},[t,n]);return(0,j.useEffect)(()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||m(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},[m]),(0,j.useLayoutEffect)(()=>{if(!r)return;let e=pS(r);if(!(!e||f.current===e)){f.current=e,u(e);try{globalThis.localStorage?.setItem(kb,e)}catch{}}},[r]),(0,j.useLayoutEffect)(()=>{if(!i)return;let e=a,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;if(t){f.current=t,u(t);try{globalThis.localStorage?.setItem(kb,t)}catch{}}},[i,a]),{token:o,chatAgentsData:s,resolveAgentIdForPost:p,onChatAgentChange:m,displayAgentId:(0,j.useMemo)(()=>r&&pS(r)||l||s?.defaultId||`main`,[r,l,s]),showChatAgentSelector:(s?.items.length??0)>1}}function KQe(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`);i&&r.set(`skill`,i),a&&r.set(`slash`,a);let o=r.toString();return o?`?${o}`:``}var NV=null;function PV(e){NV=String(e??``).trim()||null}function qQe(e){let t=String(e??``).trim();return!t||NV!==t?!1:(NV=null,!0)}function FV(e){e.register.then(t=>{if(e.isActive&&!e.isActive())return;let n=(t.key??``).trim();if(n){if(n!==e.sessionKey){PV(n),e.navigateToSession(n,e.replaceNavigate??!0,e.search),e.onReconciled?.(n,t);return}e.onRegistered?.(e.sessionKey,t)}}).catch(t=>{if(e.isActive&&!e.isActive())return;let n=t instanceof Error?t.message:`Could not register session`;e.onError(n)})}var JQe=80;function YQe(e){let t=e.trim();(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim());let n=t.indexOf(`
|
|
4840
|
-
`);return n!==-1&&(t=t.slice(0,n).trim()),t.length>JQe&&(t=t.slice(0,JQe-1).trimEnd()+`…`),t}function XQe(e){let t=Zy([{type:`text`,text:e}]).split(/\n/)[0]?.trim();if(!t)return null;let n=YQe(t);return n.length>0?n:null}function ZQe(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}function IV(e){let t=e.trim();t&&window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:t},bubbles:!0}))}function LV(e,t){let n=e.key?.trim();if(!n||!wb(n)||(e.messageCount??0)!==0)return!1;let r=pS(n);return!(!r||r!==yb(t)||Zb(n))}function QQe(e,t){let n=yb(t);return e.filter(e=>LV(e,n)).sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())[0]??null}function $Qe(e,t){let n=t.trim();return e.find(e=>e.key.trim()===n)}function e$e(e,t,n){if(!t?.length)return e;let r=new Map(e.map(e=>[e.key.trim(),e]));for(let e of t){let t=e.key.trim();!t||r.has(t)||LV(e,n)&&r.set(t,e)}return[...r.values()].toSorted((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())}async function t$e(e,t){let n=Cb();try{return e$e(await e.loadSessions(),n,t)}catch{return n??[]}}async function n$e(e){let t=yb(e.agentId),n=e.currentSessionKey?.trim()||null;if(e.forceNew){let{sessionKey:n,register:r}=e.sessionMgr.openOptimisticNewSession(t);return{kind:`create`,sessionKey:n,register:r}}let r=await t$e(e.sessionMgr,t);if(n){let e=$Qe(r,n);if(e&&LV(e,t))return{kind:`noop`,sessionKey:n}}let i=QQe(r,t);if(i&&i.key.trim()!==n)return{kind:`reuse`,sessionKey:i.key,session:i};let{sessionKey:a,register:o}=e.sessionMgr.openOptimisticNewSession(t);return{kind:`create`,sessionKey:a,register:o}}var RV=null;function zV(e){if(RV)return RV;let t=(async()=>{let t=e.agentId??void 0,n=await n$e({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,currentSessionKey:e.currentSessionKey,forceNew:e.forceNew});if(n.kind===`noop`)return e.onOpened(n.sessionKey),(e.routeSessionKey?.trim()||null)!==n.sessionKey&&e.navigateToSession(n.sessionKey,e.replaceNavigate??!1,e.search),n.sessionKey;if(n.kind===`reuse`)return PV(n.sessionKey),e.onOpened(n.sessionKey),e.navigateToSession(n.sessionKey,e.replaceNavigate??!1,e.search),IV(n.sessionKey),n.sessionKey;let{sessionKey:r,register:i}=n;return Sb({key:r,messageCount:0,updatedAt:new Date().toISOString()}),PV(r),e.onOpened(r),e.navigateToSession(r,e.replaceNavigate??!1,e.search),IV(r),e.followRegistration?.({sessionKey:r,register:i,replaceNavigate:e.replaceNavigate,search:e.search}),r})().finally(()=>{RV=null});return RV=t,t}var r$e={current:null},i$e={current:null};function a$e(){let e=Hn(),{sessionKey:t}=Wn(),n=e.pathname.endsWith(`/new`),r=t?decodeURIComponent(t):void 0,i=AQe(n,r),a=wV(i),o=n?null:r??null,s=(0,j.useRef)(i);return s.current=i,r$e.current=o,!n&&r&&(i$e.current=r),(0,j.useLayoutEffect)(()=>{qb.getState().focusedSessionKey!==o&&qb.getState().setFocusedSessionKey(o)},[o]),{isNewRoute:n,decodedKey:r,routedSessionKey:i,viewSessionKey:a,routedFocusedSessionKey:o,routeSessionKeyRef:s,locationSearch:e.search,locationState:e.state}}var o$e={get current(){return i$e.current}},BV={get current(){return r$e.current},set current(e){r$e.current=e,qb.getState().setFocusedSessionKey(e)}};function s$e(e){let t=(0,fm.c)(15),{token:n,isNewRoute:r,decodedKey:i,locationSearch:a,sessionMgrRef:o,resolveAgentIdForPost:s,navigateToSession:c,loadSessionById:l,tryResumeAgentRun:u,restoreLiveCacheIfNeeded:d,adoptEmptySession:f,applyAgentConfig:p,patchInitUi:m}=e,h=(0,j.useRef)(0),g,_;t[0]!==f||t[1]!==p||t[2]!==i||t[3]!==r||t[4]!==l||t[5]!==a||t[6]!==c||t[7]!==m||t[8]!==s||t[9]!==d||t[10]!==o||t[11]!==n||t[12]!==u?(g=()=>{if(!n){m({loading:!1});return}let e=h.current+=1,t=!1,g=()=>!t&&e===h.current,_=e=>{g()&&o.current.loadSessionAgentConfig(e).then(t=>{g()&&p(e,t)}).catch(d$e)},v=e=>{FV({...e,navigateToSession:c,isActive:g,onError:e=>m({error:e}),onReconciled:(e,t)=>{f(e,t.name??null),_(e)},onRegistered:(e,t)=>{t.name&&qb.getState().patchSessionMeta(e,{name:t.name}),_(e)}})},y=()=>{if(!g())return Promise.resolve();let e=s();return zV({sessionMgr:o.current,agentId:e,currentSessionKey:o$e.current,routeSessionKey:null,navigateToSession:c,replaceNavigate:!0,search:KQe(a),onOpened:e=>f(e,null),followRegistration:v}).then(u$e)},b=(e,t)=>g()?(d(e),u(e,Yb(e)?.messages??t??Xb(e))):Promise.resolve();return m({loading:i===void 0&&!r,error:null}),(r?y():i?(e=>g()?qQe(e)?(_(e),b(e,Xb(e))):l(e,0).then(t=>{if(g())return b(e,t??Xb(e))}):Promise.resolve())(i):g()?o.current.loadSessions().then(e=>{if(!g())return;let t=e.filter(l$e)[0]??e[0];if(t)return g()?l(t.key,0).then(e=>{if(!g())return;d(t.key);let n=Yb(t.key)?.messages??e??Xb(t.key);return o.current.parseSessionFromHash()||c(t.key,!0),u(t.key,n)}):void 0;if(!g())return;let n=s();return zV({sessionMgr:o.current,agentId:n,currentSessionKey:null,routeSessionKey:null,navigateToSession:c,onOpened:e=>f(e,null),followRegistration:v}).then(c$e)}):Promise.resolve()).then(()=>{g()&&m({loading:!1})}).catch(e=>{t?g()&&m({loading:!1}):m({error:e instanceof Error?e.message:`Chat init failed`,loading:!1})}),()=>{t=!0}},_=[n,r,i,a,o,s,c,l,u,d,f,p,m],t[0]=f,t[1]=p,t[2]=i,t[3]=r,t[4]=l,t[5]=a,t[6]=c,t[7]=m,t[8]=s,t[9]=d,t[10]=o,t[11]=n,t[12]=u,t[13]=g,t[14]=_):(g=t[13],_=t[14]),(0,j.useEffect)(g,_)}function c$e(){}function l$e(e){return(e.messageCount??0)>0}function u$e(){}function d$e(){}async function f$e(e){let t=e.trim();if(!t)return!1;try{return!!(await hL()).find(e=>e.id===t)?.reasoning}catch{return!1}}function p$e(e){let{sessionMgrRef:t,routeSessionKeyRef:n,sendingRef:r,streamingRef:i,activeStreamSessionKeyRef:a,loadingSessionRef:o,messagesLenRef:s,thinkingSupportGenRef:c,navigateToSession:l,resolveAgentIdForPost:u,dismissClarifyOnSessionLoad:d,detachForNewConversation:f,sessionKey:p,hasMore:m}=e,h=()=>qb.getState(),g=(0,j.useRef)(Promise.resolve(void 0)),_=(0,j.useRef)(null),v=(0,j.useRef)(0),y=(0,j.useCallback)(e=>{let t=h().focusedSessionKey;if(!e.trim())return++c.current===c.current&&t&&h().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++c.current;return f$e(e).then(e=>{if(n!==c.current)return;let t=h().focusedSessionKey;t&&h().patchSessionMeta(t,{modelSupportsThinking:e})})},[c]),b=(0,j.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);h().patchSessionMeta(e,{model:n.model,thinkingLevel:n.thinkingLevel||`medium`,reasoningLevel:TV(n.reasoningLevel)}),y(n.model)}catch{}},[t,y]),x=(0,j.useCallback)(e=>{FV({...e,navigateToSession:l,onError:e=>h().setShellError(e),onReconciled:(e,t)=>{h().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t.name??null}),b(e)},onRegistered:(e,t)=>{t.name&&h().patchSessionMeta(e,{name:t.name}),b(e)}})},[l,b]),S=(0,j.useCallback)(()=>{let e=h().focusedSessionKey;if(!e||(h().sessions[e]?.name)?.trim())return;let n=++v.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===v.current){if(t){h().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),C=(0,j.useCallback)(e=>kQe({chatId:e,routeSessionKey:n.current}),[n]),w=(0,j.useCallback)((e,t)=>{let n=h().getSessionSnapshot(e);n&&(n.streaming||n.sending||n.streamingMsg)?(h().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&h().patchSessionMeta(e,{name:t.name||null})):h().setCommittedSnapshot(e,{messages:t.messages,hasMore:t.hasMore,name:t.name}),C(e)&&(_.current=t.nextBeforeCursor??null)},[C]),T=(0,j.useCallback)(async(e,r=0,i)=>{let a=async(e,r,i)=>{let s=r===0&&!i;s&&!ob(e)&&d(),o.current=!0;try{let{messages:n,hasMore:a,name:o,nextBeforeCursor:c}=await t.current.loadSession(e,r,i);if(s){if(h().setCommittedSnapshot(e,{messages:n,hasMore:a,name:o??null}),!C(e))return n;_.current=c??null,h().setShellError(null);try{let r=await t.current.loadSessionAgentConfig(e);if(!C(e))return n;h().patchSessionMeta(e,{model:r.model,thinkingLevel:r.thinkingLevel||`medium`,reasoningLevel:TV(r.reasoningLevel)}),y(r.model)}catch{}return n}if(_.current=c??null,!C(e))return;h().prependHistoryMessages(e,n,a);return}catch{if(r===0&&!i){_.current=null,h().setShellError(`Failed to load session`);let r=wV(n.current);if(r&&r===e)return;let i=await t.current.loadSessions().catch(()=>[]),o=i.filter(e=>(e.messageCount??0)>0)[0]??i[0];if(o)return l(o.key,!0),await a(o.key,0,null);{_.current=null;let e=u();zV({sessionMgr:t.current,agentId:e,currentSessionKey:null,routeSessionKey:null,navigateToSession:l,replaceNavigate:!0,onOpened:e=>{h().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null})},followRegistration:x})}}return}finally{o.current=!1}},s=g.current,c,f=new Promise(e=>{c=e});g.current=s.then(()=>f),await s;try{return await a(e,r,i)}finally{c()}},[n,C,r,i,a,o,d,l,y,u,t,x]);return{refreshModelThinkingSupport:y,pollSessionNameAfterTurn:S,applyLoadedSessionSnapshot:w,loadSessionById:T,loadMoreMessages:(0,j.useCallback)(async()=>{let e=h().focusedSessionKey;if(!(!e||h().loadingMore||!m)){h().setLoadingMore(!0);try{await T(e,s.current,_.current)}finally{h().setLoadingMore(!1)}}},[m,T,s]),onSessionModelChange:(0,j.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{model:e}),h().patchSessionMeta(p,{model:e}),y(e)}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to switch model`)}},[p,t,y]),onSessionThinkingLevelChange:(0,j.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{thinkingLevel:e}),h().patchSessionMeta(p,{thinkingLevel:e})}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to update thinking level`)}},[p,t]),createNewSession:(0,j.useCallback)(async e=>{d(),f(),_.current=null,h().setShellError(null);let n=u();await zV({sessionMgr:t.current,agentId:n,currentSessionKey:p,routeSessionKey:p,forceNew:e?.forceNew,navigateToSession:l,onOpened:e=>{h().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null})},followRegistration:x})},[d,f,l,u,p,t,x])}}function VV(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,setStreamingOnStreamStart:i,clearResumeRunIdOnBackgroundTerminal:a,clearResumeRunIdOnVisibleError:o,setError:s,sessionMgrRef:c,applyLoadedSessionSnapshot:l,finalizeMessage:u,fq:d}=e,f=()=>qb.getState(),p=()=>{c.current.loadSession(t,0).then(e=>l(t,e)).catch(()=>{})},m=()=>{f().clearStreamingState(t),Ab.clearActiveStreamSessionKey(t),a&&(Ab.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),d.dismissClarifyForSession(t),p()};return{onUserMessage:e=>{n(t)&&f().appendUserMessageIfMissing(t,e)},onStreamStart:()=>{r(),f().mutateSessionStreaming(t,()=>{}),f().setSessionFlags(t,{streaming:!0})},onToken:e=>{r(),f().mutateSessionStreaming(t,t=>{zb(t.content,e)}),n(t)&&f().setSessionFlags(t,{streaming:!0})},onThinking:(e,n)=>{r(),f().mutateSessionStreaming(t,t=>{!n&&e===``?zke(t.content):Ib(t.content,e,n)})},onThinkingEnd:()=>{r(),f().mutateSessionStreaming(t,e=>{Lb(e.content)})},onToolStart:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{Bb(t.content,e,n,i)}),f().setSessionFlags(t,{streaming:!0})},onToolEnd:(e,n,i)=>{e===`clarify`&&d.onClarifyToolEnd(t),r(),f().mutateSessionStreaming(t,t=>{Vke(t.content,e,n,i)})},onToolUpdate:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{Vb(t.content,e,n,i)})},onProgress:e=>{f().setSessionProgress(t,e)},onTtsAudio:e=>{r(),f().mutateSessionStreaming(t,t=>{let n=e.uri?.trim(),r=t.attachments??[];if(n&&r.some(e=>e.uri?.trim()===n))return;let i={name:e.name,mimeType:e.mimeType,type:`voice`,uri:e.uri,size:0};t.attachments=[...r,i]})},onCompaction:e=>{if(n(t))if(e.status===`started`)f().setSessionProgress(t,{stage:`compaction`,message:`Compacting context…`,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${Math.round((e.tokensBefore-e.tokensAfter)/1e3)}k tokens freed)`:``;f().setSessionProgress(t,{stage:`compaction`,message:`Context compacted${n}`,timestamp:Date.now()})}else f().setSessionProgress(t,null)},onClarifyRequest:d.makeOnClarifyRequest(t),onResult:()=>{if(!n(t)){m();return}if(Ab.userAborted){Ab.userAborted=!1;return}u()},onError:e=>{if(!n(t)){m();return}f().clearStreamingState(t),o&&(Ab.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),s(e),d.dismissClarifyForSession(t)}}}function m$e(e){return Yb(e)?.streamingMsg??null}function h$e(e){let{sessionKey:t,thinkingLevel:n,modelSupportsThinking:r,sessionKeyRef:i,sendingRef:a,streamingRef:o,sessionMgrRef:s,sendMessageRef:c,shouldApplyStreamUpdate:l,fq:u,applyLoadedSessionSnapshot:d,loadSessionById:f,createNewSession:p,pollSessionNameAfterTurn:m}=e,h=(0,j.useRef)(u.flushSteeringQueue);h.current=u.flushSteeringQueue;let g=()=>qb.getState(),_=e=>g().setShellError(e),v=()=>g().setShellError(null),y=(0,j.useCallback)(e=>{let t=Ab.activeStreamSessionKey??i.current;if(t&&!l(t))return;let n=t?m$e(t):null,r=null;if(n){let e=Mb(n,Date.now());Lb(e.content),Bke(e.content),r=Nb(e)}if(r&&Rke(r)&&t){let e=Yb(t)?.messages??Xb(t);g().finalizeStreamingTurn(t,Vy([...e,r]))}else t&&g().clearStreamingState(t);if(a.current=!1,o.current=!1,Ab.resetRunTracking(),u.dismissClarify(),m(),!e?.skipSteeringQueueFlush){let e=t??i.current;e&&window.setTimeout(()=>{h.current(e)},72)}let s=i.current;s&&window.setTimeout(()=>{i.current===s&&(a.current||o.current||u.pendingFollowUpsRef.current.length>0||f(s,0))},400)},[a,o,i,u.dismissClarify,u.pendingFollowUpsRef,m,f,l]),b=(0,j.useCallback)(async(e,t)=>{if(!l(e)||Ab.isStreamingFor(e)||Ab.isSending)return;let n=await lb(e);if(!n||Ab.activeResumeRunId===n)return;let r=t??Xb(e),i=Yb(e)?.hasMore??!1;try{let t=await s.current.loadSession(e,0);g().mergeCommittedFromServer(e,t.messages,t.hasMore),r=t.messages,i=t.hasMore}catch{}Ab.userAborted=!1,Ab.activeResumeRunId=n,Ab.activeStreamSessionKey=e,a.current=!0,o.current=!0,g().seedSessionIfEmpty(e,r,!0,!0,i),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null);let c=!1,f=()=>{if(c||!l(e))return;c=!0;let t=Xb(e);if(t.length===0)return;let n=t[t.length-1];if(n?.role!==`assistant`)return;let r=Nb(n),i=t.slice(0,-1);g().applyHydratedTail(e,i,r)};try{let t=VV({chatId:e,shouldApplyStreamUpdate:l,beforeAssistantDelta:f,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await Ab.sender.resume(n,e,t)}catch(t){if(t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),g().clearStreamingState(e),Ab.activeResumeRunId=null,!l(e)){Ab.clearActiveStreamSessionKey(e);return}a.current=!1,o.current=!1,Ab.clearActiveStreamSessionKey(e)}},[a,o,l,s,d,y]),x=(0,j.useCallback)(async(e,t,s)=>{if(!e.trim()&&!t?.length||!a.current&&!o.current&&!Ab.isSending)return;if(e.trim()===`/new`&&!t?.length){await p({forceNew:!0});return}if(!i.current)return;u.dismissClarifyAndClearPending();let l=r?s??n:`off`;Ab.userAborted=!0,Ab.resetRunTracking(),Ab.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0}),queueMicrotask(()=>{c.current(e,t,l)})},[a,o,i,u.dismissClarifyAndClearPending,r,n,y,c,p]);return{finalizeMessage:y,tryResumeAgentRun:b,sendMessage:(0,j.useCallback)(async(e,i,c)=>{if(!t||!l(t)||!e.trim()&&!i?.length||Ab.activeStreamSessionKey===t&&(a.current||o.current))return;let f=e.trim();if(f===`/new`&&!i?.length){await p({forceNew:!0});return}let m=r?c??n:`off`,h=t;Ab.userAborted=!1,Ab.activeStreamSessionKey=h,a.current=!0,o.current=!1,v(),u.dismissClarify();let b=[...Xb(h),{role:`user`,content:e?[{type:`text`,text:e}]:[],attachments:i,timestamp:Date.now()}],x=Yb(h);if(g().initSessionSnapshot(h,{...x??{...Ob(),hasMore:!1,streamingMsg:null,progress:null,sending:!1,streaming:!1},messages:b,hasMore:x?.hasMore??!1,streamingMsg:null,progress:null,sending:!0,streaming:!1}),!x?.name?.trim()&&f){let e=XQe(f);e&&(g().patchSessionMeta(h,{name:e}),ZQe(h,e))}try{let t=VV({chatId:h,shouldApplyStreamUpdate:l,beforeAssistantDelta:()=>{},setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await Ab.sender.send(e,h,i,m,t)}catch(e){e.name!==`AbortError`&&(g().clearStreamingState(h),_(JSON.stringify(Jy())))}finally{a.current=!1,o.current=!1,g().setSessionFlags(h,{sending:!1}),Ab.clearActiveStreamSessionKey(h)}},[t,n,r,a,o,l,s,d,y,u.dismissClarify,p]),interruptAndSend:x,abort:(0,j.useCallback)(()=>{Ab.userAborted=!0,Ab.resetRunTracking(),u.dismissClarifyAndClearPending(),Ab.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0});let e=i.current;e&&window.setTimeout(()=>{f(e,0)},300)},[u.dismissClarifyAndClearPending,a,o,y,i,f]),deleteMessageRound:(0,j.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=Xb(t),r=n[e];if(!r||!Qy(r.role))return;let c=fke(n,e);if(c===null)return;let l=$y(n,e),u=[...n];u.splice(e,l),g().updateSessionMessages(t,()=>u),s.current.deleteMessages(t,{userRoundIndex:c}).catch(()=>{f(t,0)})},[i,a,o,s,f]),retryUserMessageRound:(0,j.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=Xb(t),r=n[e];if(!r||!Qy(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&Qy(e.role))return}let l=Zy(r.content),u=dke(r.attachments);if(!l.trim()&&!u?.length)return;let d=fke(n,e);if(d===null)return;let p=$y(n,e),m=[...n];m.splice(e,p),g().updateSessionMessages(t,()=>m),(async()=>{try{await s.current.deleteMessages(t,{userRoundIndex:d}),await c.current(l,u)}catch{f(t,0)}})()},[i,a,o,s,f,c])}}function g$e(e){let t=(0,fm.c)(10),{sessionKey:n,sessionKeyRef:r,sessionMgrRef:i,loadSessionById:a,applyAgentConfig:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0],(0,j.useEffect)(_$e,s);let c,l;t[1]!==a||t[2]!==n?(c=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||a(n,0)};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},l=[n,a],t[1]=a,t[2]=n,t[3]=c,t[4]=l):(c=t[3],l=t[4]),(0,j.useEffect)(c,l);let u,d;t[5]!==o||t[6]!==r||t[7]!==i?(u=()=>{let e=()=>{let e=r.current;e&&i.current.loadSessionAgentConfig(e).then(t=>{o(e,t)}).catch(HV)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},d=[r,i,o],t[5]=o,t[6]=r,t[7]=i,t[8]=u,t[9]=d):(u=t[8],d=t[9]),(0,j.useEffect)(u,d)}function HV(){}function _$e(){let e=v$e;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function v$e(e){let t=e.detail;!t?.key||t.name===void 0||qb.getState().patchSessionMeta(t.key,{name:t.name||null})}function y$e(){let e=Un(),{isNewRoute:t,decodedKey:n,viewSessionKey:r,routedFocusedSessionKey:i,routeSessionKeyRef:a,locationSearch:o,locationState:s}=a$e(),c=(0,j.useRef)(new Mke),l=(0,j.useRef)(!1),u=(0,j.useRef)(!1),d=(0,j.useRef)(!1),f=(0,j.useRef)(0),p=(0,j.useRef)(!1),m=(0,j.useRef)(async()=>{}),h=(0,j.useRef)(0),g=i,_=qb(e=>e.initLoading),v=qb(e=>e.loadingMore),y=qb(e=>e.shellError),b=r,x=qb(e=>b?e.sessions[b]:void 0),S=b?Jb(x):!1,C=S?x?.streaming??!1:!1,w=S?x?.sending??!1:!1,T=S?x?.progress??null:null,E=x?.hasMore??!1,D=x?.name??null,O=x?.model??``,k=x?.thinkingLevel??`medium`,A=x?.reasoningLevel??`stream`,ee=x?.modelSupportsThinking??!1;(0,j.useEffect)(()=>{h.current=x?.messages.length??0},[x?.messages.length]),(0,j.useEffect)(()=>{u.current=w,d.current=C},[w,C]);let{token:te,chatAgentsData:ne,resolveAgentIdForPost:re,onChatAgentChange:ie,displayAgentId:ae,showChatAgentSelector:oe}=GQe({navigate:e,sessionKeyRef:BV,sessionKey:g,isNewRoute:t,locationState:s}),se=n!==void 0&&g!==n,ce=(0,j.useMemo)(()=>_&&(g==null||n===void 0),[_,g,n]),le=(0,j.useCallback)((t,n=!1,r)=>{let i=r??``;e({pathname:`/chat/${encodeURIComponent(t)}`,search:i},{replace:n})},[e]),ue=(0,j.useCallback)(e=>DQe({streamSessionKey:e,routeSessionKey:a.current}),[a]),de=(0,j.useCallback)(()=>{PQe({sendingRef:u,streamingRef:d})},[]),fe=WQe({sessionKey:g,decodedKey:n,sessionKeyRef:BV,activeStreamSessionKeyRef:Lke,sendingRef:u,streamingRef:d,modelSupportsThinking:ee,thinkingLevel:k,shouldApplyStreamUpdate:ue,sendMessageRef:m}),pe=(0,j.useCallback)(()=>{fe.clearVisibleClarify(),Ab.activeResumeRunId=null,Ab.userAborted=!1,MQe(de)},[fe.clearVisibleClarify,de]),{refreshModelThinkingSupport:me,pollSessionNameAfterTurn:he,applyLoadedSessionSnapshot:ge,loadSessionById:_e,loadMoreMessages:ve,onSessionModelChange:ye,onSessionThinkingLevelChange:be,createNewSession:xe}=p$e({sessionMgrRef:c,routeSessionKeyRef:a,sendingRef:u,streamingRef:d,activeStreamSessionKeyRef:Lke,loadingSessionRef:l,messagesLenRef:h,thinkingSupportGenRef:f,navigateToSession:le,resolveAgentIdForPost:re,dismissClarifyOnSessionLoad:fe.clearVisibleClarify,detachForNewConversation:pe,sessionKey:g,hasMore:E}),Se=(0,j.useCallback)(e=>{if(!OQe({cacheSessionKey:e,routeSessionKey:a.current}))return!1;let t=Yb(e);return!t||!Jb(t)&&!ob(e)&&!Ab.isStreamingFor(e)?!1:(Ab.activeStreamSessionKey=e,u.current=t.sending,d.current=t.streaming,!0)},[a]),{tryResumeAgentRun:Ce,sendMessage:we,interruptAndSend:Te,abort:Ee,deleteMessageRound:De,retryUserMessageRound:Oe}=h$e({sessionKey:g,thinkingLevel:k,modelSupportsThinking:ee,sessionKeyRef:BV,sendingRef:u,streamingRef:d,sessionMgrRef:c,sendMessageRef:m,shouldApplyStreamUpdate:ue,fq:fe,applyLoadedSessionSnapshot:ge,loadSessionById:_e,createNewSession:xe,pollSessionNameAfterTurn:he});(0,j.useEffect)(()=>{t&&pe()},[t,pe]);let ke=(0,j.useMemo)(()=>jQe({viewSessionKey:r,sessionKey:b,messages:x?.messages??[],streamingMsg:S?x?.streamingMsg??null:null}),[r,b,x?.messages,x?.streamingMsg,S]),Ae=(0,j.useCallback)((e,t)=>{qb.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),de()},[de]),je=(0,j.useCallback)((e,t)=>{NQe(e,t),me(t.model)},[me]),Me=(0,j.useCallback)(e=>{let t=qb.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]);return g$e({sessionKey:g,sessionKeyRef:BV,sendingRef:u,streamingRef:d,sessionMgrRef:c,loadSessionById:_e,applyAgentConfig:je}),s$e({token:te,isNewRoute:t,decodedKey:n,locationSearch:o,sessionMgrRef:c,resolveAgentIdForPost:re,navigateToSession:le,loadSessionById:_e,tryResumeAgentRun:Ce,restoreLiveCacheIfNeeded:Se,adoptEmptySession:Ae,applyAgentConfig:je,patchInitUi:Me}),(0,j.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.sessionKey)return;let n=t.event;if(!n||typeof n.type!=`string`)return;let r=t.sessionKey;if(n.type===`user_message`||n.type===`user_transcript`){let e=eb(n);e&&ue(r)&&qb.getState().appendUserMessageIfMissing(r,e);return}if(n.type===`tool_update`){let e=typeof n.toolName==`string`?n.toolName:``;if(e!==`workflow`||!ue(r)||Ab.isStreamingFor(r))return;let t=typeof n.toolCallId==`string`?n.toolCallId:void 0,i=n.details;qb.getState().mutateSessionStreaming(r,n=>{Vb(n.content,e,t,i)});return}n.type!==`status`||typeof n.runId!=`string`||!n.runId.trim()||(sb(r,n.runId),ue(r)&&(Ab.isStreamingFor(r)||queueMicrotask(()=>{ue(r)&&(Ab.isStreamingFor(r)||Ce(r,Xb(r)))})))};return window.addEventListener(`agent-stream`,e),()=>window.removeEventListener(`agent-stream`,e)},[Ce,ue]),(0,j.useEffect)(()=>{let e=C||w,t=p.current;if(p.current=e,!t||e)return;let n=BV.current;n&&queueMicrotask(()=>{!n||!ue(n)||Ab.isStreamingFor(n)||ob(n)&&Ce(n,Xb(n))})},[C,w,Ce,ue]),m.current=we,{auth:{hasToken:!!te},session:{sessionKey:g,sessionName:D,decodedKey:n,sessionRoutePending:se,showSessionLoading:ce,loading:_,sessionModel:O,thinkingLevel:k,onSessionThinkingLevelChange:be,reasoningLevel:A,modelSupportsThinking:ee,hasMore:E,loadingMore:v,loadMoreMessages:ve,onSessionModelChange:ye,createNewSession:xe,sessionManager:c.current},messages:{items:ke},stream:{error:y,streaming:C,sending:w,progress:T,sendMessage:we,abort:Ee,interruptAndSend:Te,deleteMessageRound:De,retryUserMessageRound:Oe},followUp:{addPendingFollowUp:fe.addPendingFollowUp,pendingFollowUps:fe.pendingFollowUps,editingFollowUpId:fe.editingFollowUpId,beginEditFollowUp:fe.beginEditFollowUp,cancelEditFollowUp:fe.cancelEditFollowUp,commitEditFollowUp:fe.commitEditFollowUp,removePendingFollowUp:fe.removePendingFollowUp,movePendingFollowUp:fe.movePendingFollowUp,reorderPendingFollowUp:fe.reorderPendingFollowUp,steerPendingFollowUp:fe.steerPendingFollowUp,steeringFollowUpId:fe.steeringFollowUpId},clarify:{clarifyPrompt:fe.clarifyPrompt,clarifySubmitting:fe.clarifySubmitting,clarifySubmitError:fe.clarifySubmitError,submitClarifyAnswer:fe.submitClarifyAnswer,cancelClarifyAnswer:fe.cancelClarifyAnswer},agents:{chatAgents:ne,displayAgentId:ae,showChatAgentSelector:oe,onChatAgentChange:ie}}}var b$e=300*1e3,x$e=Math.round(b$e/6e4);function S$e(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function C$e(e){let t=(0,fm.c)(7),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e;if(!n)return null;let c;return t[0]!==a||t[1]!==s||t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==r?(c=(0,z.jsx)(UV,{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s},n.requestId),t[0]=a,t[1]=s,t[2]=o,t[3]=n,t[4]=i,t[5]=r,t[6]=c):c=t[6],c}function UV(e){let t=(0,fm.c)(70),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e,[c,l]=(0,j.useState)(``),[u]=(0,j.useState)(T$e),[d,f]=(0,j.useState)(0),p=(0,j.useRef)(null),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=window.setInterval(()=>f(w$e),1e3);return()=>window.clearInterval(e)},h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),(0,j.useEffect)(m,h);let g,_;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p.current?.focus()},_=[],t[2]=g,t[3]=_):(g=t[2],_=t[3]),(0,j.useEffect)(g,_);let v;t[4]===o?v=t[5]:(v=e=>{o(e)},t[4]=o,t[5]=v);let y=v,b=Math.max(0,Math.ceil((u-Date.now())/1e3)),x=`clarify-meta-${n.requestId}`,S=i?`clarify-err-${n.requestId}`:void 0,C;t[6]!==s||t[7]!==r?(C=e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},t[6]=s,t[7]=r,t[8]=C):C=t[8];let w=C,T=Array.isArray(n.choices)&&n.choices.length>=2,E;t[9]!==a.clarifyDefaultChoice||t[10]!==n.default?(E=n.default?a.clarifyDefaultChoice.replace(`{{text}}`,n.default):null,t[9]=a.clarifyDefaultChoice,t[10]=n.default,t[11]=E):E=t[11];let D=E,O;t[12]===a.clarifyServerTimeout?O=t[13]:(O=a.clarifyServerTimeout.replace(`{{minutes}}`,String(x$e)),t[12]=a.clarifyServerTimeout,t[13]=O);let k=O,A;t[14]!==a.clarifyTimeRemaining||t[15]!==b?(A=a.clarifyTimeRemaining.replace(`{{time}}`,S$e(b)),t[14]=a.clarifyTimeRemaining,t[15]=b,t[16]=A):A=t[16];let ee=A,te=a.clarifyRegionAria,ne;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ne=fh(`mb-4 rounded-lg border border-edge bg-surface-elevated px-4 py-3 text-sm text-fg shadow-sm outline-none`,yh.focusRingPanel),t[17]=ne):ne=t[17];let re;t[18]===a.clarifyResumeHint?re=t[19]:(re=(0,z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.clarifyResumeHint}),t[18]=a.clarifyResumeHint,t[19]=re);let ie;t[20]===n.question?ie=t[21]:(ie=(0,z.jsx)(AD,{content:n.question,compact:!0,className:`mb-3`}),t[20]=n.question,t[21]=ie);let ae;t[22]===k?ae=t[23]:(ae=(0,z.jsx)(`li`,{children:k}),t[22]=k,t[23]=ae);let oe;t[24]!==a.clarifyDefaultTimeoutNote||t[25]!==n.default?(oe=n.default?(0,z.jsx)(`li`,{children:a.clarifyDefaultTimeoutNote}):null,t[24]=a.clarifyDefaultTimeoutNote,t[25]=n.default,t[26]=oe):oe=t[26];let se;t[27]===a.clarifySkipNote?se=t[28]:(se=(0,z.jsx)(`li`,{children:a.clarifySkipNote}),t[27]=a.clarifySkipNote,t[28]=se);let ce;t[29]===ee?ce=t[30]:(ce=(0,z.jsx)(`li`,{children:ee}),t[29]=ee,t[30]=ce);let le;t[31]!==x||t[32]!==ae||t[33]!==oe||t[34]!==se||t[35]!==ce?(le=(0,z.jsxs)(`ul`,{id:x,className:`mb-3 list-inside list-disc space-y-1 text-xs text-fg-muted`,children:[ae,oe,se,ce]}),t[31]=x,t[32]=ae,t[33]=oe,t[34]=se,t[35]=ce,t[36]=le):le=t[36];let ue;t[37]!==S||t[38]!==i?(ue=i?(0,z.jsx)(`div`,{id:S,role:`alert`,className:`mb-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:i}):null,t[37]=S,t[38]=i,t[39]=ue):ue=t[39];let de;t[40]!==c||t[41]!==D||t[42]!==T||t[43]!==a.clarifyChoicesGroupAria||t[44]!==a.clarifyCustomLabel||t[45]!==a.clarifyPlaceholder||t[46]!==a.clarifySend||t[47]!==a.clarifyUseDefault||t[48]!==o||t[49]!==y||t[50]!==n.choices||t[51]!==n.default||t[52]!==r?(de=T?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`max-h-[min(40vh,16rem)] overflow-y-auto overflow-x-hidden pr-1 [scrollbar-gutter:stable]`,"aria-label":a.clarifyChoicesGroupAria,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[n.choices.map(e=>(0,z.jsx)(gh,{type:`button`,variant:`secondary`,disabled:r,className:fh(`min-h-9 w-full justify-start rounded-lg px-3 py-2 text-left text-sm font-normal shadow-none`,`hover:border-edge`),onClick:()=>y(e),children:e},e)),n.default?(0,z.jsx)(gh,{type:`button`,variant:`ghost`,disabled:r,className:fh(`min-h-9 w-full justify-start rounded-lg border border-dashed border-edge px-3 py-2 text-left text-sm font-normal text-fg-muted`,`hover:border-edge hover:text-fg`),onClick:()=>y(n.default),children:D}):null]})}),(0,z.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:a.clarifyCustomLabel}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&o(t)},children:[(0,z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,z.jsx)(gh,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend})]})]})]}):(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&(o(t),l(``))},children:[(0,z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,z.jsx)(gh,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend}),n.default?(0,z.jsx)(gh,{type:`button`,variant:`secondary`,disabled:r,className:`shrink-0 rounded-lg px-3 py-2 text-sm font-normal text-fg-muted shadow-none hover:text-fg`,onClick:()=>y(n.default),children:a.clarifyUseDefault}):null]}),t[40]=c,t[41]=D,t[42]=T,t[43]=a.clarifyChoicesGroupAria,t[44]=a.clarifyCustomLabel,t[45]=a.clarifyPlaceholder,t[46]=a.clarifySend,t[47]=a.clarifyUseDefault,t[48]=o,t[49]=y,t[50]=n.choices,t[51]=n.default,t[52]=r,t[53]=de):de=t[53];let fe;t[54]===s?fe=t[55]:(fe=()=>void s(),t[54]=s,t[55]=fe);let pe;t[56]!==a.clarifySkip||t[57]!==r||t[58]!==fe?(pe=(0,z.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle pt-3`,children:(0,z.jsx)(gh,{type:`button`,variant:`ghost`,disabled:r,className:`text-fg-muted hover:text-fg`,onClick:fe,children:a.clarifySkip})}),t[56]=a.clarifySkip,t[57]=r,t[58]=fe,t[59]=pe):pe=t[59];let me;return t[60]!==a.clarifyRegionAria||t[61]!==x||t[62]!==w||t[63]!==re||t[64]!==ie||t[65]!==le||t[66]!==ue||t[67]!==de||t[68]!==pe?(me=(0,z.jsxs)(`section`,{ref:p,tabIndex:-1,"aria-label":te,"aria-describedby":x,onKeyDown:w,className:ne,children:[re,ie,le,ue,de,pe]}),t[60]=a.clarifyRegionAria,t[61]=x,t[62]=w,t[63]=re,t[64]=ie,t[65]=le,t[66]=ue,t[67]=de,t[68]=pe,t[69]=me):me=t[69],me}function w$e(e){return e+1}function T$e(){return Date.now()+b$e}function E$e(e,t){return e===`running`||e===`queued`?t.runLinkRunning:e===`succeeded`?t.runLinkCompleted:t.runLinkFinished}var D$e=(0,j.memo)(function(e){let t=(0,fm.c)(28),{link:n,className:r}=e,i=h(f(O$e)).workflows,a=Un(),o;t[0]!==n.definitionId||t[1]!==n.goal?(o=n.goal.trim()||n.definitionId,t[0]=n.definitionId,t[1]=n.goal,t[2]=o):o=t[2];let s=o,c;t[3]!==n.workflowSessionKey||t[4]!==a?(c=()=>a(`/chat/${encodeURIComponent(n.workflowSessionKey)}`),t[3]=n.workflowSessionKey,t[4]=a,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=fh(`flex w-full items-start gap-3 rounded-2xl border border-edge bg-surface-panel px-4 py-3 text-left`,`transition-colors hover:bg-surface-hover/60`,yh.focusRingPanel,r),t[6]=r,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,z.jsx)(no,{className:`size-4`,"aria-hidden":!0})}),t[8]=u):u=t[8];let d=E$e(n.status,i),p;t[9]===d?p=t[10]:(p=(0,z.jsx)(`span`,{className:`block text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:d}),t[9]=d,t[10]=p);let m;t[11]===n.definitionId?m=t[12]:(m=(0,z.jsx)(`span`,{className:`mt-1 block text-sm font-semibold text-fg`,children:n.definitionId}),t[11]=n.definitionId,t[12]=m);let g;t[13]===s?g=t[14]:(g=(0,z.jsx)(`span`,{className:`mt-0.5 block truncate text-sm text-fg-muted`,children:s}),t[13]=s,t[14]=g);let _;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,z.jsx)(Or,{className:`size-3.5`,"aria-hidden":!0}),t[15]=_):_=t[15];let v;t[16]===i.runLinkOpenChat?v=t[17]:(v=(0,z.jsxs)(`span`,{className:`mt-2 inline-flex items-center gap-1 text-xs font-medium text-accent-fg`,children:[i.runLinkOpenChat,_]}),t[16]=i.runLinkOpenChat,t[17]=v);let y;t[18]!==m||t[19]!==g||t[20]!==v||t[21]!==p?(y=(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[p,m,g,v]}),t[18]=m,t[19]=g,t[20]=v,t[21]=p,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==c||t[25]!==l||t[26]!==u?(b=(0,z.jsxs)(`button`,{type:`button`,onClick:c,className:l,children:[u,y]}),t[23]=y,t[24]=c,t[25]=l,t[26]=u,t[27]=b):b=t[27],b});function O$e(e){return e.language}async function k$e(){return(await Ce(v(`/api/workflows/definitions`))).definitions??[]}async function A$e(e,t){return Ce(v(`/api/workflows/definitions/validate`),{method:`POST`,body:JSON.stringify({name:e,script:t})})}async function j$e(e,t){return(await Ce(v(`/api/workflows/definitions`),{method:`POST`,body:JSON.stringify({name:e,script:t})})).definition}async function M$e(e){await Ce(v(`/api/workflows/definitions/${encodeURIComponent(e)}`),{method:`DELETE`})}async function N$e(e){let t=e?.trim(),n=new URLSearchParams;return t&&n.set(`definitionId`,t),(await Ce(v(`/api/workflows/stats${n.size>0?`?${n.toString()}`:``}`))).stats}async function P$e(e=50){return(await Ce(v(`/api/workflows/runs?limit=${e}`))).runs??[]}async function WV(e){return(await Ce(v(`/api/workflows/runs/${encodeURIComponent(e)}`))).view}async function F$e(e){return Ce(v(`/api/workflows/runs`),{method:`POST`,body:JSON.stringify(e)})}async function I$e(e){await Ce(v(`/api/workflows/runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})}async function L$e(e){return Ce(v(`/api/workflows/runs/${encodeURIComponent(e)}/retry`),{method:`POST`})}function R$e(e,t){let n=Number.parseInt(e,10);return Number.isFinite(n)?n:t+1}function z$e(e){if(e!=null){if(typeof e==`object`&&e&&`raw`in e){let t=e.raw;return t===void 0?e:t}return e}}function B$e(e){let t=new Map(e.phases.map(e=>[e.id,e.title])),n=e.phases.find(e=>e.status===`running`),r=e.agents.map((e,n)=>({id:R$e(e.id,n),label:e.label,phase:e.phaseId?t.get(e.phaseId):void 0,prompt:e.prompt??``,status:e.status,resultPreview:e.resultPreview,error:e.error,startedAtMs:e.startedAtMs,durationMs:e.startedAtMs!=null&&e.completedAtMs!=null?e.completedAtMs-e.startedAtMs:void 0,currentStep:e.currentStep,steps:e.steps?.map(e=>({id:e.id,kind:e.kind,toolName:e.toolName,label:e.label,detail:e.detail,status:e.status,resultPreview:e.resultPreview,error:e.error,startedAtMs:e.startedAtMs,durationMs:e.startedAtMs!=null&&e.completedAtMs!=null?e.completedAtMs-e.startedAtMs:void 0}))})),{metrics:i}=e.run;return{name:e.run.definitionId,description:e.run.goal||e.run.title,phases:e.phases.map(e=>e.title),currentPhase:n?.title,logs:e.logs.map(e=>e.message),agents:r,agentCount:i.agentCount,runningCount:Math.max(0,i.agentCount-i.doneAgentCount-i.errorAgentCount-i.skippedAgentCount),doneCount:i.doneAgentCount,errorCount:i.errorAgentCount,skippedCount:i.skippedAgentCount,durationMs:i.durationMs,result:z$e(e.run.result)}}new Set([`catalog`,`active`,`history`]);var GV=[`all`,`code-review`,`planning`,`research`,`writing`,`productivity`];new Set(GV),new Set([`all`,`builtin`,`user`]);var KV=`trigger`,V$e=`start`,H$e=[`code-review`,`planning`,`research`,`writing`,`productivity`],U$e={"code-review":[`code-review`,`pr`,`release`],planning:[`planning`,`implementation`,`architecture`,`decision`,`review`],research:[`research`,`investigation`,`debug`,`incident`,`troubleshooting`],writing:[`writing`,`content`,`communication`,`email`,`document`],productivity:[`productivity`,`meeting`,`comparison`,`brainstorm`,`decision-making`]},W$e={research:[{key:`question`,labelKey:`argQuestion`,placeholderKey:`argQuestionPlaceholder`,required:!0,multiline:!0}],multi_perspective_review:[{key:`target`,labelKey:`argTarget`,placeholderKey:`argTargetPlaceholder`,multiline:!0}],pr_review:[{key:`target`,labelKey:`argDiff`,placeholderKey:`argDiffPlaceholder`,multiline:!0}],debug_incident:[{key:`error`,labelKey:`argError`,placeholderKey:`argErrorPlaceholder`,required:!0,multiline:!0},{key:`context`,labelKey:`argContext`,placeholderKey:`argContextPlaceholder`,multiline:!0}],implementation_plan:[{key:`request`,labelKey:`argRequest`,placeholderKey:`argRequestPlaceholder`,required:!0,multiline:!0},{key:`scope`,labelKey:`argScope`,placeholderKey:`argScopePlaceholder`}],release_check:[{key:`target`,labelKey:`argTarget`,placeholderKey:`argReleaseTargetPlaceholder`,multiline:!0}],content_draft:[{key:`topic`,labelKey:`argTopic`,placeholderKey:`argTopicPlaceholder`,required:!0,multiline:!0},{key:`audience`,labelKey:`argAudience`,placeholderKey:`argAudiencePlaceholder`},{key:`format`,labelKey:`argFormat`,placeholderKey:`argFormatPlaceholder`}],decision_compare:[{key:`question`,labelKey:`argDecisionQuestion`,placeholderKey:`argDecisionQuestionPlaceholder`,required:!0,multiline:!0},{key:`options`,labelKey:`argOptions`,placeholderKey:`argOptionsPlaceholder`,multiline:!0},{key:`criteria`,labelKey:`argCriteria`,placeholderKey:`argCriteriaPlaceholder`,multiline:!0}],meeting_prep:[{key:`meeting_topic`,labelKey:`argMeetingTopic`,placeholderKey:`argMeetingTopicPlaceholder`,required:!0,multiline:!0},{key:`attendees`,labelKey:`argAttendees`,placeholderKey:`argAttendeesPlaceholder`},{key:`goal`,labelKey:`argMeetingGoal`,placeholderKey:`argMeetingGoalPlaceholder`,multiline:!0}],weekly_review:[{key:`wins`,labelKey:`argWins`,placeholderKey:`argWinsPlaceholder`,required:!0,multiline:!0},{key:`blockers`,labelKey:`argBlockers`,placeholderKey:`argBlockersPlaceholder`,multiline:!0},{key:`carryover`,labelKey:`argCarryover`,placeholderKey:`argCarryoverPlaceholder`,multiline:!0}],client_proposal:[{key:`client_brief`,labelKey:`argClientBrief`,placeholderKey:`argClientBriefPlaceholder`,required:!0,multiline:!0},{key:`offer`,labelKey:`argOffer`,placeholderKey:`argOfferPlaceholder`,multiline:!0},{key:`budget_hint`,labelKey:`argBudgetHint`,placeholderKey:`argBudgetHintPlaceholder`}],content_repurpose:[{key:`source`,labelKey:`argSource`,placeholderKey:`argSourcePlaceholder`,required:!0,multiline:!0},{key:`platforms`,labelKey:`argPlatforms`,placeholderKey:`argPlatformsPlaceholder`,multiline:!0}],competitor_scan:[{key:`market`,labelKey:`argMarket`,placeholderKey:`argMarketPlaceholder`,required:!0,multiline:!0},{key:`competitors`,labelKey:`argCompetitors`,placeholderKey:`argCompetitorsPlaceholder`,multiline:!0},{key:`focus`,labelKey:`argFocus`,placeholderKey:`argFocusPlaceholder`}],offer_design:[{key:`skills`,labelKey:`argSkills`,placeholderKey:`argSkillsPlaceholder`,required:!0,multiline:!0},{key:`audience`,labelKey:`argOfferAudience`,placeholderKey:`argOfferAudiencePlaceholder`,multiline:!0},{key:`constraints`,labelKey:`argConstraints`,placeholderKey:`argConstraintsPlaceholder`,multiline:!0}],inbox_triage:[{key:`inbox`,labelKey:`argInbox`,placeholderKey:`argInboxPlaceholder`,required:!0,multiline:!0},{key:`priorities`,labelKey:`argPriorities`,placeholderKey:`argPrioritiesPlaceholder`,multiline:!0}]},qV=new Set([`queued`,`running`]);function JV(e){let t=B$e(e),n=e.run.status,r=n===`running`||n===`queued`?`running`:n===`succeeded`?`done`:`error`;return{type:`tool_use`,id:`workflow-run:${e.run.id}`,name:`workflow`,input:{name:e.run.definitionId},status:r,details:t}}var G$e=(0,j.memo)(function(e){let t=(0,fm.c)(17),{view:n,sessionKey:r,onAbortCurrentTurn:i,onSendUserMessage:a}=e,o=f(K$e),s;t[0]===o?s=t[1]:(s=dV(o),t[0]=o,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=JV(n),t[2]=n,t[3]=l);let u=l,d;t[4]===n.run.status?d=t[5]:(d=qV.has(n.run.status),t[4]=n.run.status,t[5]=d);let p=d,m;t[6]!==p||t[7]!==i||t[8]!==n.run.id?(m=()=>{p&&I$e(n.run.id).catch(q$e),i?.()},t[6]=p,t[7]=i,t[8]=n.run.id,t[9]=m):m=t[9];let h=p?m:void 0,g;return t[10]!==u||t[11]!==c||t[12]!==a||t[13]!==r||t[14]!==h||t[15]!==n.run.startedAtMs?(g=(0,z.jsx)(`div`,{className:`mb-6`,children:(0,z.jsx)(uV,{block:u,startedAt:n.run.startedAtMs,sessionKey:r,onAbort:h,onSendChatMessage:a,labels:c})}),t[10]=u,t[11]=c,t[12]=a,t[13]=r,t[14]=h,t[15]=n.run.startedAtMs,t[16]=g):g=t[16],g});function K$e(e){return e.language}function q$e(){}function J$e(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.kind!==`context`)return null;let n=t.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:null;if(!n||n.kind!==`workflow-run-link`)return null;let r=typeof n.runId==`string`?n.runId.trim():``,i=typeof n.workflowSessionKey==`string`?n.workflowSessionKey.trim():``,a=typeof n.definitionId==`string`?n.definitionId.trim():``;if(!r||!i||!a)return null;let o=typeof n.goal==`string`?n.goal:``,s=typeof n.status==`string`?n.status:`running`,c=typeof t.id==`string`&&t.id.trim()?t.id.trim():`workflow-run-link:${r}`,l=typeof t.createdAt==`string`?Date.parse(t.createdAt):void 0;return{id:c,runId:r,workflowSessionKey:i,definitionId:a,goal:o,status:s,createdAtMs:Number.isFinite(l)?l:void 0}}function Y$e(e){if(!e?.length)return[];let t=new Map;for(let n of e){let e=J$e(n);e&&t.set(e.runId,e)}return[...t.values()].toSorted((e,t)=>(e.createdAtMs??0)-(t.createdAtMs??0))}function X$e(e){let t=(0,fm.c)(8),n=xe(Z$e),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]!==n||t[3]!==i?(a=n&&i?[`session-workflow-run-links`,i,n]:null,t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=async()=>Y$e((await mb(i,{includeTranscriptRows:!0})).transcriptRows),t[5]=i,t[6]=o);let s;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[7]=s):s=t[7],y(a,o,s)}function Z$e(e){return e.token}function YV(e){let t=(0,fm.c)(20),n=xe($$e),r=!!n,i;t[0]===e?i=t[1]:(i=e?.trim()||null,t[0]=e,t[1]=i);let a=i,o;t[2]!==r||t[3]!==n||t[4]!==a?(o=r&&a?[`workflow-run-live`,a,n]:null,t[2]=r,t[3]=n,t[4]=a,t[5]=o):o=t[5];let s;t[6]===a?s=t[7]:(s=()=>WV(a),t[6]=a,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1,refreshInterval:Q$e},t[8]=c):c=t[8];let l=y(o,s,c),u;t[9]!==l||t[10]!==a?(u=()=>{if(!a)return;let e=e=>{let t=e.detail;if(t?.runId===a){if(t.view){l.mutate(t.view,{revalidate:!1});return}l.mutate()}};return window.addEventListener(`workflow-run-updated`,e),()=>window.removeEventListener(`workflow-run-updated`,e)},t[9]=l,t[10]=a,t[11]=u):u=t[11];let d;t[12]!==l.mutate||t[13]!==a?(d=[l.mutate,a],t[12]=l.mutate,t[13]=a,t[14]=d):d=t[14],(0,j.useEffect)(u,d);let f;return t[15]!==l.data||t[16]!==l.error||t[17]!==l.isLoading||t[18]!==l.mutate?(f={view:l.data,loading:l.isLoading,error:l.error,mutate:l.mutate},t[15]=l.data,t[16]=l.error,t[17]=l.isLoading,t[18]=l.mutate,t[19]=f):f=t[19],f}function Q$e(e){return e&&qV.has(e.run.status)?3e3:0}function $$e(e){return e.token}function e1e(e){let t=(0,fm.c)(8),n=xe(t1e),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]!==n||t[3]!==i?(a=n&&i?[`workflow-session-meta`,i,n]:null,t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=async()=>{let e=await mb(i),t=e.customData?.workflowRunId,n=typeof t==`string`&&t.trim()?t.trim():null,r=typeof e.sessionType==`string`&&e.sessionType.trim()?e.sessionType.trim():null,a=e.customData?.sourceNoteId,o=typeof a==`string`&&a.trim()?a.trim():null,s=e.customData?.sourceNoteTitle;return{workflowRunId:n,sessionType:r,sourceNoteId:o,sourceNoteTitle:typeof s==`string`&&s.trim()?s.trim():null}},t[5]=i,t[6]=o);let s;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[7]=s):s=t[7],y(a,o,s)}function t1e(e){return e.token}var n1e=`/agents`;function XV(e){return`${n1e}/${encodeURIComponent(e)}`}function ZV(){let e=h(f(e=>e.language)),t=xe(e=>e.token),n=Un(),r=Hn(),{pathname:i}=r,[a]=Qne(),o=(0,j.useRef)(null),s=(0,j.useRef)(0),[c,l]=(0,j.useState)(null),{auth:u,session:d,messages:p,stream:m,followUp:g,clarify:_,agents:v}=y$e(),y=a.get(`skill`)?.trim()??``,b=a.get(`slash`)?.trim()??``,x=d.decodedKey??d.sessionKey,{data:S}=e1e(x),C=S?.workflowRunId??null,{view:w}=YV(C),{data:T=[],mutate:E}=X$e(x),D=!!(C&&w&&qV.has(w.run.status));(0,j.useEffect)(()=>{if(!x)return;let e=e=>{e.detail?.key===x&&E()};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},[x,E]),(0,j.useEffect)(()=>{o.current=null},[d.sessionKey]),(0,j.useEffect)(()=>{if(!u.hasToken||!y&&!b||d.showSessionLoading||d.sessionRoutePending||!d.sessionKey)return;let e=()=>{let e=new URLSearchParams(a);e.delete(`skill`),e.delete(`slash`);let t=e.toString();n({pathname:i,search:t?`?${t}`:``},{replace:!0})},t=(t,n)=>{o.current!==n&&(o.current=n,queueMicrotask(()=>{s.current+=1,l({id:s.current,text:t}),e()}))};if(y){if(!sBe(y)){e();return}let n=`${d.sessionKey}:skill:${y}`;t(`/skill:${y} `,n);return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(b)){e();return}let r=`${d.sessionKey}:slash:${b}`;o.current!==r&&queueMicrotask(()=>{(async()=>{try{let e=await Vk(),t=b.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(o.current===r)return;o.current=r,s.current+=1,l({id:s.current,text:Gk(n)})}}finally{e()}})()})},[u.hasToken,y,b,a,d.showSessionLoading,d.sessionRoutePending,d.sessionKey,n,i]);let{scrollRef:O,atBottom:k,registerListContentRef:A,scrollToBottom:ee,onScroll:te}=CV({hasToken:u.hasToken,showSessionLoading:d.showSessionLoading,sessionKey:d.sessionKey,sending:m.sending,chatMessages:p.items,hasMore:d.hasMore,loadingMore:d.loadingMore,loadMoreMessages:d.loadMoreMessages});(0,j.useEffect)(()=>{l(null)},[d.sessionKey]);let ne=(0,j.useCallback)(e=>{s.current+=1,l({id:s.current,text:e})},[]),re=(0,j.useMemo)(()=>!!d.sessionKey&&!d.showSessionLoading&&!d.sessionRoutePending&&p.items.length===0,[d.sessionKey,d.showSessionLoading,d.sessionRoutePending,p.items.length]),ie=fO(e=>e.setAgentId);(0,j.useEffect)(()=>{if(u.hasToken)return ie(v.displayAgentId),()=>ie(``)},[u.hasToken,v.displayAgentId,ie]);let ae=!d.showSessionLoading&&p.items.length===0&&!m.streaming,oe=(0,j.useMemo)(()=>(d.sessionRoutePending&&d.decodedKey?d.decodedKey:d.sessionKey)?d.sessionName?.trim()||e.chat.newSession:e.nav.chat,[d.sessionKey,d.sessionName,d.sessionRoutePending,d.decodedKey,e.nav.chat,e.chat.newSession]),se=S?.sourceNoteId??null,ce=S?.sourceNoteTitle||e.chat.sourceNoteFallbackTitle,le=(0,j.useCallback)(async t=>{se&&await kA(se,t,e.chat.sourceNoteAppendHeading)},[e.chat.sourceNoteAppendHeading,se]),ue=(0,j.useCallback)(async t=>{se&&await rVe((t.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||e.chat.sourceNoteTaskFallbackTitle).slice(0,120),{sourceNoteId:se,sourceSessionKey:x})},[x,e.chat.sourceNoteTaskFallbackTitle,se]);return u.hasToken?(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,z.jsx)(ZJe,{}),(0,z.jsx)(UJe,{chatHeadline:oe,chatAgents:v.chatAgents?.items??[],showChatAgentSelector:v.showChatAgentSelector,chatAgentId:v.displayAgentId,onChatAgentChange:v.onChatAgentChange,chatAgentDisabled:d.showSessionLoading||d.sessionRoutePending}),(0,z.jsxs)(`div`,{className:`relative mx-auto flex min-h-0 w-full max-w-[var(--max-width-chat)] flex-1 flex-col`,children:[r.state?.fromAgentEditor&&v.displayAgentId?(0,z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,z.jsxs)(mr,{to:XV(v.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:`←`}),e.agentsSettings.backToEditor]})}):null,se?(0,z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.chat.sourceNoteBanner.replace(`{{title}}`,ce)}),(0,z.jsx)(mr,{to:`/notes/${encodeURIComponent(se)}`,className:`shrink-0 font-medium text-accent transition-colors hover:text-accent-fg`,children:e.chat.sourceNoteOpen})]})}):null,d.sessionKey&&wb(d.sessionKey)&&!d.showSessionLoading&&!d.sessionRoutePending?(0,z.jsx)(IJe,{sessionKey:d.sessionKey,streaming:m.streaming,sending:m.sending}):null,(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col px-3 sm:px-5 xl:px-6`,children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsx)(`div`,{ref:O,className:fh(`chat-messages min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,ae?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:te,children:d.showSessionLoading?(0,z.jsx)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-3 py-12 text-center text-sm text-fg-muted`,children:e.chat.loading}):(0,z.jsxs)(z.Fragment,{children:[d.loadingMore?(0,z.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:e.chat.loadOlder}):null,m.error?(0,z.jsx)(iQe,{errorText:m.error}):null,T.length>0?(0,z.jsx)(`div`,{className:`mb-6 flex flex-col gap-3`,children:T.map(e=>(0,z.jsx)(D$e,{link:e},e.id))}):null,D&&w?(0,z.jsx)(G$e,{view:w,sessionKey:x,onAbortCurrentTurn:m.abort,onSendUserMessage:e=>{m.streaming||m.sending?g.addPendingFollowUp(e):m.sendMessage(e)}}):null,(0,z.jsx)(bV,{messages:p.items,authToken:t??void 0,sessionKey:d.decodedKey??d.sessionKey,streaming:m.streaming,progress:m.progress,reasoningLevel:d.reasoningLevel,registerListContentRef:A,onPickWelcomePrompt:ne,onDeleteRound:m.deleteMessageRound,onRetryUserMessageRound:m.retryUserMessageRound,deleteRoundDisabled:m.streaming||m.sending,onAbortCurrentTurn:m.abort,onSendUserMessage:e=>{m.streaming||m.sending?g.addPendingFollowUp(e):m.sendMessage(e)},onSaveAssistantToSourceNote:se?le:void 0,onExtractAssistantTask:se?ue:void 0},d.decodedKey??`new`)]})}),(0,z.jsxs)(`div`,{className:fh(`sticky bottom-0 z-10 shrink-0 bg-surface-panel`,ae?`py-2.5`:`py-4`),children:[(0,z.jsx)(C$e,{prompt:_.clarifyPrompt,submitting:_.clarifySubmitting,submitError:_.clarifySubmitError,labels:e.chat,onSubmit:_.submitClarifyAnswer,onCancel:_.cancelClarifyAnswer}),(0,z.jsx)(lJe,{disabled:d.showSessionLoading||d.sessionRoutePending||!!_.clarifyPrompt,sending:m.sending,streaming:m.streaming,sessionKey:d.sessionKey,sessionManager:d.sessionManager,welcomeDraftSeed:c,canSelectWorkingDirectory:re,thinkingLevel:d.thinkingLevel,showThinkingSelector:d.modelSupportsThinking,onThinkingChange:d.onSessionThinkingLevelChange,onSend:m.sendMessage,onAbort:m.abort,onAddPendingFollowUp:(e,t)=>void g.addPendingFollowUp(e,t),onSteeringInterrupt:(e,t)=>void m.interruptAndSend(e,t),pendingFollowUps:g.pendingFollowUps,editingFollowUpId:g.editingFollowUpId,onBeginEditFollowUp:g.beginEditFollowUp,onCancelEditFollowUp:g.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r)=>void g.commitEditFollowUp(e,t,n,r),onPendingFollowUpRemove:g.removePendingFollowUp,onPendingFollowUpMove:g.movePendingFollowUp,onPendingFollowUpReorder:g.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void g.steerPendingFollowUp(e),steeringFollowUpId:g.steeringFollowUpId,sessionModel:d.sessionModel,showModelSelector:!!(d.sessionKey&&!d.sessionRoutePending),onModelChange:d.onSessionModelChange,modelDisabled:d.showSessionLoading||d.sessionRoutePending||m.streaming,contextUsageMessages:p.items,onChatAgentChange:v.showChatAgentSelector?v.onChatAgentChange:void 0,currentAgentId:v.displayAgentId})]})]})})]}),(0,z.jsx)(xV,{visible:!d.showSessionLoading&&!k,onClick:()=>ee(!0)})]}):(0,z.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:e.chat.needToken})}function QV(){let e=(0,fm.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden`,children:(0,z.jsx)(er,{})}),e[0]=t):t=e[0],t}async function r1e(e){let t=await Te(e);if(!t.ok){let e=await t.json().catch(()=>({})),n=we(t.status,t.statusText,e.error?.message);throw Error(n)}return t.json()}function i1e(e){let t=(0,fm.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={fetcher:r1e,revalidateOnFocus:!1,dedupingInterval:2e3,shouldRetryOnError:!0,errorRetryCount:2},t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,z.jsx)(b,{value:r,children:n}),t[1]=n,t[2]=i),i}var $V=(0,j.lazy)(()=>w(()=>import(`./sessions-page-Khdw35Zk.js`).then(e=>({default:e.SessionsPage})),__vite__mapDeps([19,1,3,4,6,15,8]))),a1e=(0,j.lazy)(()=>w(()=>import(`./cron-page-COfUPKfq.js`).then(e=>({default:e.CronPage})),__vite__mapDeps([21,1,22,23,4,2,3,6,12,11,13,7,8,16,15,24]))),eH=(0,j.lazy)(()=>w(()=>import(`./notes-page-DkRX7BE2.js`).then(e=>({default:e.NotesPage})),__vite__mapDeps([31,1,22,23,4,3,6,32,8,18]))),tH=(0,j.lazy)(()=>w(()=>import(`./note-detail-page-DqSAg_5Z.js`).then(e=>({default:e.NoteDetailPage})),__vite__mapDeps([33,1,30,3,4,6,13,32,18,34]))),nH=(0,j.lazy)(()=>w(()=>import(`./workflows-page-DP57FEKW.js`).then(e=>({default:e.WorkflowsPage})),__vite__mapDeps([35,1,3,4,6,12,11,24,8]))),rH=(0,j.lazy)(()=>w(()=>import(`./skills-page-ByYT0fXZ.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([25,1,26,22,23,4,6,8]))),o1e=(0,j.lazy)(()=>w(()=>import(`./logs-page-BTVPXcHV.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([20,1,6,4,8]))),s1e=(0,j.lazy)(()=>w(()=>import(`./settings-page-DN8JBZ8F.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),c1e=(0,j.lazy)(()=>w(()=>import(`./agents-u8cmUfGQ.js`).then(e=>({default:e.AgentsSettingsPanel})),__vite__mapDeps([14,1,2,3,4,6,10,11,13,7,8,15]))),l1e=(0,j.lazy)(()=>w(()=>import(`./channels-settings-BM3doRvi.js`).then(e=>({default:e.ChannelsSettingsPanel})),__vite__mapDeps([36,1,3,4,5,6,7,8,9,12,11,37]))),u1e=(0,j.lazy)(()=>w(()=>import(`./apps-page-DF8m9cUE.js`).then(e=>({default:e.AppsPage})),__vite__mapDeps([38,1,3,4,6,8]))),iH=(0,j.lazy)(()=>w(()=>import(`./extension-page-BVbCBHoI.js`).then(e=>({default:e.ExtensionPage})),__vite__mapDeps([39,1,4]))),aH=(0,j.lazy)(()=>w(()=>import(`./extension-settings-page-t1lb2A7v.js`).then(e=>({default:e.ExtensionSettingsPage})),__vite__mapDeps([40,1,3,4,6,37,9,17,8]))),d1e=(0,j.lazy)(()=>w(()=>import(`./extension-debug-page-kyxxefKh.js`).then(e=>({default:e.ExtensionDebugPage})),__vite__mapDeps([41,1,4]))),oH=(0,j.lazy)(()=>w(()=>import(`./share-preview-page-UNAcbiMb.js`).then(e=>({default:e.SharePreviewPage})),__vite__mapDeps([42,1,26,6,4])));function sH(){let e=(0,fm.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center text-sm text-fg-muted`,"aria-busy":!0,children:`Loading…`}),e[0]=t):t=e[0],t}function f1e(){let e=(0,fm.c)(4),{agentId:t}=Wn(),n;e[0]===t?n=e[1]:(n=typeof t==`string`?t.trim():``,e[0]=t,e[1]=n);let r=n,i=r?`/agents/${encodeURIComponent(r)}`:`/agents`,a;return e[2]===i?a=e[3]:(a=(0,z.jsx)($n,{to:i,replace:!0}),e[2]=i,e[3]=a),a}function cH(){let e=(0,fm.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"aria-busy":!0,children:(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main flex-1 px-4 py-8`,children:[(0,z.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`}),(0,z.jsx)(`p`,{className:`mt-6 text-sm text-fg-muted`,children:`Loading…`})]})}),e[0]=t):t=e[0],t}var p1e=Hne([{path:`/share/:token`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(oH,{})})},{path:`/`,element:(0,z.jsx)(TL,{}),children:[{index:!0,element:(0,z.jsx)($n,{to:`/chat`,replace:!0})},{path:`chat`,element:(0,z.jsx)(QV,{}),children:[{index:!0,element:(0,z.jsx)(ZV,{})},{path:`new`,element:(0,z.jsx)(ZV,{})},{path:`:sessionKey`,element:(0,z.jsx)(ZV,{})}]},{path:`sessions`,element:(0,z.jsx)($n,{to:`/settings/sessions`,replace:!0})},{path:`logs`,element:(0,z.jsx)($n,{to:`/settings/logs`,replace:!0})},{path:`cron`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(a1e,{})})},{path:`notes`,children:[{index:!0,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(eH,{})})},{path:`:noteId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(tH,{})})}]},{path:`workflows`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(nH,{})})},{path:`skills`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(rH,{})})},{path:`channels`,children:[{index:!0,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(l1e,{})})},{path:`:channelId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(l1e,{})})}]},{path:`mcp`,element:(0,z.jsx)($n,{to:`/settings/connectors`,replace:!0})},{path:`agents`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(c1e,{})})},{path:`agents/:agentId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(c1e,{})})},{path:`apps`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(u1e,{})})},{path:`apps/:extensionId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(iH,{})})},{path:`apps/:extensionId/:pageId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(iH,{})})},{path:`settings`,element:(0,z.jsx)(iKe,{children:(0,z.jsx)(ZGe,{})}),children:[{index:!0,element:(0,z.jsx)($n,{to:`overview`,replace:!0})},{path:`skills`,element:(0,z.jsx)($n,{to:`/skills`,replace:!0})},{path:`channels`,element:(0,z.jsx)($n,{to:`/channels`,replace:!0})},{path:`mcp`,element:(0,z.jsx)($n,{to:`/settings/connectors`,replace:!0})},{path:`cron`,element:(0,z.jsx)($n,{to:`/cron?tab=settings`,replace:!0})},{path:`sessions`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)($V,{})})},{path:`logs`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(o1e,{})})},{path:`apps`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(u1e,{})})},{path:`agents`,element:(0,z.jsx)($n,{to:`/agents`,replace:!0})},{path:`agents/:agentId`,element:(0,z.jsx)(f1e,{})},{path:`extensions/debug`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(d1e,{})})},{path:`ext/:extensionId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(aH,{})})},{path:`ext/:extensionId/:panelId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(aH,{})})},{path:`:section`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(s1e,{})})}]}]}]);function m1e(){let e=(0,fm.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,j.useEffect)(h1e,t),null}function h1e(){let e=_e.persist.onFinishHydration(_1e),t=Fh.persist.onFinishHydration(g1e),n=ve();return()=>{e?.(),t?.(),n()}}function g1e(){rTe()}function _1e(){ye()}function v1e(){let e=(0,fm.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(m1e,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsx)(it,{i18n:d,children:(0,z.jsx)(i1e,{children:(0,z.jsx)(SOe,{children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[t,(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col *:min-h-0 *:flex-1`,children:(0,z.jsx)(ore,{router:p1e})})]})})})}),e[1]=n):n=e[1],n}document.documentElement.setAttribute(`lang`,u(p())),be(),Ph(),Se(),(0,dm.createRoot)(document.getElementById(`root`)).render((0,z.jsx)(j.StrictMode,{children:(0,z.jsx)(v1e,{})}));export{mL as $,so as $a,zu as $i,Tke as $n,Qne as $o,wh as $r,Zze as $t,oqe as A,xs as Aa,gxe as Ai,oO as An,ai as Ao,M_ as Ar,TBe as At,ML as B,os as Ba,Od as Bi,aje as Bn,Nr as Bo,Gh as Br,mk as Bt,BZe as C,nc as Ca,fp as Ci,gze as Cn,xi as Co,uv as Cr,vA as Ct,gZe as D,Ms as Da,Zxe as Di,fze as Dn,pi as Do,av as Dr,SBe as Dt,XB as E,Yhe as Ea,Qxe as Ei,uO as En,xle as Eo,ov as Er,aA as Et,ZKe as F,ps as Fa,Qbe as Fi,YS as Fn,Zr as Fo,FDe as Fr,Zk as Ft,CL as G,No as Ga,fd as Gi,XAe as Gn,tie as Go,Rh as Gr,vk as Gt,gGe as H,Uo as Ha,gd as Hi,eje as Hn,Er as Ho,Hh as Hr,yk as Ht,WKe as I,fs as Ia,df as Ii,RS as In,Yr as Io,PDe as Ir,Qk as It,mGe as J,$me as Ja,ld as Ji,oS as Jn,mr as Jo,Ah as Jr,bk as Jt,SL as K,Ao as Ka,dd as Ki,cS as Kn,vre as Ko,vTe as Kr,xk as Kt,nKe as L,Che as La,Sbe as Li,zS as Ln,Jr as Lo,l_ as Lr,DBe as Lt,nqe as M,Vhe as Ma,Af as Mi,eze as Mn,ri as Mo,k_ as Mr,eA as Mt,tqe as N,Ihe as Na,Df as Ni,ND as Nn,ei as No,A_ as Nr,bBe as Nt,ZXe as O,Ts as Oa,Hf as Oi,lO as On,di as Oo,iv as Or,CBe as Ot,$Ke as P,hs as Pa,oxe as Pi,AD as Pn,Qr as Po,u_ as Pr,$k as Pt,dGe as Q,Fme as Qa,Vu as Qi,wb as Qn,Wn as Qo,Sh as Qr,rk as Qt,KGe as R,us as Ra,zd as Ri,ES as Rn,qr as Ro,r_ as Rr,wBe as Rt,dV as S,ac as Sa,PSe as Si,fO as Sn,Si as So,Tv as Sr,VBe as St,jZe as T,Qs as Ta,np as Ti,cO as Tn,bi as To,lv as Tr,oA as Tt,hGe as U,Bo as Ua,Oye as Ui,$Ae as Un,Tr as Uo,yTe as Ur,Sk as Ut,vGe as V,rs as Va,Ed as Vi,fS as Vn,Oie as Vo,XTe as Vr,_k as Vt,_Ge as W,Ro as Wa,Eye as Wi,ZAe as Wn,rie as Wo,Lh as Wr,Ck as Wt,fGe as X,Rme as Xa,Qu as Xi,Hke as Xn,Hn as Xo,$we as Xr,rBe as Xt,xL as Y,xo as Ya,ad as Yi,lS as Yn,$n as Yo,jh as Yr,hk as Yt,pGe as Z,Ime as Za,Ju as Zi,kb as Zn,Un as Zo,kh as Zr,pk as Zt,L$e as _,Zc as _a,Rp as _i,Tze as _n,Gi as _o,ny as _r,JBe as _t,W$e as a,Kl as aa,_h as ai,KO as an,la as ao,Dke as ar,sVe as at,A$e as b,fc as ba,BSe as bi,yO as bn,Mle as bo,Xv as br,TA as bt,U$e as c,Wl as ca,qwe as ci,IO as cn,oa as co,H as cr,YBe as ct,B$e as d,zl as da,fh as di,LO as dn,Jde as do,yy as dr,iVe as dt,Du as ea,bh as ei,tk as en,no as eo,hb as er,rt as es,hL as et,I$e as f,Ll as fa,im as fi,WO as fn,na as fo,gy as fr,aVe as ft,P$e as g,$c as ga,aCe as gi,BO as gn,Ki as go,dy as gr,AA as gt,k$e as h,el as ha,xCe as hi,zO as hn,qi as ho,POe as hr,QBe as ht,qV as i,Jl as ia,Xwe as ii,GO as in,Na as io,pb as ir,ZBe as it,eqe as j,Khe as ja,dxe as ji,oze as jn,ii as jo,j_ as jr,EBe as jt,IXe as k,ws as ka,Bf as ki,iO as kn,ci as ko,cv as kr,rA as kt,V$e as l,Ul as la,Ywe as li,FO as ln,aa as lo,LOe as lr,OA as lt,N$e as m,bl as ma,zCe as mi,UO as mn,$i as mo,fy as mr,cVe as mt,XV as n,xu as na,yh as ni,Yze as nn,Bpe as no,mb as nr,eVe as nt,GV as o,Cve as oa,Kwe as oi,qO as on,lfe as oo,Eke as or,oVe as ot,M$e as p,Tl as pa,rm as pi,RO as pn,ta as po,py as pr,tVe as pt,yGe as q,Do as qa,ud as qi,uS as qn,xr as qo,aTe as qr,fk as qt,YV as r,vu as ra,vh as ri,Xze as rn,Ra as ro,Cke as rr,$Be as rt,H$e as s,Gl as sa,Jwe as si,HO as sn,sa as so,gb as sr,nVe as st,n1e as t,eye as ta,Zwe as ti,nk as tn,Za as to,_b as tr,zA as tt,KV as u,Hl as ua,gh as ui,VO as un,ra as uo,by as ur,XBe as ut,j$e as v,Pc as va,KSe as vi,Eze as vn,Vi as vo,COe as vr,EA as vt,RZe as w,Vge as wa,sp as wi,pze as wn,Tle as wo,sv as wr,lA as wt,dQe as x,sc as xa,zSe as xi,xO as xn,Ci as xo,Zv as xr,UBe as xt,F$e as y,mc as ya,Ep as yi,bO as yn,ki as yo,ty as yr,wA as yt,HGe as z,cs as za,jd as zi,oje as zn,Kr as zo,Jh as zr,nA as zt};
|
|
4840
|
+
`);return n!==-1&&(t=t.slice(0,n).trim()),t.length>JQe&&(t=t.slice(0,JQe-1).trimEnd()+`…`),t}function XQe(e){let t=Zy([{type:`text`,text:e}]).split(/\n/)[0]?.trim();if(!t)return null;let n=YQe(t);return n.length>0?n:null}function ZQe(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}function IV(e){let t=e.trim();t&&window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:t},bubbles:!0}))}function LV(e,t){let n=e.key?.trim();if(!n||!wb(n)||(e.messageCount??0)!==0)return!1;let r=pS(n);return!(!r||r!==yb(t)||Zb(n))}function QQe(e,t){let n=yb(t);return e.filter(e=>LV(e,n)).sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())[0]??null}function $Qe(e,t){let n=t.trim();return e.find(e=>e.key.trim()===n)}function e$e(e,t,n){if(!t?.length)return e;let r=new Map(e.map(e=>[e.key.trim(),e]));for(let e of t){let t=e.key.trim();!t||r.has(t)||LV(e,n)&&r.set(t,e)}return[...r.values()].toSorted((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())}async function t$e(e,t){let n=Cb();try{return e$e(await e.loadSessions(),n,t)}catch{return n??[]}}async function n$e(e){let t=yb(e.agentId),n=e.currentSessionKey?.trim()||null;if(e.forceNew){let{sessionKey:n,register:r}=e.sessionMgr.openOptimisticNewSession(t);return{kind:`create`,sessionKey:n,register:r}}let r=await t$e(e.sessionMgr,t);if(n){let e=$Qe(r,n);if(e&&LV(e,t))return{kind:`noop`,sessionKey:n}}let i=QQe(r,t);if(i&&i.key.trim()!==n)return{kind:`reuse`,sessionKey:i.key,session:i};let{sessionKey:a,register:o}=e.sessionMgr.openOptimisticNewSession(t);return{kind:`create`,sessionKey:a,register:o}}var RV=null;function zV(e){if(RV)return RV;let t=(async()=>{let t=e.agentId??void 0,n=await n$e({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,currentSessionKey:e.currentSessionKey,forceNew:e.forceNew});if(n.kind===`noop`)return e.onOpened(n.sessionKey),(e.routeSessionKey?.trim()||null)!==n.sessionKey&&e.navigateToSession(n.sessionKey,e.replaceNavigate??!1,e.search),n.sessionKey;if(n.kind===`reuse`)return PV(n.sessionKey),e.onOpened(n.sessionKey),e.navigateToSession(n.sessionKey,e.replaceNavigate??!1,e.search),IV(n.sessionKey),n.sessionKey;let{sessionKey:r,register:i}=n;return Sb({key:r,messageCount:0,updatedAt:new Date().toISOString()}),PV(r),e.onOpened(r),e.navigateToSession(r,e.replaceNavigate??!1,e.search),IV(r),e.followRegistration?.({sessionKey:r,register:i,replaceNavigate:e.replaceNavigate,search:e.search}),r})().finally(()=>{RV=null});return RV=t,t}var r$e={current:null},i$e={current:null};function a$e(){let e=Hn(),{sessionKey:t}=Wn(),n=e.pathname.endsWith(`/new`),r=t?decodeURIComponent(t):void 0,i=AQe(n,r),a=wV(i),o=n?null:r??null,s=(0,j.useRef)(i);return s.current=i,r$e.current=o,!n&&r&&(i$e.current=r),(0,j.useLayoutEffect)(()=>{qb.getState().focusedSessionKey!==o&&qb.getState().setFocusedSessionKey(o)},[o]),{isNewRoute:n,decodedKey:r,routedSessionKey:i,viewSessionKey:a,routedFocusedSessionKey:o,routeSessionKeyRef:s,locationSearch:e.search,locationState:e.state}}var o$e={get current(){return i$e.current}},BV={get current(){return r$e.current},set current(e){r$e.current=e,qb.getState().setFocusedSessionKey(e)}};function s$e(e){let t=(0,fm.c)(15),{token:n,isNewRoute:r,decodedKey:i,locationSearch:a,sessionMgrRef:o,resolveAgentIdForPost:s,navigateToSession:c,loadSessionById:l,tryResumeAgentRun:u,restoreLiveCacheIfNeeded:d,adoptEmptySession:f,applyAgentConfig:p,patchInitUi:m}=e,h=(0,j.useRef)(0),g,_;t[0]!==f||t[1]!==p||t[2]!==i||t[3]!==r||t[4]!==l||t[5]!==a||t[6]!==c||t[7]!==m||t[8]!==s||t[9]!==d||t[10]!==o||t[11]!==n||t[12]!==u?(g=()=>{if(!n){m({loading:!1});return}let e=h.current+=1,t=!1,g=()=>!t&&e===h.current,_=e=>{g()&&o.current.loadSessionAgentConfig(e).then(t=>{g()&&p(e,t)}).catch(d$e)},v=e=>{FV({...e,navigateToSession:c,isActive:g,onError:e=>m({error:e}),onReconciled:(e,t)=>{f(e,t.name??null),_(e)},onRegistered:(e,t)=>{t.name&&qb.getState().patchSessionMeta(e,{name:t.name}),_(e)}})},y=()=>{if(!g())return Promise.resolve();let e=s();return zV({sessionMgr:o.current,agentId:e,currentSessionKey:o$e.current,routeSessionKey:null,navigateToSession:c,replaceNavigate:!0,search:KQe(a),onOpened:e=>f(e,null),followRegistration:v}).then(u$e)},b=(e,t)=>g()?(d(e),u(e,Yb(e)?.messages??t??Xb(e))):Promise.resolve();return m({loading:i===void 0&&!r,error:null}),(r?y():i?(e=>g()?qQe(e)?(_(e),b(e,Xb(e))):l(e,0).then(t=>{if(g())return b(e,t??Xb(e))}):Promise.resolve())(i):g()?o.current.loadSessions().then(e=>{if(!g())return;let t=e.filter(l$e)[0]??e[0];if(t)return g()?l(t.key,0).then(e=>{if(!g())return;d(t.key);let n=Yb(t.key)?.messages??e??Xb(t.key);return o.current.parseSessionFromHash()||c(t.key,!0),u(t.key,n)}):void 0;if(!g())return;let n=s();return zV({sessionMgr:o.current,agentId:n,currentSessionKey:null,routeSessionKey:null,navigateToSession:c,onOpened:e=>f(e,null),followRegistration:v}).then(c$e)}):Promise.resolve()).then(()=>{g()&&m({loading:!1})}).catch(e=>{t?g()&&m({loading:!1}):m({error:e instanceof Error?e.message:`Chat init failed`,loading:!1})}),()=>{t=!0}},_=[n,r,i,a,o,s,c,l,u,d,f,p,m],t[0]=f,t[1]=p,t[2]=i,t[3]=r,t[4]=l,t[5]=a,t[6]=c,t[7]=m,t[8]=s,t[9]=d,t[10]=o,t[11]=n,t[12]=u,t[13]=g,t[14]=_):(g=t[13],_=t[14]),(0,j.useEffect)(g,_)}function c$e(){}function l$e(e){return(e.messageCount??0)>0}function u$e(){}function d$e(){}async function f$e(e){let t=e.trim();if(!t)return!1;try{return!!(await hL()).find(e=>e.id===t)?.reasoning}catch{return!1}}function p$e(e){let{sessionMgrRef:t,routeSessionKeyRef:n,sendingRef:r,streamingRef:i,activeStreamSessionKeyRef:a,loadingSessionRef:o,messagesLenRef:s,thinkingSupportGenRef:c,navigateToSession:l,resolveAgentIdForPost:u,dismissClarifyOnSessionLoad:d,detachForNewConversation:f,sessionKey:p,hasMore:m}=e,h=()=>qb.getState(),g=(0,j.useRef)(Promise.resolve(void 0)),_=(0,j.useRef)(null),v=(0,j.useRef)(0),y=(0,j.useCallback)(e=>{let t=h().focusedSessionKey;if(!e.trim())return++c.current===c.current&&t&&h().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++c.current;return f$e(e).then(e=>{if(n!==c.current)return;let t=h().focusedSessionKey;t&&h().patchSessionMeta(t,{modelSupportsThinking:e})})},[c]),b=(0,j.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);h().patchSessionMeta(e,{model:n.model,thinkingLevel:n.thinkingLevel||`medium`,reasoningLevel:TV(n.reasoningLevel)}),y(n.model)}catch{}},[t,y]),x=(0,j.useCallback)(e=>{FV({...e,navigateToSession:l,onError:e=>h().setShellError(e),onReconciled:(e,t)=>{h().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t.name??null}),b(e)},onRegistered:(e,t)=>{t.name&&h().patchSessionMeta(e,{name:t.name}),b(e)}})},[l,b]),S=(0,j.useCallback)(()=>{let e=h().focusedSessionKey;if(!e||(h().sessions[e]?.name)?.trim())return;let n=++v.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===v.current){if(t){h().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),C=(0,j.useCallback)(e=>kQe({chatId:e,routeSessionKey:n.current}),[n]),w=(0,j.useCallback)((e,t)=>{let n=h().getSessionSnapshot(e);n&&(n.streaming||n.sending||n.streamingMsg)?(h().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&h().patchSessionMeta(e,{name:t.name||null})):h().setCommittedSnapshot(e,{messages:t.messages,hasMore:t.hasMore,name:t.name}),C(e)&&(_.current=t.nextBeforeCursor??null)},[C]),T=(0,j.useCallback)(async(e,r=0,i)=>{let a=async(e,r,i)=>{let s=r===0&&!i;s&&!ob(e)&&d(),o.current=!0;try{let{messages:n,hasMore:a,name:o,nextBeforeCursor:c}=await t.current.loadSession(e,r,i);if(s){if(h().setCommittedSnapshot(e,{messages:n,hasMore:a,name:o??null}),!C(e))return n;_.current=c??null,h().setShellError(null);try{let r=await t.current.loadSessionAgentConfig(e);if(!C(e))return n;h().patchSessionMeta(e,{model:r.model,thinkingLevel:r.thinkingLevel||`medium`,reasoningLevel:TV(r.reasoningLevel)}),y(r.model)}catch{}return n}if(_.current=c??null,!C(e))return;h().prependHistoryMessages(e,n,a);return}catch{if(r===0&&!i){_.current=null,h().setShellError(`Failed to load session`);let r=wV(n.current);if(r&&r===e)return;let i=await t.current.loadSessions().catch(()=>[]),o=i.filter(e=>(e.messageCount??0)>0)[0]??i[0];if(o)return l(o.key,!0),await a(o.key,0,null);{_.current=null;let e=u();zV({sessionMgr:t.current,agentId:e,currentSessionKey:null,routeSessionKey:null,navigateToSession:l,replaceNavigate:!0,onOpened:e=>{h().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null})},followRegistration:x})}}return}finally{o.current=!1}},s=g.current,c,f=new Promise(e=>{c=e});g.current=s.then(()=>f),await s;try{return await a(e,r,i)}finally{c()}},[n,C,r,i,a,o,d,l,y,u,t,x]);return{refreshModelThinkingSupport:y,pollSessionNameAfterTurn:S,applyLoadedSessionSnapshot:w,loadSessionById:T,loadMoreMessages:(0,j.useCallback)(async()=>{let e=h().focusedSessionKey;if(!(!e||h().loadingMore||!m)){h().setLoadingMore(!0);try{await T(e,s.current,_.current)}finally{h().setLoadingMore(!1)}}},[m,T,s]),onSessionModelChange:(0,j.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{model:e}),h().patchSessionMeta(p,{model:e}),y(e)}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to switch model`)}},[p,t,y]),onSessionThinkingLevelChange:(0,j.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{thinkingLevel:e}),h().patchSessionMeta(p,{thinkingLevel:e})}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to update thinking level`)}},[p,t]),createNewSession:(0,j.useCallback)(async e=>{d(),f(),_.current=null,h().setShellError(null);let n=u();await zV({sessionMgr:t.current,agentId:n,currentSessionKey:p,routeSessionKey:p,forceNew:e?.forceNew,navigateToSession:l,onOpened:e=>{h().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null})},followRegistration:x})},[d,f,l,u,p,t,x])}}function VV(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,setStreamingOnStreamStart:i,clearResumeRunIdOnBackgroundTerminal:a,clearResumeRunIdOnVisibleError:o,setError:s,sessionMgrRef:c,applyLoadedSessionSnapshot:l,finalizeMessage:u,fq:d}=e,f=()=>qb.getState(),p=()=>{c.current.loadSession(t,0).then(e=>l(t,e)).catch(()=>{})},m=()=>{f().clearStreamingState(t),Ab.clearActiveStreamSessionKey(t),a&&(Ab.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),d.dismissClarifyForSession(t),p()};return{onUserMessage:e=>{n(t)&&f().appendUserMessageIfMissing(t,e)},onStreamStart:()=>{r(),f().mutateSessionStreaming(t,()=>{}),f().setSessionFlags(t,{streaming:!0})},onToken:e=>{r(),f().mutateSessionStreaming(t,t=>{zb(t.content,e)}),n(t)&&f().setSessionFlags(t,{streaming:!0})},onThinking:(e,n)=>{r(),f().mutateSessionStreaming(t,t=>{!n&&e===``?zke(t.content):Ib(t.content,e,n)})},onThinkingEnd:()=>{r(),f().mutateSessionStreaming(t,e=>{Lb(e.content)})},onToolStart:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{Bb(t.content,e,n,i)}),f().setSessionFlags(t,{streaming:!0})},onToolEnd:(e,n,i)=>{e===`clarify`&&d.onClarifyToolEnd(t),r(),f().mutateSessionStreaming(t,t=>{Vke(t.content,e,n,i)})},onToolUpdate:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{Vb(t.content,e,n,i)})},onProgress:e=>{f().setSessionProgress(t,e)},onTtsAudio:e=>{r(),f().mutateSessionStreaming(t,t=>{let n=e.uri?.trim(),r=t.attachments??[];if(n&&r.some(e=>e.uri?.trim()===n))return;let i={name:e.name,mimeType:e.mimeType,type:`voice`,uri:e.uri,size:0};t.attachments=[...r,i]})},onCompaction:e=>{if(n(t))if(e.status===`started`)f().setSessionProgress(t,{stage:`compaction`,message:`Compacting context…`,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${Math.round((e.tokensBefore-e.tokensAfter)/1e3)}k tokens freed)`:``;f().setSessionProgress(t,{stage:`compaction`,message:`Context compacted${n}`,timestamp:Date.now()})}else f().setSessionProgress(t,null)},onClarifyRequest:d.makeOnClarifyRequest(t),onResult:()=>{if(!n(t)){m();return}if(Ab.userAborted){Ab.userAborted=!1;return}u()},onError:e=>{if(!n(t)){m();return}f().clearStreamingState(t),o&&(Ab.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),s(e),d.dismissClarifyForSession(t)}}}function m$e(e){return Yb(e)?.streamingMsg??null}function h$e(e){let{sessionKey:t,thinkingLevel:n,modelSupportsThinking:r,sessionKeyRef:i,sendingRef:a,streamingRef:o,sessionMgrRef:s,sendMessageRef:c,shouldApplyStreamUpdate:l,fq:u,applyLoadedSessionSnapshot:d,loadSessionById:f,createNewSession:p,pollSessionNameAfterTurn:m}=e,h=(0,j.useRef)(u.flushSteeringQueue);h.current=u.flushSteeringQueue;let g=()=>qb.getState(),_=e=>g().setShellError(e),v=()=>g().setShellError(null),y=(0,j.useCallback)(e=>{let t=Ab.activeStreamSessionKey??i.current;if(t&&!l(t))return;let n=t?m$e(t):null,r=null;if(n){let e=Mb(n,Date.now());Lb(e.content),Bke(e.content),r=Nb(e)}if(r&&Rke(r)&&t){let e=Yb(t)?.messages??Xb(t);g().finalizeStreamingTurn(t,Vy([...e,r]))}else t&&g().clearStreamingState(t);if(a.current=!1,o.current=!1,Ab.resetRunTracking(),u.dismissClarify(),m(),!e?.skipSteeringQueueFlush){let e=t??i.current;e&&window.setTimeout(()=>{h.current(e)},72)}let s=i.current;s&&window.setTimeout(()=>{i.current===s&&(a.current||o.current||u.pendingFollowUpsRef.current.length>0||f(s,0))},400)},[a,o,i,u.dismissClarify,u.pendingFollowUpsRef,m,f,l]),b=(0,j.useCallback)(async(e,t)=>{if(!l(e)||Ab.isStreamingFor(e)||Ab.isSending)return;let n=await lb(e);if(!n||Ab.activeResumeRunId===n)return;let r=t??Xb(e),i=Yb(e)?.hasMore??!1;try{let t=await s.current.loadSession(e,0);g().mergeCommittedFromServer(e,t.messages,t.hasMore),r=t.messages,i=t.hasMore}catch{}Ab.userAborted=!1,Ab.activeResumeRunId=n,Ab.activeStreamSessionKey=e,a.current=!0,o.current=!0,g().seedSessionIfEmpty(e,r,!0,!0,i),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null);let c=!1,f=()=>{if(c||!l(e))return;c=!0;let t=Xb(e);if(t.length===0)return;let n=t[t.length-1];if(n?.role!==`assistant`)return;let r=Nb(n),i=t.slice(0,-1);g().applyHydratedTail(e,i,r)};try{let t=VV({chatId:e,shouldApplyStreamUpdate:l,beforeAssistantDelta:f,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await Ab.sender.resume(n,e,t)}catch(t){if(t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),g().clearStreamingState(e),Ab.activeResumeRunId=null,!l(e)){Ab.clearActiveStreamSessionKey(e);return}a.current=!1,o.current=!1,Ab.clearActiveStreamSessionKey(e)}},[a,o,l,s,d,y]),x=(0,j.useCallback)(async(e,t,s)=>{if(!e.trim()&&!t?.length||!a.current&&!o.current&&!Ab.isSending)return;if(e.trim()===`/new`&&!t?.length){await p({forceNew:!0});return}if(!i.current)return;u.dismissClarifyAndClearPending();let l=r?s??n:`off`;Ab.userAborted=!0,Ab.resetRunTracking(),Ab.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0}),queueMicrotask(()=>{c.current(e,t,l)})},[a,o,i,u.dismissClarifyAndClearPending,r,n,y,c,p]);return{finalizeMessage:y,tryResumeAgentRun:b,sendMessage:(0,j.useCallback)(async(e,i,c)=>{if(!t||!l(t)||!e.trim()&&!i?.length||Ab.activeStreamSessionKey===t&&(a.current||o.current))return;let f=e.trim();if(f===`/new`&&!i?.length){await p({forceNew:!0});return}let m=r?c??n:`off`,h=t;Ab.userAborted=!1,Ab.activeStreamSessionKey=h,a.current=!0,o.current=!1,v(),u.dismissClarify();let b=[...Xb(h),{role:`user`,content:e?[{type:`text`,text:e}]:[],attachments:i,timestamp:Date.now()}],x=Yb(h);if(g().initSessionSnapshot(h,{...x??{...Ob(),hasMore:!1,streamingMsg:null,progress:null,sending:!1,streaming:!1},messages:b,hasMore:x?.hasMore??!1,streamingMsg:null,progress:null,sending:!0,streaming:!1}),!x?.name?.trim()&&f){let e=XQe(f);e&&(g().patchSessionMeta(h,{name:e}),ZQe(h,e))}try{let t=VV({chatId:h,shouldApplyStreamUpdate:l,beforeAssistantDelta:()=>{},setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await Ab.sender.send(e,h,i,m,t)}catch(e){e.name!==`AbortError`&&(g().clearStreamingState(h),_(JSON.stringify(Jy())))}finally{a.current=!1,o.current=!1,g().setSessionFlags(h,{sending:!1}),Ab.clearActiveStreamSessionKey(h)}},[t,n,r,a,o,l,s,d,y,u.dismissClarify,p]),interruptAndSend:x,abort:(0,j.useCallback)(()=>{Ab.userAborted=!0,Ab.resetRunTracking(),u.dismissClarifyAndClearPending(),Ab.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0});let e=i.current;e&&window.setTimeout(()=>{f(e,0)},300)},[u.dismissClarifyAndClearPending,a,o,y,i,f]),deleteMessageRound:(0,j.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=Xb(t),r=n[e];if(!r||!Qy(r.role))return;let c=fke(n,e);if(c===null)return;let l=$y(n,e),u=[...n];u.splice(e,l),g().updateSessionMessages(t,()=>u),s.current.deleteMessages(t,{userRoundIndex:c}).catch(()=>{f(t,0)})},[i,a,o,s,f]),retryUserMessageRound:(0,j.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=Xb(t),r=n[e];if(!r||!Qy(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&Qy(e.role))return}let l=Zy(r.content),u=dke(r.attachments);if(!l.trim()&&!u?.length)return;let d=fke(n,e);if(d===null)return;let p=$y(n,e),m=[...n];m.splice(e,p),g().updateSessionMessages(t,()=>m),(async()=>{try{await s.current.deleteMessages(t,{userRoundIndex:d}),await c.current(l,u)}catch{f(t,0)}})()},[i,a,o,s,f,c])}}function g$e(e){let t=(0,fm.c)(10),{sessionKey:n,sessionKeyRef:r,sessionMgrRef:i,loadSessionById:a,applyAgentConfig:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0],(0,j.useEffect)(_$e,s);let c,l;t[1]!==a||t[2]!==n?(c=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||a(n,0)};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},l=[n,a],t[1]=a,t[2]=n,t[3]=c,t[4]=l):(c=t[3],l=t[4]),(0,j.useEffect)(c,l);let u,d;t[5]!==o||t[6]!==r||t[7]!==i?(u=()=>{let e=()=>{let e=r.current;e&&i.current.loadSessionAgentConfig(e).then(t=>{o(e,t)}).catch(HV)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},d=[r,i,o],t[5]=o,t[6]=r,t[7]=i,t[8]=u,t[9]=d):(u=t[8],d=t[9]),(0,j.useEffect)(u,d)}function HV(){}function _$e(){let e=v$e;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function v$e(e){let t=e.detail;!t?.key||t.name===void 0||qb.getState().patchSessionMeta(t.key,{name:t.name||null})}function y$e(){let e=Un(),{isNewRoute:t,decodedKey:n,viewSessionKey:r,routedFocusedSessionKey:i,routeSessionKeyRef:a,locationSearch:o,locationState:s}=a$e(),c=(0,j.useRef)(new Mke),l=(0,j.useRef)(!1),u=(0,j.useRef)(!1),d=(0,j.useRef)(!1),f=(0,j.useRef)(0),p=(0,j.useRef)(!1),m=(0,j.useRef)(async()=>{}),h=(0,j.useRef)(0),g=i,_=qb(e=>e.initLoading),v=qb(e=>e.loadingMore),y=qb(e=>e.shellError),b=r,x=qb(e=>b?e.sessions[b]:void 0),S=b?Jb(x):!1,C=S?x?.streaming??!1:!1,w=S?x?.sending??!1:!1,T=S?x?.progress??null:null,E=x?.hasMore??!1,D=x?.name??null,O=x?.model??``,k=x?.thinkingLevel??`medium`,A=x?.reasoningLevel??`stream`,ee=x?.modelSupportsThinking??!1;(0,j.useEffect)(()=>{h.current=x?.messages.length??0},[x?.messages.length]),(0,j.useEffect)(()=>{u.current=w,d.current=C},[w,C]);let{token:te,chatAgentsData:ne,resolveAgentIdForPost:re,onChatAgentChange:ie,displayAgentId:ae,showChatAgentSelector:oe}=GQe({navigate:e,sessionKeyRef:BV,sessionKey:g,isNewRoute:t,locationState:s}),se=n!==void 0&&g!==n,ce=(0,j.useMemo)(()=>_&&(g==null||n===void 0),[_,g,n]),le=(0,j.useCallback)((t,n=!1,r)=>{let i=r??``;e({pathname:`/chat/${encodeURIComponent(t)}`,search:i},{replace:n})},[e]),ue=(0,j.useCallback)(e=>DQe({streamSessionKey:e,routeSessionKey:a.current}),[a]),de=(0,j.useCallback)(()=>{PQe({sendingRef:u,streamingRef:d})},[]),fe=WQe({sessionKey:g,decodedKey:n,sessionKeyRef:BV,activeStreamSessionKeyRef:Lke,sendingRef:u,streamingRef:d,modelSupportsThinking:ee,thinkingLevel:k,shouldApplyStreamUpdate:ue,sendMessageRef:m}),pe=(0,j.useCallback)(()=>{fe.clearVisibleClarify(),Ab.activeResumeRunId=null,Ab.userAborted=!1,MQe(de)},[fe.clearVisibleClarify,de]),{refreshModelThinkingSupport:me,pollSessionNameAfterTurn:he,applyLoadedSessionSnapshot:ge,loadSessionById:_e,loadMoreMessages:ve,onSessionModelChange:ye,onSessionThinkingLevelChange:be,createNewSession:xe}=p$e({sessionMgrRef:c,routeSessionKeyRef:a,sendingRef:u,streamingRef:d,activeStreamSessionKeyRef:Lke,loadingSessionRef:l,messagesLenRef:h,thinkingSupportGenRef:f,navigateToSession:le,resolveAgentIdForPost:re,dismissClarifyOnSessionLoad:fe.clearVisibleClarify,detachForNewConversation:pe,sessionKey:g,hasMore:E}),Se=(0,j.useCallback)(e=>{if(!OQe({cacheSessionKey:e,routeSessionKey:a.current}))return!1;let t=Yb(e);return!t||!Jb(t)&&!ob(e)&&!Ab.isStreamingFor(e)?!1:(Ab.activeStreamSessionKey=e,u.current=t.sending,d.current=t.streaming,!0)},[a]),{tryResumeAgentRun:Ce,sendMessage:we,interruptAndSend:Te,abort:Ee,deleteMessageRound:De,retryUserMessageRound:Oe}=h$e({sessionKey:g,thinkingLevel:k,modelSupportsThinking:ee,sessionKeyRef:BV,sendingRef:u,streamingRef:d,sessionMgrRef:c,sendMessageRef:m,shouldApplyStreamUpdate:ue,fq:fe,applyLoadedSessionSnapshot:ge,loadSessionById:_e,createNewSession:xe,pollSessionNameAfterTurn:he});(0,j.useEffect)(()=>{t&&pe()},[t,pe]);let ke=(0,j.useMemo)(()=>jQe({viewSessionKey:r,sessionKey:b,messages:x?.messages??[],streamingMsg:S?x?.streamingMsg??null:null}),[r,b,x?.messages,x?.streamingMsg,S]),Ae=(0,j.useCallback)((e,t)=>{qb.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),de()},[de]),je=(0,j.useCallback)((e,t)=>{NQe(e,t),me(t.model)},[me]),Me=(0,j.useCallback)(e=>{let t=qb.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]);return g$e({sessionKey:g,sessionKeyRef:BV,sendingRef:u,streamingRef:d,sessionMgrRef:c,loadSessionById:_e,applyAgentConfig:je}),s$e({token:te,isNewRoute:t,decodedKey:n,locationSearch:o,sessionMgrRef:c,resolveAgentIdForPost:re,navigateToSession:le,loadSessionById:_e,tryResumeAgentRun:Ce,restoreLiveCacheIfNeeded:Se,adoptEmptySession:Ae,applyAgentConfig:je,patchInitUi:Me}),(0,j.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.sessionKey)return;let n=t.event;if(!n||typeof n.type!=`string`)return;let r=t.sessionKey;if(n.type===`user_message`||n.type===`user_transcript`){let e=eb(n);e&&ue(r)&&qb.getState().appendUserMessageIfMissing(r,e);return}if(n.type===`tool_update`){let e=typeof n.toolName==`string`?n.toolName:``;if(e!==`workflow`||!ue(r)||Ab.isStreamingFor(r))return;let t=typeof n.toolCallId==`string`?n.toolCallId:void 0,i=n.details;qb.getState().mutateSessionStreaming(r,n=>{Vb(n.content,e,t,i)});return}n.type!==`status`||typeof n.runId!=`string`||!n.runId.trim()||(sb(r,n.runId),ue(r)&&(Ab.isStreamingFor(r)||queueMicrotask(()=>{ue(r)&&(Ab.isStreamingFor(r)||Ce(r,Xb(r)))})))};return window.addEventListener(`agent-stream`,e),()=>window.removeEventListener(`agent-stream`,e)},[Ce,ue]),(0,j.useEffect)(()=>{let e=C||w,t=p.current;if(p.current=e,!t||e)return;let n=BV.current;n&&queueMicrotask(()=>{!n||!ue(n)||Ab.isStreamingFor(n)||ob(n)&&Ce(n,Xb(n))})},[C,w,Ce,ue]),m.current=we,{auth:{hasToken:!!te},session:{sessionKey:g,sessionName:D,decodedKey:n,sessionRoutePending:se,showSessionLoading:ce,loading:_,sessionModel:O,thinkingLevel:k,onSessionThinkingLevelChange:be,reasoningLevel:A,modelSupportsThinking:ee,hasMore:E,loadingMore:v,loadMoreMessages:ve,onSessionModelChange:ye,createNewSession:xe,sessionManager:c.current},messages:{items:ke},stream:{error:y,streaming:C,sending:w,progress:T,sendMessage:we,abort:Ee,interruptAndSend:Te,deleteMessageRound:De,retryUserMessageRound:Oe},followUp:{addPendingFollowUp:fe.addPendingFollowUp,pendingFollowUps:fe.pendingFollowUps,editingFollowUpId:fe.editingFollowUpId,beginEditFollowUp:fe.beginEditFollowUp,cancelEditFollowUp:fe.cancelEditFollowUp,commitEditFollowUp:fe.commitEditFollowUp,removePendingFollowUp:fe.removePendingFollowUp,movePendingFollowUp:fe.movePendingFollowUp,reorderPendingFollowUp:fe.reorderPendingFollowUp,steerPendingFollowUp:fe.steerPendingFollowUp,steeringFollowUpId:fe.steeringFollowUpId},clarify:{clarifyPrompt:fe.clarifyPrompt,clarifySubmitting:fe.clarifySubmitting,clarifySubmitError:fe.clarifySubmitError,submitClarifyAnswer:fe.submitClarifyAnswer,cancelClarifyAnswer:fe.cancelClarifyAnswer},agents:{chatAgents:ne,displayAgentId:ae,showChatAgentSelector:oe,onChatAgentChange:ie}}}var b$e=300*1e3,x$e=Math.round(b$e/6e4);function S$e(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function C$e(e){let t=(0,fm.c)(7),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e;if(!n)return null;let c;return t[0]!==a||t[1]!==s||t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==r?(c=(0,z.jsx)(UV,{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s},n.requestId),t[0]=a,t[1]=s,t[2]=o,t[3]=n,t[4]=i,t[5]=r,t[6]=c):c=t[6],c}function UV(e){let t=(0,fm.c)(70),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e,[c,l]=(0,j.useState)(``),[u]=(0,j.useState)(T$e),[d,f]=(0,j.useState)(0),p=(0,j.useRef)(null),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=window.setInterval(()=>f(w$e),1e3);return()=>window.clearInterval(e)},h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),(0,j.useEffect)(m,h);let g,_;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p.current?.focus()},_=[],t[2]=g,t[3]=_):(g=t[2],_=t[3]),(0,j.useEffect)(g,_);let v;t[4]===o?v=t[5]:(v=e=>{o(e)},t[4]=o,t[5]=v);let y=v,b=Math.max(0,Math.ceil((u-Date.now())/1e3)),x=`clarify-meta-${n.requestId}`,S=i?`clarify-err-${n.requestId}`:void 0,C;t[6]!==s||t[7]!==r?(C=e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},t[6]=s,t[7]=r,t[8]=C):C=t[8];let w=C,T=Array.isArray(n.choices)&&n.choices.length>=2,E;t[9]!==a.clarifyDefaultChoice||t[10]!==n.default?(E=n.default?a.clarifyDefaultChoice.replace(`{{text}}`,n.default):null,t[9]=a.clarifyDefaultChoice,t[10]=n.default,t[11]=E):E=t[11];let D=E,O;t[12]===a.clarifyServerTimeout?O=t[13]:(O=a.clarifyServerTimeout.replace(`{{minutes}}`,String(x$e)),t[12]=a.clarifyServerTimeout,t[13]=O);let k=O,A;t[14]!==a.clarifyTimeRemaining||t[15]!==b?(A=a.clarifyTimeRemaining.replace(`{{time}}`,S$e(b)),t[14]=a.clarifyTimeRemaining,t[15]=b,t[16]=A):A=t[16];let ee=A,te=a.clarifyRegionAria,ne;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ne=fh(`mb-4 rounded-lg border border-edge bg-surface-elevated px-4 py-3 text-sm text-fg shadow-sm outline-none`,yh.focusRingPanel),t[17]=ne):ne=t[17];let re;t[18]===a.clarifyResumeHint?re=t[19]:(re=(0,z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.clarifyResumeHint}),t[18]=a.clarifyResumeHint,t[19]=re);let ie;t[20]===n.question?ie=t[21]:(ie=(0,z.jsx)(AD,{content:n.question,compact:!0,className:`mb-3`}),t[20]=n.question,t[21]=ie);let ae;t[22]===k?ae=t[23]:(ae=(0,z.jsx)(`li`,{children:k}),t[22]=k,t[23]=ae);let oe;t[24]!==a.clarifyDefaultTimeoutNote||t[25]!==n.default?(oe=n.default?(0,z.jsx)(`li`,{children:a.clarifyDefaultTimeoutNote}):null,t[24]=a.clarifyDefaultTimeoutNote,t[25]=n.default,t[26]=oe):oe=t[26];let se;t[27]===a.clarifySkipNote?se=t[28]:(se=(0,z.jsx)(`li`,{children:a.clarifySkipNote}),t[27]=a.clarifySkipNote,t[28]=se);let ce;t[29]===ee?ce=t[30]:(ce=(0,z.jsx)(`li`,{children:ee}),t[29]=ee,t[30]=ce);let le;t[31]!==x||t[32]!==ae||t[33]!==oe||t[34]!==se||t[35]!==ce?(le=(0,z.jsxs)(`ul`,{id:x,className:`mb-3 list-inside list-disc space-y-1 text-xs text-fg-muted`,children:[ae,oe,se,ce]}),t[31]=x,t[32]=ae,t[33]=oe,t[34]=se,t[35]=ce,t[36]=le):le=t[36];let ue;t[37]!==S||t[38]!==i?(ue=i?(0,z.jsx)(`div`,{id:S,role:`alert`,className:`mb-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:i}):null,t[37]=S,t[38]=i,t[39]=ue):ue=t[39];let de;t[40]!==c||t[41]!==D||t[42]!==T||t[43]!==a.clarifyChoicesGroupAria||t[44]!==a.clarifyCustomLabel||t[45]!==a.clarifyPlaceholder||t[46]!==a.clarifySend||t[47]!==a.clarifyUseDefault||t[48]!==o||t[49]!==y||t[50]!==n.choices||t[51]!==n.default||t[52]!==r?(de=T?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`max-h-[min(40vh,16rem)] overflow-y-auto overflow-x-hidden pr-1 [scrollbar-gutter:stable]`,"aria-label":a.clarifyChoicesGroupAria,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[n.choices.map(e=>(0,z.jsx)(gh,{type:`button`,variant:`secondary`,disabled:r,className:fh(`min-h-9 w-full justify-start rounded-lg px-3 py-2 text-left text-sm font-normal shadow-none`,`hover:border-edge`),onClick:()=>y(e),children:e},e)),n.default?(0,z.jsx)(gh,{type:`button`,variant:`ghost`,disabled:r,className:fh(`min-h-9 w-full justify-start rounded-lg border border-dashed border-edge px-3 py-2 text-left text-sm font-normal text-fg-muted`,`hover:border-edge hover:text-fg`),onClick:()=>y(n.default),children:D}):null]})}),(0,z.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:a.clarifyCustomLabel}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&o(t)},children:[(0,z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,z.jsx)(gh,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend})]})]})]}):(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&(o(t),l(``))},children:[(0,z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,z.jsx)(gh,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend}),n.default?(0,z.jsx)(gh,{type:`button`,variant:`secondary`,disabled:r,className:`shrink-0 rounded-lg px-3 py-2 text-sm font-normal text-fg-muted shadow-none hover:text-fg`,onClick:()=>y(n.default),children:a.clarifyUseDefault}):null]}),t[40]=c,t[41]=D,t[42]=T,t[43]=a.clarifyChoicesGroupAria,t[44]=a.clarifyCustomLabel,t[45]=a.clarifyPlaceholder,t[46]=a.clarifySend,t[47]=a.clarifyUseDefault,t[48]=o,t[49]=y,t[50]=n.choices,t[51]=n.default,t[52]=r,t[53]=de):de=t[53];let fe;t[54]===s?fe=t[55]:(fe=()=>void s(),t[54]=s,t[55]=fe);let pe;t[56]!==a.clarifySkip||t[57]!==r||t[58]!==fe?(pe=(0,z.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle pt-3`,children:(0,z.jsx)(gh,{type:`button`,variant:`ghost`,disabled:r,className:`text-fg-muted hover:text-fg`,onClick:fe,children:a.clarifySkip})}),t[56]=a.clarifySkip,t[57]=r,t[58]=fe,t[59]=pe):pe=t[59];let me;return t[60]!==a.clarifyRegionAria||t[61]!==x||t[62]!==w||t[63]!==re||t[64]!==ie||t[65]!==le||t[66]!==ue||t[67]!==de||t[68]!==pe?(me=(0,z.jsxs)(`section`,{ref:p,tabIndex:-1,"aria-label":te,"aria-describedby":x,onKeyDown:w,className:ne,children:[re,ie,le,ue,de,pe]}),t[60]=a.clarifyRegionAria,t[61]=x,t[62]=w,t[63]=re,t[64]=ie,t[65]=le,t[66]=ue,t[67]=de,t[68]=pe,t[69]=me):me=t[69],me}function w$e(e){return e+1}function T$e(){return Date.now()+b$e}function E$e(e,t){return e===`running`||e===`queued`?t.runLinkRunning:e===`succeeded`?t.runLinkCompleted:t.runLinkFinished}var D$e=(0,j.memo)(function(e){let t=(0,fm.c)(28),{link:n,className:r}=e,i=h(f(O$e)).workflows,a=Un(),o;t[0]!==n.definitionId||t[1]!==n.goal?(o=n.goal.trim()||n.definitionId,t[0]=n.definitionId,t[1]=n.goal,t[2]=o):o=t[2];let s=o,c;t[3]!==n.workflowSessionKey||t[4]!==a?(c=()=>a(`/chat/${encodeURIComponent(n.workflowSessionKey)}`),t[3]=n.workflowSessionKey,t[4]=a,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=fh(`flex w-full items-start gap-3 rounded-2xl border border-edge bg-surface-panel px-4 py-3 text-left`,`transition-colors hover:bg-surface-hover/60`,yh.focusRingPanel,r),t[6]=r,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,z.jsx)(no,{className:`size-4`,"aria-hidden":!0})}),t[8]=u):u=t[8];let d=E$e(n.status,i),p;t[9]===d?p=t[10]:(p=(0,z.jsx)(`span`,{className:`block text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:d}),t[9]=d,t[10]=p);let m;t[11]===n.definitionId?m=t[12]:(m=(0,z.jsx)(`span`,{className:`mt-1 block text-sm font-semibold text-fg`,children:n.definitionId}),t[11]=n.definitionId,t[12]=m);let g;t[13]===s?g=t[14]:(g=(0,z.jsx)(`span`,{className:`mt-0.5 block truncate text-sm text-fg-muted`,children:s}),t[13]=s,t[14]=g);let _;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,z.jsx)(Or,{className:`size-3.5`,"aria-hidden":!0}),t[15]=_):_=t[15];let v;t[16]===i.runLinkOpenChat?v=t[17]:(v=(0,z.jsxs)(`span`,{className:`mt-2 inline-flex items-center gap-1 text-xs font-medium text-accent-fg`,children:[i.runLinkOpenChat,_]}),t[16]=i.runLinkOpenChat,t[17]=v);let y;t[18]!==m||t[19]!==g||t[20]!==v||t[21]!==p?(y=(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[p,m,g,v]}),t[18]=m,t[19]=g,t[20]=v,t[21]=p,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==c||t[25]!==l||t[26]!==u?(b=(0,z.jsxs)(`button`,{type:`button`,onClick:c,className:l,children:[u,y]}),t[23]=y,t[24]=c,t[25]=l,t[26]=u,t[27]=b):b=t[27],b});function O$e(e){return e.language}async function k$e(){return(await Ce(v(`/api/workflows/definitions`))).definitions??[]}async function A$e(e,t){return Ce(v(`/api/workflows/definitions/validate`),{method:`POST`,body:JSON.stringify({name:e,script:t})})}async function j$e(e,t){return(await Ce(v(`/api/workflows/definitions`),{method:`POST`,body:JSON.stringify({name:e,script:t})})).definition}async function M$e(e){await Ce(v(`/api/workflows/definitions/${encodeURIComponent(e)}`),{method:`DELETE`})}async function N$e(e){let t=e?.trim(),n=new URLSearchParams;return t&&n.set(`definitionId`,t),(await Ce(v(`/api/workflows/stats${n.size>0?`?${n.toString()}`:``}`))).stats}async function P$e(e=50){return(await Ce(v(`/api/workflows/runs?limit=${e}`))).runs??[]}async function WV(e){return(await Ce(v(`/api/workflows/runs/${encodeURIComponent(e)}`))).view}async function F$e(e){return Ce(v(`/api/workflows/runs`),{method:`POST`,body:JSON.stringify(e)})}async function I$e(e){await Ce(v(`/api/workflows/runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})}async function L$e(e){return Ce(v(`/api/workflows/runs/${encodeURIComponent(e)}/retry`),{method:`POST`})}function R$e(e,t){let n=Number.parseInt(e,10);return Number.isFinite(n)?n:t+1}function z$e(e){if(e!=null){if(typeof e==`object`&&e&&`raw`in e){let t=e.raw;return t===void 0?e:t}return e}}function B$e(e){let t=new Map(e.phases.map(e=>[e.id,e.title])),n=e.phases.find(e=>e.status===`running`),r=e.agents.map((e,n)=>({id:R$e(e.id,n),label:e.label,phase:e.phaseId?t.get(e.phaseId):void 0,prompt:e.prompt??``,status:e.status,resultPreview:e.resultPreview,error:e.error,startedAtMs:e.startedAtMs,durationMs:e.startedAtMs!=null&&e.completedAtMs!=null?e.completedAtMs-e.startedAtMs:void 0,currentStep:e.currentStep,steps:e.steps?.map(e=>({id:e.id,kind:e.kind,toolName:e.toolName,label:e.label,detail:e.detail,status:e.status,resultPreview:e.resultPreview,error:e.error,startedAtMs:e.startedAtMs,durationMs:e.startedAtMs!=null&&e.completedAtMs!=null?e.completedAtMs-e.startedAtMs:void 0}))})),{metrics:i}=e.run;return{name:e.run.definitionId,description:e.run.goal||e.run.title,phases:e.phases.map(e=>e.title),currentPhase:n?.title,logs:e.logs.map(e=>e.message),agents:r,agentCount:i.agentCount,runningCount:Math.max(0,i.agentCount-i.doneAgentCount-i.errorAgentCount-i.skippedAgentCount),doneCount:i.doneAgentCount,errorCount:i.errorAgentCount,skippedCount:i.skippedAgentCount,durationMs:i.durationMs,result:z$e(e.run.result)}}new Set([`catalog`,`active`,`history`]);var GV=[`all`,`code-review`,`planning`,`research`,`writing`,`productivity`];new Set(GV),new Set([`all`,`builtin`,`user`]);var KV=`trigger`,V$e=`start`,H$e=[`code-review`,`planning`,`research`,`writing`,`productivity`],U$e={"code-review":[`code-review`,`pr`,`release`],planning:[`planning`,`implementation`,`architecture`,`decision`,`review`],research:[`research`,`investigation`,`debug`,`incident`,`troubleshooting`],writing:[`writing`,`content`,`communication`,`email`,`document`],productivity:[`productivity`,`meeting`,`comparison`,`brainstorm`,`decision-making`]},W$e={research:[{key:`question`,labelKey:`argQuestion`,placeholderKey:`argQuestionPlaceholder`,required:!0,multiline:!0}],multi_perspective_review:[{key:`target`,labelKey:`argTarget`,placeholderKey:`argTargetPlaceholder`,multiline:!0}],pr_review:[{key:`target`,labelKey:`argDiff`,placeholderKey:`argDiffPlaceholder`,multiline:!0}],debug_incident:[{key:`error`,labelKey:`argError`,placeholderKey:`argErrorPlaceholder`,required:!0,multiline:!0},{key:`context`,labelKey:`argContext`,placeholderKey:`argContextPlaceholder`,multiline:!0}],implementation_plan:[{key:`request`,labelKey:`argRequest`,placeholderKey:`argRequestPlaceholder`,required:!0,multiline:!0},{key:`scope`,labelKey:`argScope`,placeholderKey:`argScopePlaceholder`}],release_check:[{key:`target`,labelKey:`argTarget`,placeholderKey:`argReleaseTargetPlaceholder`,multiline:!0}],content_draft:[{key:`topic`,labelKey:`argTopic`,placeholderKey:`argTopicPlaceholder`,required:!0,multiline:!0},{key:`audience`,labelKey:`argAudience`,placeholderKey:`argAudiencePlaceholder`},{key:`format`,labelKey:`argFormat`,placeholderKey:`argFormatPlaceholder`}],decision_compare:[{key:`question`,labelKey:`argDecisionQuestion`,placeholderKey:`argDecisionQuestionPlaceholder`,required:!0,multiline:!0},{key:`options`,labelKey:`argOptions`,placeholderKey:`argOptionsPlaceholder`,multiline:!0},{key:`criteria`,labelKey:`argCriteria`,placeholderKey:`argCriteriaPlaceholder`,multiline:!0}],meeting_prep:[{key:`meeting_topic`,labelKey:`argMeetingTopic`,placeholderKey:`argMeetingTopicPlaceholder`,required:!0,multiline:!0},{key:`attendees`,labelKey:`argAttendees`,placeholderKey:`argAttendeesPlaceholder`},{key:`goal`,labelKey:`argMeetingGoal`,placeholderKey:`argMeetingGoalPlaceholder`,multiline:!0}],weekly_review:[{key:`wins`,labelKey:`argWins`,placeholderKey:`argWinsPlaceholder`,required:!0,multiline:!0},{key:`blockers`,labelKey:`argBlockers`,placeholderKey:`argBlockersPlaceholder`,multiline:!0},{key:`carryover`,labelKey:`argCarryover`,placeholderKey:`argCarryoverPlaceholder`,multiline:!0}],client_proposal:[{key:`client_brief`,labelKey:`argClientBrief`,placeholderKey:`argClientBriefPlaceholder`,required:!0,multiline:!0},{key:`offer`,labelKey:`argOffer`,placeholderKey:`argOfferPlaceholder`,multiline:!0},{key:`budget_hint`,labelKey:`argBudgetHint`,placeholderKey:`argBudgetHintPlaceholder`}],content_repurpose:[{key:`source`,labelKey:`argSource`,placeholderKey:`argSourcePlaceholder`,required:!0,multiline:!0},{key:`platforms`,labelKey:`argPlatforms`,placeholderKey:`argPlatformsPlaceholder`,multiline:!0}],competitor_scan:[{key:`market`,labelKey:`argMarket`,placeholderKey:`argMarketPlaceholder`,required:!0,multiline:!0},{key:`competitors`,labelKey:`argCompetitors`,placeholderKey:`argCompetitorsPlaceholder`,multiline:!0},{key:`focus`,labelKey:`argFocus`,placeholderKey:`argFocusPlaceholder`}],offer_design:[{key:`skills`,labelKey:`argSkills`,placeholderKey:`argSkillsPlaceholder`,required:!0,multiline:!0},{key:`audience`,labelKey:`argOfferAudience`,placeholderKey:`argOfferAudiencePlaceholder`,multiline:!0},{key:`constraints`,labelKey:`argConstraints`,placeholderKey:`argConstraintsPlaceholder`,multiline:!0}],inbox_triage:[{key:`inbox`,labelKey:`argInbox`,placeholderKey:`argInboxPlaceholder`,required:!0,multiline:!0},{key:`priorities`,labelKey:`argPriorities`,placeholderKey:`argPrioritiesPlaceholder`,multiline:!0}]},qV=new Set([`queued`,`running`]);function JV(e){let t=B$e(e),n=e.run.status,r=n===`running`||n===`queued`?`running`:n===`succeeded`?`done`:`error`;return{type:`tool_use`,id:`workflow-run:${e.run.id}`,name:`workflow`,input:{name:e.run.definitionId},status:r,details:t}}var G$e=(0,j.memo)(function(e){let t=(0,fm.c)(17),{view:n,sessionKey:r,onAbortCurrentTurn:i,onSendUserMessage:a}=e,o=f(K$e),s;t[0]===o?s=t[1]:(s=dV(o),t[0]=o,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=JV(n),t[2]=n,t[3]=l);let u=l,d;t[4]===n.run.status?d=t[5]:(d=qV.has(n.run.status),t[4]=n.run.status,t[5]=d);let p=d,m;t[6]!==p||t[7]!==i||t[8]!==n.run.id?(m=()=>{p&&I$e(n.run.id).catch(q$e),i?.()},t[6]=p,t[7]=i,t[8]=n.run.id,t[9]=m):m=t[9];let h=p?m:void 0,g;return t[10]!==u||t[11]!==c||t[12]!==a||t[13]!==r||t[14]!==h||t[15]!==n.run.startedAtMs?(g=(0,z.jsx)(`div`,{className:`mb-6`,children:(0,z.jsx)(uV,{block:u,startedAt:n.run.startedAtMs,sessionKey:r,onAbort:h,onSendChatMessage:a,labels:c})}),t[10]=u,t[11]=c,t[12]=a,t[13]=r,t[14]=h,t[15]=n.run.startedAtMs,t[16]=g):g=t[16],g});function K$e(e){return e.language}function q$e(){}function J$e(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.kind!==`context`)return null;let n=t.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:null;if(!n||n.kind!==`workflow-run-link`)return null;let r=typeof n.runId==`string`?n.runId.trim():``,i=typeof n.workflowSessionKey==`string`?n.workflowSessionKey.trim():``,a=typeof n.definitionId==`string`?n.definitionId.trim():``;if(!r||!i||!a)return null;let o=typeof n.goal==`string`?n.goal:``,s=typeof n.status==`string`?n.status:`running`,c=typeof t.id==`string`&&t.id.trim()?t.id.trim():`workflow-run-link:${r}`,l=typeof t.createdAt==`string`?Date.parse(t.createdAt):void 0;return{id:c,runId:r,workflowSessionKey:i,definitionId:a,goal:o,status:s,createdAtMs:Number.isFinite(l)?l:void 0}}function Y$e(e){if(!e?.length)return[];let t=new Map;for(let n of e){let e=J$e(n);e&&t.set(e.runId,e)}return[...t.values()].toSorted((e,t)=>(e.createdAtMs??0)-(t.createdAtMs??0))}function X$e(e){let t=(0,fm.c)(8),n=xe(Z$e),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]!==n||t[3]!==i?(a=n&&i?[`session-workflow-run-links`,i,n]:null,t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=async()=>Y$e((await mb(i,{includeTranscriptRows:!0})).transcriptRows),t[5]=i,t[6]=o);let s;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[7]=s):s=t[7],y(a,o,s)}function Z$e(e){return e.token}function YV(e){let t=(0,fm.c)(20),n=xe($$e),r=!!n,i;t[0]===e?i=t[1]:(i=e?.trim()||null,t[0]=e,t[1]=i);let a=i,o;t[2]!==r||t[3]!==n||t[4]!==a?(o=r&&a?[`workflow-run-live`,a,n]:null,t[2]=r,t[3]=n,t[4]=a,t[5]=o):o=t[5];let s;t[6]===a?s=t[7]:(s=()=>WV(a),t[6]=a,t[7]=s);let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1,refreshInterval:Q$e},t[8]=c):c=t[8];let l=y(o,s,c),u;t[9]!==l||t[10]!==a?(u=()=>{if(!a)return;let e=e=>{let t=e.detail;if(t?.runId===a){if(t.view){l.mutate(t.view,{revalidate:!1});return}l.mutate()}};return window.addEventListener(`workflow-run-updated`,e),()=>window.removeEventListener(`workflow-run-updated`,e)},t[9]=l,t[10]=a,t[11]=u):u=t[11];let d;t[12]!==l.mutate||t[13]!==a?(d=[l.mutate,a],t[12]=l.mutate,t[13]=a,t[14]=d):d=t[14],(0,j.useEffect)(u,d);let f;return t[15]!==l.data||t[16]!==l.error||t[17]!==l.isLoading||t[18]!==l.mutate?(f={view:l.data,loading:l.isLoading,error:l.error,mutate:l.mutate},t[15]=l.data,t[16]=l.error,t[17]=l.isLoading,t[18]=l.mutate,t[19]=f):f=t[19],f}function Q$e(e){return e&&qV.has(e.run.status)?3e3:0}function $$e(e){return e.token}function e1e(e){let t=(0,fm.c)(8),n=xe(t1e),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]!==n||t[3]!==i?(a=n&&i?[`workflow-session-meta`,i,n]:null,t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=async()=>{let e=await mb(i),t=e.customData?.workflowRunId,n=typeof t==`string`&&t.trim()?t.trim():null,r=typeof e.sessionType==`string`&&e.sessionType.trim()?e.sessionType.trim():null,a=e.customData?.sourceNoteId,o=typeof a==`string`&&a.trim()?a.trim():null,s=e.customData?.sourceNoteTitle;return{workflowRunId:n,sessionType:r,sourceNoteId:o,sourceNoteTitle:typeof s==`string`&&s.trim()?s.trim():null}},t[5]=i,t[6]=o);let s;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[7]=s):s=t[7],y(a,o,s)}function t1e(e){return e.token}var n1e=`/agents`;function XV(e){return`${n1e}/${encodeURIComponent(e)}`}function ZV(){let e=h(f(e=>e.language)),t=xe(e=>e.token),n=Un(),r=Hn(),{pathname:i}=r,[a]=Qne(),o=(0,j.useRef)(null),s=(0,j.useRef)(0),[c,l]=(0,j.useState)(null),{auth:u,session:d,messages:p,stream:m,followUp:g,clarify:_,agents:v}=y$e(),y=a.get(`skill`)?.trim()??``,b=a.get(`slash`)?.trim()??``,x=d.decodedKey??d.sessionKey,{data:S}=e1e(x),C=S?.workflowRunId??null,{view:w}=YV(C),{data:T=[],mutate:E}=X$e(x),D=!!(C&&w&&qV.has(w.run.status));(0,j.useEffect)(()=>{if(!x)return;let e=e=>{e.detail?.key===x&&E()};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},[x,E]),(0,j.useEffect)(()=>{o.current=null},[d.sessionKey]),(0,j.useEffect)(()=>{if(!u.hasToken||!y&&!b||d.showSessionLoading||d.sessionRoutePending||!d.sessionKey)return;let e=()=>{let e=new URLSearchParams(a);e.delete(`skill`),e.delete(`slash`);let t=e.toString();n({pathname:i,search:t?`?${t}`:``},{replace:!0})},t=(t,n)=>{o.current!==n&&(o.current=n,queueMicrotask(()=>{s.current+=1,l({id:s.current,text:t}),e()}))};if(y){if(!sBe(y)){e();return}let n=`${d.sessionKey}:skill:${y}`;t(`/skill:${y} `,n);return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(b)){e();return}let r=`${d.sessionKey}:slash:${b}`;o.current!==r&&queueMicrotask(()=>{(async()=>{try{let e=await Vk(),t=b.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(o.current===r)return;o.current=r,s.current+=1,l({id:s.current,text:Gk(n)})}}finally{e()}})()})},[u.hasToken,y,b,a,d.showSessionLoading,d.sessionRoutePending,d.sessionKey,n,i]);let{scrollRef:O,atBottom:k,registerListContentRef:A,scrollToBottom:ee,onScroll:te}=CV({hasToken:u.hasToken,showSessionLoading:d.showSessionLoading,sessionKey:d.sessionKey,sending:m.sending,chatMessages:p.items,hasMore:d.hasMore,loadingMore:d.loadingMore,loadMoreMessages:d.loadMoreMessages});(0,j.useEffect)(()=>{l(null)},[d.sessionKey]);let ne=(0,j.useCallback)(e=>{s.current+=1,l({id:s.current,text:e})},[]),re=(0,j.useMemo)(()=>!!d.sessionKey&&!d.showSessionLoading&&!d.sessionRoutePending&&p.items.length===0,[d.sessionKey,d.showSessionLoading,d.sessionRoutePending,p.items.length]),ie=fO(e=>e.setAgentId);(0,j.useEffect)(()=>{if(u.hasToken)return ie(v.displayAgentId),()=>ie(``)},[u.hasToken,v.displayAgentId,ie]);let ae=!d.showSessionLoading&&p.items.length===0&&!m.streaming,oe=(0,j.useMemo)(()=>(d.sessionRoutePending&&d.decodedKey?d.decodedKey:d.sessionKey)?d.sessionName?.trim()||e.chat.newSession:e.nav.chat,[d.sessionKey,d.sessionName,d.sessionRoutePending,d.decodedKey,e.nav.chat,e.chat.newSession]),se=S?.sourceNoteId??null,ce=S?.sourceNoteTitle||e.chat.sourceNoteFallbackTitle,le=(0,j.useCallback)(async t=>{se&&await kA(se,t,e.chat.sourceNoteAppendHeading)},[e.chat.sourceNoteAppendHeading,se]),ue=(0,j.useCallback)(async t=>{se&&await rVe((t.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||e.chat.sourceNoteTaskFallbackTitle).slice(0,120),{sourceNoteId:se,sourceSessionKey:x})},[x,e.chat.sourceNoteTaskFallbackTitle,se]);return u.hasToken?(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,z.jsx)(ZJe,{}),(0,z.jsx)(UJe,{chatHeadline:oe,chatAgents:v.chatAgents?.items??[],showChatAgentSelector:v.showChatAgentSelector,chatAgentId:v.displayAgentId,onChatAgentChange:v.onChatAgentChange,chatAgentDisabled:d.showSessionLoading||d.sessionRoutePending}),(0,z.jsxs)(`div`,{className:`relative mx-auto flex min-h-0 w-full max-w-[var(--max-width-chat)] flex-1 flex-col`,children:[r.state?.fromAgentEditor&&v.displayAgentId?(0,z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,z.jsxs)(mr,{to:XV(v.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:`←`}),e.agentsSettings.backToEditor]})}):null,se?(0,z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.chat.sourceNoteBanner.replace(`{{title}}`,ce)}),(0,z.jsx)(mr,{to:`/notes/${encodeURIComponent(se)}`,className:`shrink-0 font-medium text-accent transition-colors hover:text-accent-fg`,children:e.chat.sourceNoteOpen})]})}):null,d.sessionKey&&wb(d.sessionKey)&&!d.showSessionLoading&&!d.sessionRoutePending?(0,z.jsx)(IJe,{sessionKey:d.sessionKey,streaming:m.streaming,sending:m.sending}):null,(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col px-3 sm:px-5 xl:px-6`,children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsx)(`div`,{ref:O,className:fh(`chat-messages min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,ae?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:te,children:d.showSessionLoading?(0,z.jsx)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-3 py-12 text-center text-sm text-fg-muted`,children:e.chat.loading}):(0,z.jsxs)(z.Fragment,{children:[d.loadingMore?(0,z.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:e.chat.loadOlder}):null,m.error?(0,z.jsx)(iQe,{errorText:m.error}):null,T.length>0?(0,z.jsx)(`div`,{className:`mb-6 flex flex-col gap-3`,children:T.map(e=>(0,z.jsx)(D$e,{link:e},e.id))}):null,D&&w?(0,z.jsx)(G$e,{view:w,sessionKey:x,onAbortCurrentTurn:m.abort,onSendUserMessage:e=>{m.streaming||m.sending?g.addPendingFollowUp(e):m.sendMessage(e)}}):null,(0,z.jsx)(bV,{messages:p.items,authToken:t??void 0,sessionKey:d.decodedKey??d.sessionKey,streaming:m.streaming,progress:m.progress,reasoningLevel:d.reasoningLevel,registerListContentRef:A,onPickWelcomePrompt:ne,onDeleteRound:m.deleteMessageRound,onRetryUserMessageRound:m.retryUserMessageRound,deleteRoundDisabled:m.streaming||m.sending,onAbortCurrentTurn:m.abort,onSendUserMessage:e=>{m.streaming||m.sending?g.addPendingFollowUp(e):m.sendMessage(e)},onSaveAssistantToSourceNote:se?le:void 0,onExtractAssistantTask:se?ue:void 0},d.decodedKey??`new`)]})}),(0,z.jsxs)(`div`,{className:fh(`sticky bottom-0 z-10 shrink-0 bg-surface-panel`,ae?`py-2.5`:`py-4`),children:[(0,z.jsx)(C$e,{prompt:_.clarifyPrompt,submitting:_.clarifySubmitting,submitError:_.clarifySubmitError,labels:e.chat,onSubmit:_.submitClarifyAnswer,onCancel:_.cancelClarifyAnswer}),(0,z.jsx)(lJe,{disabled:d.showSessionLoading||d.sessionRoutePending||!!_.clarifyPrompt,sending:m.sending,streaming:m.streaming,sessionKey:d.sessionKey,sessionManager:d.sessionManager,welcomeDraftSeed:c,canSelectWorkingDirectory:re,thinkingLevel:d.thinkingLevel,showThinkingSelector:d.modelSupportsThinking,onThinkingChange:d.onSessionThinkingLevelChange,onSend:m.sendMessage,onAbort:m.abort,onAddPendingFollowUp:(e,t)=>void g.addPendingFollowUp(e,t),onSteeringInterrupt:(e,t)=>void m.interruptAndSend(e,t),pendingFollowUps:g.pendingFollowUps,editingFollowUpId:g.editingFollowUpId,onBeginEditFollowUp:g.beginEditFollowUp,onCancelEditFollowUp:g.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r)=>void g.commitEditFollowUp(e,t,n,r),onPendingFollowUpRemove:g.removePendingFollowUp,onPendingFollowUpMove:g.movePendingFollowUp,onPendingFollowUpReorder:g.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void g.steerPendingFollowUp(e),steeringFollowUpId:g.steeringFollowUpId,sessionModel:d.sessionModel,showModelSelector:!!(d.sessionKey&&!d.sessionRoutePending),onModelChange:d.onSessionModelChange,modelDisabled:d.showSessionLoading||d.sessionRoutePending||m.streaming,contextUsageMessages:p.items,onChatAgentChange:v.showChatAgentSelector?v.onChatAgentChange:void 0,currentAgentId:v.displayAgentId})]})]})})]}),(0,z.jsx)(xV,{visible:!d.showSessionLoading&&!k,onClick:()=>ee(!0)})]}):(0,z.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:e.chat.needToken})}function QV(){let e=(0,fm.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden`,children:(0,z.jsx)(er,{})}),e[0]=t):t=e[0],t}async function r1e(e){let t=await Te(e);if(!t.ok){let e=await t.json().catch(()=>({})),n=we(t.status,t.statusText,e.error?.message);throw Error(n)}return t.json()}function i1e(e){let t=(0,fm.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={fetcher:r1e,revalidateOnFocus:!1,dedupingInterval:2e3,shouldRetryOnError:!0,errorRetryCount:2},t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,z.jsx)(b,{value:r,children:n}),t[1]=n,t[2]=i),i}var $V=(0,j.lazy)(()=>w(()=>import(`./sessions-page-BvtdbmW8.js`).then(e=>({default:e.SessionsPage})),__vite__mapDeps([19,1,3,4,6,15,8]))),a1e=(0,j.lazy)(()=>w(()=>import(`./cron-page-Dx6dE3eD.js`).then(e=>({default:e.CronPage})),__vite__mapDeps([21,1,22,23,4,2,3,6,12,11,13,7,8,16,15,24]))),eH=(0,j.lazy)(()=>w(()=>import(`./notes-page-D40ZpS0Y.js`).then(e=>({default:e.NotesPage})),__vite__mapDeps([31,1,22,23,4,3,6,32,8,18]))),tH=(0,j.lazy)(()=>w(()=>import(`./note-detail-page-DG3DVFTf.js`).then(e=>({default:e.NoteDetailPage})),__vite__mapDeps([33,1,30,3,4,6,13,32,18,34]))),nH=(0,j.lazy)(()=>w(()=>import(`./workflows-page-Be7l_SWw.js`).then(e=>({default:e.WorkflowsPage})),__vite__mapDeps([35,1,3,4,6,12,11,24,8]))),rH=(0,j.lazy)(()=>w(()=>import(`./skills-page-QwFCB4yV.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([25,1,26,22,23,4,6,8]))),o1e=(0,j.lazy)(()=>w(()=>import(`./logs-page-CiG0m81R.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([20,1,6,4,8]))),s1e=(0,j.lazy)(()=>w(()=>import(`./settings-page-D972_jaS.js`).then(e=>({default:e.SettingsPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),c1e=(0,j.lazy)(()=>w(()=>import(`./agents-DQ0mQxIA.js`).then(e=>({default:e.AgentsSettingsPanel})),__vite__mapDeps([14,1,2,3,4,6,10,11,13,7,8,15]))),l1e=(0,j.lazy)(()=>w(()=>import(`./channels-settings-BEtP53V6.js`).then(e=>({default:e.ChannelsSettingsPanel})),__vite__mapDeps([36,1,3,4,5,6,7,8,9,12,11,37]))),u1e=(0,j.lazy)(()=>w(()=>import(`./apps-page-Uv4kOmDE.js`).then(e=>({default:e.AppsPage})),__vite__mapDeps([38,1,3,4,6,8]))),iH=(0,j.lazy)(()=>w(()=>import(`./extension-page-CcIGQah2.js`).then(e=>({default:e.ExtensionPage})),__vite__mapDeps([39,1,4]))),aH=(0,j.lazy)(()=>w(()=>import(`./extension-settings-page-DuDCSb3J.js`).then(e=>({default:e.ExtensionSettingsPage})),__vite__mapDeps([40,1,3,4,6,37,9,17,8]))),d1e=(0,j.lazy)(()=>w(()=>import(`./extension-debug-page-BNkhvRQW.js`).then(e=>({default:e.ExtensionDebugPage})),__vite__mapDeps([41,1,4]))),oH=(0,j.lazy)(()=>w(()=>import(`./share-preview-page-CKCTMo0_.js`).then(e=>({default:e.SharePreviewPage})),__vite__mapDeps([42,1,26,6,4])));function sH(){let e=(0,fm.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center text-sm text-fg-muted`,"aria-busy":!0,children:`Loading…`}),e[0]=t):t=e[0],t}function f1e(){let e=(0,fm.c)(4),{agentId:t}=Wn(),n;e[0]===t?n=e[1]:(n=typeof t==`string`?t.trim():``,e[0]=t,e[1]=n);let r=n,i=r?`/agents/${encodeURIComponent(r)}`:`/agents`,a;return e[2]===i?a=e[3]:(a=(0,z.jsx)($n,{to:i,replace:!0}),e[2]=i,e[3]=a),a}function cH(){let e=(0,fm.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"aria-busy":!0,children:(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main flex-1 px-4 py-8`,children:[(0,z.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`}),(0,z.jsx)(`p`,{className:`mt-6 text-sm text-fg-muted`,children:`Loading…`})]})}),e[0]=t):t=e[0],t}var p1e=Hne([{path:`/share/:token`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(oH,{})})},{path:`/`,element:(0,z.jsx)(TL,{}),children:[{index:!0,element:(0,z.jsx)($n,{to:`/chat`,replace:!0})},{path:`chat`,element:(0,z.jsx)(QV,{}),children:[{index:!0,element:(0,z.jsx)(ZV,{})},{path:`new`,element:(0,z.jsx)(ZV,{})},{path:`:sessionKey`,element:(0,z.jsx)(ZV,{})}]},{path:`sessions`,element:(0,z.jsx)($n,{to:`/settings/sessions`,replace:!0})},{path:`logs`,element:(0,z.jsx)($n,{to:`/settings/logs`,replace:!0})},{path:`cron`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(a1e,{})})},{path:`notes`,children:[{index:!0,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(eH,{})})},{path:`:noteId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(tH,{})})}]},{path:`workflows`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(nH,{})})},{path:`skills`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(rH,{})})},{path:`channels`,children:[{index:!0,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(l1e,{})})},{path:`:channelId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(l1e,{})})}]},{path:`mcp`,element:(0,z.jsx)($n,{to:`/settings/connectors`,replace:!0})},{path:`agents`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(c1e,{})})},{path:`agents/:agentId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(c1e,{})})},{path:`apps`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(u1e,{})})},{path:`apps/:extensionId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(iH,{})})},{path:`apps/:extensionId/:pageId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(iH,{})})},{path:`settings`,element:(0,z.jsx)(iKe,{children:(0,z.jsx)(ZGe,{})}),children:[{index:!0,element:(0,z.jsx)($n,{to:`overview`,replace:!0})},{path:`skills`,element:(0,z.jsx)($n,{to:`/skills`,replace:!0})},{path:`channels`,element:(0,z.jsx)($n,{to:`/channels`,replace:!0})},{path:`mcp`,element:(0,z.jsx)($n,{to:`/settings/connectors`,replace:!0})},{path:`cron`,element:(0,z.jsx)($n,{to:`/cron?tab=settings`,replace:!0})},{path:`sessions`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)($V,{})})},{path:`logs`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(sH,{}),children:(0,z.jsx)(o1e,{})})},{path:`apps`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(u1e,{})})},{path:`agents`,element:(0,z.jsx)($n,{to:`/agents`,replace:!0})},{path:`agents/:agentId`,element:(0,z.jsx)(f1e,{})},{path:`extensions/debug`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(d1e,{})})},{path:`ext/:extensionId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(aH,{})})},{path:`ext/:extensionId/:panelId`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(aH,{})})},{path:`:section`,element:(0,z.jsx)(j.Suspense,{fallback:(0,z.jsx)(cH,{}),children:(0,z.jsx)(s1e,{})})}]}]}]);function m1e(){let e=(0,fm.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,j.useEffect)(h1e,t),null}function h1e(){let e=_e.persist.onFinishHydration(_1e),t=Fh.persist.onFinishHydration(g1e),n=ve();return()=>{e?.(),t?.(),n()}}function g1e(){rTe()}function _1e(){ye()}function v1e(){let e=(0,fm.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(m1e,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsx)(it,{i18n:d,children:(0,z.jsx)(i1e,{children:(0,z.jsx)(SOe,{children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[t,(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col *:min-h-0 *:flex-1`,children:(0,z.jsx)(ore,{router:p1e})})]})})})}),e[1]=n):n=e[1],n}document.documentElement.setAttribute(`lang`,u(p())),be(),Ph(),Se(),(0,dm.createRoot)(document.getElementById(`root`)).render((0,z.jsx)(j.StrictMode,{children:(0,z.jsx)(v1e,{})}));export{mL as $,so as $a,zu as $i,Tke as $n,Qne as $o,wh as $r,Zze as $t,oqe as A,xs as Aa,gxe as Ai,oO as An,ai as Ao,M_ as Ar,TBe as At,ML as B,os as Ba,Od as Bi,aje as Bn,Nr as Bo,Gh as Br,mk as Bt,BZe as C,nc as Ca,fp as Ci,gze as Cn,xi as Co,uv as Cr,vA as Ct,gZe as D,Ms as Da,Zxe as Di,fze as Dn,pi as Do,av as Dr,SBe as Dt,XB as E,Yhe as Ea,Qxe as Ei,uO as En,xle as Eo,ov as Er,aA as Et,ZKe as F,ps as Fa,Qbe as Fi,YS as Fn,Zr as Fo,FDe as Fr,Zk as Ft,CL as G,No as Ga,fd as Gi,XAe as Gn,tie as Go,Rh as Gr,vk as Gt,gGe as H,Uo as Ha,gd as Hi,eje as Hn,Er as Ho,Hh as Hr,yk as Ht,WKe as I,fs as Ia,df as Ii,RS as In,Yr as Io,PDe as Ir,Qk as It,mGe as J,$me as Ja,ld as Ji,oS as Jn,mr as Jo,Ah as Jr,bk as Jt,SL as K,Ao as Ka,dd as Ki,cS as Kn,vre as Ko,vTe as Kr,xk as Kt,nKe as L,Che as La,Sbe as Li,zS as Ln,Jr as Lo,l_ as Lr,DBe as Lt,nqe as M,Vhe as Ma,Af as Mi,eze as Mn,ri as Mo,k_ as Mr,eA as Mt,tqe as N,Ihe as Na,Df as Ni,ND as Nn,ei as No,A_ as Nr,bBe as Nt,ZXe as O,Ts as Oa,Hf as Oi,lO as On,di as Oo,iv as Or,CBe as Ot,$Ke as P,hs as Pa,oxe as Pi,AD as Pn,Qr as Po,u_ as Pr,$k as Pt,dGe as Q,Fme as Qa,Vu as Qi,wb as Qn,Wn as Qo,Sh as Qr,rk as Qt,KGe as R,us as Ra,zd as Ri,ES as Rn,qr as Ro,r_ as Rr,wBe as Rt,dV as S,ac as Sa,PSe as Si,fO as Sn,Si as So,Tv as Sr,VBe as St,jZe as T,Qs as Ta,np as Ti,cO as Tn,bi as To,lv as Tr,oA as Tt,hGe as U,Bo as Ua,Oye as Ui,$Ae as Un,Tr as Uo,yTe as Ur,Sk as Ut,vGe as V,rs as Va,Ed as Vi,fS as Vn,Oie as Vo,XTe as Vr,_k as Vt,_Ge as W,Ro as Wa,Eye as Wi,ZAe as Wn,rie as Wo,Lh as Wr,Ck as Wt,fGe as X,Rme as Xa,Qu as Xi,Hke as Xn,Hn as Xo,$we as Xr,rBe as Xt,xL as Y,xo as Ya,ad as Yi,lS as Yn,$n as Yo,jh as Yr,hk as Yt,pGe as Z,Ime as Za,Ju as Zi,kb as Zn,Un as Zo,kh as Zr,pk as Zt,L$e as _,Zc as _a,Rp as _i,Tze as _n,Gi as _o,ny as _r,JBe as _t,W$e as a,Kl as aa,_h as ai,KO as an,la as ao,Dke as ar,sVe as at,A$e as b,fc as ba,BSe as bi,yO as bn,Mle as bo,Xv as br,TA as bt,U$e as c,Wl as ca,qwe as ci,IO as cn,oa as co,H as cr,YBe as ct,B$e as d,zl as da,fh as di,LO as dn,Jde as do,yy as dr,iVe as dt,Du as ea,bh as ei,tk as en,no as eo,hb as er,rt as es,hL as et,I$e as f,Ll as fa,im as fi,WO as fn,na as fo,gy as fr,aVe as ft,P$e as g,$c as ga,aCe as gi,BO as gn,Ki as go,dy as gr,AA as gt,k$e as h,el as ha,xCe as hi,zO as hn,qi as ho,POe as hr,QBe as ht,qV as i,Jl as ia,Xwe as ii,GO as in,Na as io,pb as ir,ZBe as it,eqe as j,Khe as ja,dxe as ji,oze as jn,ii as jo,j_ as jr,EBe as jt,IXe as k,ws as ka,Bf as ki,iO as kn,ci as ko,cv as kr,rA as kt,V$e as l,Ul as la,Ywe as li,FO as ln,aa as lo,LOe as lr,OA as lt,N$e as m,bl as ma,zCe as mi,UO as mn,$i as mo,fy as mr,cVe as mt,XV as n,xu as na,yh as ni,Yze as nn,Bpe as no,mb as nr,eVe as nt,GV as o,Cve as oa,Kwe as oi,qO as on,lfe as oo,Eke as or,oVe as ot,M$e as p,Tl as pa,rm as pi,RO as pn,ta as po,py as pr,tVe as pt,yGe as q,Do as qa,ud as qi,uS as qn,xr as qo,aTe as qr,fk as qt,YV as r,vu as ra,vh as ri,Xze as rn,Ra as ro,Cke as rr,$Be as rt,H$e as s,Gl as sa,Jwe as si,HO as sn,sa as so,gb as sr,nVe as st,n1e as t,eye as ta,Zwe as ti,nk as tn,Za as to,_b as tr,zA as tt,KV as u,Hl as ua,gh as ui,VO as un,ra as uo,by as ur,XBe as ut,j$e as v,Pc as va,KSe as vi,Eze as vn,Vi as vo,COe as vr,EA as vt,RZe as w,Vge as wa,sp as wi,pze as wn,Tle as wo,sv as wr,lA as wt,dQe as x,sc as xa,zSe as xi,xO as xn,Ci as xo,Zv as xr,UBe as xt,F$e as y,mc as ya,Ep as yi,bO as yn,ki as yo,ty as yr,wA as yt,HGe as z,cs as za,jd as zi,oje as zn,Kr as zo,Jh as zr,nA as zt};
|