@xopcai/xopc 0.0.117 → 0.0.119
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/README.md +26 -24
- package/README.zh-CN.md +46 -42
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BBLhJ2C6.js → agent-avatar-dicebear-CU8J6zou.js} +1 -1
- package/dist/gateway/static/root/assets/agents-B0hkpLhP.js +2 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-B9vfYoEr.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-ClOzIO24.js +1 -0
- package/dist/gateway/static/root/assets/{apps-page-DdDx0V4z.js → apps-page-DU0dz9Zo.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-DZsVqMhU.js → archive-plugin-BkVIgZzA.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CIol6JWX.js → attachment-load-CaCMWh1D.js} +1 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-DhGDpKP3.js +1 -0
- package/dist/gateway/static/root/assets/automations-page-CTedroVo.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B3UauMfp.js → binary-plugins-B4TO_bsn.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-2HJoFchH.js → block-editor-DJRWwWNI.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-FCDwOOBK.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-Befi89CL.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-_G8eb2vJ.js +1 -0
- package/dist/gateway/static/root/assets/channel-recipient-api-BNSuJb5f.js +1 -0
- package/dist/gateway/static/root/assets/channels-settings-C3d5JBJX.js +1 -0
- package/dist/gateway/static/root/assets/cn-BQ_8x0bT.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-yaUNvt5u.js +2 -0
- package/dist/gateway/static/root/assets/cron-expression-B3B1eqnr.js +2 -0
- package/dist/gateway/static/root/assets/dreaming-settings-DNrdg1Ve.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DX5WRE_t.js → extension-debug-page-DYh402XV.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Buah7Bw-.js → extension-page-Cr_TizrN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DuroLVnf.js → extension-settings-page-BU1KoKRj.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-B5zdl27C.js → fetch-Y7AEX4H3.js} +1 -1
- package/dist/gateway/static/root/assets/format-cron-label-arqgGlVV.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-gT4ZhE7h.js → gateway-config-api-RbMmAOpX.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-C79wkXef.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B3kL8KGY.js → gateway-startup-retry-DiD_Tx4N.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-9paXuHdo.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-AR-fVh0P.js → goals-config-api-DqxVi0p5.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-Cpb21ezg.js → goals-page-CS0R-Af2.js} +2 -2
- package/dist/gateway/static/root/assets/goals-settings-CSuzZ8Ae.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-DXPaYJm3.js +1 -0
- package/dist/gateway/static/root/assets/index-BoKafJIZ.js +191 -0
- package/dist/gateway/static/root/assets/index-CArhCcYn.css +1 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-Dvg53qnd.js +1 -0
- package/dist/gateway/static/root/assets/{logs-page-DefCgF4o.js → logs-page-DLXPcksQ.js} +2 -2
- package/dist/gateway/static/root/assets/{markdown-split-ChbR9LGO.js → markdown-split-CpHxbtWJ.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-B82oP80n.js → media-plugins-SFPQRSxq.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CrDHEbss.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BDF2iyRk.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-CSb_hwig.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-CDknITM3.js → note-image-lightbox-BUYURRgn.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-BsIBSFyZ.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DV3xQsWB.js → preview-open-alternatives-BHz9iWYA.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CwzSovcS.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BODCXnvY.js → save-bar-controls-CefkOlRg.js} +1 -1
- package/dist/gateway/static/root/assets/schedule-field-CmTRoOcE.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-qtfEI6QM.js → schema-form-FMKv1vGu.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-PHmX-NmA.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BRAeKJN4.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BHZKjVcS.js → settings-collapsible-section-BouO6JTi.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-5i35D-J1.js → settings-form-section-D-4lBl6X.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-KKrbFjy8.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-BJ4Gsef5.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-CrUjHPQo.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-B0H63tDv.js → share-preview-page-BDy2btRN.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-B18OBmH5.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-C28-2uKQ.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Bm2ebkwl.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-CRngrlnZ.js +1 -0
- package/dist/gateway/static/root/assets/typed-models-lib-BltBc0b-.js +1 -0
- package/dist/gateway/static/root/assets/{use-channel-catalog-BCjP_VHb.js → use-channel-catalog-CjN-51e6.js} +1 -1
- package/dist/gateway/static/root/assets/user-profile-settings-panel-DJ1dKwZy.js +1 -0
- package/dist/gateway/static/root/assets/utils-B5M5-YvK.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-CeEevm7z.js +1 -0
- package/dist/gateway/static/root/assets/{voice-player-store-BlF9V05n.js → voice-player-store-B7ykUlHM.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-C4PzUQjB.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-BL84_-Ky.js +18 -0
- package/dist/gateway/static/root/index.html +6 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +4 -5
- package/dist/src/agent/agent-manager.js +6 -9
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/agent-scope.js +0 -2
- package/dist/src/agent/agent-scope.js.map +1 -1
- package/dist/src/agent/background-review/prompts.d.ts +2 -2
- package/dist/src/agent/background-review/prompts.js +2 -2
- package/dist/src/agent/background-review/prompts.js.map +1 -1
- package/dist/src/agent/background-review/settings.d.ts +1 -1
- package/dist/src/agent/background-review/settings.js +7 -8
- package/dist/src/agent/background-review/settings.js.map +1 -1
- package/dist/src/agent/bootstrap/bootstrap-cache.d.ts +1 -0
- package/dist/src/agent/bootstrap/bootstrap-cache.js +4 -3
- package/dist/src/agent/bootstrap/bootstrap-cache.js.map +1 -1
- package/dist/src/agent/bootstrap/bootstrap-files.d.ts +4 -0
- package/dist/src/agent/bootstrap/bootstrap-files.js +4 -3
- package/dist/src/agent/bootstrap/bootstrap-files.js.map +1 -1
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +4 -2
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js.map +1 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.d.ts +2 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +17 -16
- package/dist/src/agent/bootstrap/load-bootstrap-files.js.map +1 -1
- package/dist/src/agent/bootstrap/types.d.ts +1 -1
- package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
- package/dist/src/agent/context/workspace.d.ts +4 -2
- package/dist/src/agent/context/workspace.js +5 -4
- package/dist/src/agent/context/workspace.js.map +1 -1
- package/dist/src/agent/embedded/run-for-session.js +106 -15
- package/dist/src/agent/embedded/run-for-session.js.map +1 -1
- package/dist/src/agent/fallback/candidates.d.ts +0 -8
- package/dist/src/agent/fallback/candidates.js +10 -11
- package/dist/src/agent/fallback/candidates.js.map +1 -1
- package/dist/src/agent/index.js +1 -1
- package/dist/src/agent/lifecycle/handlers/compaction.d.ts +1 -3
- package/dist/src/agent/lifecycle/handlers/compaction.js +1 -16
- package/dist/src/agent/lifecycle/handlers/compaction.js.map +1 -1
- package/dist/src/agent/lifecycle/progress.d.ts +0 -1
- package/dist/src/agent/lifecycle/progress.js +1 -6
- package/dist/src/agent/lifecycle/progress.js.map +1 -1
- package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +1 -2
- package/dist/src/agent/lifecycle/timeout-wrapper.js +1 -7
- package/dist/src/agent/lifecycle/timeout-wrapper.js.map +1 -1
- package/dist/src/agent/memory/builtin-memory-store.d.ts +4 -2
- package/dist/src/agent/memory/builtin-memory-store.js +11 -6
- package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
- package/dist/src/agent/memory/builtin-provider.js +36 -7
- package/dist/src/agent/memory/builtin-provider.js.map +1 -1
- package/dist/src/agent/memory/candidate-extractor.d.ts +6 -0
- package/dist/src/agent/memory/candidate-extractor.js +60 -0
- package/dist/src/agent/memory/candidate-extractor.js.map +1 -0
- package/dist/src/agent/memory/manager.d.ts +2 -1
- package/dist/src/agent/memory/manager.js +27 -3
- package/dist/src/agent/memory/manager.js.map +1 -1
- package/dist/src/agent/memory/memory-config.js +3 -0
- package/dist/src/agent/memory/memory-config.js.map +1 -1
- package/dist/src/agent/memory/prefetch-coordinator.js.map +1 -1
- package/dist/src/agent/memory/types.d.ts +27 -4
- package/dist/src/agent/middleware/self-verify.d.ts +0 -1
- package/dist/src/agent/middleware/self-verify.js +0 -2
- package/dist/src/agent/middleware/self-verify.js.map +1 -1
- package/dist/src/agent/models/index.d.ts +1 -1
- package/dist/src/agent/models/manager.d.ts +4 -20
- package/dist/src/agent/models/manager.js +9 -126
- package/dist/src/agent/models/manager.js.map +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.d.ts +0 -4
- package/dist/src/agent/orchestration/agent-orchestrator.js +1 -9
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/prompt/memory/index.d.ts +4 -2
- package/dist/src/agent/prompt/memory/index.js +18 -12
- package/dist/src/agent/prompt/memory/index.js.map +1 -1
- package/dist/src/agent/prompt/sections/memory-skills.js +1 -1
- package/dist/src/agent/prompt/sections/memory-skills.js.map +1 -1
- package/dist/src/agent/prompt/sections/tooling.js +2 -2
- package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.d.ts +0 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +4 -31
- package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
- package/dist/src/agent/prompt/subagent-context.js +1 -1
- package/dist/src/agent/prompt/subagent-context.js.map +1 -1
- package/dist/src/agent/prompt/types.d.ts +1 -1
- package/dist/src/agent/reply/post-compaction-context.js +1 -3
- package/dist/src/agent/reply/post-compaction-context.js.map +1 -1
- package/dist/src/agent/reply/startup-context.js +1 -5
- package/dist/src/agent/reply/startup-context.js.map +1 -1
- package/dist/src/agent/service.d.ts +4 -12
- package/dist/src/agent/service.js +10 -48
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/service.types.d.ts +2 -2
- package/dist/src/agent/session/session-config-service.d.ts +11 -11
- package/dist/src/agent/session/session-config-service.js +14 -14
- package/dist/src/agent/session/session-config-service.js.map +1 -1
- package/dist/src/agent/session/session-inspector.js +3 -2
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/starter-agents.js +12 -12
- package/dist/src/agent/starter-agents.js.map +1 -1
- package/dist/src/agent/tools/automation-tool.d.ts +14 -0
- package/dist/src/agent/tools/automation-tool.js +102 -0
- package/dist/src/agent/tools/automation-tool.js.map +1 -0
- package/dist/src/agent/tools/curated-memory-tool.js +57 -2
- package/dist/src/agent/tools/curated-memory-tool.js.map +1 -1
- package/dist/src/agent/tools/delegate-tool.js +1 -1
- package/dist/src/agent/tools/delegate-tool.js.map +1 -1
- package/dist/src/agent/tools/factory.d.ts +3 -3
- package/dist/src/agent/tools/factory.js +2 -2
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/index.d.ts +1 -1
- package/dist/src/agent/tools/index.js +2 -2
- package/dist/src/agent/tools/web-extract.js +6 -8
- package/dist/src/agent/tools/web-extract.js.map +1 -1
- package/dist/src/agent-manifest/index.js +2 -2
- package/dist/src/agent-manifest/resolver.d.ts +4 -2
- package/dist/src/agent-manifest/resolver.js +6 -3
- package/dist/src/agent-manifest/resolver.js.map +1 -1
- package/dist/src/agent-manifest/schema.d.ts +238 -0
- package/dist/src/agent-manifest/schema.js +16 -5
- package/dist/src/agent-manifest/schema.js.map +1 -1
- package/dist/src/agent-manifest/validator.d.ts +3 -2
- package/dist/src/agent-manifest/validator.js +2 -1
- package/dist/src/agent-manifest/validator.js.map +1 -1
- package/dist/src/ai-assist/text-assist.d.ts +1 -1
- package/dist/src/ai-assist/text-assist.js +56 -0
- package/dist/src/ai-assist/text-assist.js.map +1 -1
- package/dist/src/auth/profiles/store.js.map +1 -1
- package/dist/src/automations/api/routes.d.ts +3 -0
- package/dist/src/automations/api/routes.js +193 -0
- package/dist/src/automations/api/routes.js.map +1 -0
- package/dist/src/automations/domain/index.d.ts +3 -0
- package/dist/src/automations/domain/index.js +3 -0
- package/dist/src/automations/domain/schedule.d.ts +4 -0
- package/dist/src/automations/domain/schedule.js +37 -0
- package/dist/src/automations/domain/schedule.js.map +1 -0
- package/dist/src/automations/domain/types.d.ts +160 -0
- package/dist/src/automations/domain/validation.d.ts +370 -0
- package/dist/src/automations/domain/validation.js +149 -0
- package/dist/src/automations/domain/validation.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-prompt.d.ts +26 -0
- package/dist/src/automations/draft/automation-draft-prompt.js +127 -0
- package/dist/src/automations/draft/automation-draft-prompt.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-service.d.ts +12 -0
- package/dist/src/automations/draft/automation-draft-service.js +135 -0
- package/dist/src/automations/draft/automation-draft-service.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +99 -0
- package/dist/src/automations/draft/automation-draft-validator.js +105 -0
- package/dist/src/automations/draft/automation-draft-validator.js.map +1 -0
- package/dist/src/automations/draft/automation-draft.types.d.ts +40 -0
- package/dist/src/automations/draft/index.d.ts +3 -0
- package/dist/src/automations/draft/index.js +3 -0
- package/dist/src/automations/index.d.ts +3 -0
- package/dist/src/automations/index.js +8 -0
- package/dist/src/automations/product-events.d.ts +5 -0
- package/dist/src/automations/product-events.js +21 -0
- package/dist/src/automations/product-events.js.map +1 -0
- package/dist/src/automations/service/action-executor.d.ts +9 -0
- package/dist/src/automations/service/action-executor.js +157 -0
- package/dist/src/automations/service/action-executor.js.map +1 -0
- package/dist/src/automations/service/automation-service.d.ts +54 -0
- package/dist/src/automations/service/automation-service.js +404 -0
- package/dist/src/automations/service/automation-service.js.map +1 -0
- package/dist/src/automations/service/index.d.ts +2 -0
- package/dist/src/automations/service/index.js +3 -0
- package/dist/src/automations/storage/automation-repository.d.ts +6 -0
- package/dist/src/automations/storage/automation-repository.js +61 -0
- package/dist/src/automations/storage/automation-repository.js.map +1 -0
- package/dist/src/automations/storage/automation-run-repository.d.ts +17 -0
- package/dist/src/automations/storage/automation-run-repository.js +130 -0
- package/dist/src/automations/storage/automation-run-repository.js.map +1 -0
- package/dist/src/automations/storage/index.d.ts +2 -0
- package/dist/src/automations/storage/index.js +3 -0
- package/dist/src/channels/pipeline.d.ts +1 -1
- package/dist/src/channels/pipeline.js.map +1 -1
- package/dist/src/channels/plugin-types.d.ts +3 -0
- package/dist/src/chat-commands/agent-edit.js +0 -1
- package/dist/src/chat-commands/agent-edit.js.map +1 -1
- package/dist/src/chat-commands/builtins/model.js +2 -2
- package/dist/src/chat-commands/builtins/model.js.map +1 -1
- package/dist/src/chat-commands/builtins/thinking.js.map +1 -1
- package/dist/src/cli/command-catalog.js +0 -39
- package/dist/src/cli/command-catalog.js.map +1 -1
- package/dist/src/cli/command-loaders.js +0 -1
- package/dist/src/cli/command-loaders.js.map +1 -1
- package/dist/src/cli/command-manifest.d.ts +1 -1
- package/dist/src/cli/command-manifest.js +1 -5
- package/dist/src/cli/command-manifest.js.map +1 -1
- package/dist/src/cli/commands/agents.js +7 -6
- package/dist/src/cli/commands/agents.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/{cron-health.d.ts → migrations.d.ts} +1 -1
- package/dist/src/cli/commands/doctor/checks/migrations.js +40 -0
- package/dist/src/cli/commands/doctor/checks/migrations.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -0
- package/dist/src/cli/commands/doctor/checks/provider-auth.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +0 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js.map +1 -1
- package/dist/src/cli/commands/doctor/flow.js +2 -2
- package/dist/src/cli/commands/doctor/flow.js.map +1 -1
- package/dist/src/cli/commands/gateway/call.js +2 -2
- package/dist/src/cli/commands/gateway/call.js.map +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/gateway/run-foreground.js +4 -2
- package/dist/src/cli/commands/gateway/run-foreground.js.map +1 -1
- package/dist/src/cli/commands/init.js +33 -14
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/models.js +13 -31
- package/dist/src/cli/commands/models.js.map +1 -1
- package/dist/src/cli/commands/onboard/model.js +17 -10
- package/dist/src/cli/commands/onboard/model.js.map +1 -1
- package/dist/src/cli/commands/onboard.js +2 -2
- package/dist/src/cli/commands/onboard.js.map +1 -1
- package/dist/src/cli/commands/tui.js +26 -4
- package/dist/src/cli/commands/tui.js.map +1 -1
- package/dist/src/cli/index.d.ts +1 -0
- package/dist/src/cli/index.js +10 -5
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/registry.js +1 -1
- package/dist/src/cli/registry.js.map +1 -1
- package/dist/src/cli/templates.d.ts +1 -1
- package/dist/src/cli/templates.js +1 -11
- package/dist/src/cli/templates.js.map +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +2 -0
- package/dist/src/cli/utils/init-workspace-core.js.map +1 -1
- package/dist/src/commands/agents.config.d.ts +9 -0
- package/dist/src/commands/agents.config.js +42 -12
- package/dist/src/commands/agents.config.js.map +1 -1
- package/dist/src/config/agent-profile.js +5 -3
- package/dist/src/config/agent-profile.js.map +1 -1
- package/dist/src/config/agent-typed-models.js +3 -5
- package/dist/src/config/agent-typed-models.js.map +1 -1
- package/dist/src/config/config-surface.d.ts +3 -0
- package/dist/src/config/index.d.ts +0 -1
- package/dist/src/config/index.js +3 -3
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/config/paths.d.ts +8 -10
- package/dist/src/config/paths.js +16 -16
- package/dist/src/config/paths.js.map +1 -1
- package/dist/src/config/profile.js +0 -1
- package/dist/src/config/profile.js.map +1 -1
- package/dist/src/config/rules.js +0 -5
- package/dist/src/config/rules.js.map +1 -1
- package/dist/src/config/schema.d.ts +45 -44
- package/dist/src/config/schema.js +68 -52
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/web-patch.d.ts +0 -12
- package/dist/src/config/web-patch.js +2 -29
- package/dist/src/config/web-patch.js.map +1 -1
- package/dist/src/extensions/api.d.ts +2 -0
- package/dist/src/extensions/api.js +10 -0
- package/dist/src/extensions/api.js.map +1 -1
- package/dist/src/extensions/extension-registry-impl.d.ts +4 -1
- package/dist/src/extensions/extension-registry-impl.js +8 -0
- package/dist/src/extensions/extension-registry-impl.js.map +1 -1
- package/dist/src/extensions/loader.d.ts +3 -3
- package/dist/src/extensions/loader.js +3 -3
- package/dist/src/extensions/loader.js.map +1 -1
- package/dist/src/extensions/sdk/testing.d.ts +2 -0
- package/dist/src/extensions/sdk/testing.js +7 -0
- package/dist/src/extensions/sdk/testing.js.map +1 -1
- package/dist/src/extensions/types/core.d.ts +10 -1
- package/dist/src/extensions/types/index.d.ts +1 -1
- package/dist/src/extensions/types/{phase4.d.ts → registration.d.ts} +2 -2
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agent-builtin-tools.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
- package/dist/src/gateway/agents-admin.d.ts +8 -0
- package/dist/src/gateway/agents-admin.js +63 -34
- package/dist/src/gateway/agents-admin.js.map +1 -1
- package/dist/src/gateway/capability-presets-admin.d.ts +1 -0
- package/dist/src/gateway/capability-presets-admin.js +19 -10
- package/dist/src/gateway/capability-presets-admin.js.map +1 -1
- package/dist/src/gateway/chat-stream/mapper.js +9 -2
- package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +11 -0
- package/dist/src/gateway/dreaming-automation-reconciler.js +105 -0
- package/dist/src/gateway/dreaming-automation-reconciler.js.map +1 -0
- package/dist/src/gateway/global-defaults-admin.d.ts +36 -0
- package/dist/src/gateway/global-defaults-admin.js +146 -0
- package/dist/src/gateway/global-defaults-admin.js.map +1 -0
- package/dist/src/gateway/heartbeat/service.d.ts +0 -2
- package/dist/src/gateway/heartbeat/service.js +0 -7
- package/dist/src/gateway/heartbeat/service.js.map +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +5 -6
- package/dist/src/gateway/hono/lib/config-payload.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
- package/dist/src/gateway/hono/routes/agents.js +33 -1
- package/dist/src/gateway/hono/routes/agents.js.map +1 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +4 -5
- package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +12 -6
- package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +27 -37
- package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
- package/dist/src/gateway/hono/routes/global-defaults.d.ts +3 -0
- package/dist/src/gateway/hono/routes/global-defaults.js +61 -0
- package/dist/src/gateway/hono/routes/global-defaults.js.map +1 -0
- package/dist/src/gateway/hono/routes/home.d.ts +2 -2
- package/dist/src/gateway/hono/routes/home.js +34 -25
- package/dist/src/gateway/hono/routes/home.js.map +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +21 -9
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/memory.js +75 -4
- package/dist/src/gateway/hono/routes/memory.js.map +1 -1
- package/dist/src/gateway/hono/routes/migrations.d.ts +3 -0
- package/dist/src/gateway/hono/routes/migrations.js +35 -0
- package/dist/src/gateway/hono/routes/migrations.js.map +1 -0
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/public-gateway.js +2 -1
- package/dist/src/gateway/hono/routes/public-gateway.js.map +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +14 -0
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/run-loop.js +2 -0
- package/dist/src/gateway/run-loop.js.map +1 -1
- package/dist/src/gateway/security/operator-scopes.js +5 -1
- package/dist/src/gateway/security/operator-scopes.js.map +1 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +4 -4
- package/dist/src/gateway/service/config-coordinator.js +14 -8
- package/dist/src/gateway/service/config-coordinator.js.map +1 -1
- package/dist/src/gateway/service/marketplace-service.d.ts +4 -4
- package/dist/src/gateway/service/marketplace-service.js +11 -7
- package/dist/src/gateway/service/marketplace-service.js.map +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +2 -1
- package/dist/src/gateway/service/sessions-api.js +6 -1
- package/dist/src/gateway/service/sessions-api.js.map +1 -1
- package/dist/src/gateway/service.d.ts +7 -3
- package/dist/src/gateway/service.js +61 -27
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/goals/goal-service.js +45 -4
- package/dist/src/goals/goal-service.js.map +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/migrations/config/default-capability-preset.d.ts +10 -0
- package/dist/src/migrations/config/default-capability-preset.js +135 -0
- package/dist/src/migrations/config/default-capability-preset.js.map +1 -0
- package/dist/src/migrations/index.d.ts +4 -0
- package/dist/src/migrations/index.js +4 -0
- package/dist/src/migrations/registry.d.ts +8 -0
- package/dist/src/migrations/registry.js +18 -0
- package/dist/src/migrations/registry.js.map +1 -0
- package/dist/src/migrations/runner.d.ts +17 -0
- package/dist/src/migrations/runner.js +191 -0
- package/dist/src/migrations/runner.js.map +1 -0
- package/dist/src/migrations/types.d.ts +34 -0
- package/dist/src/notes/service.js +27 -2
- package/dist/src/notes/service.js.map +1 -1
- package/dist/src/providers/index.d.ts +4 -5
- package/dist/src/providers/index.js +16 -16
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/providers/model-registry.d.ts +0 -1
- package/dist/src/providers/model-registry.js +0 -3
- package/dist/src/providers/model-registry.js.map +1 -1
- package/dist/src/routing/resolve-tui-session-key.d.ts +3 -0
- package/dist/src/routing/resolve-tui-session-key.js +14 -3
- package/dist/src/routing/resolve-tui-session-key.js.map +1 -1
- package/dist/src/session/session-workspace.js +2 -7
- package/dist/src/session/session-workspace.js.map +1 -1
- package/dist/src/session/store.js +0 -5
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/session/transcript-outline.d.ts +47 -0
- package/dist/src/session/transcript-outline.js +481 -0
- package/dist/src/session/transcript-outline.js.map +1 -0
- package/dist/src/storage/sqlite/index.d.ts +1 -3
- package/dist/src/storage/sqlite/index.js +2 -4
- package/dist/src/storage/sqlite/memory-index-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/memory-index-repository.js +15 -14
- package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -1
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +44 -1
- package/dist/src/storage/sqlite/memory-records-repository.js +164 -20
- package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/014_memory_record_governance.sql +10 -0
- package/dist/src/storage/sqlite/migrations/015_memory_trace_feedback.sql +4 -0
- package/dist/src/storage/sqlite/migrations/016_automations.sql +47 -0
- package/dist/src/storage/sqlite/migrations/017_automation_run_events.sql +14 -0
- package/dist/src/storage/sqlite/migrations/018_automation_safety.sql +1 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +56 -46
- package/dist/src/tui/backends/embedded-backend.d.ts +9 -0
- package/dist/src/tui/backends/embedded-backend.js +55 -27
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +4 -0
- package/dist/src/tui/backends/gateway-sse-backend.js +30 -3
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/components/tui-header.d.ts +0 -1
- package/dist/src/tui/components/tui-header.js +3 -8
- package/dist/src/tui/components/tui-header.js.map +1 -1
- package/dist/src/tui/tui-backend.d.ts +4 -0
- package/dist/src/tui/tui-commands.d.ts +5 -0
- package/dist/src/tui/tui-commands.js +43 -0
- package/dist/src/tui/tui-commands.js.map +1 -1
- package/dist/src/tui/tui-startup-resources.js +2 -1
- package/dist/src/tui/tui-startup-resources.js.map +1 -1
- package/dist/src/tui/tui-startup-text.js +12 -12
- package/dist/src/tui/tui-startup-text.js.map +1 -1
- package/dist/src/tui/tui-transcript-tree.d.ts +1 -1
- package/dist/src/tui/tui-transcript-tree.js +17 -257
- package/dist/src/tui/tui-transcript-tree.js.map +1 -1
- package/dist/src/tui/tui-types.d.ts +2 -0
- package/dist/src/tui/tui-types.js.map +1 -1
- package/dist/src/tui/tui.js +11 -3
- package/dist/src/tui/tui.js.map +1 -1
- package/dist/src/workflows/domain/index.js +1 -1
- package/dist/src/workflows/domain/run.d.ts +7 -7
- package/dist/src/workflows/domain/run.js.map +1 -1
- package/dist/src/workflows/index.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.d.ts +2 -0
- package/dist/src/workflows/service/workflow-run-service.js +31 -9
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +1 -1
- package/package.json +4 -2
- package/dist/gateway/static/root/assets/agents-C6xgagZd.js +0 -71
- package/dist/gateway/static/root/assets/app-management-settings-panel-CBpLONvG.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-CGcc54yj.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-CUOO-PQk.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-api-XQoMTI0A.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CfqF-kGr.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-BYyRzsex.js +0 -1
- package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DIvEz4NX.js +0 -2
- package/dist/gateway/static/root/assets/createLucideIcon-DPHK1VkS.js +0 -1
- package/dist/gateway/static/root/assets/cron-api-R41aQCX9.js +0 -1
- package/dist/gateway/static/root/assets/cron-dreaming-jobs-nCMWCf0p.js +0 -1
- package/dist/gateway/static/root/assets/cron-page-D97nFqQD.js +0 -3
- package/dist/gateway/static/root/assets/dreaming-settings-Bceaw1PG.js +0 -1
- package/dist/gateway/static/root/assets/format-cron-label-BsotZDO5.js +0 -2
- package/dist/gateway/static/root/assets/format-interval-label-Dn_QKIqb.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-iISWAZRm.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DCUROLMQ.js +0 -1
- package/dist/gateway/static/root/assets/goals-settings-CPAuFwoD.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-config-api-D7bKFEeO.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-CC69vNx0.js +0 -1
- package/dist/gateway/static/root/assets/index-CwhK8qCh.js +0 -122
- package/dist/gateway/static/root/assets/index-CyfhARL-.css +0 -1
- package/dist/gateway/static/root/assets/interval-presets-0DtsnxE0.js +0 -1
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-BPREtN8B.js +0 -1
- package/dist/gateway/static/root/assets/messages-Cf1O9JB0.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-DmKiIihT.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-CxxfLRJZ.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-X2slSx7V.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BvmUWqgu.js +0 -1
- package/dist/gateway/static/root/assets/schedule-field-CgJSCD3B.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-B0yESuuL.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-q2M8RKOo.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-CGozabLD.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-FoOSe6nU.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Cy5zWyYQ.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DaZNFro9.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CnwtUzvw.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-DXs2VmBt.js +0 -1
- package/dist/gateway/static/root/assets/typed-models-lib-4gPuydz_.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DvKiOglO.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-CAVZcONQ.js +0 -18
- package/dist/src/agent/context/workspace-templates/USER.md +0 -24
- package/dist/src/agent/fallback/error.d.ts +0 -22
- package/dist/src/agent/fallback/error.js +0 -32
- package/dist/src/agent/fallback/error.js.map +0 -1
- package/dist/src/agent/fallback/index.d.ts +0 -5
- package/dist/src/agent/fallback/index.js +0 -9
- package/dist/src/agent/fallback/index.js.map +0 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.d.ts +0 -29
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js +0 -76
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js.map +0 -1
- package/dist/src/agent/service/reconcile-dreaming-cron.d.ts +0 -6
- package/dist/src/agent/service/reconcile-dreaming-cron.js +0 -84
- package/dist/src/agent/service/reconcile-dreaming-cron.js.map +0 -1
- package/dist/src/agent/tools/cronjob-tool.d.ts +0 -29
- package/dist/src/agent/tools/cronjob-tool.js +0 -274
- package/dist/src/agent/tools/cronjob-tool.js.map +0 -1
- package/dist/src/cli/commands/cron-cli.d.ts +0 -2
- package/dist/src/cli/commands/cron-cli.js +0 -15
- package/dist/src/cli/commands/cron-cli.js.map +0 -1
- package/dist/src/cli/commands/cron.d.ts +0 -4
- package/dist/src/cli/commands/cron.js +0 -188
- package/dist/src/cli/commands/cron.js.map +0 -1
- package/dist/src/cli/commands/doctor/checks/cron-health.js +0 -35
- package/dist/src/cli/commands/doctor/checks/cron-health.js.map +0 -1
- package/dist/src/cron/execution-types.d.ts +0 -42
- package/dist/src/cron/executor.d.ts +0 -67
- package/dist/src/cron/executor.js +0 -669
- package/dist/src/cron/executor.js.map +0 -1
- package/dist/src/cron/index.d.ts +0 -7
- package/dist/src/cron/index.js +0 -7
- package/dist/src/cron/job-content.d.ts +0 -5
- package/dist/src/cron/job-content.js +0 -15
- package/dist/src/cron/job-content.js.map +0 -1
- package/dist/src/cron/run-log-store.d.ts +0 -12
- package/dist/src/cron/run-log-store.js +0 -58
- package/dist/src/cron/run-log-store.js.map +0 -1
- package/dist/src/cron/schedule.d.ts +0 -10
- package/dist/src/cron/schedule.js +0 -85
- package/dist/src/cron/schedule.js.map +0 -1
- package/dist/src/cron/service.d.ts +0 -58
- package/dist/src/cron/service.js +0 -419
- package/dist/src/cron/service.js.map +0 -1
- package/dist/src/cron/types.d.ts +0 -183
- package/dist/src/cron/validation.d.ts +0 -500
- package/dist/src/cron/validation.js +0 -192
- package/dist/src/cron/validation.js.map +0 -1
- package/dist/src/cron/workflow-run-completion.d.ts +0 -23
- package/dist/src/cron/workflow-run-completion.js +0 -72
- package/dist/src/cron/workflow-run-completion.js.map +0 -1
- package/dist/src/extensions/types/phase4.js +0 -1
- package/dist/src/gateway/hono/routes/cron.d.ts +0 -3
- package/dist/src/gateway/hono/routes/cron.js +0 -109
- package/dist/src/gateway/hono/routes/cron.js.map +0 -1
- package/dist/src/storage/sqlite/cron-job-repository.d.ts +0 -6
- package/dist/src/storage/sqlite/cron-job-repository.js +0 -70
- package/dist/src/storage/sqlite/cron-job-repository.js.map +0 -1
- package/dist/src/storage/sqlite/cron-run-repository.d.ts +0 -5
- package/dist/src/storage/sqlite/cron-run-repository.js +0 -96
- package/dist/src/storage/sqlite/cron-run-repository.js.map +0 -1
- /package/dist/src/{cron → automations/domain}/types.js +0 -0
- /package/dist/src/{config/defaults.d.ts → automations/draft/automation-draft.types.js} +0 -0
- /package/dist/src/{config/defaults.js → extensions/types/registration.js} +0 -0
- /package/dist/src/{cron/execution-types.js → migrations/types.js} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Cf1O9JB0.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-B5zdl27C.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Ai as p,Bi as m,Ca as h,Cs as g,Ct as _,Gi as v,Gr as y,Hi as b,Ii as x,Ji as S,La as C,Li as w,Lr as T,Ls as E,Mi as D,Ms as O,Nn as k,Oa as A,Oo as j,Pn as M,Qa as N,Ra as P,Ro as F,Rr as I,Sa as L,St as ee,Ta as R,Ti as z,Ua as B,Ui as V,Vi as H,_t as U,bo as te,bt as W,dt as G,fa as K,fi as ne,ft as re,gt as ie,hi as ae,ht as oe,io as q,ki as se,li as ce,mi as le,na as ue,no as de,nt as fe,pi as J,pt as pe,rt as me,s as he,ss as ge,tt as _e,ui as ve,us as ye,ut as be,vt as xe,xt as Se,yt as Ce,za as we}from"./index-CwhK8qCh.js";import{a as Te,c as Ee,d as De,f as Oe,l as ke,n as Ae,o as je,r as Me,s as Ne,t as Pe,u as Fe}from"./voice-api-key-field-DvKiOglO.js";import{t as Ie}from"./settings-advanced-gate-q2M8RKOo.js";import{t as Le}from"./settings-collapsible-section-BHZKjVcS.js";import{n as Re,t as ze}from"./settings-form-section-5i35D-J1.js";import{n as Be,t as Ve}from"./save-bar-controls-BODCXnvY.js";var Y=n(),X=e(t(),1),Z=r(),He=()=>c(Oe);function Ue(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var We={saving:!1,savedFlash:!1,error:void 0};function Ge({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.imageModelsSettings,i=!!s(e=>e.token),[c,l]=(0,X.useReducer)(me,We),{saving:u,error:p}=c,m=y(),g=(0,X.useMemo)(()=>new Set(m.map(e=>e.id)),[m]),{data:_=[],isLoading:v}=f(i?He():null,De,{revalidateOnFocus:!1}),b=_.some(e=>e.configured),x=ke(_),S=x.credDirty;(0,X.useEffect)(()=>{if(!S)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[S]);let C=(0,X.useCallback)(async()=>{l({type:`patch`,patch:{saving:!0,error:void 0}});try{x.credDirty&&await x.saveCredentials(r.credentialsSaveError),l({type:`patch`,patch:{savedFlash:!0}}),d({type:`success`,title:r.saved})}catch(e){l({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{saving:!1}})}},[x,r.credentialsSaveError,r.saved]),w=(0,X.useCallback)(()=>{x.credDirty&&x.onDiscardCredentials(),l({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[x]);Be({id:`image-models`,dirty:S,saving:u,save:C,discard:w});let T=(0,X.useMemo)(()=>Ue(r),[r]),E=(0,X.useMemo)(()=>({getApiKey:n.providersSettings.getApiKey,getApiKeyIntl:n.providersSettings.getApiKeyIntl,getApiKeyCn:n.providersSettings.getApiKeyCn}),[n.providersSettings]),D=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,O=e?`w-full text-sm text-fg-muted`:`mx-auto w-full max-w-app-main px-4 py-8 text-sm text-fg-muted`,k=e?`flex w-full items-center gap-2 text-sm text-fg-muted`:`mx-auto flex w-full max-w-app-main items-center gap-2 px-4 py-8 text-sm text-fg-muted`;return i?v?(0,Z.jsxs)(`div`,{className:k,children:[(0,Z.jsx)(q,{className:`size-4 animate-spin`}),` Loading…`]}):(0,Z.jsxs)(`div`,{className:D,children:[e?null:(0,Z.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:w,disabled:!S||u,children:r.discard}),(0,Z.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>void C(),disabled:!S||u,children:[u?(0,Z.jsx)(q,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(A,{className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`ml-1.5`,children:u?r.saving:r.save})]})]})]}),p?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:p}):null,(0,Z.jsx)(Le,{advancedOnly:!0,icon:h,showLabel:r.providersTitle,hideLabel:r.providersTitle,defaultOpen:b,children:_.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.providersEmpty}):(0,Z.jsx)(Fe,{summaries:_,credDraft:x.credDraft,credBaseline:x.credBaseline,credDirty:x.credDirty,credSaving:x.credSaving,credError:x.credError,credSavedFlash:x.credSavedFlash,credNoopFlash:x.credNoopFlash,updateCredRow:x.updateCredRow,onDiscardCredentials:x.onDiscardCredentials,onSaveCredentials:()=>void x.saveCredentials(r.credentialsSaveError),extensionIds:g,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:t,apiKeyLinkLabels:E,messages:T})})]}):(0,Z.jsx)(`div`,{className:O,children:t===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Q=m;function Ke(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function qe(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Je(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function Ye(){return i(H,m)}function Xe(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ze(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var Qe=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],$e=[{id:`whisper-1`,name:`Whisper-1`}],et=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],tt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],nt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],rt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],it=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],at=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],ot=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],st=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],ct=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function lt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function ut(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function dt(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function ft(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function pt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function mt(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function ht(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function gt(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function _t({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.voiceSettings,i=!!s(e=>e.token),[l,u]=(0,X.useReducer)(gt,{form:null,baseline:null}),p=l.form,m=l.baseline,[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),x=(0,X.useRef)(!1),S=(0,X.useRef)({parsed:null,models:void 0}),{data:C,error:w,isLoading:T,mutate:E}=I(i),{data:D,error:O,isLoading:k,mutate:A}=f(i?c(`/api/voice/models`):null,Ae,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=f(i?c(`/api/voice/providers`):null,Me,{revalidateOnFocus:!1}),{data:P,error:L,isLoading:ee}=f(i?c(`/api/voice/stt-providers`):null,Te,{revalidateOnFocus:!1}),R=(0,X.useMemo)(()=>j?.providers??[],[j]),B=(0,X.useMemo)(()=>P?.providers??[],[P]),H=(0,X.useMemo)(()=>C?.payload?.config===void 0?null:je(C.payload.config),[C]),U=(0,X.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]);i?H!==null&&D!==void 0&&!x.current&&(S.current.parsed!==H||S.current.models!==D)&&(S.current={parsed:H,models:D},u({type:`sync`,value:H}),g(D)):(S.current.parsed!==null||S.current.models!==void 0)&&(S.current={parsed:null,models:void 0},u({type:`reset`}),g(null),x.current=!1);let te=!!(i&&(H===null||D===void 0||j===void 0||P===void 0)&&(T||k||N||ee)),W=w instanceof Error?w.message:w?String(w):O instanceof Error?O.message:O?String(O):M instanceof Error?M.message:M?String(M):L instanceof Error?L.message:L?String(L):null,G=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),K=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),ne=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),re=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ie=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ae=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),oe=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),se=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),ce=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),le=(0,X.useCallback)(e=>{x.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]),ue=(0,X.useCallback)(async()=>{if(!(!p||_)){v(!0),b(null);try{await Ne(p),u({type:`saved`,value:p}),x.current=!1,d({type:`success`,title:r.saved})}catch(e){b(e instanceof Error?e.message:r.saveError)}finally{v(!1)}}},[p,_,r.saveError]),de=(0,X.useCallback)(()=>{m&&(x.current=!1,u({type:`discard`}),b(null))},[m]);Be({id:`voice`,dirty:U,saving:_,save:ue,discard:de});let fe=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,J=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;if(!i)return(0,Z.jsxs)(`div`,{className:J,children:[e?null:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.voice}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]});if(te)return(0,Z.jsx)(`div`,{className:J,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(q,{className:`size-4 animate-spin`}),r.loading]})});if(!p||h===null)return(0,Z.jsxs)(`div`,{className:J,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y??W??r.loadError}),(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>{E(),A()},children:r.retry})]});let pe=p.stt,me=p.tts,he=pt(r);return(0,Z.jsxs)(`div`,{className:fe,children:[(0,Z.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,Z.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.voice}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,Z.jsxs)(`a`,{href:z(t,`voice`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,(0,Z.jsx)(F,{className:`size-3.5`})]})]}),e?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,disabled:!U||_,onClick:de,children:r.discard}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!U||_,onClick:()=>void ue(),children:_?r.saving:r.save})]})]}),U&&!e?(0,Z.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(vt,{v:r,stt:pe,tts:me}),(0,Z.jsx)(bt,{v:r,apiKeyLabels:he,stt:pe,models:h,sttProviders:B,updateStt:G,updateSttAlibaba:K,updateSttOpenai:ne,updateSttFallback:re}),(0,Z.jsx)(Tt,{v:r,apiKeyLabels:he,tts:me,models:h,ttsProviders:R,updateTts:ie,updateTtsAlibaba:ae,updateTtsOpenai:oe,updateTtsEdge:se,updateTtsMinimax:ce,updateTtsLocalCli:le})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Z.jsx)(`strong`,{className:`text-accent`,children:r.notes.title}),` `,r.notes.duration]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:r.notes.envVars})]})]})}function vt(e){let t=(0,Y.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${lt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,Z.jsx)(yt,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?dt(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,Z.jsx)(yt,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${ut(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,Z.jsx)(yt,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function yt(e){let t=(0,Y.c)(10),{label:n,value:r,ready:a}=e,o;t[0]===n?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=o);let s=a?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=i(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Z.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function bt(e){let t=(0,Y.c)(46),{v:n,apiKeyLabels:r,stt:a,models:o,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=o?.stt?.alibaba?.length?o.stt.alibaba:Qe,p=o?.stt?.openai?.length?o.stt.openai:$e,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==a||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s=typeof o?.apiKey==`string`?o.apiKey:``,m=typeof o?.model==`string`?o.model:``,x={...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`openai`?a.openai??{}:{},...o??{}},S=(e?.fields??[]).filter(wt),C;t[17]!==a.provider||t[18]!==a.providers||t[19]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[17]=a.provider,t[18]=a.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(N,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==a.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,Z.jsx)(Et,{checked:a.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=a.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=a.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:n.stt.provider}),(0,Z.jsx)(`select`,{className:Ye(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[lt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:n.stt.model}),a.provider===`alibaba`?(0,Z.jsx)(`select`,{className:Ye(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(Ct)}):a.provider===`openai`?(0,Z.jsx)(`select`,{className:Ye(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(St)}):a.provider===`groq`?(0,Z.jsx)(`select`,{className:Ye(),value:m||et[0].id,onChange:e=>w({model:e.target.value}),children:et.map(xt)}):(0,Z.jsx)(`input`,{className:Je(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:n.stt.apiKey}),(0,Z.jsx)(Pe,{kind:`stt`,providerId:a.provider,fieldId:`voice-stt-${a.provider}-api-key`,value:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.provider===`openai`?a.openai?.apiKey??``:s,onChange:e=>{a.provider===`alibaba`?l({apiKey:e}):a.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Ke(a.provider)?` ${Ke(a.provider)}`:``]})]})]}),S.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Z.jsx)(Dt,{field:e,value:mt(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Q},e.key))}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,Z.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,Z.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function xt(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function St(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Ct(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function wt(e){return e.key!==`apiKey`&&e.key!==`model`}function Tt({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:a,updateTts:o,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:tt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:nt,m=r?.tts?.alibaba?.length?r.tts.alibaba:rt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:it,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:at,_=r?.tts?.minimax?.length?r.tts.minimax:ot,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:st,[y,b]=(0,X.useState)(e.tts.test.sampleText),[x,C]=(0,X.useState)({status:`idle`}),w=(0,X.useRef)(null),T=(0,X.useRef)(null),E=(0,X.useCallback)(()=>{w.current?.pause(),w.current=null,T.current&&=(URL.revokeObjectURL(T.current),null)},[]),D=(0,X.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.id)||(e.add(n.id),t.push(n));return t},[a]),O=D.find(e=>e.id===n.provider),k=n.providers?.[n.provider],A={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...k??{}},j=(O?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),M=!!O?.diagnostics.requiresApiKey,N=!!O?.configured||!M,P=n.enabled?N?`ready`:`action`:`muted`,F=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,I=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,X.useEffect)(()=>()=>E(),[E]);let L=(0,X.useCallback)(e=>{o({provider:e}),C({status:`idle`})},[o]),ee=(0,X.useCallback)(async()=>{let t=y.trim();if(!t){C({status:`error`,message:e.tts.test.emptyText});return}E(),C({status:`loading`});try{let r=await Ee({text:t,provider:n.provider,providerConfig:A,...F?{model:F}:{},...I?{voice:I}:{}}),i=Ze(r.audio,r.mimeType);T.current=i;let a=new Audio(i);w.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Xe(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>C({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>C({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),C({status:`playing`,summary:o})}catch(e){E(),C({status:`error`,message:e instanceof Error?e.message:String(e)})}},[F,I,A,E,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),R=(0,X.useCallback)(e=>{o({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,o]),z=(0,X.useCallback)((e,t)=>{let r={[e.key]:t};R(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,R,l,u,c]);return(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(S,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Et,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>o({enabled:e})}),(0,Z.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2.5 text-sm`,P===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:P===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?N?`${e.tts.statusReady} ${ut(n.provider,e)}${I?` · ${I}`:``}`:`${e.tts.statusNeedsSetup} ${ut(n.provider,e)} · ${O?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.trigger}),(0,Z.jsxs)(`select`,{className:Ye(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`off`,children:e.tts.triggerOff}),(0,Z.jsx)(`option`,{value:`inbound`,children:e.tts.triggerInbound}),(0,Z.jsx)(`option`,{value:`tagged`,children:e.tts.triggerTagged}),(0,Z.jsx)(`option`,{value:`always`,children:e.tts.triggerAlways})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.provider}),(0,Z.jsx)(`select`,{className:Ye(),value:n.provider,onChange:e=>L(e.target.value),children:D.map(t=>(0,Z.jsx)(`option`,{value:t.id,children:ut(t.id,e)},t.id))}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[O?.configured?e.tts.configured:O?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${O.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,O?.description??ft(n.provider,e)]})]})]}),(0,Z.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,open:!N||n.provider===`tts-local-cli`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.stt.apiKey}),(0,Z.jsx)(Pe,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,qe(n.provider)?` ${qe(n.provider)}`:``]})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.stt.model}),(0,Z.jsx)(`select`,{className:Ye(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(`select`,{className:Ye(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Z.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Q),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(`select`,{className:Ye(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.preset}),(0,Z.jsxs)(`select`,{className:Ye(),value:``,onChange:e=>{let t=ct.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Z.jsx)(`option`,{value:``,children:e.tts.localCli.presetPlaceholder}),ct.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.id},e.id))]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.command}),(0,Z.jsx)(`input`,{className:i(Je(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.cwd}),(0,Z.jsx)(`input`,{className:i(Je(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Z.jsxs)(`select`,{className:Ye(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`wav`,children:`wav`}),(0,Z.jsx)(`option`,{value:`mp3`,children:`mp3`}),(0,Z.jsx)(`option`,{value:`opus`,children:`opus`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Z.jsx)(`input`,{className:Je(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,j.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:j.map(e=>(0,Z.jsx)(Dt,{field:e,value:mt(A,e),onChange:t=>z(e,t),className:e.type===`textarea`?`sm:col-span-2`:Q},e.key))}):null]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>void ee(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,Z.jsx)(q,{className:`size-4 animate-spin`}):(0,Z.jsx)(we,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Z.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>{E(),C(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:x.status!==`playing`,className:`h-9`,children:[(0,Z.jsx)(K,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Z.jsx)(`textarea`,{className:i(Je(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,Z.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[x.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,x.summary]}):null,x.status===`error`?(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function Et(e){let t=(0,Y.c)(33),{checked:n,title:r,description:a,onLabel:o,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`border-accent/45 bg-accent/10 text-fg shadow-surface dark:bg-accent/15`:`border-edge bg-surface-panel text-fg hover:border-accent/35 hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=i(`group flex w-full items-center justify-between gap-4 rounded-2xl border px-4 py-3 text-left transition-colors`,b,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?o:s,h;t[7]!==p||t[8]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===a?_=t[14]:(_=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:a}),t[13]=a,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,x;t[18]===y?x=t[19]:(x=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=x);let S=n?`translate-x-5`:`translate-x-0.5`,C;t[20]===S?C=t[21]:(C=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,S),t[20]=S,t[21]=C);let w;t[22]===C?w=t[23]:(w=(0,Z.jsx)(`span`,{className:C}),t[22]=C,t[23]=w);let T;t[24]!==x||t[25]!==w?(T=(0,Z.jsx)(`span`,{className:x,"aria-hidden":!0,children:w}),t[24]=x,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==T||t[31]!==d?(E=(0,Z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,T]}),t[27]=n,t[28]=l,t[29]=v,t[30]=T,t[31]=d,t[32]=E):E=t[32],E}function Dt(e){let t=(0,Y.c)(36),{field:n,value:r,onChange:a,className:o}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===o?e=t[1]:(e=i(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,Z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,Z.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==a?(f=e=>a(ht(n,e.target.checked)),t[9]=n,t[10]=a,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===o?u=t[20]:(u=i(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,Z.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==o||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==a?(f=n.type===`select`?(0,Z.jsx)(`select`,{id:s,className:Ye(),value:l,required:n.required,onChange:e=>a(ht(n,e.target.value)),children:(n.options??[]).map(Ot)}):n.type===`textarea`?(0,Z.jsx)(`textarea`,{id:s,className:i(Je(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(ht(n,e.target.value))}):n.type===`password`?(0,Z.jsx)(D,{id:s,className:o,value:l,onChange:e=>a(ht(n,e)),placeholder:n.placeholder,labels:se}):(0,Z.jsx)(`input`,{id:s,className:Je(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(ht(n,e.target.value))}),t[23]=o,t[24]=n,t[25]=l,t[26]=s,t[27]=a,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,Z.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Ot(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function kt(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function At(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),T()}async function jt(e){let t=await l(c(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Mt(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Nt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function Pt(){return i(H,m)}var Ft=[`brave`,`tavily`,`bing`,`searxng`];function It(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Lt=_e();function Rt({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.webSearchSettings,c=n.logs,l=!!s(e=>e.token),[u,f]=(0,X.useReducer)(Lt,{form:null,baseline:null}),m=u.form,h=u.baseline,[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),x=(0,X.useRef)(!1),S=(0,X.useRef)(null),{data:w,error:T,isLoading:E,mutate:D}=I(l);fe({enabled:l,parsed:(0,X.useMemo)(()=>w?.payload?.config===void 0?null:kt(w.payload.config),[w]),dirty:x.current,trackedParsedRef:S,dispatch:f,onResetDirty:()=>{x.current=!1}});let O=!!(l&&E&&w===void 0&&!T),k=T instanceof Error?T.message:T?String(T):null,A=(0,X.useMemo)(()=>!m||!h?!1:JSON.stringify(m)!==JSON.stringify(h),[m,h]),j=(0,X.useCallback)(e=>{x.current=!0,f({type:`patch`,patch:e})},[]),M=(0,X.useCallback)(async()=>{if(!(!m||_)){v(!0),b(null);try{await At(m),x.current=!1,f({type:`saved`,value:m}),d({type:`success`,title:r.saved})}catch(e){b(e instanceof Error?e.message:r.saveError)}finally{v(!1)}}},[m,_,r.saveError]),N=(0,X.useCallback)(()=>{h&&(x.current=!1,f({type:`discard`}),b(null))},[h]);Be({id:`search`,dirty:A,saving:_,save:M,discard:N});let P=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,L=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;return l?O?(0,Z.jsxs)(`div`,{className:i(L,`items-center`),children:[(0,Z.jsx)(q,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading})]}):m?(0,Z.jsxs)(`div`,{className:P,children:[(0,Z.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,Z.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,Z.jsxs)(`a`,{href:z(t,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,(0,Z.jsx)(F,{className:`size-3.5`})]})]}),e?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,disabled:!A||_,onClick:N,children:r.discard}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!A||_,onClick:()=>void M(),children:_?r.saving:r.save})]})]}),A&&!e?(0,Z.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null,(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{icon:R,title:r.sectionRegion,subtitle:r.sectionRegionHint}),(0,Z.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Z.jsx)(Mt,{label:r.regionLabel,description:r.regionDesc,children:(0,Z.jsxs)(`select`,{className:Pt(),value:m.regionMode,onChange:e=>j({regionMode:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`auto`,children:r.regionAuto}),(0,Z.jsx)(`option`,{value:`cn`,children:r.regionCn}),(0,Z.jsx)(`option`,{value:`global`,children:r.regionGlobal})]})})})]}),(0,Z.jsx)(Ie,{children:(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{icon:g,title:r.sectionBlocklist,subtitle:r.sectionBlocklistHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:m.blocklistEnabled,onChange:e=>j({blocklistEnabled:e.target.checked})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:r.blocklistEnabled}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.blocklistEnabledDesc})]})]}),(0,Z.jsx)(Mt,{label:r.blocklistDomains,description:r.blocklistDomainsDesc,children:(0,Z.jsx)(`textarea`,{className:i(Nt(),`min-h-[6rem] font-mono text-xs`),value:m.blocklistDomains.join(`
|
|
2
|
-
`),placeholder:r.blocklistDomainsPlaceholder,disabled:!m.blocklistEnabled,onChange:e=>{j({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Re,{icon:R,title:r.sectionSearch,subtitle:r.sectionSearchHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Z.jsx)(Mt,{label:r.maxResultsLabel,description:r.maxResultsDesc,children:(0,Z.jsx)(`input`,{type:`number`,min:1,max:50,className:Nt(),value:m.maxResults,onChange:e=>j({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.providersTitle}),m.providers.map((e,t)=>(0,Z.jsx)(zt,{row:e,providerIndex:t,labels:r,secretLabels:p(n.providersSettings),onChange:e=>{let n=[...m.providers];n[t]=e,j({providers:n})},onRemove:()=>{j({providers:m.providers.filter((e,n)=>n!==t)})}},`${e.type}:${e.url}:${e.apiKey}:${e.disabled}`)),(0,Z.jsxs)(V,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>j({providers:[...m.providers,It()]}),children:[(0,Z.jsx)(C,{className:`size-4`}),r.addProvider]})]})]})]}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r.footerHint})]}):(0,Z.jsxs)(`div`,{className:L,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y??k??r.loadError}),(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void D(),children:c.refresh})]}):(0,Z.jsxs)(`div`,{className:L,children:[e?null:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function zt(e){let t=(0,Y.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>jt(r).then(Bt),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(Pt(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==s||t[4]!==n?(p=e=>s({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=s,t[4]=n,t[5]=p):p=t[5];let m;t[6]===a.providerTypes?m=t[7]:(m=Ft.map(e=>(0,Z.jsx)(`option`,{value:e,children:a.providerTypes[e]},e)),t[6]=a.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,Z.jsx)(`select`,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==n?(g=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:g}),t[15]=n.disabled,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==a.disabled||t[19]!==_?(v=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,a.disabled]}),t[18]=a.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(ue,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=(0,Z.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:c,children:y}),t[22]=c,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,b]}),t[24]=b,t[25]=v,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==h?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,x]}),t[27]=x,t[28]=h,t[29]=S):S=t[29];let C;t[30]!==a.urlDesc||t[31]!==a.urlLabel||t[32]!==s||t[33]!==n?(C=n.type===`searxng`?(0,Z.jsx)(Mt,{label:a.urlLabel,description:a.urlDesc,children:(0,Z.jsx)(`input`,{type:`url`,className:Nt(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>s({...n,url:e.target.value})})}):null,t[30]=a.urlDesc,t[31]=a.urlLabel,t[32]=s,t[33]=n,t[34]=C):C=t[34];let w;t[35]!==s||t[36]!==n?(w=e=>s({...n,apiKey:e}),t[35]=s,t[36]=n,t[37]=w):w=t[37];let T;t[38]!==a.keyPlaceholder||t[39]!==a.keyPlaceholderMasked||t[40]!==a.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==o||t[44]!==w?(T=(0,Z.jsx)(D,{value:n.apiKey,onChange:w,placeholder:a.keyPlaceholder,labels:o,reveal:u,loadFailedLabel:a.saveError,notInConfigFile:a.keyPlaceholderMasked}),t[38]=a.keyPlaceholder,t[39]=a.keyPlaceholderMasked,t[40]=a.saveError,t[41]=u,t[42]=n.apiKey,t[43]=o,t[44]=w,t[45]=T):T=t[45];let E;t[46]!==a.apiKeyDesc||t[47]!==a.apiKeyLabel||t[48]!==T?(E=(0,Z.jsx)(Mt,{label:a.apiKeyLabel,description:a.apiKeyDesc,children:T}),t[46]=a.apiKeyDesc,t[47]=a.apiKeyLabel,t[48]=T,t[49]=E):E=t[49];let O;return t[50]!==S||t[51]!==C||t[52]!==E?(O=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel/60 p-4 dark:border-edge-subtle`,children:[S,C,E]}),t[50]=S,t[51]=C,t[52]=E,t[53]=O):O=t[53],O}function Bt(e){return e.apiKey??null}var Vt=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function Ht(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function Ut(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function Wt(){let e=await u(c(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(Ht(t)||`HTTP ${e.status}`);return{...t.payload,config:Ut(t.payload.config)}}async function Gt(e){let t=await u(c(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(Ht(n)||`HTTP ${t.status}`);return await Se(),n.payload}function Kt(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}function qt(){let e=(0,Y.c)(31),t=s(Qt),n=!!t,{data:r,isLoading:i}=I(n),a;e[0]===n?a=e[1]:(a=n?c(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},e[4]=l):l=e[4];let{data:u,isLoading:d}=f(a,o,l),p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[5]=p):p=e[5];let{data:m,isLoading:h}=f(n?ee:null,Zt,p),g;e[6]===m?g=e[7]:(g=m===void 0?[]:m,e[6]=m,e[7]=g);let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=f(n?W:null,Xt,v),b;bb0:{if(!u||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==u||e[12]!==_?(t=ie(u,xe(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=u,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=Ut(y.config),e[14]=y.config,e[15]=t),S=t}let C=S,w;if(e[16]!==x||e[17]!==C||e[18]!==u||e[19]!==_){w=[];let t=new Set((u??[]).filter(Yt).map(Jt)),n;e[21]===C?n=e[22]:(n=new Set(C?Object.keys(C.providers):[]),e[21]=C,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?C.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;w.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(C){let t;e[23]===C.providers?t=e[24]:(t=Object.entries(C.providers),e[23]=C.providers,e[24]=t);for(let[e,n]of t)w.some(t=>t.id===e)||w.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=C,e[18]=u,e[19]=_,e[20]=w}else w=e[20];let T=w,E=i||d||h,D;return e[25]!==x||e[26]!==T||e[27]!==C||e[28]!==E||e[29]!==_?(D={cards:T,loading:E,builtinRows:x,customConfig:C,allModels:_},e[25]=x,e[26]=T,e[27]=C,e[28]=E,e[29]=_,e[30]=D):D=e[30],D}function Jt(e){return e.id}function Yt(e){return e.configured}function Xt(){return Wt()}function Zt(){return _()}function Qt(e){return e.token}function $t(e){let t=(0,Y.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=qt();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-surface-hover`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(tn)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(en),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(C,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge-subtle bg-surface-panel/40 px-6 py-10 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,Z.jsx)(C,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,Z.jsx)(nn,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function en(e){return e.configured}function tn(e){return(0,Z.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function nn(e){let t=(0,Y.c)(28),{card:n,labels:r,onManage:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=i(`group relative flex flex-col justify-between rounded-2xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=s);let c;t[3]!==n.isCustom||t[4]!==r.custom?(c=n.isCustom?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=c):c=t[5];let l;t[6]!==s||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(ge,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(L,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==p?(g=(0,Z.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==a||t[25]!==g||t[26]!==d?(_=(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:o,children:[d,g]}),t[24]=a,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}async function rn(e){let t=await u(c(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function an(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function on(e,t){let n=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function sn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function cn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function ln(e){let t=await u(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var un=[`common`,`specialty`,`enterprise`,`oauth`,`extension`];function dn(e){let t=new Map;for(let e of un)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}var fn={ollama:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`},lmstudio:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`},openrouter:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``},zhipuCn:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`},zaiGeneral:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`}};function pn(e){return e===`openrouter`?`openrouter`:e===`zhipuCn`?`zhipu-cn`:e===`zaiGeneral`?`zai`:e}var mn=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function hn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function gn(){return i(H,m)}function _n(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function vn(e){return e===`text,image`?[`text`,`image`]:[`text`]}function yn(e){let t=(0,Y.c)(21),{open:n,onOpenChange:r,builtinRows:a,customConfig:o,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,X.useState)(u),[p,m]=(0,X.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let g=h,_;t[3]!==g||t[4]!==l?(_=()=>{l(),g(!1)},t[3]=g,t[4]=l,t[5]=_):_=t[5];let v=_,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(ne,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,k),t[7]=b):b=t[7];let x;t[8]!==a||t[9]!==o||t[10]!==v||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.providerId||t[15]!==d.type?(x=(0,Z.jsxs)(J,{children:[y,(0,Z.jsx)(ve,{className:b,children:d.type===`pick`?(0,Z.jsx)(xn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>f({type:`builtin`,providerId:e}),onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,Z.jsx)(Sn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v}):(0,Z.jsx)(Tn,{customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v})})]}),t[8]=a,t[9]=o,t[10]=v,t[11]=s,t[12]=c,t[13]=p,t[14]=d.providerId,t[15]=d.type,t[16]=x):x=t[16];let S;return t[17]!==g||t[18]!==n||t[19]!==x?(S=(0,Z.jsx)(le,{open:n,onOpenChange:g,children:x}),t[17]=g,t[18]=n,t[19]=x,t[20]=S):S=t[20],S}function bn(e){let t=(0,Y.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function xn(e){let t=(0,Y.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:a,labels:o,onPickBuiltin:s,onPickCustom:c}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=be[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,p;t[7]===f?p=t[8]:(p=dn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===o.step1Title?h=t[10]:(h=(0,Z.jsx)(ae,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=h);let g;t[11]===o.close?g=t[12]:(g=(0,Z.jsx)(bn,{label:o.close}),t[11]=o.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(R,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]===a?y=t[18]:(y=e=>a(e.target.value),t[17]=a,t[18]=y);let x=o.searchPlaceholder,S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,b),t[19]=S):S=t[19];let C;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==y?(C=(0,Z.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[v,(0,Z.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:x,autoComplete:`off`,autoFocus:!0,className:S})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=y,t[23]=C):C=t[23];let T;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(T=u?null:(0,Z.jsxs)(`button`,{type:`button`,onClick:c,className:i(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w.press),children:[(0,Z.jsx)(j,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.addCustom}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,Z.jsx)(ye,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=o.addCustom,t[25]=o.customDescription,t[26]=c,t[27]=u,t[28]=T):T=t[28];let E;t[29]!==f.length||t[30]!==m||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(E=f.length===0?(0,Z.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:un.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:o.categories[e]??e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:i(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w.press),children:[(0,Z.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,Z.jsx)(ge,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=o.categories,t[32]=o.noResults,t[33]=s,t[34]=E):E=t[34];let D;t[35]!==T||t[36]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[T,E]}),t[35]=T,t[36]=E,t[37]=D):D=t[37];let O;return t[38]!==C||t[39]!==D||t[40]!==_?(O=(0,Z.jsxs)(Z.Fragment,{children:[_,C,D]}),t[38]=C,t[39]=D,t[40]=_,t[41]=O):O=t[41],O}function Sn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=be[e],[u,d]=(0,X.useState)(``),[f,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),y=(0,X.useRef)(null),x=a(r).providersSettings,S=p(x),C=(0,X.useMemo)(()=>G(e,r),[e,r]),T=c?.supportsApiKey!==!1,E=c?.supportsOAuth===!0,[O,k]=(0,X.useState)(null),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(`idle`),[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[ee,R]=(0,X.useState)(``),z=M===`waiting`||M===`waiting_code`;(0,X.useEffect)(()=>{if(!O||!z)return;let e=window.setInterval(()=>{(async()=>{try{let t=await an(O);t.status===`waiting_auth`||t.status===`waiting_code`?(N(t.status===`waiting_code`?`waiting_code`:`waiting`),j(t.message??null),F(t.authUrl??null),L(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),N(`success`),j(t.message??x.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),N(`error`),j(t.error??t.message??x.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[O,z,s,x.revokeFailed,x.saved]),(0,X.useEffect)(()=>()=>{O&&cn(O).catch(()=>{})},[O]);let B=async()=>{N(`waiting`),j(x.oauthStarting),g(null);try{k((await rn(e)).sessionId)}catch(e){N(`error`),j(e instanceof Error?e.message:x.revokeFailed)}},H=async()=>{if(O){try{await sn(O)}catch{}N(`idle`),j(null),k(null),F(null),L(null)}},te=async()=>{if(!(!O||!ee.trim()))try{await on(O,ee.trim()),R(``),j(x.oauthProcessingCode)}catch(e){N(`error`),j(e instanceof Error?e.message:x.revokeFailed)}},W=async()=>{let t=u.trim();if(!(!t||!T)){m(!0),g(null);try{await U({[e]:t}),v(!0),window.setTimeout(s,600)}catch(e){g(e instanceof Error?e.message:n.saveError)}finally{m(!1)}}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),"aria-label":n.back,children:(0,Z.jsx)(ye,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(ae,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,Z.jsx)(bn,{label:n.close})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,T?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Z.jsx)(D,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:S,inputRef:y,onKeyDown:e=>{e.key===`Enter`&&W()}})]}):null,E?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:x.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:x.oauthHint})]}),(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:z,onClick:()=>void B(),children:[z?(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,x.oauth]})]}),A?(0,Z.jsx)(`p`,{className:i(`text-xs`,M===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:A}):null,M===`waiting`||M===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P?(0,Z.jsxs)(`a`,{href:P,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[x.openAuthPage,(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void H(),children:x.cancelOAuth})]}):null,I?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,M===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:ee,onChange:e=>R(e.target.value),onKeyDown:e=>e.key===`Enter`&&void te(),placeholder:x.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,onClick:()=>void te(),children:x.submitCode})]}):null]}):null,C.length>0&&T?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[re(e,n),(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,h?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),T?(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!u.trim()||f||_,onClick:()=>void W(),children:_?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Cn(e=`custom`){if(e!==`custom`&&fn[e]){let t=fn[e];return{preset:e,providerId:pn(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function wn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:fn[t.key]?{...Cn(t.key),modelIds:e.modelIds}:e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Tn({customConfig:e,labels:t,language:n,onBack:r,onSaved:o}){let[s,c]=(0,X.useReducer)(wn,void 0,()=>Cn()),[l,u]=(0,X.useState)(!1),d=p(a(n).providersSettings),{preset:f,providerId:m,baseUrl:h,api:g,apiKey:_,modelIds:y,error:x}=s,S=async()=>{let n=m.trim(),r=h.trim();if(!n){c({type:`setError`,value:t.providerIdRequired});return}if(!r){c({type:`setError`,value:t.baseUrlRequired});return}let i=y.map(e=>e.trim()).filter(Boolean);u(!0),c({type:`setError`,value:null});try{let t=e?.providers??{},a={baseUrl:r,api:g,apiKey:_.trim()||void 0,models:i.map(e=>({id:e}))};await Gt({providers:{...t,[n]:a}}),o()}catch(e){c({type:`setError`,value:e instanceof Error?e.message:t.saveError})}finally{u(!1)}},T=m.trim()&&h.trim();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),"aria-label":t.back,children:(0,Z.jsx)(ye,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(ae,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:t.step2CustomTitle}),(0,Z.jsx)(bn,{label:t.close})]}),(0,Z.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.customDescription}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:t.presetLabel}),(0,Z.jsxs)(`select`,{id:`custom-preset`,value:f,onChange:e=>c({type:`applyPreset`,key:e.target.value}),className:gn(),children:[(0,Z.jsx)(`option`,{value:`custom`,children:t.presetCustom}),(0,Z.jsx)(`option`,{value:`ollama`,children:t.presetOllama}),(0,Z.jsx)(`option`,{value:`lmstudio`,children:t.presetLmStudio}),(0,Z.jsx)(`option`,{value:`openrouter`,children:t.presetOpenRouter}),(0,Z.jsx)(`option`,{value:`zhipuCn`,children:t.presetZhipuCn}),(0,Z.jsx)(`option`,{value:`zaiGeneral`,children:t.presetZaiGeneral})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:t.providerIdLabel}),(0,Z.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:m,onChange:e=>c({type:`setProviderId`,value:e.target.value}),placeholder:t.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:t.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:h,onChange:e=>c({type:`setBaseUrl`,value:e.target.value}),placeholder:t.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:t.apiTypeLabel}),(0,Z.jsx)(`select`,{id:`custom-api-type`,value:g,onChange:e=>c({type:`setApi`,value:e.target.value}),className:gn(),children:Vt.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:t.apiKeyLabel}),(0,Z.jsx)(D,{id:`custom-api-key`,value:_,onChange:e=>c({type:`setApiKey`,value:e}),placeholder:t.apiKeyPlaceholder,labels:d})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.modelIdLabel}),y.map((e,n)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>c({type:`updateModelId`,index:n,value:e.target.value}),placeholder:t.modelIdPlaceholder,className:i(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),y.length>1?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c({type:`removeModelSlot`,index:n}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,w.press),children:(0,Z.jsx)(v,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${n}`)),(0,Z.jsxs)(V,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>c({type:`addModelSlot`}),children:[(0,Z.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),t.addModel]})]}),x?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:r,children:t.cancel}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!T||l,onClick:()=>void S(),children:l?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t.saving]}):t.save})]})]})}function En(e){let t=(0,Y.c)(156),{model:n,isNew:r,providerId:a,onSave:o,onClose:s,m:c}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:Kt(``),t[0]=n,t[1]=l);let[u,d]=(0,X.useState)(l),[f,p]=(0,X.useState)(Dn),m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=m):m=t[2];let h=m,g;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(g=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,c.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,c.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,c.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=c.modelIdRequired,t[7]=c.mustBePositive,t[8]=g):g=t[8];let _=g,y;t[9]!==u||t[10]!==s||t[11]!==o||t[12]!==_?(y=()=>{if(!_())return;let e=(u.id||``).trim();o({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),s()},t[9]=u,t[10]=s,t[11]=o,t[12]=_,t[13]=y):y=t[13];let b=y,S=u,C;t[14]===S?C=t[15]:(C=_n(S),t[14]=S,t[15]=C);let w=C,T=r?c.addModelTitle:c.editModelTitle,E;t[16]===T?E=t[17]:(E=(0,Z.jsx)(ae,{className:`text-base font-semibold text-fg`,children:T}),t[16]=T,t[17]=E);let D;t[18]!==c.modelProviderLabel||t[19]!==a?(D=a?(0,Z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[c.modelProviderLabel,`: `,a]}):null,t[18]=c.modelProviderLabel,t[19]=a,t[20]=D):D=t[20];let O;t[21]!==E||t[22]!==D?(O=(0,Z.jsxs)(`div`,{children:[E,D]}),t[21]=E,t[22]=D,t[23]=O):O=t[23];let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=i(x,`p-1.5 hover:bg-surface-base`),t[24]=k):k=t[24];let A;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(v,{className:`size-4`}),t[25]=A):A=t[25];let j;t[26]===c.close?j=t[27]:(j=(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:k,"aria-label":c.close,children:A})}),t[26]=c.close,t[27]=j);let M;t[28]!==O||t[29]!==j?(M=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[O,j]}),t[28]=O,t[29]=j,t[30]=M):M=t[30];let N;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=N):N=t[31];let P;t[32]===c.modelId?P=t[33]:(P=(0,Z.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,N]}),t[32]=c.modelId,t[33]=P);let F;t[34]===f?F=t[35]:(F=i(hn(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=F);let I=u.id||``,L;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>h(`id`,e.target.value),t[36]=L):L=t[36];let ee=!r,R;t[37]!==F||t[38]!==I||t[39]!==ee?(R=(0,Z.jsx)(`input`,{className:F,value:I,onChange:L,placeholder:`e.g. llama3.1:8b`,disabled:ee}),t[37]=F,t[38]=I,t[39]=ee,t[40]=R):R=t[40];let z;t[41]===f?z=t[42]:(z=f.has(`id`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=z);let B;t[43]!==P||t[44]!==R||t[45]!==z?(B=(0,Z.jsxs)(`div`,{children:[P,R,z]}),t[43]=P,t[44]=R,t[45]=z,t[46]=B):B=t[46];let H;t[47]===c.displayName?H=t[48]:(H=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=H);let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=hn(),t[49]=U):U=t[49];let te=u.name||``,W;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>h(`name`,e.target.value),t[50]=W):W=t[50];let G;t[51]===te?G=t[52]:(G=(0,Z.jsx)(`input`,{className:U,value:te,onChange:W}),t[51]=te,t[52]=G);let K;t[53]!==H||t[54]!==G?(K=(0,Z.jsxs)(`div`,{children:[H,G]}),t[53]=H,t[54]=G,t[55]=K):K=t[55];let ne;t[56]===c.inputTypes?ne=t[57]:(ne=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=ne);let re;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(re=gn(),t[58]=re):re=t[58];let ie;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>h(`input`,vn(e.target.value)),t[59]=ie):ie=t[59];let oe;t[60]===c?oe=t[61]:(oe=mn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=oe);let q;t[62]!==w||t[63]!==oe?(q=(0,Z.jsx)(`select`,{className:re,value:w,onChange:ie,children:oe}),t[62]=w,t[63]=oe,t[64]=q):q=t[64];let se;t[65]!==ne||t[66]!==q?(se=(0,Z.jsxs)(`div`,{children:[ne,q]}),t[65]=ne,t[66]=q,t[67]=se):se=t[67];let le=u.reasoning||!1,ue;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>h(`reasoning`,e.target.checked),t[68]=ue):ue=t[68];let de;t[69]===le?de=t[70]:(de=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[69]=le,t[70]=de);let fe;t[71]!==c.reasoning||t[72]!==de?(fe=(0,Z.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,c.reasoning]}),t[71]=c.reasoning,t[72]=de,t[73]=fe):fe=t[73];let J;t[74]!==se||t[75]!==fe?(J=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[se,fe]}),t[74]=se,t[75]=fe,t[76]=J):J=t[76];let pe;t[77]===c.contextWindow?pe=t[78]:(pe=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=pe);let me;t[79]===f?me=t[80]:(me=i(hn(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=me);let he=u.contextWindow??128e3,ge;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=ge):ge=t[81];let _e;t[82]!==me||t[83]!==he?(_e=(0,Z.jsx)(`input`,{type:`number`,min:1,className:me,value:he,onChange:ge}),t[82]=me,t[83]=he,t[84]=_e):_e=t[84];let ve;t[85]===f?ve=t[86]:(ve=f.has(`contextWindow`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=ve);let ye;t[87]!==pe||t[88]!==_e||t[89]!==ve?(ye=(0,Z.jsxs)(`div`,{children:[pe,_e,ve]}),t[87]=pe,t[88]=_e,t[89]=ve,t[90]=ye):ye=t[90];let be;t[91]===c.maxOutputTokens?be=t[92]:(be=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=be);let xe;t[93]===f?xe=t[94]:(xe=i(hn(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=xe);let Se=u.maxTokens??16384,Ce;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Ce):Ce=t[95];let we;t[96]!==xe||t[97]!==Se?(we=(0,Z.jsx)(`input`,{type:`number`,min:1,className:xe,value:Se,onChange:Ce}),t[96]=xe,t[97]=Se,t[98]=we):we=t[98];let Te;t[99]===f?Te=t[100]:(Te=f.has(`maxTokens`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=Te);let Ee;t[101]!==be||t[102]!==we||t[103]!==Te?(Ee=(0,Z.jsxs)(`div`,{children:[be,we,Te]}),t[101]=be,t[102]=we,t[103]=Te,t[104]=Ee):Ee=t[104];let De;t[105]!==ye||t[106]!==Ee?(De=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ye,Ee]}),t[105]=ye,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]===c.costSection?Oe=t[109]:(Oe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Oe);let ke;t[110]===c.costInput?ke=t[111]:(ke=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=ke);let Ae;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=hn(),t[112]=Ae):Ae=t[112];let je=u.cost?.input??0,Me;t[113]===u.cost?Me=t[114]:(Me=e=>h(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[113]=u.cost,t[114]=Me);let Ne;t[115]!==je||t[116]!==Me?(Ne=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ae,value:je,onChange:Me}),t[115]=je,t[116]=Me,t[117]=Ne):Ne=t[117];let Pe;t[118]!==ke||t[119]!==Ne?(Pe=(0,Z.jsxs)(`div`,{children:[ke,Ne]}),t[118]=ke,t[119]=Ne,t[120]=Pe):Pe=t[120];let Fe;t[121]===c.costOutput?Fe=t[122]:(Fe=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Fe);let Ie;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=hn(),t[123]=Ie):Ie=t[123];let Le=u.cost?.output??0,Re;t[124]===u.cost?Re=t[125]:(Re=e=>h(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[124]=u.cost,t[125]=Re);let ze;t[126]!==Le||t[127]!==Re?(ze=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ie,value:Le,onChange:Re}),t[126]=Le,t[127]=Re,t[128]=ze):ze=t[128];let Be;t[129]!==Fe||t[130]!==ze?(Be=(0,Z.jsxs)(`div`,{children:[Fe,ze]}),t[129]=Fe,t[130]=ze,t[131]=Be):Be=t[131];let Ve;t[132]!==Pe||t[133]!==Be?(Ve=(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Pe,Be]}),t[132]=Pe,t[133]=Be,t[134]=Ve):Ve=t[134];let He;t[135]!==Oe||t[136]!==Ve?(He=(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Oe,Ve]}),t[135]=Oe,t[136]=Ve,t[137]=He):He=t[137];let Ue;t[138]!==B||t[139]!==K||t[140]!==J||t[141]!==De||t[142]!==He?(Ue=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[B,K,J,De,He]}),t[138]=B,t[139]=K,t[140]=J,t[141]=De,t[142]=He,t[143]=Ue):Ue=t[143];let We;t[144]===c.cancel?We=t[145]:(We=(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(V,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=We);let Ge=r?c.addModelConfirm:c.saveModelConfirm,Q;t[146]!==b||t[147]!==Ge?(Q=(0,Z.jsx)(V,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:b,children:Ge}),t[146]=b,t[147]=Ge,t[148]=Q):Q=t[148];let Ke;t[149]!==We||t[150]!==Q?(Ke=(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[We,Q]}),t[149]=We,t[150]=Q,t[151]=Ke):Ke=t[151];let qe;return t[152]!==M||t[153]!==Ue||t[154]!==Ke?(qe=(0,Z.jsxs)(Z.Fragment,{children:[M,Ue,Ke]}),t[152]=M,t[153]=Ue,t[154]=Ke,t[155]=qe):qe=t[155],qe}function Dn(){return new Map}function On(e){let t=(0,Y.c)(16),{open:n,onOpenChange:r,providerId:a,model:o,isNew:s,onSave:c,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(ne,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,M)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,k,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==s||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==c||t[7]!==n||t[8]!==a?(f=n?(0,Z.jsx)(En,{model:o,isNew:s,providerId:a,onSave:c,onClose:()=>r(!1),m:l},`${a??`none`}-${o?.id??`new`}`):null,t[2]=s,t[3]=l,t[4]=o,t[5]=r,t[6]=c,t[7]=n,t[8]=a,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,Z.jsxs)(J,{children:[u,(0,Z.jsx)(ve,{className:d,onOpenAutoFocus:kn,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,Z.jsx)(le,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function kn(e){return e.preventDefault()}function An(e){let t=(0,Y.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Ce(n).then(jn),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,Z.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,Z.jsx)(D,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function jn(e){return e.apiKey??null}function Mn(e){let t=(0,Y.c)(16),{open:n,onOpenChange:r,providerId:a,isCustom:o,builtinRows:s,customConfig:c,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(ne,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,k),t[1]=m):m=t[1];let h;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==o||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==a?(h=(0,Z.jsxs)(J,{children:[p,(0,Z.jsx)(ve,{className:m,children:o?(0,Z.jsx)(Pn,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,Z.jsx)(Nn,{providerId:a,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=o,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=a,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,Z.jsx)(le,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function Nn({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=be[e],d=n.filter(t=>t.provider===e),[f,p]=(0,X.useState)(l?.apiKey??``),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[y,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),T=a(o).providersSettings,E=l?.supportsApiKey!==!1,D=l?.supportsOAuth===!0,k=l?.authMode===`oauth`&&l.authStatus===`connected`,A=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[I,L]=(0,X.useState)(`idle`),[ee,R]=(0,X.useState)(null),[z,B]=(0,X.useState)(null),[H,te]=(0,X.useState)(``),W=I===`waiting`||I===`waiting_code`,K=(0,X.useMemo)(()=>G(e,o),[e,o]),ne=f!==(l?.apiKey??``),ie=async()=>{let t=f.trim();if(!(!t||!E||oe(t))){h(!0),x(null);try{await U({[e]:t}),_(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){x(e instanceof Error?e.message:r.saveError)}finally{h(!1)}}};(0,X.useEffect)(()=>{if(!j||!W)return;let e=window.setInterval(()=>{(async()=>{try{let t=await an(j);t.status===`waiting_auth`||t.status===`waiting_code`?(L(t.status===`waiting_code`?`waiting_code`:`waiting`),P(t.message??null),R(t.authUrl??null),B(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),L(`success`),P(t.message??T.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),L(`error`),P(t.error??t.message??T.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[j,W,s,c,T.revokeFailed,T.saved]),(0,X.useEffect)(()=>()=>{j&&cn(j).catch(()=>{})},[j]);let se=async()=>{try{await pe(e),c(),s()}catch{}},le=async()=>{L(`waiting`),P(T.oauthStarting),x(null);try{M((await rn(e)).sessionId)}catch(e){L(`error`),P(e instanceof Error?e.message:T.revokeFailed)}},fe=async()=>{if(j){try{await sn(j)}catch{}L(`idle`),P(null),M(null),R(null),B(null)}},J=async()=>{if(!(!j||!H.trim()))try{await on(j,H.trim()),te(``),P(T.oauthProcessingCode)}catch(e){L(`error`),P(e instanceof Error?e.message:T.revokeFailed)}},me=async()=>{try{await ln(e),c(),s()}catch(e){x(e instanceof Error?e.message:T.revokeFailed)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(ae,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),children:(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.baseUrl?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,Z.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:l.baseUrl})]}):l?.category===`extension`?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,E?(0,Z.jsx)(An,{providerId:e,inputId:`manage-api-key`,value:f,onChange:e=>{p(e),_(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):l?.category===`extension`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:r.extensionKeyHint}),l?.extensionId?(0,Z.jsxs)(O,{to:`/settings/ext/${encodeURIComponent(l.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:s,children:[r.openExtensionSettings,(0,Z.jsx)(F,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,D?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:T.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:k?T.sourceOauth:T.oauthHint})]}),k?(0,Z.jsx)(V,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void me(),children:T.revoke}):(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:W,onClick:()=>void le(),children:[W?(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),T.oauth]})]}),N?(0,Z.jsx)(`p`,{className:i(`text-xs`,I===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:N}):null,I===`waiting`||I===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ee?(0,Z.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,Z.jsx)(F,{className:`size-4`,"aria-hidden":!0}),T.openAuthPage]}):null,(0,Z.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:T.cancelOAuth})]}):null,z?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:z}):null,I===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:H,onChange:e=>te(e.target.value),onKeyDown:e=>e.key===`Enter`&&void J(),placeholder:T.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),(0,Z.jsx)(V,{type:`button`,variant:`primary`,onClick:()=>void J(),children:T.submitCode})]}):null]}):null,K.length>0&&E?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[re(e,r),(0,Z.jsx)(F,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.length>0?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,d.length,`)`]}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,Z.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[A?(0,Z.jsxs)(V,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>C(!0),children:[(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:E&&ne&&!oe(f.trim())?(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:!f.trim()||m||g,onClick:()=>void ie(),children:g?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):m?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,Z.jsx)(he,{open:S,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>C(!1)})]})}function Pn({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,X.useState)(l?.baseUrl??``),[f,p]=(0,X.useState)(l?.apiKey??``),[m,h]=(0,X.useState)(l?.models??[]),[g,_]=(0,X.useState)(!1),[y,x]=(0,X.useState)(null),[S,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),M=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:oe(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},N=async()=>{let e=M({models:m});if(e){_(!0),x(null);try{await Gt(e),s(),o()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{_(!1)}}},P=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await Gt({providers:r}),s(),o()}catch{}},F=(e,t)=>{j({model:e,isNew:t}),k(!0)},I=async e=>{if(!A)return;let t=A.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=M({models:t});if(r)try{await Gt(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}},L=async e=>{let t=m.filter(t=>t.id!==e);h(t),D(null);let r=M({models:t});if(r)try{await Gt(r),s()}catch(e){x(e instanceof Error?e.message:n.saveError)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ae,{className:`text-base font-semibold text-fg`,children:e}),(0,Z.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,Z.jsx)(ce,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),children:(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Z.jsx)(An,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:p,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,m.length>0?` (${m.length})`:``]}),(0,Z.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>F(null,!0),children:[(0,Z.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),m.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,Z.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,Z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),onClick:()=>F(e,!1),"aria-label":c.editModel,children:(0,Z.jsx)(B,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,w.press),onClick:()=>D(e.id),"aria-label":c.removeModel,children:(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),y?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsxs)(V,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>T(!0),children:[(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(V,{type:`button`,variant:`primary`,disabled:g,onClick:()=>void N(),children:g?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,Z.jsx)(he,{open:S,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void P(),onCancel:()=>T(!1)}),(0,Z.jsx)(he,{open:E!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,E??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{E&&L(E)},onCancel:()=>D(null)}),(0,Z.jsx)(On,{open:O,onOpenChange:e=>{k(e),e||j(null)},providerId:e,model:A?.model??null,isNew:A?.isNew??!1,onSave:e=>void I(e),m:c})]})}var Fn=[`services`,`image-models`,`voice`,`search`];function In(e){let t=(e??``).trim();return Fn.includes(t)?t:`services`}function Ln(){let e=(0,Y.c)(72),t=o(zn),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,s=r.modelsHub,[c,l]=E(),u;e[2]===c?u=e[3]:(u=In(c.get(`tab`)),e[2]=c,e[3]=u);let d=u,[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=qt(),_;e[4]!==s.servicesHint||e[5]!==s.tabs.services?(_={id:`services`,icon:P,label:s.tabs.services,hint:s.servicesHint},e[4]=s.servicesHint,e[5]=s.tabs.services,e[6]=_):_=e[6];let v;e[7]!==s.imageModelsHint||e[8]!==s.tabs.imageModels?(v={id:`image-models`,icon:te,label:s.tabs.imageModels,hint:s.imageModelsHint},e[7]=s.imageModelsHint,e[8]=s.tabs.imageModels,e[9]=v):v=e[9];let y;e[10]!==s.tabs.voice||e[11]!==s.voiceHint?(y={id:`voice`,icon:N,label:s.tabs.voice,hint:s.voiceHint},e[10]=s.tabs.voice,e[11]=s.voiceHint,e[12]=y):y=e[12];let b;e[13]!==s.searchHint||e[14]!==s.tabs.search?(b={id:`search`,icon:R,label:s.tabs.search,hint:s.searchHint},e[13]=s.searchHint,e[14]=s.tabs.search,e[15]=b):b=e[15];let x;e[16]!==_||e[17]!==v||e[18]!==y||e[19]!==b?(x=[_,v,y,b],e[16]=_,e[17]=v,e[18]=y,e[19]=b,e[20]=x):x=e[20];let S=x,C;e[21]===l?C=e[22]:(C=e=>{l(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=l,e[22]=C);let T=C,D=Rn,O;e[23]===r.settingsSections.credentials?O=e[24]:(O=(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.settingsSections.credentials}),e[23]=r.settingsSections.credentials,e[24]=O);let k;e[25]===s.subtitle?k=e[26]:(k=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.subtitle}),e[25]=s.subtitle,e[26]=k);let A;e[27]===t?A=e[28]:(A=z(t,`configuration`),e[27]=t,e[28]=A);let j;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),e[29]=j):j=e[29];let M;e[30]!==s.docsLink||e[31]!==A?(M=(0,Z.jsxs)(`a`,{href:A,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[s.docsLink,j]}),e[30]=s.docsLink,e[31]=A,e[32]=M):M=e[32];let I;e[33]!==M||e[34]!==O||e[35]!==k?(I=(0,Z.jsx)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[O,k,M]})}),e[33]=M,e[34]=O,e[35]=k,e[36]=I):I=e[36];let L;e[37]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(Ve,{}),e[37]=L):L=e[37];let ee=s.tabsAria,B;e[38]!==d||e[39]!==T?(B=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),T(Fn[(Fn.indexOf(d)+(e.key===`ArrowRight`?1:-1)+Fn.length)%Fn.length]))},e[38]=d,e[39]=T,e[40]=B):B=e[40];let V;e[41]!==d||e[42]!==T||e[43]!==S?(V=S.map(e=>{let{id:t,icon:n,label:r}=e,a=t===d;return(0,Z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,id:`hub-tab-${t}`,"aria-controls":`hub-panel-${t}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>T(t),children:[(0,Z.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:r})]},t)}),e[41]=d,e[42]=T,e[43]=S,e[44]=V):V=e[44];let H;e[45]!==s.tabsAria||e[46]!==B||e[47]!==V?(H=(0,Z.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,"aria-label":ee,onKeyDown:B,children:V}),e[45]=s.tabsAria,e[46]=B,e[47]=V,e[48]=H):H=e[48];let U;e[49]!==d||e[50]!==s.connectedProviders||e[51]!==S?(U=S.map(e=>(0,Z.jsx)(Vn,{id:e.id,activeTab:d,hint:e.hint,children:e.id===`services`?(0,Z.jsx)($t,{labels:s.connectedProviders,onAdd:()=>p(!0),onManage:(e,t)=>h({providerId:e,isCustom:t})}):(0,Z.jsx)(Bn,{tab:e.id})},e.id)),e[49]=d,e[50]=s.connectedProviders,e[51]=S,e[52]=U):U=e[52];let W;e[53]!==f||e[54]!==s.addProviderDialog||e[55]!==t||e[56]!==g.builtinRows||e[57]!==g.customConfig?(W=(0,Z.jsx)(yn,{open:f,onOpenChange:p,builtinRows:g.builtinRows,customConfig:g.customConfig,labels:s.addProviderDialog,language:t,onSaved:D}),e[53]=f,e[54]=s.addProviderDialog,e[55]=t,e[56]=g.builtinRows,e[57]=g.customConfig,e[58]=W):W=e[58];let G;e[59]!==s.manageProviderDialog||e[60]!==t||e[61]!==m||e[62]!==g.allModels||e[63]!==g.builtinRows||e[64]!==g.customConfig?(G=m?(0,Z.jsx)(Mn,{open:!0,onOpenChange:e=>{e||h(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:g.builtinRows,customConfig:g.customConfig,allModels:g.allModels,labels:s.manageProviderDialog,language:t,onSaved:D}):null,e[59]=s.manageProviderDialog,e[60]=t,e[61]=m,e[62]=g.allModels,e[63]=g.builtinRows,e[64]=g.customConfig,e[65]=G):G=e[65];let K;return e[66]!==I||e[67]!==H||e[68]!==U||e[69]!==W||e[70]!==G?(K=(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[I,L,H,U,W,G]}),e[66]=I,e[67]=H,e[68]=U,e[69]=W,e[70]=G,e[71]=K):K=e[71],K}function Rn(){Se()}function zn(e){return e.language}function Bn(e){let t=(0,Y.c)(3),{tab:n}=e;switch(n){case`services`:return null;case`image-models`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ge,{embedded:!0}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(_t,{embedded:!0}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Rt,{embedded:!0}),t[2]=e):e=t[2],e}}}function Vn({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,X.useRef)(a);return a&&(o.current=!0),o.current?(0,Z.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!a,className:i(a?`flex min-w-0 flex-col gap-3`:void 0),children:[a?(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{Ln as ModelsHubPanel};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-2HJoFchH.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-CwhK8qCh.js","assets/preload-helper-zJ_50EbN.js","assets/dist-CkobR7mk.js","assets/Combination-BzaXOLd9.js","assets/dist-DokQNVMQ.js","assets/vendor-react-BOUWij0V.js","assets/cn-JdwAhgNB.js","assets/vendor-swr-BIWyz7Rc.js","assets/createLucideIcon-DPHK1VkS.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-DjbfSsfA.js","assets/config-reload-event-Bjh2zoKp.js","assets/messages-Cf1O9JB0.js","assets/fetch-B5zdl27C.js","assets/gateway-startup-retry-B3kL8KGY.js","assets/toast-z0toXu32.js","assets/theme-store-CD2wtgZV.js","assets/index-CyfhARL-.css","assets/vendor-codemirror-CNP1wPe7.js","assets/note-image-lightbox-CDknITM3.js","assets/voice-player-store-BlF9V05n.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-AssmZFx4.js","assets/code-editor-dZTY2dRW.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-Cf1O9JB0.js";import{t as s}from"./locale-store-DjbfSsfA.js";import{i as c}from"./theme-store-CD2wtgZV.js";import{r as l}from"./toast-z0toXu32.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{At as d,Bt as f,Ci as p,Co as m,Ds as h,Dt as g,Fs as _,Gi as v,Ht as y,Is as b,Jo as x,Lo as S,Lt as C,Nt as w,Ot as T,Po as E,Rt as D,Ts as ee,Tt as te,Ua as O,bi as k,ha as ne,ia as A,ja as j,jt as M,kt as N,ra as re,to as ie,zt as P}from"./index-CwhK8qCh.js";import{n as ae,t as F}from"./note-image-lightbox-CDknITM3.js";import{r as I}from"./note-time-hm6JO_Wi.js";var L=n(),R=e(t(),1),z=r(),B={edit:O,ai_edit:ne,sync:j,restore:h};function V(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function oe({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let c=o(s(e=>e.language)).notes,f=c,{data:p}=u(e?[`note-history`,e]:null,()=>d(e)),[h,g]=(0,R.useState)(!1),[_,y]=(0,R.useState)(null),b=(0,R.useCallback)(async t=>{g(!0);try{await P(e,t),l({type:`success`,title:c.restoreSuccess}),y(null),i()}catch{l({type:`error`,title:c.restoreFailed})}finally{g(!1)}},[e,c.restoreSuccess,c.restoreFailed,i]),x=Date.now();return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,z.jsx)(m,{className:`h-4 w-4`,"aria-hidden":!0}),c.history]}),(0,z.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,z.jsx)(v,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:p?.length?(0,z.jsx)(`ul`,{className:`divide-y divide-edge`,children:p.map(e=>{let r=B[e.trigger]??O,i=t===e.timestamp,o=_===e.timestamp;return(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:a(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:V(e.trigger,c)}),(0,z.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:I(e.timestamp,x,f)})]}),e.snippet&&(0,z.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,z.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:o?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:c.restoreConfirm}),(0,z.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),b(e.timestamp)},disabled:h,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:h?`...`:c.restore}),(0,z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,z.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),y(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:c.restore})})]},e.timestamp)})}):(0,z.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:c.historyEmpty}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:c.historyEmptyDescription})]})})]})}function se(e){let t=(0,L.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:l,noteThreads:d,openingChat:f,onOpenChat:p,onOpenNewChat:m}=e,h=o(s(J)).notes,g=_(),v=r?.aiDeep?.catalysis,y=v?.report??null,b;t[0]===n?b=t[1]:(b=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=b);let x;t[2]===n?x=t[3]:(x=()=>T(n),t[2]=n,t[3]=x);let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},t[4]=S):S=t[4];let{data:w,mutate:E,isLoading:te}=u(b,x,S),O;t[5]===n?O=t[6]:(O=async e=>{try{await D(n,e)}catch{}},t[5]=n,t[6]=O);let k=O,j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,z.jsx)(ne,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[7]=j):j=t[7];let M;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,z.jsx)(ee,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=M):M=t[8];let N;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,z.jsx)(ie,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=N):N=t[9],(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[j,(0,z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:h.catalysisSectionTitle})]}),(0,z.jsx)(`button`,{type:`button`,onClick:l,"aria-label":h.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:M})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,z.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:h.catalysisSectionDescription}),w?(0,z.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.contextStatusTitle}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void E(()=>C(n),{revalidate:!1}),disabled:te,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:h.contextRebuild}),(0,z.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,w.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:w.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:w.status})]}),(0,z.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:h.contextStatusDetail.replace(`{{attachments}}`,String(w.attachments.length)).replace(`{{tokens}}`,String(w.tokenEstimate??0))}),w.attachments.length>0?(0,z.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:w.attachments.slice(0,5).map(q)}):null]}):null,(0,z.jsx)(`button`,{type:`button`,onClick:c,disabled:i,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:i?h.processing:y?h.recatalyze:h.catalyzeAction}),y?(0,z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.valueHypothesis}),(0,z.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:y.valueHypothesis})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.targetUsers}),(0,z.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:y.targetUsers.slice(0,5).map(K)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.keyQuestions}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.keyQuestions.slice(0,3).map(G)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.mvpPathLabel}),(0,z.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.mvpPath.slice(0,3).map(W)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.risks}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.risks.slice(0,3).map(U)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.nextActions}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:y.nextActions.slice(0,4).map(H)})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:h.confidenceLabel.replace(`{{percent}}`,String(Math.round(y.confidence*100)))}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void k(`helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":h.feedbackHelpfulAria,children:(0,z.jsx)(re,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void k(`not_helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,v?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":h.feedbackNotHelpfulAria,children:(0,z.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]}):(0,z.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:h.noCatalysisReportHint}),(0,z.jsxs)(`section`,{className:`mt-6 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[N,h.relatedThreadsTitle]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.relatedThreadsDescription})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:p,disabled:f,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:f?h.openingChat:h.openThread}),(0,z.jsx)(`button`,{type:`button`,onClick:m,disabled:f,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:h.newThread})]})]}),d.length>0?(0,z.jsx)(`div`,{className:`space-y-2`,children:d.slice(0,5).map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>g(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||h.noteDiscussionFallback}),(0,z.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:h.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,z.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:h.noThreads})]})]})]})}function H(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,z.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function U(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-fg-muted`}),(0,z.jsx)(`span`,{children:e})]},e)}function W(e,t){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,z.jsx)(`span`,{children:e})]},e)}function G(e){return(0,z.jsxs)(`li`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-accent`}),(0,z.jsx)(`span`,{children:e})]},e)}function K(e){return(0,z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function q(e){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,z.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function J(e){return e.language}var Y=()=>i(()=>import(`./block-editor-2HJoFchH.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),X=()=>i(()=>import(`./markdown-editor-AssmZFx4.js`).then(e=>e.n),__vite__mapDeps([24,1,3,20,7,25])),ce=(0,R.lazy)(()=>Y().then(e=>({default:e.BlockEditor}))),le=(0,R.lazy)(()=>X().then(e=>({default:e.MarkdownEditor})));function ue(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,z.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,z.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function de(e){let t=(0,L.c)(14),{mode:n,onModeChange:r,labels:i}=e,o;t[0]===i.edit?o=t[1]:(o={id:`wysiwyg`,label:i.edit,Icon:E},t[0]=i.edit,t[1]=o);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:x},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:S},t[4]=i.preview,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=[o,s,c],t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=l,d;return t[10]!==n||t[11]!==u||t[12]!==r?(d=(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-edge p-0.5`,children:u.map(e=>{let{id:t,label:i,Icon:o}=e;return(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&Y(),t===`source`&&X()},onFocus:()=>{t===`wysiwyg`&&Y(),t===`source`&&X()},className:a(`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium transition-colors`,n===t?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,z.jsx)(o,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=u,t[12]=r,t[13]=d):d=t[13],d}function Z(e){let t=(0,L.c)(9),{noteId:n,onBack:r,onSaved:i}=e,a=s(Q),c;t[0]===a?c=t[1]:(c=o(a),t[0]=a,t[1]=c);let l=c.notes.lightboxClose,u;t[2]!==n||t[3]!==r||t[4]!==i?(u=(0,z.jsx)(fe,{noteId:n,onBack:r,onSaved:i}),t[2]=n,t[3]=r,t[4]=i,t[5]=u):u=t[5];let d;return t[6]!==l||t[7]!==u?(d=(0,z.jsx)(F,{closeLabel:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8],d}function Q(e){return e.language}function fe({noteId:e,onBack:t,onSaved:n}){let r=o(s(e=>e.language)).notes,i=_(),d=c(e=>e.resolved)===`dark`,{openImage:h}=ae(),[v,b]=(0,R.useState)(`wysiwyg`),[x,S]=(0,R.useState)(null),[C,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(!1),[O,A]=(0,R.useState)(``),[j,re]=(0,R.useState)(360),[P,F]=(0,R.useState)(!1),[I,L]=(0,R.useState)(!1),[B,V]=(0,R.useState)(!1),H=(0,R.useRef)(!1),U=(0,R.useRef)(!1),W=(0,R.useRef)(null),G=(0,R.useRef)(null),K=(0,R.useRef)(null),q=(0,R.useRef)(null),J=(0,R.useRef)(null),Y=k(e=>e.setPageHeader),X=k(e=>e.clearPageHeader),{data:Z,mutate:Q}=u(e?[`note-detail`,e]:null,()=>g(e)),{data:fe=[],mutate:pe}=u(e?[`note-threads`,e]:null,()=>M(e),{revalidateOnFocus:!1});(0,R.useEffect)(()=>{H.current=!1,A(``),T(null),S(null),U.current=!1},[e]),(0,R.useEffect)(()=>{!Z||H.current||(A(Z.title??``),H.current=!0)},[Z]);let me=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,he=(0,R.useMemo)(()=>(0,z.jsx)(`button`,{type:`button`,onClick:t,"aria-label":r.back,className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p),children:(0,z.jsx)(ee,{className:`h-4 w-4`,"aria-hidden":!0})}),[r.back,t]),ge=(0,R.useCallback)(t=>{A(t),e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){D(!0);try{await f(e,{title:t}),await Q(),n?.()}catch{}finally{D(!1)}}},600))},[e,Q,n]),_e=(0,R.useMemo)(()=>(0,z.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,p),children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:O||me||void 0,children:O||me}),E?(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:r.saving}):null]}),[r.saving,E,me,O]),$=(0,R.useCallback)(async(t=!1)=>{V(!0);try{let n=await w(e,{forceNew:t});await Q(),await pe(),i(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){l({type:`error`,title:r.chatOpenFailedTitle,message:e instanceof Error?e.message:r.chatOpenFailedMessage})}finally{V(!1)}},[Q,pe,i,e,r.chatOpenFailedMessage,r.chatOpenFailedTitle]),ve=(0,R.useCallback)(async()=>{L(!0);try{await te(e),await Q(),l({type:`success`,title:r.catalysisDone})}catch(e){l({type:`error`,title:r.catalysisFailed,message:e instanceof Error?e.message:r.chatOpenFailedMessage})}finally{L(!1)}},[Q,e]),ye=(0,R.useCallback)(()=>{S(x===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!I&&ve()},[x,I,ve,Z?.aiDeep?.catalysis?.report]),be=(0,R.useMemo)(()=>(0,z.jsxs)(`div`,{className:a(`flex items-center gap-2`,p),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:ye,disabled:I,"aria-label":r.catalysisSectionTitle,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,x===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,z.jsx)(ne,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),I?r.catalyzing:r.catalyzeButton]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(!1),disabled:B,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,z.jsx)(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B?r.openingChat:r.openChatButton]}),(0,z.jsx)(de,{mode:v,onModeChange:b,labels:{edit:r.modeEdit,source:r.modeSource,preview:r.modePreview}}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>S(x===`history`?null:`history`),"aria-label":r.history,className:a(`rounded-lg p-1.5 transition-colors`,x===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,z.jsx)(m,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[I,ye,$,v,r.history,r.modeEdit,r.modePreview,r.modeSource,B,x]);(0,R.useLayoutEffect)(()=>(Y({startExtra:he,main:Z?_e:null,end:Z?be:null}),()=>X()),[X,be,_e,he,Z,Y]);let xe=(0,R.useCallback)(t=>{e&&(K.current=t,W.current&&clearTimeout(W.current),W.current=setTimeout(async()=>{let t=K.current;if(K.current=null,t!==null){D(!0);try{await f(e,{markdown:t}),await Q(),n?.()}catch(e){l({type:`error`,title:r.saveFailed,message:e instanceof Error?e.message:r.saveFailedHint})}finally{D(!1)}}},600))},[e,Q,r.saveFailed,r.saveFailedHint,n]),Se=(0,R.useCallback)(t=>{N(e,t.timestamp).then(e=>{e&&T(e)})},[e]),Ce=(0,R.useCallback)(()=>{S(null),T(null)},[]),we=(0,R.useCallback)(()=>{S(null),T(null),Q(),n?.()},[Q,n]);if((0,R.useEffect)(()=>()=>{W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current);let t=K.current,n=q.current;K.current=null,q.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&f(e,r)},[e]),Z===void 0)return(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,z.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(Z===null)return(0,z.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.notFoundTitle}),(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFoundDescription}),(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:r.back})]});let Te=C!==null,Ee=Te?C.title??``:O,De=Te?C.markdown??``:Z.markdown??``;return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,z.jsx)(`div`,{ref:J,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:Te?(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Ee&&(0,z.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Ee}),De?(0,z.jsx)(y,{noteId:e,content:De,className:`opacity-80`}):(0,z.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]}):(0,z.jsxs)(z.Fragment,{children:[v===`wysiwyg`&&(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,z.jsx)(`input`,{type:`text`,value:O,onChange:e=>ge(e.target.value),onCompositionStart:()=>{U.current=!0},onCompositionEnd:()=>{U.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!U.current&&!t.isComposing&&(e.preventDefault(),(J.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:r.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(ue,{}),children:(0,z.jsx)(ce,{initialContent:Z.markdown??``,onChange:xe,noteId:e},`wysiwyg-${e}`)})})]}),v===`source`&&(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,z.jsx)(`input`,{type:`text`,value:O,onChange:e=>ge(e.target.value),placeholder:r.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(ue,{}),children:(0,z.jsx)(le,{initialContent:Z.markdown??``,onChange:xe,isDark:d},`source-${e}`)})})]}),v===`preview`&&(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&h(t.currentSrc||t.src,t.alt)},children:[O&&(0,z.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:O}),Z.markdown?(0,z.jsx)(y,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,z.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]})]})})}),(0,z.jsx)(`div`,{className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!P&&`transition-[width] duration-300 ease-in-out`),style:{width:x?j:0},children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,style:{width:j},children:[(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),F(!0);let n=e.clientX,r=j,i=e.pointerId,a=e=>{let t=r-(e.clientX-n);re(Math.max(280,Math.min(600,t)))},o=()=>{try{t.releasePointerCapture(i)}catch{}F(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},className:a(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,P&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:x===`history`?(0,z.jsx)(oe,{noteId:e,activeTimestamp:C?.timestamp??null,onSelect:Se,onClose:Ce,onRestored:we}):x===`breakdown`?(0,z.jsx)(se,{noteId:e,note:Z??null,catalyzing:I,onCatalyze:ve,onClose:()=>S(null),noteThreads:fe,openingChat:B,onOpenChat:()=>$(!1),onOpenNewChat:()=>$(!0)}):null})]})})]})}function pe(){let e=(0,L.c)(5),{noteId:t}=b(),n=_(),r;e[0]===n?r=e[1]:(r=()=>{n(`/notes`)},e[0]=n,e[1]=r);let i=r;if(!t)return null;let a;return e[2]!==i||e[3]!==t?(a=(0,z.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,z.jsx)(Z,{noteId:t,onBack:i})}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}export{pe as NoteDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Cf1O9JB0.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s}from"./fetch-B5zdl27C.js";import{r as c}from"./toast-z0toXu32.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{Bo as u,Bt as d,Ci as f,Et as p,Fs as m,Ft as h,Ha as g,It as _,Mt as v,Os as y,Pt as b,Qa as x,So as S,Ta as C,Ut as w,Va as T,Wa as E,bi as D,bo as O,fa as k,fo as A,io as j,la as M,ma as N,na as P,qt as F,rt as I,wa as L,ys as R,za as z}from"./index-CwhK8qCh.js";import{t as B}from"./voice-player-store-BlF9V05n.js";import{n as V,r as ee,t as te}from"./note-time-hm6JO_Wi.js";import{a as ne,i as re,n as H,o as ie,r as ae,t as oe}from"./dist-By6Rh2ee.js";var se=n(),U=e(t(),1),W=r();function ce(e){let t=(0,se.c)(15),{noteId:n,attachmentId:r,className:a}=e,[o,s]=(0,U.useState)(!1),c;t[0]!==r||t[1]!==n?(c=F(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c;if(o){let e;t[3]===a?e=t[4]:(e=i(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,a),t[3]=a,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsx)(S,{className:`h-4 w-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,W.jsx)(`div`,{className:e,"aria-hidden":!0,children:n}),t[6]=e,t[7]=r),r}let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>s(!0),t[8]=u):u=t[8];let d;t[9]===a?d=t[10]:(d=i(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,a),t[9]=a,t[10]=d);let f;return t[11]!==n||t[12]!==l||t[13]!==d?(f=(0,W.jsx)(w,{src:l,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:u,className:d}),t[11]=n,t[12]=l,t[13]=d,t[14]=f):f=t[14],f}function G(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function le(e){let t=(0,se.c)(38),{noteId:n,attachmentId:r,durationSec:a,className:o}=e,{playing:s,loading:c,currentTime:l,duration:u,noteId:d,attachmentId:f}=B(),p=B(q),m=d===n&&f===r,h=m&&s,g=m&&c,_=m?l:0,v=m&&u>0?u:a??0,y=v>0?Math.min(_/v*100,100):0,b;t[0]!==r||t[1]!==a||t[2]!==n||t[3]!==p?(b=e=>{e.stopPropagation(),p(n,r,a)},t[0]=r,t[1]=a,t[2]=n,t[3]=p,t[4]=b):b=t[4];let x=b,S;t[5]!==r||t[6]!==a||t[7]!==n||t[8]!==p?(S=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),p(n,r,a))},t[5]=r,t[6]=a,t[7]=n,t[8]=p,t[9]=S):S=t[9];let C=S,w;t[10]===o?w=t[11]:(w=i(`flex items-center gap-2`,o),t[10]=o,t[11]=w);let T=h?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,D;t[12]===T?D=t[13]:(D=i(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full transition-colors`,T),t[12]=T,t[13]=D);let O=h?`Pause`:`Play`,k;t[14]!==g||t[15]!==h?(k=g?(0,W.jsx)(j,{className:`h-3.5 w-3.5 animate-spin`}):h?(0,W.jsx)(E,{className:`h-3.5 w-3.5`}):(0,W.jsx)(z,{className:`h-3.5 w-3.5 ml-0.5`}),t[14]=g,t[15]=h,t[16]=k):k=t[16];let A;t[17]!==x||t[18]!==C||t[19]!==D||t[20]!==O||t[21]!==k?(A=(0,W.jsx)(`button`,{type:`button`,onClick:x,onKeyDown:C,className:D,"aria-label":O,children:k}),t[17]=x,t[18]=C,t[19]=D,t[20]=O,t[21]=k,t[22]=A):A=t[22];let M=`${y}%`,N;t[23]===M?N=t[24]:(N=(0,W.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,W.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:M}})}),t[23]=M,t[24]=N);let P;t[25]!==v||t[26]!==m||t[27]!==_?(P=G(m&&_>0?_:v),t[25]=v,t[26]=m,t[27]=_,t[28]=P):P=t[28];let F;t[29]===P?F=t[30]:(F=(0,W.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:P}),t[29]=P,t[30]=F);let I;t[31]!==N||t[32]!==F?(I=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[N,F]}),t[31]=N,t[32]=F,t[33]=I):I=t[33];let L;return t[34]!==I||t[35]!==w||t[36]!==A?(L=(0,W.jsxs)(`div`,{className:w,onClick:K,children:[A,I]}),t[34]=I,t[35]=w,t[36]=A,t[37]=L):L=t[37],L}function K(e){return e.stopPropagation()}function q(e){return e.toggle}var ue={thought:A,todo:N,voice:x,media:O,bookmark:R,mixed:A,task:N};function de(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function J(e){let t=(0,se.c)(78),{note:n,onPress:r,onPin:a,onArchive:o,onDelete:s,labels:c,timeLabels:l}=e,d=ue[n.kind]||A,f;t[0]!==c||t[1]!==n?(f=de(n,c),t[0]=c,t[1]=n,t[2]=f):f=t[2];let p=f,m=!n.snippet?.trim(),[h]=(0,U.useState)(Y),_;t[3]!==n.createdAt||t[4]!==h||t[5]!==l?(_=ee(n.createdAt,h,l),t[3]=n.createdAt,t[4]=h,t[5]=l,t[6]=_):_=t[6];let v=_,b,x;t[7]!==n.id||t[8]!==r?(b=()=>r(n.id),x=e=>{(e.key===`Enter`||e.key===` `)&&r(n.id)},t[7]=n.id,t[8]=r,t[9]=b,t[10]=x):(b=t[9],x=t[10]);let S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`group relative flex cursor-pointer flex-col gap-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,`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`),t[11]=S):S=t[11];let C;t[12]!==d||t[13]!==n.coverAttachmentId||t[14]!==n.id||t[15]!==n.kind||t[16]!==n.voiceAttachmentId||t[17]!==n.voiceDurationSec?(C=n.coverAttachmentId?(0,W.jsx)(ce,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,W.jsx)(le,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-32 shrink-0`}):(0,W.jsx)(d,{className:`mt-0.5 h-4 w-4 shrink-0 text-fg-muted`}),t[12]=d,t[13]=n.coverAttachmentId,t[14]=n.id,t[15]=n.kind,t[16]=n.voiceAttachmentId,t[17]=n.voiceDurationSec,t[18]=C):C=t[18];let w;t[19]===n.title?w=t[20]:(w=n.title&&(0,W.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[19]=n.title,t[20]=w);let E=n.title?`text-fg-muted`:m?`italic text-fg-muted`:`text-fg`,D;t[21]===E?D=t[22]:(D=i(`text-sm line-clamp-3`,E),t[21]=E,t[22]=D);let O;t[23]!==p||t[24]!==D?(O=(0,W.jsx)(`p`,{className:D,children:p}),t[23]=p,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==O||t[27]!==w?(k=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,O]}),t[26]=O,t[27]=w,t[28]=k):k=t[28];let j;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,W.jsx)(ie,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,onClick:me,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-0 transition-opacity group-hover:opacity-100 hover:bg-surface-hover focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":`Actions`,children:(0,W.jsx)(u,{className:`h-4 w-4`})})}),t[29]=j):j=t[29];let M;t[30]!==n.id||t[31]!==n.pinned||t[32]!==a?(M=()=>a(n.id,!n.pinned),t[30]=n.id,t[31]=n.pinned,t[32]=a,t[33]=M):M=t[33];let N;t[34]===n.pinned?N=t[35]:(N=n.pinned?(0,W.jsx)(T,{className:`h-4 w-4`}):(0,W.jsx)(g,{className:`h-4 w-4`}),t[34]=n.pinned,t[35]=N);let F=n.pinned?c.unpin:c.pin,I;t[36]!==M||t[37]!==N||t[38]!==F?(I=(0,W.jsxs)(H,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:M,children:[N,F]}),t[36]=M,t[37]=N,t[38]=F,t[39]=I):I=t[39];let L;t[40]!==n.id||t[41]!==o?(L=()=>o(n.id),t[40]=n.id,t[41]=o,t[42]=L):L=t[42];let R;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,W.jsx)(y,{className:`h-4 w-4`}),t[43]=R):R=t[43];let z;t[44]!==c.archive||t[45]!==L?(z=(0,W.jsxs)(H,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:L,children:[R,c.archive]}),t[44]=c.archive,t[45]=L,t[46]=z):z=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,W.jsx)(ne,{className:`my-1 h-px bg-edge-subtle`}),t[47]=B):B=t[47];let V;t[48]!==n.id||t[49]!==s?(V=()=>s(n.id),t[48]=n.id,t[49]=s,t[50]=V):V=t[50];let te;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,W.jsx)(P,{className:`h-4 w-4`}),t[51]=te):te=t[51];let G;t[52]!==c.delete||t[53]!==V?(G=(0,W.jsxs)(H,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:V,children:[te,c.delete]}),t[52]=c.delete,t[53]=V,t[54]=G):G=t[54];let K;t[55]!==I||t[56]!==z||t[57]!==G?(K=(0,W.jsxs)(re,{children:[j,(0,W.jsx)(ae,{children:(0,W.jsxs)(oe,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:pe,children:[I,z,B,G]})})]}),t[55]=I,t[56]=z,t[57]=G,t[58]=K):K=t[58];let q;t[59]!==k||t[60]!==K||t[61]!==C?(q=(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[C,k,K]}),t[59]=k,t[60]=K,t[61]=C,t[62]=q):q=t[62];let J;t[63]===n.pinned?J=t[64]:(J=n.pinned&&(0,W.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent`,children:(0,W.jsx)(g,{className:`h-3 w-3`})}),t[63]=n.pinned,t[64]=J);let X;t[65]===n.tags?X=t[66]:(X=n.tags?.map(fe),t[65]=n.tags,t[66]=X);let Z;t[67]===v?Z=t[68]:(Z=(0,W.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:v}),t[67]=v,t[68]=Z);let Q;t[69]!==J||t[70]!==X||t[71]!==Z?(Q=(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[J,X,Z]}),t[69]=J,t[70]=X,t[71]=Z,t[72]=Q):Q=t[72];let he;return t[73]!==q||t[74]!==Q||t[75]!==b||t[76]!==x?(he=(0,W.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:b,onKeyDown:x,className:S,children:[q,Q]}),t[73]=q,t[74]=Q,t[75]=b,t[76]=x,t[77]=he):he=t[77],he}function fe(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function pe(e){return e.stopPropagation()}function me(e){return e.stopPropagation()}function Y(){return Date.now()}var X=3e4;function Z(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function Q({placeholder:e,sendLabel:t,onCapture:n,onImagePick:r,onVoiceCapture:a,recordingLabel:o=`Recording…`,imageDisabled:s=!1,voiceDisabled:c=!1}){let[l,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(0),[_,v]=(0,U.useState)(!1),y=(0,U.useRef)(null),b=(0,U.useRef)(null),S=(0,U.useRef)(null),C=(0,U.useRef)([]),w=(0,U.useRef)(0),T=(0,U.useRef)(null),E=(0,U.useRef)(null),D=(0,U.useCallback)(()=>{T.current&&=(clearInterval(T.current),null),E.current&&=(clearTimeout(E.current),null),S.current?.getTracks().forEach(e=>e.stop()),S.current=null,b.current=null,C.current=[],m(!1),g(0)},[]);(0,U.useEffect)(()=>()=>D(),[D]);let A=(0,U.useCallback)(async()=>{let e=b.current;if(!e||e.state!==`recording`)return;v(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-w.current)/1e3)),n=e.mimeType||Z()||`audio/webm`,r=new Blob(C.current,{type:n});if(D(),r.size>0&&a){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,i=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await a(i,t)}finally{v(!1)}return}v(!1)},[D,a]),j=(0,U.useCallback)(async()=>{if(!(!a||_||p)&&!(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`))try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=Z(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);S.current=e,b.current=n,C.current=[],w.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&C.current.push(e.data)},n.start(),m(!0),g(0),T.current=setInterval(()=>{g(Math.round((Date.now()-w.current)/1e3))},250),E.current=setTimeout(()=>{A()},X)}catch{D()}},[D,a,p,A,_]),M=(0,U.useCallback)(()=>{if(p){A();return}j()},[p,j,A]),N=(0,U.useCallback)(async e=>{let t=l.trim();if(!(!t||d)){f(!0),u(``);try{await n(t,e)}catch{u(t)}finally{f(!1),y.current?.focus()}}},[l,d,n]),P=(0,U.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),N()),e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),N({navigate:!1}))},[N]),F=d||_;return(0,W.jsxs)(`div`,{className:i(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel px-2 py-2 shadow-float dark:shadow-elevated`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent`,p&&`border-danger ring-1 ring-danger/40`),children:[r&&(0,W.jsx)(`button`,{type:`button`,onClick:r,disabled:F||s||p,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Image`,children:(0,W.jsx)(O,{className:`h-4 w-4`})}),a&&(0,W.jsx)(`button`,{type:`button`,onClick:M,disabled:F||c||d,className:i(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,p?`bg-danger-soft text-danger hover:bg-danger-soft`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-label":p?`Stop recording`:`Voice`,"aria-pressed":p,children:p?(0,W.jsx)(k,{className:`h-4 w-4 fill-current`}):(0,W.jsx)(x,{className:`h-4 w-4`})}),p?(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:o.replace(`{{seconds}}`,String(h))}):(0,W.jsx)(`textarea`,{ref:y,value:l,onChange:e=>u(e.target.value),onKeyDown:P,placeholder:e,rows:1,disabled:F,className:`min-h-8 flex-1 resize-none bg-transparent py-1.5 text-sm leading-5 text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`}}),(0,W.jsx)(`button`,{type:`button`,disabled:!l.trim()||F||p,onClick:e=>void N({navigate:!e.shiftKey}),"aria-label":t,className:i(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,l.trim()&&!F&&!p?`text-accent hover:bg-accent-soft`:`text-fg-disabled`),children:(0,W.jsx)(L,{className:`h-4 w-4`})})]})}var he={statusFilter:`all`,kindFilter:`all`,search:``};function $(){let e=(0,se.c)(107),t=a(o(xe)).notes,n=!!s(be),[r,u]=(0,U.useReducer)(I,he),[g]=(0,U.useState)(ye),y=m(),x;e[0]!==n||e[1]!==r.kindFilter||e[2]!==r.search||e[3]!==r.statusFilter?(x=n?[`notes-list`,r.statusFilter,r.kindFilter,r.search]:null,e[0]=n,e[1]=r.kindFilter,e[2]=r.search,e[3]=r.statusFilter,e[4]=x):x=e[4];let S=x,w;e[5]!==r.kindFilter||e[6]!==r.search||e[7]!==r.statusFilter?(w=()=>v({status:r.statusFilter===`all`?void 0:r.statusFilter,kind:r.kindFilter===`all`?void 0:r.kindFilter,search:r.search||void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),e[5]=r.kindFilter,e[6]=r.search,e[7]=r.statusFilter,e[8]=w):w=e[8];let T;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(T={keepPreviousData:!0},e[9]=T):T=e[9];let{data:E,mutate:O,isLoading:k}=l(S,w,T),A=k&&!E,j;e[10]===E?.items?j=e[11]:(j=E?.items??[],e[10]=E?.items,e[11]=j);let N=j,P=E?.total??0,F=D(ve),L=D(_e),R=P>0?t.noteCount.replace(`{{count}}`,String(P)):null,z,B;e[12]!==L||e[13]!==n||e[14]!==t.title||e[15]!==R||e[16]!==F?(z=()=>n?(F({startExtra:null,main:(0,W.jsxs)(`div`,{className:i(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,f),children:[(0,W.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),R?(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:R}):null]}),end:null}),()=>L()):(L(),()=>L()),B=[L,n,t.title,R,F],e[12]=L,e[13]=n,e[14]=t.title,e[15]=R,e[16]=F,e[17]=z,e[18]=B):(z=e[17],B=e[18]),(0,U.useLayoutEffect)(z,B);let ee;e[19]!==t.daysAgo||e[20]!==t.justNow||e[21]!==t.minutesAgo||e[22]!==t.today||e[23]!==t.yesterday?(ee={justNow:t.justNow,minutesAgo:t.minutesAgo,today:t.today,yesterday:t.yesterday,daysAgo:t.daysAgo},e[19]=t.daysAgo,e[20]=t.justNow,e[21]=t.minutesAgo,e[22]=t.today,e[23]=t.yesterday,e[24]=ee):ee=e[24];let ne=ee,re;e[25]!==O||e[26]!==y?(re=async(e,t)=>{let n=await b(e,`web`);await O(),t?.navigate!==!1&&y(`/notes/${n.id}`)},e[25]=O,e[26]=y,e[27]=re):re=e[27];let H=re,ie;e[28]!==O||e[29]!==t.imageUploadFailed||e[30]!==t.imageUploadFailedHint?(ie=()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let n=e.files?.[0];if(n)try{await h(n,`web`),await O()}catch(e){let n=e;c({type:`error`,title:t.imageUploadFailed,message:n instanceof Error?n.message:t.imageUploadFailedHint})}},e.click()},e[28]=O,e[29]=t.imageUploadFailed,e[30]=t.imageUploadFailedHint,e[31]=ie):ie=e[31];let ae=ie,oe;e[32]!==O||e[33]!==t.voiceUploadFailed||e[34]!==t.voiceUploadFailedHint?(oe=async(e,n)=>{try{await _(e,n,`web`),await O()}catch(e){let n=e;c({type:`error`,title:t.voiceUploadFailed,message:n instanceof Error?n.message:t.voiceUploadFailedHint})}},e[32]=O,e[33]=t.voiceUploadFailed,e[34]=t.voiceUploadFailedHint,e[35]=oe):oe=e[35];let ce=oe,G;e[36]===O?G=e[37]:(G=async(e,t)=>{await d(e,{pinned:t}),await O()},e[36]=O,e[37]=G);let le=G,K;e[38]===O?K=e[39]:(K=async e=>{await d(e,{status:`archived`}),await O()},e[38]=O,e[39]=K);let q=K,ue;e[40]===O?ue=e[41]:(ue=async e=>{await p(e),await O()},e[40]=O,e[41]=ue);let de=ue,fe;e[42]===y?fe=e[43]:(fe=e=>{y(`/notes/${e}`)},e[42]=y,e[43]=fe);let pe=fe;if(!n){let n;e[44]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsx)(M,{className:`h-10 w-10 text-fg-muted`}),e[44]=n):n=e[44];let r;return e[45]===t.needToken?r=e[46]:(r=(0,W.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[n,(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]}),e[45]=t.needToken,e[46]=r),r}let me;e[47]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,W.jsx)(C,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),e[47]=me):me=e[47];let Y;e[48]===u?Y=e[49]:(Y=e=>u({type:`patch`,patch:{search:e.target.value}}),e[48]=u,e[49]=Y);let X;e[50]!==t.searchPlaceholder||e[51]!==Y||e[52]!==r.search?(X=(0,W.jsxs)(`div`,{className:`relative`,children:[me,(0,W.jsx)(`input`,{type:`search`,value:r.search,onChange:Y,placeholder:t.searchPlaceholder,className:`w-full rounded-xl border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`})]}),e[50]=t.searchPlaceholder,e[51]=Y,e[52]=r.search,e[53]=X):X=e[53];let Z;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(Z=[`all`,`inbox`,`processed`,`archived`],e[54]=Z):Z=e[54];let $;e[55]!==u||e[56]!==t.filterAll||e[57]!==t.filterArchived||e[58]!==t.filterInbox||e[59]!==t.filterProcessed||e[60]!==r.statusFilter?($=Z.map(e=>{let n=e===`all`?t.filterAll:e===`inbox`?t.filterInbox:e===`processed`?t.filterProcessed:t.filterArchived;return(0,W.jsx)(`button`,{type:`button`,onClick:()=>u({type:`patch`,patch:{statusFilter:e}}),className:i(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,r.statusFilter===e?`bg-accent text-white`:`bg-surface-hover text-fg-muted hover:text-fg`),children:n},e)}),e[55]=u,e[56]=t.filterAll,e[57]=t.filterArchived,e[58]=t.filterInbox,e[59]=t.filterProcessed,e[60]=r.statusFilter,e[61]=$):$=e[61];let Se,Ce;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,W.jsx)(`div`,{className:`mx-1 h-4 w-px bg-edge-subtle`}),Ce=[`all`,`thought`,`todo`,`voice`,`media`,`bookmark`],e[62]=Se,e[63]=Ce):(Se=e[62],Ce=e[63]);let we;e[64]!==u||e[65]!==t.kindAll||e[66]!==t.kindBookmark||e[67]!==t.kindMedia||e[68]!==t.kindThought||e[69]!==t.kindTodo||e[70]!==t.kindVoice||e[71]!==r.kindFilter?(we=Ce.map(e=>{let n=e===`all`?t.kindAll:e===`thought`?t.kindThought:e===`todo`?t.kindTodo:e===`voice`?t.kindVoice:e===`media`?t.kindMedia:t.kindBookmark;return(0,W.jsx)(`button`,{type:`button`,onClick:()=>u({type:`patch`,patch:{kindFilter:e}}),className:i(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,r.kindFilter===e?`bg-accent text-white`:`bg-surface-hover text-fg-muted hover:text-fg`),children:n},e)}),e[64]=u,e[65]=t.kindAll,e[66]=t.kindBookmark,e[67]=t.kindMedia,e[68]=t.kindThought,e[69]=t.kindTodo,e[70]=t.kindVoice,e[71]=r.kindFilter,e[72]=we):we=e[72];let Te;e[73]!==$||e[74]!==we?(Te=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[$,Se,we]}),e[73]=$,e[74]=we,e[75]=Te):Te=e[75];let Ee;e[76]!==X||e[77]!==Te?(Ee=(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4 p-4 pb-2`,children:[X,Te]}),e[76]=X,e[77]=Te,e[78]=Ee):Ee=e[78];let De;e[79]!==q||e[80]!==de||e[81]!==pe||e[82]!==le||e[83]!==t.archive||e[84]!==t.delete||e[85]!==t.imageNote||e[86]!==t.noNotes||e[87]!==t.noNotesDescription||e[88]!==t.noText||e[89]!==t.pin||e[90]!==t.unpin||e[91]!==N||e[92]!==g||e[93]!==A||e[94]!==ne?(De=(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pt-3 pb-24 [scrollbar-gutter:stable]`,children:A?(0,W.jsx)(`div`,{className:`flex flex-col gap-3`,children:[1,2,3].map(ge)}):N.length===0?(0,W.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] flex-col items-center justify-center gap-2 py-16 text-center`,children:[(0,W.jsx)(M,{className:`h-8 w-8 text-fg-muted`}),(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:t.noNotes}),(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.noNotesDescription})]}):(0,W.jsx)(`div`,{className:`flex flex-col gap-3`,children:N.map((e,n)=>{let r=n>0?te(N[n-1].createdAt):null;return(0,W.jsxs)(`div`,{children:[te(e.createdAt)!==r&&(0,W.jsx)(`div`,{className:i(`pb-2 text-xs font-medium text-fg-muted`,n>0&&`pt-2`),children:V(e.createdAt,g,ne)}),(0,W.jsx)(J,{note:e,onPress:pe,onPin:le,onArchive:q,onDelete:de,timeLabels:ne,labels:{pin:t.pin,unpin:t.unpin,archive:t.archive,delete:t.delete,imageNote:t.imageNote,noText:t.noText}})]},e.id)})})}),e[79]=q,e[80]=de,e[81]=pe,e[82]=le,e[83]=t.archive,e[84]=t.delete,e[85]=t.imageNote,e[86]=t.noNotes,e[87]=t.noNotesDescription,e[88]=t.noText,e[89]=t.pin,e[90]=t.unpin,e[91]=N,e[92]=g,e[93]=A,e[94]=ne,e[95]=De):De=e[95];let Oe;e[96]!==H||e[97]!==ae||e[98]!==ce||e[99]!==t.quickCapturePlaceholder||e[100]!==t.recording||e[101]!==t.send?(Oe=(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 bg-gradient-to-t from-surface-panel from-60% via-surface-panel/90 to-transparent px-4 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-6`,children:(0,W.jsx)(`div`,{className:`pointer-events-auto`,children:(0,W.jsx)(Q,{placeholder:t.quickCapturePlaceholder,sendLabel:t.send,onCapture:H,onImagePick:ae,onVoiceCapture:ce,recordingLabel:t.recording})})}),e[96]=H,e[97]=ae,e[98]=ce,e[99]=t.quickCapturePlaceholder,e[100]=t.recording,e[101]=t.send,e[102]=Oe):Oe=e[102];let ke;return e[103]!==Ee||e[104]!==De||e[105]!==Oe?(ke=(0,W.jsxs)(`div`,{className:`relative mx-auto flex h-full min-h-0 w-full max-w-3xl flex-1 flex-col overflow-hidden`,children:[Ee,De,Oe]}),e[103]=Ee,e[104]=De,e[105]=Oe,e[106]=ke):ke=e[106],ke}function ge(e){return(0,W.jsx)(`div`,{className:`h-24 animate-pulse rounded-xl bg-surface-hover`},e)}function _e(e){return e.clearPageHeader}function ve(e){return e.setPageHeader}function ye(){return Date.now()}function be(e){return e.token}function xe(e){return e.language}export{$ as NotesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Cf1O9JB0.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{a as s,c,i as l,n as u,o as d,t as f}from"./fetch-B5zdl27C.js";import{a as p,i as m}from"./vendor-swr-BIWyz7Rc.js";import{An as h,Ca as g,Cn as _,Di as v,Dn as y,En as b,Hi as x,Ia as S,Ja as C,Kn as w,Lr as T,Ls as E,Mi as D,Ms as O,Ni as k,Nn as A,On as j,Oo as M,Pn as N,Ro as P,Rr as F,Sn as I,Tn as L,Ui as R,Wo as z,_o as B,aa as V,bn as H,ci as U,di as W,es as G,fi as K,ga as ee,hi as q,ht as te,io as ne,ja as re,kn as J,mi as Y,pi as X,ps as ie,rt as ae,s as oe,ta as se,ui as ce,us as le,va as ue,vn as de,wn as fe,xn as pe,yn as me}from"./index-CwhK8qCh.js";import{t as he}from"./settings-collapsible-section-BHZKjVcS.js";import{n as ge,r as _e,t as ve}from"./settings-form-section-5i35D-J1.js";import{t as ye}from"./browser-BLJWD7WI.js";var Z=n(),Q=e(t(),1);function be(e,t){let{mutate:n}=p(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),T()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await I();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await de();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await me(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await H():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}var $=r();function xe(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function Se(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:s,lanOnly:c,onRefreshQr:l}=e,u=s===void 0?!1:s,d=c===void 0?!1:c,f=o(Te),p;t[0]===f?p=t[1]:(p=a(f),t[0]=f,t[1]=p);let m=p,h=m.tunnelSettings,g=d?m.remoteAccess.lan:null,_;t[2]!==m.clipboard.copyFailed||t[3]!==h.pairCopied||t[4]!==h.pairCopyLink?(_={copy:h.pairCopyLink,copied:h.pairCopied,copyFailed:m.clipboard.copyFailed},t[2]=m.clipboard.copyFailed,t[3]=h.pairCopied,t[4]=h.pairCopyLink,t[5]=_):_=t[5];let v=_,{tunnelActive:y,tunnelStatus:b,tunnelQr:x,pairContext:S,pairBaseUrl:C,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:D,resetPairBaseFromContext:k,baseOk:A,localhostWarn:j,pairingBlocked:M,deepLink:N,qrPayload:P,qrDataUrl:F,qrGenFailed:I,encoding:L}=n,z;t[6]===k?z=t[7]:(z=e=>{k(e.recommended.url)},t[6]=k,t[7]=z);let B=be(r,z),V,H,U,W,G;if(t[8]!==D||t[9]!==E||t[10]!==A||t[11]!==B||t[12]!==r||t[13]!==g||t[14]!==d||t[15]!==j||t[16]!==l||t[17]!==C||t[18]!==S?.candidates||t[19]!==S?.recommended||t[20]!==M||t[21]!==T||t[22]!==u||t[23]!==h.pairBaseUrlHint||t[24]!==h.pairBaseUrlLabel||t[25]!==h.pairBaseUrlPlaceholder||t[26]!==h.pairBlockedLoopbackBody||t[27]!==h.pairBlockedNextSteps||t[28]!==h.pairBlockedTitle||t[29]!==h.pairCandidatesTitle||t[30]!==h.pairEnableLanButton||t[31]!==h.pairEnableLanEnabling||t[32]!==h.pairEnableLanSecurityAuditLink||t[33]!==h.pairInvalidBaseUrl||t[34]!==h.pairLocalhostWarning||t[35]!==h.pairSelectCandidateHint||t[36]!==h.pairSelectCandidateTitle||t[37]!==h.pairSubtitle||t[38]!==h.pairSuggestedLanLabel||t[39]!==h.pairTitle||t[40]!==h.pairTunnelActive||t[41]!==h.pairTunnelLanUrl||t[42]!==h.pairTunnelPublicUrl||t[43]!==h.pairUseSuggestedUrl||t[44]!==h.pairWaitingForTunnel||t[45]!==h.refreshQr||t[46]!==y||t[47]!==x||t[48]!==b?.publicUrl){G=Symbol.for(`react.early_return_sentinel`);bb0:{let e=S?.candidates.filter(we)??[],n=d?(e.find(Ce)?.url??e[0]?.url??``).trim():S?.recommended.url?.trim()??``,a=(d||!y)&&e.length>1,o=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:i(`text-xs font-medium`,r),children:a?h.pairSelectCandidateTitle:h.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:i(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,C.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>D(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),a?(0,$.jsx)(`p`,{className:i(`mt-1 text-[11px] leading-relaxed`,r),children:h.pairSelectCandidateHint}):null]})};if(V=u&&!d,V&&!y){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ee,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===h.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,h.pairTitle]}),t[55]=h.pairTitle,t[56]=n);let r;t[57]===h.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:h.pairWaitingForTunnel}),t[57]=h.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(ve,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],G=i;break bb0}let s=g?.pairTitle??h.pairTitle,c=d?g?.pairSubtitle??h.pairSubtitle:y?h.pairTunnelActive:h.pairSubtitle,f=!!(l&&(d||u&&y)),p=V?`mb-2`:`mb-3`,m;t[62]===p?m=t[63]:(m=i(`flex flex-wrap items-start justify-between gap-2`,p),t[62]=p,t[63]=m);let _;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(ee,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=_):_=t[64];let v;t[65]===s?v=t[66]:(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[_,s]}),t[65]=s,t[66]=v);let w;t[67]!==V||t[68]!==c||t[69]!==h.pairSubtitle?(w=V?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:h.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c}),t[67]=V,t[68]=c,t[69]=h.pairSubtitle,t[70]=w):w=t[70];let k;t[71]!==v||t[72]!==w?(k=(0,$.jsxs)(`div`,{children:[v,w]}),t[71]=v,t[72]=w,t[73]=k):k=t[73];let N;t[74]!==l||t[75]!==f||t[76]!==h.refreshQr?(N=f?(0,$.jsxs)(R,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void l(),children:[(0,$.jsx)(re,{className:`size-4`}),h.refreshQr]}):null,t[74]=l,t[75]=f,t[76]=h.refreshQr,t[77]=N):N=t[77],t[78]!==m||t[79]!==k||t[80]!==N?(H=(0,$.jsxs)(`div`,{className:m,children:[k,N]}),t[78]=m,t[79]=k,t[80]=N,t[81]=H):H=t[81],U=M?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:h.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:h.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:h.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(R,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:E,children:h.pairUseSuggestedUrl})]}):null,e.length>0?o(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(R,{type:`button`,className:`w-full sm:w-auto`,disabled:B.busy||!r,onClick:()=>B.setConfirmOpen(!0),children:[B.busy?(0,$.jsx)(ne,{className:`size-3.5 animate-spin`}):null,B.busy?h.pairEnableLanEnabling:h.pairEnableLanButton]})}),B.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:B.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:d?g?.pairBlockedNextSteps??h.pairBlockedNextSteps:h.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(O,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:h.pairEnableLanSecurityAuditLink}),d&&g?.pairPublicTabLink?(0,$.jsx)(O,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairPublicTabLink}):null]})]}):null,W=y&&!d?V?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg border border-edge bg-surface-panel px-3 py-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:b?.publicUrl})]}),x?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:h.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:x.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:h.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:i(xe(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||h.pairBaseUrlPlaceholder,value:C,onChange:e=>T(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:h.pairBaseUrlHint}),!A&&C.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:h.pairInvalidBaseUrl}):null,j?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:h.pairLocalhostWarning}):null,a?o(`neutral`):null]})}t[8]=D,t[9]=E,t[10]=A,t[11]=B,t[12]=r,t[13]=g,t[14]=d,t[15]=j,t[16]=l,t[17]=C,t[18]=S?.candidates,t[19]=S?.recommended,t[20]=M,t[21]=T,t[22]=u,t[23]=h.pairBaseUrlHint,t[24]=h.pairBaseUrlLabel,t[25]=h.pairBaseUrlPlaceholder,t[26]=h.pairBlockedLoopbackBody,t[27]=h.pairBlockedNextSteps,t[28]=h.pairBlockedTitle,t[29]=h.pairCandidatesTitle,t[30]=h.pairEnableLanButton,t[31]=h.pairEnableLanEnabling,t[32]=h.pairEnableLanSecurityAuditLink,t[33]=h.pairInvalidBaseUrl,t[34]=h.pairLocalhostWarning,t[35]=h.pairSelectCandidateHint,t[36]=h.pairSelectCandidateTitle,t[37]=h.pairSubtitle,t[38]=h.pairSuggestedLanLabel,t[39]=h.pairTitle,t[40]=h.pairTunnelActive,t[41]=h.pairTunnelLanUrl,t[42]=h.pairTunnelPublicUrl,t[43]=h.pairUseSuggestedUrl,t[44]=h.pairWaitingForTunnel,t[45]=h.refreshQr,t[46]=y,t[47]=x,t[48]=b?.publicUrl,t[49]=V,t[50]=H,t[51]=U,t[52]=W,t[53]=G}else V=t[49],H=t[50],U=t[51],W=t[52],G=t[53];if(G!==Symbol.for(`react.early_return_sentinel`))return G;let K;t[82]===h.pairSecurityNote?K=t[83]:(K=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:h.pairSecurityNote}),t[82]=h.pairSecurityNote,t[83]=K);let q;t[84]!==v||t[85]!==N||t[86]!==L||t[87]!==M||t[88]!==F||t[89]!==I||t[90]!==h.pairEncoding||t[91]!==h.pairImageError||t[92]!==h.pairQrDisabled?(q=N?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[F&&!I?(0,$.jsx)(`img`,{src:F,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,L?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairEncoding}):null,I?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:h.pairImageError}):null,(0,$.jsx)(w,{text:N,labels:v})]}):M?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.pairQrDisabled}):null,t[84]=v,t[85]=N,t[86]=L,t[87]=M,t[88]=F,t[89]=I,t[90]=h.pairEncoding,t[91]=h.pairImageError,t[92]=h.pairQrDisabled,t[93]=q):q=t[93];let te;t[94]!==V||t[95]!==P||t[96]!==h.deeplinkTitle?(te=P&&!V?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:h.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:P})]}):null,t[94]=V,t[95]=P,t[96]=h.deeplinkTitle,t[97]=te):te=t[97];let J;t[98]!==V||t[99]!==h.pairMobileProbeHint||t[100]!==h.pairSchemeHint?(J=V?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:h.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:h.pairMobileProbeHint})]}),t[98]=V,t[99]=h.pairMobileProbeHint,t[100]=h.pairSchemeHint,t[101]=J):J=t[101];let Y,X;t[102]===B?(Y=t[103],X=t[104]):(Y=()=>void B.runEnableLanPairing(),X=()=>{B.busy||B.setConfirmOpen(!1)},t[102]=B,t[103]=Y,t[104]=X);let ie;t[105]!==B.confirmOpen||t[106]!==h.consentCancel||t[107]!==h.pairEnableLanButton||t[108]!==h.pairEnableLanConfirmBody||t[109]!==h.pairEnableLanConfirmTitle||t[110]!==Y||t[111]!==X?(ie=(0,$.jsx)(oe,{open:B.confirmOpen,title:h.pairEnableLanConfirmTitle,description:h.pairEnableLanConfirmBody,confirmLabel:h.pairEnableLanButton,cancelLabel:h.consentCancel,onConfirm:Y,onCancel:X}),t[105]=B.confirmOpen,t[106]=h.consentCancel,t[107]=h.pairEnableLanButton,t[108]=h.pairEnableLanConfirmBody,t[109]=h.pairEnableLanConfirmTitle,t[110]=Y,t[111]=X,t[112]=ie):ie=t[112];let ae;return t[113]!==K||t[114]!==q||t[115]!==te||t[116]!==J||t[117]!==ie||t[118]!==H||t[119]!==U||t[120]!==W?(ae=(0,$.jsx)(ve,{children:(0,$.jsxs)($.Fragment,{children:[H,U,W,K,q,te,J,ie]})}),t[113]=K,t[114]=q,t[115]=te,t[116]=J,t[117]=ie,t[118]=H,t[119]=U,t[120]=W,t[121]=ae):ae=t[121],ae}function Ce(e){return e.reachable}function we(e){return e.kind===`lan`}function Te(e){return e.language}function Ee(e){let t=(0,Z.c)(40),{open:n,title:r,intro:a,bullets:o,checkboxLabel:s,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(K,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,N)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,A),t[3]=g):g=t[3];let _;t[4]===r?_=t[5]:(_=(0,$.jsx)(q,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=_);let v;t[6]===a?v=t[7]:(v=(0,$.jsx)(W,{className:`mt-2 text-sm text-fg-muted`,children:a}),t[6]=a,t[7]=v);let y;t[8]===o?y=t[9]:(y=o.map(De),t[8]=o,t[9]=y);let b;t[10]===y?b=t[11]:(b=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=b);let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>p(e.target.checked),t[12]=x):x=t[12];let S;t[13]===f?S=t[14]:(S=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:x}),t[13]=f,t[14]=S);let C;t[15]===s?C=t[16]:(C=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=C);let w;t[17]!==C||t[18]!==S?(w=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[S,C]}),t[17]=C,t[18]=S,t[19]=w):w=t[19];let T;t[20]!==l||t[21]!==d?(T=(0,$.jsx)(R,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=T):T=t[22];let E=!f,D;t[23]!==c||t[24]!==u||t[25]!==E?(D=(0,$.jsx)(R,{type:`button`,disabled:E,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==T||t[28]!==D?(O=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[T,D]}),t[27]=T,t[28]=D,t[29]=O):O=t[29];let k;t[30]!==w||t[31]!==O||t[32]!==_||t[33]!==v||t[34]!==b?(k=(0,$.jsxs)(X,{children:[h,(0,$.jsxs)(ce,{className:g,onOpenAutoFocus:Oe,children:[_,v,b,w,O]})]}),t[30]=w,t[31]=O,t[32]=_,t[33]=v,t[34]=b,t[35]=k):k=t[35];let j;return t[36]!==n||t[37]!==m||t[38]!==k?(j=(0,$.jsx)(Y,{open:n,onOpenChange:m,children:k}),t[36]=n,t[37]=m,t[38]=k,t[39]=j):j=t[39],j}function De(e){return(0,$.jsx)(`li`,{children:e},e)}function Oe(e){return e.preventDefault()}function ke(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ae=[`preparing_frpc`,`registering`,`starting_frpc`];function je(e){return e?e===`reconnecting_frpc`?Ae.indexOf(`starting_frpc`):Ae.indexOf(e):-1}function Me(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ae.indexOf(e),i=je(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Ne(e,t,n){let r=n.startProgress;return Me(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function Pe(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Fe(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ie(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,a]=(0,Q.useState)(0),o;t[0]!==a||t[1]!==n.state?(o=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>a(Le),1e3);return()=>window.clearInterval(e)},t[0]=a,t[1]=n.state,t[2]=o):o=t[2];let s=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==s?(c=[n.state,s],t[3]=n.state,t[4]=s,t[5]=c):c=t[5],(0,Q.useEffect)(o,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,u,d,f,p;if(t[6]!==n||t[7]!==r){let e=Fe(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,u=`mt-3 space-y-3 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-3`;let a;t[13]===r.startProgressTitle?a=t[14]:(a=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=a);let o;t[15]===r.startProgressHint?o=t[16]:(o=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=o),t[17]!==a||t[18]!==o?(d=(0,$.jsxs)(`div`,{children:[a,o]}),t[17]=a,t[18]=o,t[19]=d):d=t[19];let s=Ae.map(e=>{let t=Me(e,n),a=Ne(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(ie,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(ne,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(G,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:i(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Pe(r,e)}),a?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:a}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:i(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[ke(n.frpcDownload.bytesReceived),` /`,` `,ke(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===s?f=t[21]:(f=(0,$.jsx)(`ol`,{className:`space-y-2`,children:s}),t[20]=s,t[21]=f),p=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12];let m;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(m=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=m):m=t[24];let h;return t[25]!==u||t[26]!==d||t[27]!==f||t[28]!==p||t[29]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f,p,m]}),t[25]=u,t[26]=d,t[27]=f,t[28]=p,t[29]=m,t[30]=h):h=t[30],h}function Le(e){return e+1}function Re(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function ze(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function Be(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Ve(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function He(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:a,statusErr:o,starting:s,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,_,v,y,b,x,C,T;t[0]!==r||t[1]!==s?(T=ze(r),_=r.enabled||s,v=s||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(C=i(_e(),`space-y-4`),t[9]=C):C=t[9],x=`flex flex-wrap items-start justify-between gap-3`,b=`flex items-center gap-2`,y=i(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Be(T)),t[0]=r,t[1]=s,t[2]=_,t[3]=v,t[4]=y,t[5]=b,t[6]=x,t[7]=C,t[8]=T):(_=t[2],v=t[3],y=t[4],b=t[5],x=t[6],C=t[7],T=t[8]);let E=T===`connected`&&`bg-emerald-500`,D=T===`progress`&&`bg-amber-500 animate-pulse`,O=T===`error`&&`bg-red-500`,k=T===`off`&&`bg-fg-subtle`,A;t[10]!==E||t[11]!==D||t[12]!==O||t[13]!==k?(A=i(`size-1.5 rounded-full`,E,D,O,k),t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=A):A=t[14];let j;t[15]===A?j=t[16]:(j=(0,$.jsx)(`span`,{className:A,"aria-hidden":!0}),t[15]=A,t[16]=j);let N;t[17]!==a||t[18]!==r||t[19]!==n?(N=a&&!r.enabled?n.loading:Re(n,r),t[17]=a,t[18]=r,t[19]=n,t[20]=N):N=t[20];let P;t[21]!==j||t[22]!==N||t[23]!==y?(P=(0,$.jsxs)(`span`,{className:y,children:[j,N]}),t[21]=j,t[22]=N,t[23]=y,t[24]=P):P=t[24];let F;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(F=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ve(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=F):F=t[28];let I;t[29]!==P||t[30]!==F||t[31]!==b?(I=(0,$.jsxs)(`div`,{className:b,children:[P,F]}),t[29]=P,t[30]=F,t[31]=b,t[32]=I):I=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(M,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=L):L=t[33];let z;t[34]!==I||t[35]!==x?(z=(0,$.jsxs)(`div`,{className:x,children:[I,L]}),t[34]=I,t[35]=x,t[36]=z):z=t[36];let B;t[37]===o?B=t[38]:(B=o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o instanceof Error?o.message:String(o)}):null,t[37]=o,t[38]=B);let V;t[39]!==l||t[40]!==n.consentExpiredBanner?(V=l?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=l,t[40]=n.consentExpiredBanner,t[41]=V):V=t[41];let H;t[42]!==_||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(H=_?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,$.jsx)(w,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,v?(0,$.jsx)(Ie,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(R,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(ne,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(R,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(ne,{className:`size-4 animate-spin`}):(0,$.jsx)(S,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(se,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(R,{type:`button`,disabled:s||g,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(ne,{className:`size-4 animate-spin`}):(0,$.jsx)(S,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=u,t[44]=m,t[45]=h,t[46]=v,t[47]=r,t[48]=g,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=H):H=t[54];let U;return t[55]!==z||t[56]!==B||t[57]!==V||t[58]!==H||t[59]!==C?(U=(0,$.jsxs)(`section`,{className:C,children:[z,B,V,H]}),t[55]=z,t[56]=B,t[57]=V,t[58]=H,t[59]=C,t[60]=U):U=t[60],U}var Ue=`https://console.xopc.ai/keys/tunnel`,We={reconfiguring:!1};function Ge(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:a,brokerSecretConfiguredInConfig:o,brokerSecretMaskedValue:s,brokerSecretDraft:c,savingBrokerSecret:l,brokerSecretNotice:u,copyFailedLabel:d,onDraftChange:f,onSave:p,onClear:m,sectionRef:h}=e,g=(0,Q.useId)(),_=a&&!r,v=!_,[y,b]=(0,Q.useReducer)(ae,We),{reconfiguring:x}=y,S;t[0]!==o||t[1]!==c||t[2]!==r||t[3]!==x?(S=o&&!r&&!x&&!c.trim(),t[0]=o,t[1]=c,t[2]=r,t[3]=x,t[4]=S):S=t[4];let C=S,w;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(w={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=w):w=t[9];let T=w,E;t[10]===c?E=t[11]:(E=c.trim().length>0&&!te(c.trim()),t[10]=c,t[11]=E);let O=E,k;t[12]===f?k=t[13]:(k=()=>{b({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[12]=f,t[13]=k);let A=k,j=_&&`ring-1 ring-amber-500/30`,M;t[14]===j?M=t[15]:(M=i(j),t[14]=j,t[15]=M);let N=v?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:_?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,F;t[16]===N?F=t[17]:(F=i(`flex size-9 shrink-0 items-center justify-center rounded-lg`,N),t[16]=N,t[17]=F);let I;t[18]===v?I=t[19]:(I=v?(0,$.jsx)(ie,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=v,t[19]=I);let L;t[20]!==F||t[21]!==I?(L=(0,$.jsx)(`span`,{className:F,children:I}),t[20]=F,t[21]=I,t[22]=L):L=t[22];let z=v?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,V;t[23]===z?V=t[24]:(V=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:z}),t[23]=z,t[24]=V);let H=v?n.brokerSecretReadyHint:n.brokerSecretHint,U;t[25]===H?U=t[26]:(U=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:H}),t[25]=H,t[26]=U);let W;t[27]!==_||t[28]!==n.brokerSecretMissingHint?(W=_?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=_,t[28]=n.brokerSecretMissingHint,t[29]=W):W=t[29];let G;t[30]!==V||t[31]!==U||t[32]!==W?(G=(0,$.jsxs)(`div`,{children:[V,U,W]}),t[30]=V,t[31]=U,t[32]=W,t[33]=G):G=t[33];let K;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(P,{className:`size-3`,"aria-hidden":!0}),t[34]=K):K=t[34];let ee;t[35]===n.brokerSecretConsoleLink?ee=t[36]:(ee=(0,$.jsxs)(`a`,{href:Ue,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,K]}),t[35]=n.brokerSecretConsoleLink,t[36]=ee);let q;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(q=r?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-muted`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=q):q=t[39];let re;t[40]!==o||t[41]!==c||t[42]!==r||t[43]!==s||t[44]!==O||t[45]!==A||t[46]!==d||t[47]!==g||t[48]!==_||t[49]!==m||t[50]!==f||t[51]!==p||t[52]!==x||t[53]!==l||t[54]!==T||t[55]!==C||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(re=C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(D,{id:g,value:s,labels:T,reveal:Ke,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(R,{type:`button`,variant:`secondary`,disabled:l,onClick:()=>{b({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(R,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:g,children:n.brokerSecretTitle}),(0,$.jsx)(D,{id:g,value:c,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:T,disabled:l}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(R,{type:`button`,disabled:l||!O,onClick:p,children:[l?(0,$.jsx)(ne,{className:`size-4 animate-spin`}):null,_?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),o||r?(0,$.jsx)(R,{type:`button`,variant:`ghost`,disabled:l,onClick:m,children:n.brokerSecretClear}):null,x?(0,$.jsx)(R,{type:`button`,variant:`ghost`,disabled:l,onClick:A,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=o,t[41]=c,t[42]=r,t[43]=s,t[44]=O,t[45]=A,t[46]=d,t[47]=g,t[48]=_,t[49]=m,t[50]=f,t[51]=p,t[52]=x,t[53]=l,t[54]=T,t[55]=C,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=re):re=t[66];let J;t[67]===u?J=t[68]:(J=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[67]=u,t[68]=J);let Y;t[69]!==G||t[70]!==ee||t[71]!==q||t[72]!==re||t[73]!==J?(Y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[G,ee,q,re,J]}),t[69]=G,t[70]=ee,t[71]=q,t[72]=re,t[73]=J,t[74]=Y):Y=t[74];let X;t[75]!==L||t[76]!==Y?(X=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[L,Y]}),t[75]=L,t[76]=Y,t[77]=X):X=t[77];let oe;t[78]!==X||t[79]!==M?(oe=(0,$.jsx)(ve,{className:M,children:X}),t[78]=X,t[79]=M,t[80]=oe):oe=t[80];let se;return t[81]!==h||t[82]!==oe?(se=(0,$.jsx)(`div`,{ref:h,id:`tunnel-broker-secret-setup`,children:oe}),t[81]=h,t[82]=oe,t[83]=se):se=t[83],se}function Ke(){return j().then(qe)}function qe(e){return e.registrationSecret??null}function Je(e){let t=(0,Z.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=v(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=i(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(P,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,$.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}var Ye=e(ye(),1),Xe={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function Ze(e){return Ye.toDataURL(e,Xe)}function Qe(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function $e(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function et(e,t){return e?t?Qe(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function tt(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=p(),a=(0,Q.useRef)(!1),{data:o}=m(r?`tunnel-status`:null,L,{refreshInterval:6e4}),{data:c,mutate:l}=m(r?`tunnel-pair-context`:null,_,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let u=o?.state===`connected`&&!!o.publicUrl?.trim(),f=u&&!n,{data:h,mutate:g}=m(f&&r?`tunnel-qr`:null,fe,{refreshInterval:4*6e4}),{data:v,mutate:y}=m(!f&&r&&c?.pairingReady?`tunnel-pair`:null,pe,{refreshInterval:4*6e4}),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(c!==w.pairContext||n!==w.preferLan)){T({pairContext:c,preferLan:n});let e=et(c,n);b!==e&&x(e)}let E=(0,Q.useCallback)(e=>{a.current=!0,x(e)},[]),D=(0,Q.useCallback)(()=>{let e=et(c,n);e&&(a.current=!0,x(e))},[c,n]),O=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,x(t))},[]),k=(0,Q.useCallback)(e=>{a.current=!1,x(e?.trim()||et(c,n))},[c,n]),A=b.trim(),j=(0,Q.useMemo)(()=>{try{let e=new URL(A);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[A]),M=j&&d(A),N=!f&&!!(c&&!c.pairingReady&&c.blockReason===`GATEWAY_LOOPBACK_ONLY`),P=!f&&j&&!M&&!!v?.pairingSecret&&(c?.pairingReady===!0||!N),F=(0,Q.useMemo)(()=>{let e=Qe(c);return n?e||(A&&!$e(c,A)?A:``):A},[c,n,A]),I=(0,Q.useMemo)(()=>{if(!e)return``;if(S.trim())return S.trim();if(f&&h?.qrPayload?.trim())return h.qrPayload.trim();if(!P||!v?.pairingSecret)return``;let t=c?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=c?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?F:t?.url??A;return i?s({baseUrl:i,pairingSecret:v.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,F,v?.pairingSecret,P,S,n,A,f,h?.qrPayload,c?.candidates]),R=U(()=>Ze(I),[I],{enabled:!!I,initial:null,errorData:null}),z=I?R.data:null,B=!!(I&&R.error!==null&&!R.loading);return{tunnelActive:u,tunnelStatus:o,tunnelQr:h,pairContext:c,pairBaseUrl:b,setPairBaseUrl:E,applySuggestedPairUrl:D,applyCandidateUrl:O,baseOk:j,localhostWarn:M,pairingBlocked:N,deepLink:I,qrPayload:I,qrDataUrl:z,qrGenFailed:B,encoding:!!(I&&!z&&!B),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){C(e.trim()),g({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:h?.lanUrl??null},!1);return}C(``),await l(),f?await g():c?.pairingReady&&await y()},[y,l,g,c?.pairingReady,h?.lanUrl,o?.publicUrl,f]),resetPairBaseFromContext:k}}var nt={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function rt({embedded:e=!1}){let t=o(e=>e.language),n=a(t).tunnelSettings,r=c(e=>e.token),s=!!r,[l,u]=(0,Q.useReducer)(ae,nt),{actionError:d,starting:f,stopping:p,savingAutoStart:g,consentOpen:_,autoStartConfirmOpen:v,releaseConfirmOpen:x,releasing:S,brokerSecretDraft:C,savingBrokerSecret:w,brokerSecretNotice:E}=l,D=(0,Q.useRef)(null),O=tt(r??``),{data:k}=F(s),{data:A,error:j,isLoading:N,mutate:P}=m(s?`tunnel-status`:null,L,{refreshInterval:e=>f?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),I=(0,Q.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return A?.config?.autoStart===!0},[k,A?.config?.autoStart]),z=(0,Q.useMemo)(()=>{let e=k?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[k]),B=te(z),V=A?.registrationSecret?.source===`env`,H=A?.registrationSecret?.source===`missing`,U=A?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{P()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[P]);let W=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),G=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{starting:!0}});try{let e=await J();await P(),T(),await O.refreshQr(e.qrPayload)}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{starting:!1}})}},[P,O.refreshQr]),K=(0,Q.useCallback)(()=>{if(!U){u({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),D.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(A?.consentRequired){u({type:`patch`,patch:{consentOpen:!0}});return}G()},[U,A?.consentRequired,G,n.brokerSecretRequiredBeforeStart]),ee=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{consentOpen:!1}}),u({type:`patch`,patch:{actionError:null}});try{await y(),await Promise.all([P(),G()])}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[P,G]),q=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{actionError:null}}),u({type:`patch`,patch:{stopping:!0}});try{await h(),await Promise.all([O.refreshQr(),P()]),T()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{stopping:!1}})}},[P,O.refreshQr]),re=(0,Q.useCallback)(async e=>{u({type:`patch`,patch:{savingAutoStart:!0}}),u({type:`patch`,patch:{actionError:null}});try{await b({autoStart:e}),T()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingAutoStart:!1}})}},[]),Y=(0,Q.useCallback)(()=>{if(I){re(!1);return}if(A?.consentRequired){u({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!A?.canAutoStart){u({type:`patch`,patch:{actionError:n.autoStartHint}});return}u({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[re,A?.canAutoStart,A?.consentRequired,n,I]),X=(0,Q.useCallback)(async()=>{let e=C.trim();if(e){u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await b({registrationSecret:e}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),T(),await P(),u({type:`patch`,patch:{actionError:null}})}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[C,P,n.brokerSecretSaved]),ie=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await b({registrationSecret:null}),u({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),T(),await P()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{savingBrokerSecret:!1}})}},[P,n.brokerSecretCleared]),se=(0,Q.useCallback)(async()=>{u({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await h({release:!0}),await Promise.all([O.refreshQr(),P()]),T()}catch(e){u({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{u({type:`patch`,patch:{releasing:!1}})}},[P,O.refreshQr]),ce=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!s)return(0,$.jsx)(`div`,{className:e?void 0:`mx-auto w-full max-w-app-main px-4 py-8`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let le=A??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:I,brokerUrl:`https://frp.xopc.ai/api`}},ue=A?.consentRequired&&(le.enabled||I||A?.consent?.acceptedAt),de=(0,$.jsx)(Ge,{t:n,brokerSecretFromEnv:V,brokerSecretMissing:H,brokerSecretConfiguredInConfig:B,brokerSecretMaskedValue:B?z:``,brokerSecretDraft:C,savingBrokerSecret:w,brokerSecretNotice:E,copyFailedLabel:a(t).clipboard.copyFailed,onDraftChange:e=>u({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void X(),onClear:()=>void ie(),sectionRef:D}),fe=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ee,{open:_,title:n.consentTitle,intro:n.consentIntro,bullets:W,checkboxLabel:n.consentCheckbox,confirmLabel:ue?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void ee(),onCancel:()=>u({type:`patch`,patch:{consentOpen:!1}})},_?`consent-open`:`consent-closed`),(0,$.jsx)(oe,{open:v,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{u({type:`patch`,patch:{autoStartConfirmOpen:!1}}),re(!0)},onCancel:()=>u({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(oe,{open:x,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>u({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,de,(0,$.jsx)(He,{t:n,status:le,isLoading:N,statusErr:j,starting:f,stopping:p,showConsentExpired:!!ue,copyLabels:ce,startDisabled:!U,startDisabledReason:U?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:K,onStop:()=>void q()}),(0,$.jsx)(Se,{pairQr:O,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void O.refreshQr()}),(0,$.jsxs)(he,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!I&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:I,disabled:g||!I&&!A?.canAutoStart,onChange:Y}),n.autoStart]}),!A?.canAutoStart&&!I?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,le.subdomain||le.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(R,{type:`button`,variant:`secondary`,disabled:S||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[S?(0,$.jsx)(ne,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(he,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(M,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Je,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),fe]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,de,(0,$.jsx)(He,{t:n,status:le,isLoading:N,statusErr:j,starting:f,stopping:p,showConsentExpired:!!ue,copyLabels:ce,startDisabled:!U,startDisabledReason:U?void 0:n.brokerSecretRequiredBeforeStart,onStart:K,onStop:()=>void q()}),(0,$.jsx)(Se,{pairQr:O,gatewayToken:r??``}),le.subdomain||le.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(R,{type:`button`,variant:`secondary`,disabled:S||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>u({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[S?(0,$.jsx)(ne,{className:`size-4 animate-spin`}):null,n.release]})}):null,le.subdomain||le.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ve,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:i(`flex items-center gap-3 text-sm text-fg`,!I&&!A?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:I,disabled:g||!I&&!A?.canAutoStart,onChange:Y}),n.autoStart]}),!A?.canAutoStart&&!I?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(M,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Je,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),fe]})}async function it(){let e=await f(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function at(e=`serve`){let t=await f(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function ot(){let e=await f(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var st=`https://tailscale.com/download`;function ct(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:st,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function lt({embedded:e=!1}){let t=o(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!c(e=>e.token),[s,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),{data:f,mutate:p,isLoading:h}=m(i?`exposure-status`:null,it,{refreshInterval:3e4}),g=f?.tailscale.hostname,_=f?.tailscale.active===!0,v=f?.tailscale.cliAvailable!==!1,y=g?`https://${g}/`:null,b=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await at(`serve`),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]),x=(0,Q.useCallback)(async()=>{l(!0),d(null);try{await ot(),await p()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[p]);if(!i)return null;let C=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(ct,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&f?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(ct,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,h&&!f?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ve,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(w,{text:y,labels:r})}):null,u?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_?(0,$.jsxs)(R,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void x(),children:[s?(0,$.jsx)(ne,{className:`mr-1 h-4 w-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(R,{type:`button`,disabled:s||!v,onClick:()=>void b(),children:[s?(0,$.jsx)(ne,{className:`mr-1 h-4 w-4 animate-spin`}):(0,$.jsx)(S,{className:`mr-1 h-4 w-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(Je,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?C:(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{icon:M,title:n.title,subtitle:n.subtitle}),C]})}function ut(){let e=(0,Z.c)(26),t=o(ft),n=c(dt),r;e[0]===t?r=e[1]:(r=a(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={preferLan:!0},e[2]=s):s=e[2];let l=tt(n??``,s),u;e[3]!==i.subtitle||e[4]!==i.title?(u=(0,$.jsx)(ge,{icon:g,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=u):u=e[5];let d;e[6]===i.body?d=e[7]:(d=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=d);let f;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),e[8]=f):f=e[8];let p;e[9]===i.link?p=e[10]:(p=(0,$.jsxs)(O,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,f]}),e[9]=i.link,e[10]=p);let m;e[11]!==d||e[12]!==p?(m=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[d,p]}),e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;e[14]!==u||e[15]!==m?(h=(0,$.jsxs)(ve,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=h):h=e[16];let _=n??``,v;e[17]===l?v=e[18]:(v=()=>void l.refreshQr(),e[17]=l,e[18]=v);let y;e[19]!==l||e[20]!==_||e[21]!==v?(y=(0,$.jsx)(Se,{pairQr:l,gatewayToken:_,lanOnly:!0,onRefreshQr:v}),e[19]=l,e[20]=_,e[21]=v,e[22]=y):y=e[22];let b;return e[23]!==y||e[24]!==h?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,y]}),e[23]=y,e[24]=h,e[25]=b):b=e[25],b}function dt(e){return e.token}function ft(e){return e.language}function pt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=o(mt),s;t[0]===i?s=t[1]:(s=a(i),t[0]=i,t[1]=s);let c=s.remoteAccess.ssh,[l,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await k(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=p):p=t[3];let m,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>void f(),h=(0,$.jsx)(z,{className:`mr-1 h-4 w-4`}),t[4]=m,t[5]=h):(m=t[4],h=t[5]);let g=l?c.copied:c.copy,_;t[6]===g?_=t[7]:(_=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(R,{type:`button`,variant:`ghost`,onClick:m,children:[h,g]})}),t[6]=g,t[7]=_);let v;t[8]!==r||t[9]!==c.hint?(v=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c.hint}):null,t[8]=r,t[9]=c.hint,t[10]=v):v=t[10];let y;t[11]!==_||t[12]!==v?(y=(0,$.jsxs)($.Fragment,{children:[p,_,v]}),t[11]=_,t[12]=v,t[13]=y):y=t[13];let b=y;if(r){let e;t[14]!==c.subtitle||t[15]!==c.title?(e=(0,$.jsx)(ge,{icon:V,title:c.title,subtitle:c.subtitle}),t[14]=c.subtitle,t[15]=c.title,t[16]=e):e=t[16];let n;t[17]===b?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:b}),t[17]=b,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ve,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let x;t[22]!==c.subtitle||t[23]!==c.title?(x=(0,$.jsx)(ge,{icon:V,title:c.title,subtitle:c.subtitle}),t[22]=c.subtitle,t[23]=c.title,t[24]=x):x=t[24];let S;t[25]===b?S=t[26]:(S=(0,$.jsx)(`div`,{className:`mt-4`,children:b}),t[25]=b,t[26]=S);let C;return t[27]!==x||t[28]!==S?(C=(0,$.jsxs)(ve,{children:[x,S]}),t[27]=x,t[28]=S,t[29]=C):C=t[29],C}function mt(e){return e.language}function ht(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(pt,{embedded:!0}),e[0]=t):t=e[0],t}function gt(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function _t(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,a;t[0]===r?a=t[1]:(a=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,gt(r)),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,$.jsx)(`span`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function vt(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=o(xt),s;t[0]===r?s=t[1]:(s=a(r),t[0]=r,t[1]=s);let l=s.remoteAccess.guide,u=!!c(bt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,it,d),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:15e3},t[3]=p):p=t[3];let{data:h}=m(u?`tunnel-status`:null,L,p),v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v={refreshInterval:6e4},t[4]=v):v=t[4];let{data:y}=m(u?`tunnel-pair-context`:null,_,v);if(!u)return null;let b=f?.tailscale.active===!0,x=h?.state,S=h?.enabled&&x===`connected`,w=h?.enabled&&(x===`connecting`||x===`reconnecting`||!!h?.startProgress||!!h?.frpcDownload),T=(y?.candidates??[]).some(yt),E=b?`active`:`off`,D=b?l.statusActive:l.statusOff,O;t[5]!==l.tailscaleCardTitle||t[6]!==E||t[7]!==D?(O={tab:`tailscale`,icon:M,title:l.tailscaleCardTitle,kind:E,statusLabel:D},t[5]=l.tailscaleCardTitle,t[6]=E,t[7]=D,t[8]=O):O=t[8];let k=S?`active`:w?`connecting`:`off`,A=S?l.statusActive:w?l.statusConnecting:l.statusOff,j;t[9]!==l.publicCardTitle||t[10]!==k||t[11]!==A?(j={tab:`public`,icon:C,title:l.publicCardTitle,kind:k,statusLabel:A},t[9]=l.publicCardTitle,t[10]=k,t[11]=A,t[12]=j):j=t[12];let N=T?`active`:`off`,P=T?l.statusActive:l.statusOff,F;t[13]!==l.reverseProxyCardTitle||t[14]!==N||t[15]!==P?(F={tab:`reverse-proxy`,icon:ue,title:l.reverseProxyCardTitle,kind:N,statusLabel:P},t[13]=l.reverseProxyCardTitle,t[14]=N,t[15]=P,t[16]=F):F=t[16];let I;t[17]!==l.sshCardStatus||t[18]!==l.sshCardTitle?(I={tab:`ssh`,icon:V,title:l.sshCardTitle,kind:`off`,statusLabel:l.sshCardStatus},t[17]=l.sshCardStatus,t[18]=l.sshCardTitle,t[19]=I):I=t[19];let R;t[20]!==l.lanCardStatus||t[21]!==l.lanCardTitle?(R={tab:`lan`,icon:g,title:l.lanCardTitle,kind:`off`,statusLabel:l.lanCardStatus},t[20]=l.lanCardStatus,t[21]=l.lanCardTitle,t[22]=R):R=t[22];let z;t[23]!==j||t[24]!==F||t[25]!==I||t[26]!==R||t[27]!==O?(z=[O,j,F,I,R],t[23]=j,t[24]=F,t[25]=I,t[26]=R,t[27]=O,t[28]=z):z=t[28];let B=z,H;return t[29]!==B||t[30]!==n?(H=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:B.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:i(`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3 py-2.5 text-left transition-colors`,`hover:border-edge hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(_t,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=B,t[30]=n,t[31]=H):H=t[31],H}function yt(e){return e.kind===`reverse-proxy`}function bt(e){return e.token}function xt(e){return e.language}function St(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:a,icon:o,onOpen:s,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-2xl bg-surface-base px-4 py-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==a||t[6]!==l?(p=a&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=a,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Ct(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=o(Et),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let s=i.remoteAccess,l=s.guide,u=!!c(Tt),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:3e4},t[2]=d):d=t[2];let{data:f}=m(u?`exposure-status`:null,it,d),p;t[3]===f?.conflicts?p=t[4]:(p=f?.conflicts??[],t[3]=f?.conflicts,t[4]=p);let h=p;if(!u){let e;return t[5]===l.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.needToken}),t[5]=l.needToken,t[6]=e),e}let _;t[7]===n?_=t[8]:(_=(0,$.jsx)(vt,{onOpenTab:n}),t[7]=n,t[8]=_);let v;t[9]!==h||t[10]!==l.conflictsHint||t[11]!==l.conflictsTitle?(v=h.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:l.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:l.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:h.map(wt)})]}):null,t[9]=h,t[10]=l.conflictsHint,t[11]=l.conflictsTitle,t[12]=v):v=t[12];let y;t[13]===l.pickMethod?y=t[14]:(y=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.pickMethod}),t[13]=l.pickMethod,t[14]=y);let b;t[15]===n?b=t[16]:(b=()=>n(`tailscale`),t[15]=n,t[16]=b);let x;t[17]!==l.configure||t[18]!==l.recommended||t[19]!==l.tailscaleCardDesc||t[20]!==l.tailscaleCardTitle||t[21]!==b?(x=(0,$.jsx)(St,{icon:M,title:l.tailscaleCardTitle,description:l.tailscaleCardDesc,recommended:!0,recommendedLabel:l.recommended,openLabel:l.configure,onOpen:b}),t[17]=l.configure,t[18]=l.recommended,t[19]=l.tailscaleCardDesc,t[20]=l.tailscaleCardTitle,t[21]=b,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=()=>n(`public`),t[23]=n,t[24]=S);let w;t[25]!==l.configure||t[26]!==l.publicCardDesc||t[27]!==l.publicCardTitle||t[28]!==S?(w=(0,$.jsx)(St,{icon:C,title:l.publicCardTitle,description:l.publicCardDesc,openLabel:l.configure,onOpen:S}),t[25]=l.configure,t[26]=l.publicCardDesc,t[27]=l.publicCardTitle,t[28]=S,t[29]=w):w=t[29];let T;t[30]===n?T=t[31]:(T=()=>n(`reverse-proxy`),t[30]=n,t[31]=T);let E;t[32]!==l.configure||t[33]!==l.reverseProxyCardDesc||t[34]!==l.reverseProxyCardTitle||t[35]!==T?(E=(0,$.jsx)(St,{icon:ue,title:l.reverseProxyCardTitle,description:l.reverseProxyCardDesc,openLabel:l.configure,onOpen:T}),t[32]=l.configure,t[33]=l.reverseProxyCardDesc,t[34]=l.reverseProxyCardTitle,t[35]=T,t[36]=E):E=t[36];let D;t[37]===n?D=t[38]:(D=()=>n(`ssh`),t[37]=n,t[38]=D);let O;t[39]!==l.configure||t[40]!==l.sshCardDesc||t[41]!==l.sshCardTitle||t[42]!==D?(O=(0,$.jsx)(St,{icon:V,title:l.sshCardTitle,description:l.sshCardDesc,openLabel:l.configure,onOpen:D}),t[39]=l.configure,t[40]=l.sshCardDesc,t[41]=l.sshCardTitle,t[42]=D,t[43]=O):O=t[43];let k;t[44]===n?k=t[45]:(k=()=>n(`lan`),t[44]=n,t[45]=k);let A;t[46]!==l.configure||t[47]!==l.lanCardDesc||t[48]!==l.lanCardTitle||t[49]!==k?(A=(0,$.jsx)(St,{icon:g,title:l.lanCardTitle,description:l.lanCardDesc,openLabel:l.configure,onOpen:k}),t[46]=l.configure,t[47]=l.lanCardDesc,t[48]=l.lanCardTitle,t[49]=k,t[50]=A):A=t[50];let j;t[51]!==w||t[52]!==E||t[53]!==O||t[54]!==A||t[55]!==x?(j=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[x,w,E,O,A]}),t[51]=w,t[52]=E,t[53]=O,t[54]=A,t[55]=x,t[56]=j):j=t[56];let N;t[57]!==j||t[58]!==y?(N=(0,$.jsxs)(`div`,{children:[y,j]}),t[57]=j,t[58]=y,t[59]=N):N=t[59];let P;t[60]===l.oneAtATimeHint?P=t[61]:(P=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:l.oneAtATimeHint}),t[60]=l.oneAtATimeHint,t[61]=P);let F;t[62]===s.advanced.proxyTitle?F=t[63]:(F=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.advanced.proxyTitle}),t[62]=s.advanced.proxyTitle,t[63]=F);let I;t[64]===s.advanced.proxyBody?I=t[65]:(I=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.advanced.proxyBody}),t[64]=s.advanced.proxyBody,t[65]=I);let L;t[66]!==r||t[67]!==s.advanced.proxyDocs?(L=(0,$.jsx)(Je,{language:r,label:s.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=s.advanced.proxyDocs,t[68]=L):L=t[68];let R;t[69]!==F||t[70]!==I||t[71]!==L?(R=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-4 py-3`,children:[F,I,L]}),t[69]=F,t[70]=I,t[71]=L,t[72]=R):R=t[72];let z;t[73]!==l.docsLink||t[74]!==r?(z=(0,$.jsx)(Je,{language:r,label:l.docsLink}),t[73]=l.docsLink,t[74]=r,t[75]=z):z=t[75];let B;return t[76]!==N||t[77]!==P||t[78]!==R||t[79]!==z||t[80]!==_||t[81]!==v?(B=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[_,v,N,P,R,z]}),t[76]=N,t[77]=P,t[78]=R,t[79]=z,t[80]=_,t[81]=v,t[82]=B):B=t[82],B}function wt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Tt(e){return e.token}function Et(e){return e.language}async function Dt(e){let t=await f(l(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Ot(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function kt(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function At(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||kt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function jt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function Mt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Nt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Pt(){let e=o(e=>e.language),t=a(e).remoteAccess.reverseProxy,n=!!c(e=>e.token),r=At(),{mutate:l}=p(),{data:u,mutate:d}=m(n?`tunnel-pair-context`:null,_,{refreshInterval:6e4}),f=Mt(u),[h,g]=(0,Q.useState)(``),[v,y]=(0,Q.useState)({busy:!1,result:null}),[b,x]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{h||(f?g(f):r&&g(r))},[f,r,h]);let S=(0,Q.useMemo)(()=>h.trim()||(f??r??``),[f,r,h]),C=!f&&!!r&&S===r,T=Nt(u),{data:E,mutate:D}=m(n&&S?[`reverse-proxy-pair`,S]:null,()=>pe(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),O=(0,Q.useMemo)(()=>!S||!E?.pairingSecret?``:s({baseUrl:S,pairingSecret:E.pairingSecret,lanUrl:T}),[S,T,E?.pairingSecret]),k=U(()=>Ze(O),[O],{enabled:!!O,initial:null,errorData:null}),A=(0,Q.useCallback)(async()=>{let e=h.trim()||S;if(e){y({busy:!0,result:null});try{y({busy:!1,result:await Dt(e)})}catch(e){y({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[h,S]),j=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){x({busy:!0,error:null});try{await Ot(e),await d(),await l(`tunnel-pair-context`),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[S,l,d]),N=(0,Q.useCallback)(async()=>{x({busy:!0,error:null});try{await Ot(null),await d(),await l(`tunnel-pair-context`),g(``),y({busy:!1,result:null}),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}},[l,d]),P=(0,Q.useCallback)(async()=>{await D()},[D]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{icon:M,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:i(jt(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:h,onChange:e=>{g(e.target.value),y({busy:!1,result:null})}}),(0,$.jsxs)(R,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void A(),disabled:v.busy||!h.trim(),children:[v.busy?(0,$.jsx)(ne,{className:`size-3.5 animate-spin`}):null,v.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),C&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,v.result?(0,$.jsx)(Ft,{result:v.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[S&&f!==S?(0,$.jsxs)(R,{type:`button`,onClick:()=>void j(),disabled:b.busy,children:[b.busy?(0,$.jsx)(ne,{className:`size-3.5 animate-spin`}):null,b.busy?t.saving:t.saveAsDefault]}):null,f?(0,$.jsx)(R,{type:`button`,variant:`ghost`,onClick:()=>void N(),disabled:b.busy,children:t.clear}):null]}),b.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:b.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(ve,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),O?(0,$.jsxs)(R,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void P(),children:[(0,$.jsx)(re,{className:`size-4`}),t.refreshQr]}):null]}),S?E?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,S,T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,T]}):null]}),k.data?(0,$.jsx)(`img`,{src:k.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):k.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(w,{text:O,labels:{copy:t.copyLink,copied:t.copied,copyFailed:a(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function Ft(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var It=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Lt(e){return e&&It.includes(e)?e:`guide`}function Rt(e,t){return e.tabs[t]}function zt(e,t){return e.tabIntro[t]}function Bt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Vt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Ct,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(lt,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(rt,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Pt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ht,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ut,{}),t[6]=e):e=t[6],e}}}function Ht(){let e=(0,Z.c)(2),t=o(Wt),n=a(t).remoteAccess,r=!!c(Ut),[s,l]=E(),u=Lt(s.get(`tab`)),d;e[0]===l?d=e[1]:(d=e=>{l(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=l,e[1]=d);let f=d,p=zt(n,u);return(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-5 px-4 py-8`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.pageTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.pageSubtitle}),(0,$.jsx)(Je,{language:t,label:n.docsLink,section:Bt(u),className:`mt-1`})]}),r?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,role:`tablist`,"aria-label":n.tabsAria,onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=It[(It.indexOf(u)+(e.key===`ArrowRight`?1:-1)+It.length)%It.length];f(t)},children:[(0,$.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:It.map(e=>{let t=e===u;return(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,id:`remote-access-tab-${e}`,"aria-controls":`remote-access-panel-${e}`,className:i(`shrink-0 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>f(e),children:Rt(n,e)},e)})}),u===`public`?null:(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:p}),(0,$.jsx)(`div`,{role:`tabpanel`,id:`remote-access-panel-${u}`,"aria-labelledby":`remote-access-tab-${u}`,className:`min-w-0`,children:(0,$.jsx)(Vt,{tab:u,onOpenTab:f})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Ut(e){return e.token}function Wt(e){return e.language}export{Ht as RemoteAccessHub};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{Ui as a,Vi as o,zi as s}from"./index-CwhK8qCh.js";import{n as c,r as l}from"./interval-presets-0DtsnxE0.js";var u=n(),d=e(t(),1),f=r(),p=i(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,s),m=i(o,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function h(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function g({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=c,minSeconds:a=1}){let o=(0,d.useMemo)(()=>new Set(i),[i]),s=(0,d.useMemo)(()=>o.has(e)?String(e):``,[o,e]),[l,u]=(0,d.useState)(null),g=(0,d.useRef)(e);g.current!==e&&(g.current=e,u(null));let _=Math.max(a,Math.round(e/1e3)),v=l===null?String(_):l;return(0,f.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(`input`,{type:`number`,min:a,step:1,disabled:r,className:p,value:v,onChange:e=>{let n=e.target.value;u(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=a&&t(r*1e3)},onBlur:()=>{if(l===null)return;let e=parseInt(l,10);t(!Number.isFinite(e)||e<a?a*1e3:e*1e3),u(null)}}),(0,f.jsxs)(`select`,{className:m,disabled:r,value:s,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),u(null))},children:[(0,f.jsx)(`option`,{value:``,children:n.presets.custom}),i.map(e=>(0,f.jsx)(`option`,{value:String(e),children:h(e,n.presets)},e))]})]})]})}var _=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,s),v=()=>({start:`09:00`,end:`22:00`,timezone:``});function y(e){let t=(0,u.c)(55),{value:n,onChange:r,labels:i,disabled:o}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(v()),t[0]=r,t[1]=e);let n;return t[2]!==o||t[3]!==i.add||t[4]!==e?(n=(0,f.jsx)(a,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:o,onClick:e,children:i.add}),t[2]=o,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let s;t[6]===i.start?s=t[7]:(s=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=s);let c;t[8]!==r||t[9]!==n?(c=e=>r({...n,start:e.target.value}),t[8]=r,t[9]=n,t[10]=c):c=t[10];let l;t[11]!==o||t[12]!==c||t[13]!==n.start?(l=(0,f.jsx)(`input`,{type:`time`,step:60,disabled:o,className:_,value:n.start,onChange:c}),t[11]=o,t[12]=c,t[13]=n.start,t[14]=l):l=t[14];let d;t[15]!==s||t[16]!==l?(d=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[s,l]}),t[15]=s,t[16]=l,t[17]=d):d=t[17];let p;t[18]===i.end?p=t[19]:(p=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[18]=i.end,t[19]=p);let m;t[20]!==r||t[21]!==n?(m=e=>r({...n,end:e.target.value}),t[20]=r,t[21]=n,t[22]=m):m=t[22];let h;t[23]!==o||t[24]!==m||t[25]!==n.end?(h=(0,f.jsx)(`input`,{type:`time`,step:60,disabled:o,className:_,value:n.end,onChange:m}),t[23]=o,t[24]=m,t[25]=n.end,t[26]=h):h=t[26];let g;t[27]!==p||t[28]!==h?(g=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[p,h]}),t[27]=p,t[28]=h,t[29]=g):g=t[29];let y;t[30]===i.timezone?y=t[31]:(y=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[30]=i.timezone,t[31]=y);let b;t[32]!==r||t[33]!==n?(b=e=>r({...n,timezone:e.target.value}),t[32]=r,t[33]=n,t[34]=b):b=t[34];let x;t[35]!==o||t[36]!==b||t[37]!==n.timezone?(x=(0,f.jsx)(`input`,{type:`text`,disabled:o,className:_,value:n.timezone,onChange:b,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[35]=o,t[36]=b,t[37]=n.timezone,t[38]=x):x=t[38];let S;t[39]!==x||t[40]!==y?(S=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[y,x]}),t[39]=x,t[40]=y,t[41]=S):S=t[41];let C;t[42]!==S||t[43]!==d||t[44]!==g?(C=(0,f.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[d,g,S]}),t[42]=S,t[43]=d,t[44]=g,t[45]=C):C=t[45];let w;t[46]===r?w=t[47]:(w=()=>r(null),t[46]=r,t[47]=w);let T;t[48]!==o||t[49]!==i.clear||t[50]!==w?(T=(0,f.jsx)(a,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:o,onClick:w,children:i.clear}),t[48]=o,t[49]=i.clear,t[50]=w,t[51]=T):T=t[51];let E;return t[52]!==C||t[53]!==T?(E=(0,f.jsxs)(`div`,{className:`space-y-2`,children:[C,T]}),t[52]=C,t[53]=T,t[54]=E):E=t[54],E}function b(e){let t=(0,u.c)(34),{disabled:n,label:r,hint:a,className:o}=e,s;t[0]===o?s=t[1]:(s=i(`flex flex-col gap-2`,o),t[0]=o,t[1]=s);let d;t[2]===r?d=t[3]:(d=r?(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=d);let p;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(p=e.kind===`cron`?(0,f.jsx)(l,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=p):p=t[10];let m;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(m=e.kind===`interval`?(0,f.jsx)(g,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??c,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=m):m=t[18];let h;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(h=e.kind===`active-hours`?(0,f.jsx)(y,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=h):h=t[24];let _;t[25]===a?_=t[26]:(_=a?(0,f.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[25]=a,t[26]=_);let v;return t[27]!==s||t[28]!==d||t[29]!==p||t[30]!==m||t[31]!==h||t[32]!==_?(v=(0,f.jsxs)(`div`,{className:s,children:[d,p,m,h,_]}),t[27]=s,t[28]=d,t[29]=p,t[30]=m,t[31]=h,t[32]=_,t[33]=v):v=t[33],v}export{b as t};
|