@xopcai/xopc 0.0.404 → 0.0.406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CdwFK70g.js → agent-avatar-dicebear-BE3ci_lj.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BMj9HwIQ.js → agent-defaults-settings-panel-DzDaum4Y.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-hrm6V8Dp.js → agents-BfC3FYYe.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Rg9jOmoj.js → app-management-settings-panel-BDbJKxa-.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-S3yp0GUO.js → appearance-settings-CEOOrVYb.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-ChrJSB_2.js → apps-page-CpoG_3PG.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-J7hwA5cs.js → archive-plugin-B7pzPErg.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Cesz1cjw.js → automations-page-CcQjEiqk.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DdopDyED.js → automations-workspace-BVTP3pzt.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-Bg4Se8Kg.js → binary-plugins-D5kTu6gH.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Bw1sO9YH.js → block-editor-CnW6rF_e.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-Y46Mf8aY.js → browser-automation-inputs-CAcUtInP.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BcNjBdFQ.js → browser-automations-page-DT7-lnPN.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-ByeqxrSF.js → browser-settings-page-ByK8znt2.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-CIv3LUQk.js → capabilities-Dl3LttAm.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-BUTQSo3A.js → capabilities-page-C8tv6M_O.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-B-Uwmjbo.js → capabilities-settings-panel-OVLgL6yL.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-BGGJKzPL.js → capability-header-actions-jztljvVW.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-z6iuM4HE.js → channels-D8BKMMPW.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-oMmP0flJ.js → chat-terminal-dock-BVlFOKJj.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CERhSG5W.js → computer-settings-page-CvQgrTwb.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DyW3mLTh.js → connector-service-page-BNcTUa99.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-CdMwhiio.js → connectors-page-CWlLRQpK.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-CO3Jhdzg.js → date-picker-BKUmdSp7.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DbyMpo5J.js → dependency-picker-BarQvwoO.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DJ9OAPJs.js → desktop-pet-IvADYxyi.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CNrNXWlk.js → desktop-pet-settings-y6WzhGEK.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-TzK-VCuf.js → device-pairing-wizard-D3IUZ8xW.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BmFgRA8G.js → directory-picker-path-field-DnEvwMTm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C3ZpHHYc.js → extension-debug-page-CCvuK1m0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-gfOwpT2R.js → extension-page-DegRwY3R.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BS7cDqZJ.js → extension-settings-page-B8UQgGgZ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-UB6hyqcj.js → gateway-settings-DlLyLsXY.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BRfDRn2k.js → highlighted-body-KQOG7T2V-MjAoJQJX.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DBUnR1DO.js → home-page-DAYtNK3o.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-BoMWmqwF.js → image-generation-api-SQDixWjO.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-CPiPsiEP.js → imports-page-1ZId0Ng0.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DmURUvvA.js → index-K2cy4f-3.js} +116 -116
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D9y8h4dR.js → keyboard-shortcuts-settings-yMwBt1Sv.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DoAmV6on.js → local-app-workbench-page-a7J0NPIs.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CE6Ag8oQ.js → local-apps-page-CF6_kS9C.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DFysUb2k.js → logs-page-C8y5yhoM.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-CmXPsu0I.js → management-settings-C7dL_jNu.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DvfdiczR.js → media-plugins-UYX1YivF.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-7zpLTDLZ.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-BpddDFQt.js → note-detail-panel-Bxm523Up.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-B7ARnjnB.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-DQ4KZsWt.js → notes-page-BOeS2v6x.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BcxVEGa2.js → page-context-capture-button-DOrPS73o.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-CCQDxb7E.js → personal-page-BujiHops.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-CGFQ_-bG.js → plugin-details-dialog-XOzQrJQN.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-presentation-DF1gfuGf.js → plugin-presentation-CPEwVLd4.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CXjjpXVx.js → preview-open-alternatives-BP9C0kH3.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DqiyvM4c.js → product-open-page-D151rJVy.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-f7Q4giA3.js → product-preview-content-CAo0XpP-.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CxB_kF0F.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-DO_pIhy-.js → projects-page-Dvu_3c2g.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BFtELmg0.js → remote-access-hub-CbzBV_BL.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-B9Beu-oK.js → runtime-tools-settings-panel-DyLxlqWV.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-ZAX7C5uI.js → schema-form-ClP4uPSj.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-BUMUjup5.js → session-manager-DMDBMYfh.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-D27knqOl.js → sessions-page-CvfoPeM6.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BOkrHL8q.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BTUFu5KS.js → settings-form-section-B4NShgv-.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-YFr6zzh7.js → settings-page-C54bw5J9.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-C5Jszsd1.js → setup-status-panel-BVKQ2inq.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CsfrvY_G.js → share-preview-page-BxN9t3MD.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-BW6BNot0.js → shares-settings-BOa9NAUc.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-o3HSgF_K.js → skill-api-E0E-MH1S.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-BJsPnE87.js → skill-reload-api-DEN6tOwG.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Kuf2t7MG.js → skills-page-CeNVBQG9.js} +1 -1
- package/dist/gateway/static/root/assets/{style-DOz6lLJB.js → style-Bs9x3WBj.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-B69rR6vw.js → system-settings-panel-DpQPaJId.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-DzK53B5p.js +2 -0
- package/dist/gateway/static/root/assets/{task-expandable-content-BZCJqajv.js → task-expandable-content-BoGtWYbk.js} +1 -1
- package/dist/gateway/static/root/assets/{tasks-PuIUgF9L.js → tasks-B4bZpO6O.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-BIq3Ayeg.js → tracing-settings-page-BUUnZfZW.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-V9pJ8fUo.js → tunnel-api-3GopOQ_S.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DZdpti28.js → usage-page-B8j47CWQ.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BnMIUc_5.js → use-autosave-CYIuWnRn.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-BEgJ97hp.js → user-model-page-DxcH74eP.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-1h6fMaZL.js → voice-api-key-field-BN37Lklj.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CVNqSNz8.js → work-discovery-overlay-C_bcAAX6.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Dq63AthQ.js → workflow-run-setup-panel-B5oKCzTn.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-CfA1iwZu.js → workflows-page-Bo5b5t_9.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BsW2acj1.js → xopc-cloud-account-card-DGGi4zVC.js} +1 -1
- package/dist/gateway/static/root/index.html +4 -4
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/tasks.js +27 -8
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/external-tools/cliProvider.js +2 -2
- package/dist/src/agent/external-tools/composio-provider.js +2 -2
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +1 -1
- package/dist/src/agent-catalog/repository.js +1 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/write.d.ts +14 -0
- package/dist/src/automations/domain/validation.d.ts +28 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -1
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +2 -2
- package/dist/src/cli/commands/extension.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/execution-environments/local-worktree-manager.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/config.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +3 -2
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -0
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/imports/importService.js +1 -1
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/personal-agent/service.js +1 -1
- package/dist/src/providers/prompt-cache-lifecycle.d.ts +1 -1
- package/dist/src/providers/prompt-cache-lifecycle.js +1 -1
- package/dist/src/runtime-tools/archive.js +1 -1
- package/dist/src/storage/sqlite/migrations/258_task_phase_changes.sql +20 -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/schema.js +1 -1
- package/dist/src/tasks/capabilities/read.js +3 -2
- package/dist/src/tasks/capabilities/write.js +3 -3
- package/dist/src/tasks/task-application-service.d.ts +2 -1
- package/dist/src/tasks/task-application-service.js +80 -12
- package/dist/src/tasks/task-collaboration-delivery.js +2 -1
- package/dist/src/tasks/task-context-assembler.js +2 -1
- package/dist/src/tasks/task-read-model-projector.js +13 -5
- package/dist/src/tasks/task-repository.d.ts +11 -1
- package/dist/src/tasks/task-repository.js +42 -7
- package/dist/src/tasks/task-run-coordinator.d.ts +2 -0
- package/dist/src/tasks/task-run-coordinator.js +26 -17
- package/dist/src/tasks/task-run-repository.js +5 -2
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-SuiLTd5Y.js +0 -1
- package/dist/gateway/static/root/assets/note-image-lightbox-CMLVzPsQ.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-PBK7vXK5.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDzdr1zW.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DOb97OLI.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./messages-Bwv-AOYl.js";import{t as o}from"./cn-0WouolD0.js";import{a as s,c,n as l,r as u}from"./locale-store-D5h-Ha6-.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{n as p,r as m}from"./gateway-config-swr-BvuySoCX.js";import{$l as h,G as g,Ic as _,Ju as v,Kc as y,Ml as b,Ms as x,Ns as S,Nu as C,On as w,Ps as T,Qn as E,Rc as D,Rs as O,Vn as k,Xl as A,Za as j,Zl as M,cu as N,dd as P,ds as F,du as I,fs as L,is as R,lu as ee,no as te,pd as z,ss as ne,uf as re}from"./index-DmURUvvA.js";import{t as B}from"./number-input-DDeqHK-G.js";import{n as ie,r as ae,t as oe}from"./settings-page-layout-Dx5S-Msc.js";import{n as se,t as ce}from"./settings-form-section-BTUFu5KS.js";import{t as le}from"./settings-advanced-gate-CDzdr1zW.js";var V=e(t(),1),H=n(),U=18790,W={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return T(e)}async function ue(e){let t=await s(u(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function q(e){return K(e)?``:e.trim()}function de(e){return[...e].map(e=>e.trim()).sort()}function fe(e){return JSON.stringify({outboundProxy:e.outboundProxy,bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:q(e.auth.token),password:q(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:de(e.auth.trustedProxy.requiredHeaders),allowUsers:de(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},trustedProxies:de(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function pe(e,t){return fe(e)!==fe(t)}async function me(e){return(await s(u(`/api/gateway/cors-origin-candidates?port=${encodeURIComponent(String(e))}`))).payload?.candidates??[]}function he(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function J(e){let t=G(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):W.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):W.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):W.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function ge(e){let t=G(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:Y(t.requiredHeaders,32),allowUsers:Y(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function _e(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function Y(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function ve(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function ye(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function be(e){try{let t=new URL(e.trim());return[`http:`,`https:`].includes(t.protocol)&&!!t.hostname&&!t.username&&!t.password&&!t.search&&!t.hash&&(!t.pathname||t.pathname===`/`)}catch{return!1}}function xe(e){let t=e.outboundProxy;if((t.mode===`custom`||t.url.trim())&&!be(t.url))return`Use an HTTP or HTTPS proxy origin without credentials, path, query or fragment.`;let n=ye(e);return n&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:n&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:n&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function Se(e){let t=G(e)?e:{},n=G(t.gateway)?t.gateway:{},r=G(n.auth)?n.auth:{},i=G(n.security)?n.security:{},a=G(t.update)?t.update:{},o=G(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[],u=ve(n.bind),d=typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,f=G(n.outboundProxy)?n.outboundProxy:{};return{outboundProxy:{mode:f.mode===`custom`||f.mode===`direct`?f.mode:`environment`,url:typeof f.url==`string`?f.url:``,noProxy:typeof f.noProxy==`string`?f.noProxy:``},bind:u,customBindHost:d,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):U,auth:{mode:he(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:J(r.rateLimit),trustedProxy:ge(r.trustedProxy)},corsOrigins:l,trustedProxies:Y(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:_e(n.channelConnectDeferMode),channelConnectDeferIds:Y(n.channelConnectDeferIds),channelConnectDeferSkipIds:Y(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function Ce(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!K(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!K(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function we(e){let t=xe(e);if(t)throw Error(t);await s(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{outboundProxy:e.outboundProxy,bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:Ce(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),p()}var X=r();function Te(e){let t=(0,H.c)(46),{value:n,onChange:r,g:i}=e,[a,s]=(0,V.useState)(!1),c;t[0]!==a||t[1]!==n.mode||t[2]!==n.url?(c=a&&n.mode===`custom`&&!be(n.url),t[0]=a,t[1]=n.mode,t[2]=n.url,t[3]=c):c=t[3];let l=c,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,O),t[4]=u):u=t[4];let d=u,f;t[5]===i.outboundProxyTitle?f=t[6]:(f=(0,X.jsx)(`h2`,{id:`outbound-proxy-title`,className:`text-sm font-semibold text-fg`,children:i.outboundProxyTitle}),t[5]=i.outboundProxyTitle,t[6]=f);let p;t[7]===i.outboundProxyHint?p=t[8]:(p=(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.outboundProxyHint}),t[7]=i.outboundProxyHint,t[8]=p);let m;t[9]===i.outboundProxyMode?m=t[10]:(m=(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-mode`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyMode}),t[9]=i.outboundProxyMode,t[10]=m);let h;t[11]!==r||t[12]!==n?(h=e=>r({...n,mode:e.target.value}),t[11]=r,t[12]=n,t[13]=h):h=t[13];let g;t[14]===i.outboundProxyEnvironment?g=t[15]:(g=(0,X.jsx)(L,{value:`environment`,children:i.outboundProxyEnvironment}),t[14]=i.outboundProxyEnvironment,t[15]=g);let _;t[16]===i.outboundProxyCustom?_=t[17]:(_=(0,X.jsx)(L,{value:`custom`,children:i.outboundProxyCustom}),t[16]=i.outboundProxyCustom,t[17]=_);let v;t[18]===i.outboundProxyDirect?v=t[19]:(v=(0,X.jsx)(L,{value:`direct`,children:i.outboundProxyDirect}),t[18]=i.outboundProxyDirect,t[19]=v);let y;t[20]!==h||t[21]!==g||t[22]!==_||t[23]!==v||t[24]!==n.mode?(y=(0,X.jsxs)(F,{id:`outbound-proxy-mode`,value:n.mode,onChange:h,children:[g,_,v]}),t[20]=h,t[21]=g,t[22]=_,t[23]=v,t[24]=n.mode,t[25]=y):y=t[25];let b;t[26]!==y||t[27]!==m?(b=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[m,y]}),t[26]=y,t[27]=m,t[28]=b):b=t[28];let x;t[29]!==i.outboundProxyInvalid||t[30]!==i.outboundProxyUrl||t[31]!==l||t[32]!==r||t[33]!==n?(x=n.mode===`custom`&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-url`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyUrl}),(0,X.jsx)(`input`,{id:`outbound-proxy-url`,className:d,value:n.url,placeholder:`http://127.0.0.1:7897`,autoComplete:`off`,spellCheck:!1,"aria-invalid":l,"aria-describedby":l?`outbound-proxy-error`:void 0,onChange:e=>r({...n,url:e.target.value}),onBlur:()=>s(!0)}),l&&(0,X.jsx)(`p`,{id:`outbound-proxy-error`,role:`alert`,className:`text-xs text-danger`,children:i.outboundProxyInvalid})]}),t[29]=i.outboundProxyInvalid,t[30]=i.outboundProxyUrl,t[31]=l,t[32]=r,t[33]=n,t[34]=x):x=t[34];let S;t[35]!==i.outboundProxyBypass||t[36]!==i.outboundProxyBypassHint||t[37]!==r||t[38]!==n?(S=n.mode!==`direct`&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-bypass`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyBypass}),(0,X.jsx)(`input`,{id:`outbound-proxy-bypass`,className:d,value:n.noProxy,placeholder:`.example.com,192.168.1.10`,autoComplete:`off`,spellCheck:!1,"aria-describedby":`outbound-proxy-bypass-hint`,onChange:e=>r({...n,noProxy:e.target.value})}),(0,X.jsx)(`p`,{id:`outbound-proxy-bypass-hint`,className:`text-xs text-fg-muted`,children:i.outboundProxyBypassHint})]}),t[35]=i.outboundProxyBypass,t[36]=i.outboundProxyBypassHint,t[37]=r,t[38]=n,t[39]=S):S=t[39];let C;return t[40]!==b||t[41]!==x||t[42]!==S||t[43]!==f||t[44]!==p?(C=(0,X.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,"aria-labelledby":`outbound-proxy-title`,children:[f,p,b,x,S]}),t[40]=b,t[41]=x,t[42]=S,t[43]=f,t[44]=p,t[45]=C):C=t[45],C}var Ee={critical:3,warn:2,info:1};function De(){return u(`/api/doctor?security=true`)}function Oe(e){return e.toSorted((e,t)=>Ee[t.severity]-Ee[e.severity]||e.checkId.localeCompare(t.checkId))}function ke(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=Oe((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function Ae(){return ke(await s(De()))}function je(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,o=l(Ne),s;t[0]===o?s=t[1]:(s=a(o),t[0]=o,t[1]=s);let c=s.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[De(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:g,isLoading:_,isValidating:b,mutate:x}=d(u,Me,p),S=m??null,C=g instanceof Error?g.message:g?String(g):null,w=_||b,T;t[6]===x?T=t[7]:(T=()=>{x(),f(De())},t[6]=x,t[7]=T);let E=T,O=!n||w,k;t[8]===w?k=t[9]:(k=w?(0,X.jsx)(v,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),t[8]=w,t[9]=k);let A;t[10]===c.securityAuditRefresh?A=t[11]:(A=(0,X.jsx)(`span`,{className:`ml-1.5`,children:c.securityAuditRefresh}),t[10]=c.securityAuditRefresh,t[11]=A);let j;t[12]!==E||t[13]!==O||t[14]!==k||t[15]!==A?(j=(0,X.jsxs)(y,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:E,children:[k,A]}),t[12]=E,t[13]=O,t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]!==c.securityAuditSubtitle||t[18]!==c.securityAuditTitle||t[19]!==j?(M=(0,X.jsx)(se,{icon:h,title:c.securityAuditTitle,subtitle:c.securityAuditSubtitle,trailing:j}),t[17]=c.securityAuditSubtitle,t[18]=c.securityAuditTitle,t[19]=j,t[20]=M):M=t[20];let N;t[21]===c.securityAuditSavedConfigHint?N=t[22]:(N=(0,X.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:c.securityAuditSavedConfigHint}),t[21]=c.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==C||t[24]!==c.securityAuditLoadError?(P=C?(0,X.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[c.securityAuditLoadError,`: `,C]}):null,t[23]=C,t[24]=c.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==S||t[27]!==C||t[28]!==w?(F=!C&&w&&!S?(0,X.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,X.jsx)(D,{className:`h-11 w-full rounded-lg`}),(0,X.jsx)(D,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=S,t[27]=C,t[28]=w,t[29]=F):F=t[29];let L;t[30]!==S||t[31]!==c?(L=S?(0,X.jsx)(Pe,{g:c,audit:S}):null,t[30]=S,t[31]=c,t[32]=L):L=t[32];let R;return t[33]!==M||t[34]!==N||t[35]!==P||t[36]!==F||t[37]!==L?(R=(0,X.jsxs)(ce,{children:[M,N,P,F,L]}),t[33]=M,t[34]=N,t[35]=P,t[36]=F,t[37]=L,t[38]=R):R=t[38],R}function Me(){return Ae()}function Ne(e){return e.language}function Pe(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,a,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=Re(n,r.status,r.findings),d=`space-y-4`,l=o(`rounded-lg px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,c=`flex items-start gap-2`,i=a.icon,s=o(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==s?(f=(0,X.jsx)(i,{className:s,"aria-hidden":!0}),t[10]=i,t[11]=s,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,X.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,X.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,X.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==c||t[21]!==f||t[22]!==h?(g=(0,X.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,X.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,X.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,X.jsx)(Ie,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,X.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,X.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Fe)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,X.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function Fe(e){return(0,X.jsx)(`li`,{className:`font-mono`,children:e},e)}function Ie(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,a,s,c;if(t[0]!==r.severity){let e=Le(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,s=`flex items-start gap-2`,i=e.icon,a=o(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=s,t[4]=c}else i=t[1],a=t[2],s=t[3],c=t[4];let l;t[5]!==i||t[6]!==a?(l=(0,X.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,X.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,X.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==s||t[26]!==l?(g=(0,X.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,X.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function Le(e){switch(e){case`critical`:return{icon:re,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:b,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:z,iconClass:`text-fg-muted`}}}function Re(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:re,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`bg-red-50 text-red-950 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:b,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`bg-amber-50 text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:z,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`bg-surface-base/55 text-fg`}:{icon:h,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`bg-emerald-50 text-emerald-950 dark:bg-emerald-950/40 dark:text-emerald-100`}}var ze=new Set([`security`,`advanced`]);function Be(e,t){return t===`advanced`?!0:!ze.has(e)}function Ve(e,t){return e.filter(e=>Be(e,t))}function He(){return`network`}function Ue(e,t){let n=(0,H.c)(5),r=k(We),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{Be(e,r)||t(He())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,V.useEffect)(i,a)}function We(e){return e.mode}function Z(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,O,`dark:border-edge`)}var Ge=[`network`,`access`,`updates`,`security`,`proxy`,`advanced`],Ke={network:C,access:P,updates:I,security:M,proxy:N,advanced:A};function qe(e){return e&&Ge.includes(e)?e:`network`}function Je(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:t===`proxy`?e.outboundProxyTitle:e.tabAdvanced}function Ye(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:t===`proxy`?e.outboundProxyHint:e.advancedSectionHint}function Xe(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var Ze={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Qe(){let e=c(e=>e.baseUrl),t=l(e=>e.language),n=a(t),r=n.gatewaySettings,[s,u]=i(),f=k(e=>e.mode),p=f===`advanced`,h=qe(s.get(`tab`)),_=(0,V.useMemo)(()=>Ve(Ge,f),[f]),b=(0,V.useCallback)(e=>{u(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[u]);Ue(h,b);let S=c(e=>e.conversationId),C=c(e=>e.tokenExpired),T=c(e=>e.openTokenDialog),D=!!S,[O,A]=(0,V.useReducer)(Xe,{form:null,baseline:null,appliedBaseline:null}),M=O.form,N=O.baseline,P=O.appliedBaseline,[I,R]=(0,V.useReducer)(te,Ze),{saving:z,error:oe,auditRefreshToken:se,restarting:ce,restartConfirmOpen:H}=I,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:q,isLoading:de,mutate:fe}=m(D),he=d(D&&M?[`gateway-cors-origin-candidates`,M.port]:null,([,e])=>me(e),{revalidateOnFocus:!1}),J=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(Se(K.payload.config)),[K]);D?J!==null&&(G.current||(G.current=!0,A({type:`init-applied`,value:J})),!U.current&&W.current!==J&&(W.current=J,A({type:`sync`,value:J}),R({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,A({type:`reset`}),U.current=!1);let ge=!!(D&&de&&K===void 0&&!q),_e=q instanceof Error?q.message:q?String(q):null,Y=(0,V.useMemo)(()=>!M||!N?!1:JSON.stringify(M)!==JSON.stringify(N),[M,N]),ve=(0,V.useMemo)(()=>!N||!P?!1:pe(P,N),[P,N]),ye=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),be=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Ce=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),Ee=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,bind:e})})},[]),De=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Oe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,port:e})})},[]),ke=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Ae=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Me=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Ne=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Fe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Ie=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Le=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Re=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),ze=(0,V.useCallback)(async()=>{if(!M||z)return;let e=xe(M);if(e){R({type:`patch`,patch:{error:e}});return}R({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await we(M),U.current=!1,A({type:`saved`,value:M}),R({type:`patch`,patch:{saveOk:!0,auditRefreshToken:se+1}})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:r.saveError}})}finally{R({type:`patch`,patch:{saving:!1}})}},[M,z,r.saveError]),Be=(0,V.useCallback)(()=>{N&&(U.current=!1,A({type:`discard`}),R({type:`patch`,patch:{error:null,saveOk:!1}}))},[N]),He=x(r),We=(0,V.useCallback)(async()=>{if(!ce){R({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await E();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):R({type:`patch`,patch:{error:e.message||r.restartGatewayFailed}})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{R({type:`patch`,patch:{restarting:!1}})}}},[ce,r.restartGatewayFailed]);return D?ge?(0,X.jsx)(ae,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,X.jsx)(w,{sections:3})}):M?(0,X.jsxs)(ae,{gap:`gap-6`,children:[(0,X.jsx)(ie,{title:n.settingsSections.gateway,docsLink:ne(t,`gateway`),docsLabel:r.docsLink,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(y,{type:`button`,variant:`secondary`,disabled:!Y||z,onClick:Be,children:r.discard}),(0,X.jsx)(y,{type:`button`,variant:`primary`,disabled:!Y||z,onClick:()=>void ze(),children:z?r.saving:r.save})]})}),C?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-red-50 px-4 py-3 dark:bg-red-950/40`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,X.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:r.tokenExpired})]}),(0,X.jsx)(`div`,{children:(0,X.jsx)(y,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>T(),children:r.updateToken})})]}):null,oe?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:oe}):null,ve?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-amber-50 px-3 py-2 dark:bg-amber-950/40`,children:[(0,X.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:r.restartHint}),(0,X.jsxs)(y,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:ce,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[ce?(0,X.jsx)(v,{className:`size-3.5 animate-spin`}):(0,X.jsx)(ee,{className:`size-3.5`}),r.restartGatewayButton]})]}):null,(0,X.jsx)(j,{open:H,title:r.restartGatewayButton,description:r.restartGatewayConfirm,confirmLabel:r.restartGatewayButton,cancelLabel:r.discard,destructive:!0,onConfirm:()=>void We(),onCancel:()=>R({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,X.jsx)(je,{enabled:D,refreshToken:se}),(0,X.jsx)($e,{g:r,activeTab:h,visibleTabs:_,onChange:b}),(0,X.jsxs)(Q,{g:r,id:`network`,activeTab:h,children:[(0,X.jsxs)(`section`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`zh`?`当前服务连接`:`Current service connection`}),(0,X.jsx)(`p`,{className:`break-all text-sm text-fg-muted`,children:e}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:r.retry}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>T(),children:r.updateToken}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:r.restartGatewayButton})]})]}),(0,X.jsxs)(g,{title:t===`zh`?`服务监听配置`:`Service listener configuration`,summary:`${M.bind} · ${M.port}`,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:r.bindMode}),(0,X.jsxs)(F,{id:`gateway-bind-mode`,className:Z(),value:M.bind,onChange:e=>Ee(e.target.value),children:[(0,X.jsx)(L,{value:`loopback`,children:r.bindLoopback}),p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{value:`lan`,children:r.bindLan}),(0,X.jsx)(L,{value:`auto`,children:r.bindAuto}),(0,X.jsx)(L,{value:`custom`,children:r.bindCustom}),(0,X.jsx)(L,{value:`tailnet`,children:r.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:r.customBindHost}),(0,X.jsx)(`input`,{id:`gateway-custom-bind-host`,className:o(Z(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>De(e.target.value),placeholder:r.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:r.listenPort}),(0,X.jsx)(B,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:o(Z(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);Oe(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]})]}),(0,X.jsx)(le,{children:(0,X.jsx)(rt,{g:r,origins:M.corsOrigins,candidates:he.data??[],onChange:Ce})})]})]}),(0,X.jsxs)(Q,{g:r,id:`access`,activeTab:h,children:[M.auth.mode===`none`?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:r.authModeNone}):null,(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:r.authMode}),(0,X.jsxs)(F,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>ye({mode:e.target.value}),className:Z(),children:[(0,X.jsx)(L,{value:`token`,children:r.authModeToken}),(0,X.jsx)(L,{value:`password`,children:r.authModePassword}),p||M.auth.mode===`trusted-proxy`||M.auth.mode===`none`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{value:`trusted-proxy`,children:r.authModeTrustedProxy}),(0,X.jsx)(L,{value:`none`,children:r.authModeNoneLabel})]}):null]})]}),(0,X.jsx)(le,{children:M.auth.mode===`trusted-proxy`?(0,X.jsx)(tt,{g:r,form:M,onTrustedProxyChange:Fe,onTrustedProxiesChange:Pe,onAllowRealIpFallbackChange:Le}):null}),M.auth.mode===`token`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(st,{id:`gateway-access-token`,label:r.accessToken,help:r.tokenHelp,placeholder:r.tokenPlaceholder,value:M.auth.token,labels:He,reveal:()=>ue(`token`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>ye({token:e})}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>T(),children:r.changeToken})]}):null,M.auth.mode===`password`?(0,X.jsx)(st,{id:`gateway-auth-password`,label:r.authPassword,help:r.authPasswordHelp,placeholder:r.authPasswordPlaceholder,value:M.auth.password,labels:He,reveal:()=>ue(`password`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>ye({password:e})}):null,(0,X.jsx)(le,{children:M.auth.mode===`none`?null:(0,X.jsx)(ot,{g:r,rateLimit:M.auth.rateLimit,onChange:ke})})]}),(0,X.jsxs)(Q,{g:r,id:`updates`,activeTab:h,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:r.updateChannel}),(0,X.jsxs)(F,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>be(e.target.value),className:Z(),children:[(0,X.jsx)(L,{value:`stable`,children:r.channelStable}),p||M.updateChannel===`beta`?(0,X.jsx)(L,{value:`beta`,children:r.channelBeta}):null,p||M.updateChannel===`dev`?(0,X.jsx)(L,{value:`dev`,children:r.channelDev}):null]})]}),(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.updateAutoSection}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.updateCheckOnStart}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateCheckOnStartHint})]})]}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.updateAutoEnabled}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateAutoEnabledHint})]})]}),(0,X.jsx)(le,{children:(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:r.updateAutoStableDelayHours}),(0,X.jsx)(B,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableDelayHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableDelayHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:r.updateAutoStableJitterHours}),(0,X.jsx)(B,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableJitterHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableJitterHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:r.updateAutoBetaCheckIntervalHours}),(0,X.jsx)(B,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoBetaCheckIntervalHoursHint})]})]})})]})]}),(0,X.jsx)(Q,{g:r,id:`security`,activeTab:h,children:(0,X.jsx)(et,{g:r,form:M,onSecurityStrictChange:Ie,onDangerouslyAllowHostHeaderOriginFallbackChange:Re})}),(0,X.jsx)(Q,{g:r,id:`proxy`,activeTab:h,children:(0,X.jsx)(Te,{value:M.outboundProxy,g:r,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,outboundProxy:e})})}})}),(0,X.jsx)(Q,{g:r,id:`advanced`,activeTab:h,children:(0,X.jsx)(nt,{g:r,form:M,onDeferModeChange:Ae,onDeferIdsChange:Me,onSkipIdsChange:Ne})})]}):(0,X.jsxs)(ae,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:oe??_e??r.loadError}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:r.retry})]}):(0,X.jsxs)(ae,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(ie,{title:n.settingsSections.gateway}),(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function $e(e){let t=(0,H.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Je(n,e),icon:Ke[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,X.jsx)(R,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Q(e){let t=(0,H.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Je(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Ye(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,X.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,X.jsx)(oe,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,showHeading:!1,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function et(e){let t=(0,H.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,X.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,X.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,X.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function tt(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,X.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,X.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==c.requiredHeaders?(_=(0,X.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==c.allowUsers?(y=(0,X.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,X.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,X.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,X.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,X.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,X.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function nt(e){let t=(0,H.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:a,onSkipIdsChange:o}=e,s;t[0]===n.channelConnectDeferMode?s=t[1]:(s=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=s);let c=r.channelConnectDeferMode,l;t[2]===i?l=t[3]:(l=e=>i(e.target.value),t[2]=i,t[3]=l);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=Z(),t[4]=u):u=t[4];let d;t[5]===n.channelConnectDeferModeAuto?d=t[6]:(d=(0,X.jsx)(L,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=d);let f;t[7]===n.channelConnectDeferModeOff?f=t[8]:(f=(0,X.jsx)(L,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=f);let p;t[9]===n.channelConnectDeferModeExplicit?p=t[10]:(p=(0,X.jsx)(L,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=p);let m;t[11]!==r.channelConnectDeferMode||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,X.jsxs)(F,{id:`gateway-channel-defer-mode`,value:c,onChange:l,className:u,children:[d,f,p]}),t[11]=r.channelConnectDeferMode,t[12]=l,t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;t[17]===n.channelConnectDeferModeHint?h=t[18]:(h=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=h);let g;t[19]!==s||t[20]!==m||t[21]!==h?(g=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[s,m,h]}),t[19]=s,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;t[23]!==r.channelConnectDeferIds||t[24]!==r.channelConnectDeferMode||t[25]!==n.channelConnectDeferIds||t[26]!==n.channelConnectDeferIdsHint||t[27]!==n.channelIdListEmpty||t[28]!==n.channelIdListPlaceholder||t[29]!==a?(_=r.channelConnectDeferMode===`explicit`?(0,X.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:a}):null,t[23]=r.channelConnectDeferIds,t[24]=r.channelConnectDeferMode,t[25]=n.channelConnectDeferIds,t[26]=n.channelConnectDeferIdsHint,t[27]=n.channelIdListEmpty,t[28]=n.channelIdListPlaceholder,t[29]=a,t[30]=_):_=t[30];let v;t[31]!==r.channelConnectDeferMode||t[32]!==r.channelConnectDeferSkipIds||t[33]!==n.channelConnectDeferSkipIds||t[34]!==n.channelConnectDeferSkipIdsHint||t[35]!==n.channelIdListEmpty||t[36]!==n.channelIdListPlaceholder||t[37]!==o?(v=r.channelConnectDeferMode===`off`?null:(0,X.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:o}),t[31]=r.channelConnectDeferMode,t[32]=r.channelConnectDeferSkipIds,t[33]=n.channelConnectDeferSkipIds,t[34]=n.channelConnectDeferSkipIdsHint,t[35]=n.channelIdListEmpty,t[36]=n.channelIdListPlaceholder,t[37]=o,t[38]=v):v=t[38];let y;return t[39]!==g||t[40]!==_||t[41]!==v?(y=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[g,_,v]}),t[39]=g,t[40]=_,t[41]=v,t[42]=y):y=t[42],y}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==l||t[10]!==s?(h=s.length===0?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:o(`text-fg-muted hover:text-fg`,_.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=o(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let v=s.length>=c,y;t[13]===f?y=t[14]:(y=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=y);let b;t[15]!==a||t[16]!==v||t[17]!==y?(b=(0,X.jsx)(`input`,{className:g,placeholder:a,disabled:v,onKeyDown:y}),t[15]=a,t[16]=v,t[17]=y,t[18]=b):b=t[18];let x;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==b?(x=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[p,m,h,b,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=b,t[24]=x):x=t[24],x}function rt(e){let t=(0,H.c)(36),{g:n,origins:r,candidates:i,onChange:a}=e,o;t[0]===r?o=t[1]:(o=r.includes(`*`),t[0]=r,t[1]=o);let s=o,c,l,u,d,f,p,m,h,g;if(t[2]!==i||t[3]!==n.corsAddDetectedOrigins||t[4]!==n.corsDetectedOrigins||t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==a||t[10]!==r){let e;t[20]===r?e=t[21]:(e=e=>!r.includes(e.url),t[20]=r,t[21]=e);let o=i.filter(e);c=$,l=n.corsOrigins,u=n.corsOriginsHint,d=n.corsOriginsEmpty,f=n.corsOriginsPlaceholder,p=r,m=128,h=a,g=o.length>0?(0,X.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.corsDetectedOrigins}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(at)}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,className:`mt-2 text-xs`,onClick:()=>a([...r,...o.map(it)]),children:n.corsAddDetectedOrigins})]}):null,t[2]=i,t[3]=n.corsAddDetectedOrigins,t[4]=n.corsDetectedOrigins,t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=a,t[10]=r,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h,t[19]=g}else c=t[11],l=t[12],u=t[13],d=t[14],f=t[15],p=t[16],m=t[17],h=t[18],g=t[19];let _;t[22]!==n.corsOriginsWildcardWarning||t[23]!==s?(_=s?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[22]=n.corsOriginsWildcardWarning,t[23]=s,t[24]=_):_=t[24];let v;return t[25]!==c||t[26]!==_||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==h||t[34]!==g?(v=(0,X.jsxs)(c,{title:l,hint:u,emptyText:d,placeholder:f,values:p,maxItems:m,onChange:h,children:[g,_]}),t[25]=c,t[26]=_,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m,t[33]=h,t[34]=g,t[35]=v):v=t[35],v}function it(e){return e.url}function at(e){return(0,X.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e.url,` · `,e.interfaceName]},e.url)}function ot(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,X.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Z(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,X.jsx)(B,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,X.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Z(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,X.jsx)(B,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,X.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Z(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,X.jsx)(B,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,X.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,X.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function st(e){let t=(0,H.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,X.jsx)(S,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{Qe as GatewaySettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./messages-Bwv-AOYl.js";import{t as o}from"./cn-0WouolD0.js";import{a as s,c,n as l,r as u}from"./locale-store-D5h-Ha6-.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{n as p,r as m}from"./gateway-config-swr-BvuySoCX.js";import{$l as h,G as g,Ic as _,Ju as v,Kc as y,Ml as b,Ms as x,Ns as S,Nu as C,On as w,Ps as T,Qn as E,Rc as D,Rs as O,Vn as k,Xl as A,Za as j,Zl as M,cu as N,dd as P,ds as F,du as I,fs as L,is as R,lu as ee,no as te,pd as z,ss as ne,uf as re}from"./index-K2cy4f-3.js";import{t as B}from"./number-input-DDeqHK-G.js";import{n as ie,r as ae,t as oe}from"./settings-page-layout-Dx5S-Msc.js";import{n as se,t as ce}from"./settings-form-section-B4NShgv-.js";import{t as le}from"./settings-advanced-gate-BOkrHL8q.js";var V=e(t(),1),H=n(),U=18790,W={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return T(e)}async function ue(e){let t=await s(u(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function q(e){return K(e)?``:e.trim()}function de(e){return[...e].map(e=>e.trim()).sort()}function fe(e){return JSON.stringify({outboundProxy:e.outboundProxy,bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:q(e.auth.token),password:q(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:de(e.auth.trustedProxy.requiredHeaders),allowUsers:de(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},trustedProxies:de(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function pe(e,t){return fe(e)!==fe(t)}async function me(e){return(await s(u(`/api/gateway/cors-origin-candidates?port=${encodeURIComponent(String(e))}`))).payload?.candidates??[]}function he(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function J(e){let t=G(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):W.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):W.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):W.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function ge(e){let t=G(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:Y(t.requiredHeaders,32),allowUsers:Y(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function _e(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function Y(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function ve(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function ye(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function be(e){try{let t=new URL(e.trim());return[`http:`,`https:`].includes(t.protocol)&&!!t.hostname&&!t.username&&!t.password&&!t.search&&!t.hash&&(!t.pathname||t.pathname===`/`)}catch{return!1}}function xe(e){let t=e.outboundProxy;if((t.mode===`custom`||t.url.trim())&&!be(t.url))return`Use an HTTP or HTTPS proxy origin without credentials, path, query or fragment.`;let n=ye(e);return n&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:n&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:n&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function Se(e){let t=G(e)?e:{},n=G(t.gateway)?t.gateway:{},r=G(n.auth)?n.auth:{},i=G(n.security)?n.security:{},a=G(t.update)?t.update:{},o=G(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[],u=ve(n.bind),d=typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,f=G(n.outboundProxy)?n.outboundProxy:{};return{outboundProxy:{mode:f.mode===`custom`||f.mode===`direct`?f.mode:`environment`,url:typeof f.url==`string`?f.url:``,noProxy:typeof f.noProxy==`string`?f.noProxy:``},bind:u,customBindHost:d,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):U,auth:{mode:he(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:J(r.rateLimit),trustedProxy:ge(r.trustedProxy)},corsOrigins:l,trustedProxies:Y(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:_e(n.channelConnectDeferMode),channelConnectDeferIds:Y(n.channelConnectDeferIds),channelConnectDeferSkipIds:Y(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function Ce(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!K(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!K(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function we(e){let t=xe(e);if(t)throw Error(t);await s(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{outboundProxy:e.outboundProxy,bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:Ce(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),p()}var X=r();function Te(e){let t=(0,H.c)(46),{value:n,onChange:r,g:i}=e,[a,s]=(0,V.useState)(!1),c;t[0]!==a||t[1]!==n.mode||t[2]!==n.url?(c=a&&n.mode===`custom`&&!be(n.url),t[0]=a,t[1]=n.mode,t[2]=n.url,t[3]=c):c=t[3];let l=c,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,O),t[4]=u):u=t[4];let d=u,f;t[5]===i.outboundProxyTitle?f=t[6]:(f=(0,X.jsx)(`h2`,{id:`outbound-proxy-title`,className:`text-sm font-semibold text-fg`,children:i.outboundProxyTitle}),t[5]=i.outboundProxyTitle,t[6]=f);let p;t[7]===i.outboundProxyHint?p=t[8]:(p=(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.outboundProxyHint}),t[7]=i.outboundProxyHint,t[8]=p);let m;t[9]===i.outboundProxyMode?m=t[10]:(m=(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-mode`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyMode}),t[9]=i.outboundProxyMode,t[10]=m);let h;t[11]!==r||t[12]!==n?(h=e=>r({...n,mode:e.target.value}),t[11]=r,t[12]=n,t[13]=h):h=t[13];let g;t[14]===i.outboundProxyEnvironment?g=t[15]:(g=(0,X.jsx)(L,{value:`environment`,children:i.outboundProxyEnvironment}),t[14]=i.outboundProxyEnvironment,t[15]=g);let _;t[16]===i.outboundProxyCustom?_=t[17]:(_=(0,X.jsx)(L,{value:`custom`,children:i.outboundProxyCustom}),t[16]=i.outboundProxyCustom,t[17]=_);let v;t[18]===i.outboundProxyDirect?v=t[19]:(v=(0,X.jsx)(L,{value:`direct`,children:i.outboundProxyDirect}),t[18]=i.outboundProxyDirect,t[19]=v);let y;t[20]!==h||t[21]!==g||t[22]!==_||t[23]!==v||t[24]!==n.mode?(y=(0,X.jsxs)(F,{id:`outbound-proxy-mode`,value:n.mode,onChange:h,children:[g,_,v]}),t[20]=h,t[21]=g,t[22]=_,t[23]=v,t[24]=n.mode,t[25]=y):y=t[25];let b;t[26]!==y||t[27]!==m?(b=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[m,y]}),t[26]=y,t[27]=m,t[28]=b):b=t[28];let x;t[29]!==i.outboundProxyInvalid||t[30]!==i.outboundProxyUrl||t[31]!==l||t[32]!==r||t[33]!==n?(x=n.mode===`custom`&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-url`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyUrl}),(0,X.jsx)(`input`,{id:`outbound-proxy-url`,className:d,value:n.url,placeholder:`http://127.0.0.1:7897`,autoComplete:`off`,spellCheck:!1,"aria-invalid":l,"aria-describedby":l?`outbound-proxy-error`:void 0,onChange:e=>r({...n,url:e.target.value}),onBlur:()=>s(!0)}),l&&(0,X.jsx)(`p`,{id:`outbound-proxy-error`,role:`alert`,className:`text-xs text-danger`,children:i.outboundProxyInvalid})]}),t[29]=i.outboundProxyInvalid,t[30]=i.outboundProxyUrl,t[31]=l,t[32]=r,t[33]=n,t[34]=x):x=t[34];let S;t[35]!==i.outboundProxyBypass||t[36]!==i.outboundProxyBypassHint||t[37]!==r||t[38]!==n?(S=n.mode!==`direct`&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-bypass`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyBypass}),(0,X.jsx)(`input`,{id:`outbound-proxy-bypass`,className:d,value:n.noProxy,placeholder:`.example.com,192.168.1.10`,autoComplete:`off`,spellCheck:!1,"aria-describedby":`outbound-proxy-bypass-hint`,onChange:e=>r({...n,noProxy:e.target.value})}),(0,X.jsx)(`p`,{id:`outbound-proxy-bypass-hint`,className:`text-xs text-fg-muted`,children:i.outboundProxyBypassHint})]}),t[35]=i.outboundProxyBypass,t[36]=i.outboundProxyBypassHint,t[37]=r,t[38]=n,t[39]=S):S=t[39];let C;return t[40]!==b||t[41]!==x||t[42]!==S||t[43]!==f||t[44]!==p?(C=(0,X.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,"aria-labelledby":`outbound-proxy-title`,children:[f,p,b,x,S]}),t[40]=b,t[41]=x,t[42]=S,t[43]=f,t[44]=p,t[45]=C):C=t[45],C}var Ee={critical:3,warn:2,info:1};function De(){return u(`/api/doctor?security=true`)}function Oe(e){return e.toSorted((e,t)=>Ee[t.severity]-Ee[e.severity]||e.checkId.localeCompare(t.checkId))}function ke(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=Oe((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function Ae(){return ke(await s(De()))}function je(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,o=l(Ne),s;t[0]===o?s=t[1]:(s=a(o),t[0]=o,t[1]=s);let c=s.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[De(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:g,isLoading:_,isValidating:b,mutate:x}=d(u,Me,p),S=m??null,C=g instanceof Error?g.message:g?String(g):null,w=_||b,T;t[6]===x?T=t[7]:(T=()=>{x(),f(De())},t[6]=x,t[7]=T);let E=T,O=!n||w,k;t[8]===w?k=t[9]:(k=w?(0,X.jsx)(v,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),t[8]=w,t[9]=k);let A;t[10]===c.securityAuditRefresh?A=t[11]:(A=(0,X.jsx)(`span`,{className:`ml-1.5`,children:c.securityAuditRefresh}),t[10]=c.securityAuditRefresh,t[11]=A);let j;t[12]!==E||t[13]!==O||t[14]!==k||t[15]!==A?(j=(0,X.jsxs)(y,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:E,children:[k,A]}),t[12]=E,t[13]=O,t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]!==c.securityAuditSubtitle||t[18]!==c.securityAuditTitle||t[19]!==j?(M=(0,X.jsx)(se,{icon:h,title:c.securityAuditTitle,subtitle:c.securityAuditSubtitle,trailing:j}),t[17]=c.securityAuditSubtitle,t[18]=c.securityAuditTitle,t[19]=j,t[20]=M):M=t[20];let N;t[21]===c.securityAuditSavedConfigHint?N=t[22]:(N=(0,X.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:c.securityAuditSavedConfigHint}),t[21]=c.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==C||t[24]!==c.securityAuditLoadError?(P=C?(0,X.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[c.securityAuditLoadError,`: `,C]}):null,t[23]=C,t[24]=c.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==S||t[27]!==C||t[28]!==w?(F=!C&&w&&!S?(0,X.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,X.jsx)(D,{className:`h-11 w-full rounded-lg`}),(0,X.jsx)(D,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=S,t[27]=C,t[28]=w,t[29]=F):F=t[29];let L;t[30]!==S||t[31]!==c?(L=S?(0,X.jsx)(Pe,{g:c,audit:S}):null,t[30]=S,t[31]=c,t[32]=L):L=t[32];let R;return t[33]!==M||t[34]!==N||t[35]!==P||t[36]!==F||t[37]!==L?(R=(0,X.jsxs)(ce,{children:[M,N,P,F,L]}),t[33]=M,t[34]=N,t[35]=P,t[36]=F,t[37]=L,t[38]=R):R=t[38],R}function Me(){return Ae()}function Ne(e){return e.language}function Pe(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,a,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=Re(n,r.status,r.findings),d=`space-y-4`,l=o(`rounded-lg px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,c=`flex items-start gap-2`,i=a.icon,s=o(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==s?(f=(0,X.jsx)(i,{className:s,"aria-hidden":!0}),t[10]=i,t[11]=s,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,X.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,X.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,X.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==c||t[21]!==f||t[22]!==h?(g=(0,X.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,X.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,X.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,X.jsx)(Ie,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,X.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,X.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Fe)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,X.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function Fe(e){return(0,X.jsx)(`li`,{className:`font-mono`,children:e},e)}function Ie(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,a,s,c;if(t[0]!==r.severity){let e=Le(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,s=`flex items-start gap-2`,i=e.icon,a=o(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=s,t[4]=c}else i=t[1],a=t[2],s=t[3],c=t[4];let l;t[5]!==i||t[6]!==a?(l=(0,X.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,X.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,X.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==s||t[26]!==l?(g=(0,X.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,X.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function Le(e){switch(e){case`critical`:return{icon:re,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:b,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:z,iconClass:`text-fg-muted`}}}function Re(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:re,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`bg-red-50 text-red-950 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:b,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`bg-amber-50 text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:z,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`bg-surface-base/55 text-fg`}:{icon:h,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`bg-emerald-50 text-emerald-950 dark:bg-emerald-950/40 dark:text-emerald-100`}}var ze=new Set([`security`,`advanced`]);function Be(e,t){return t===`advanced`?!0:!ze.has(e)}function Ve(e,t){return e.filter(e=>Be(e,t))}function He(){return`network`}function Ue(e,t){let n=(0,H.c)(5),r=k(We),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{Be(e,r)||t(He())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,V.useEffect)(i,a)}function We(e){return e.mode}function Z(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,O,`dark:border-edge`)}var Ge=[`network`,`access`,`updates`,`security`,`proxy`,`advanced`],Ke={network:C,access:P,updates:I,security:M,proxy:N,advanced:A};function qe(e){return e&&Ge.includes(e)?e:`network`}function Je(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:t===`proxy`?e.outboundProxyTitle:e.tabAdvanced}function Ye(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:t===`proxy`?e.outboundProxyHint:e.advancedSectionHint}function Xe(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var Ze={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Qe(){let e=c(e=>e.baseUrl),t=l(e=>e.language),n=a(t),r=n.gatewaySettings,[s,u]=i(),f=k(e=>e.mode),p=f===`advanced`,h=qe(s.get(`tab`)),_=(0,V.useMemo)(()=>Ve(Ge,f),[f]),b=(0,V.useCallback)(e=>{u(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[u]);Ue(h,b);let S=c(e=>e.conversationId),C=c(e=>e.tokenExpired),T=c(e=>e.openTokenDialog),D=!!S,[O,A]=(0,V.useReducer)(Xe,{form:null,baseline:null,appliedBaseline:null}),M=O.form,N=O.baseline,P=O.appliedBaseline,[I,R]=(0,V.useReducer)(te,Ze),{saving:z,error:oe,auditRefreshToken:se,restarting:ce,restartConfirmOpen:H}=I,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:q,isLoading:de,mutate:fe}=m(D),he=d(D&&M?[`gateway-cors-origin-candidates`,M.port]:null,([,e])=>me(e),{revalidateOnFocus:!1}),J=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(Se(K.payload.config)),[K]);D?J!==null&&(G.current||(G.current=!0,A({type:`init-applied`,value:J})),!U.current&&W.current!==J&&(W.current=J,A({type:`sync`,value:J}),R({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,A({type:`reset`}),U.current=!1);let ge=!!(D&&de&&K===void 0&&!q),_e=q instanceof Error?q.message:q?String(q):null,Y=(0,V.useMemo)(()=>!M||!N?!1:JSON.stringify(M)!==JSON.stringify(N),[M,N]),ve=(0,V.useMemo)(()=>!N||!P?!1:pe(P,N),[P,N]),ye=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),be=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Ce=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),Ee=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,bind:e})})},[]),De=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Oe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,port:e})})},[]),ke=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Ae=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Me=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Ne=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Fe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Ie=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Le=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Re=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),ze=(0,V.useCallback)(async()=>{if(!M||z)return;let e=xe(M);if(e){R({type:`patch`,patch:{error:e}});return}R({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await we(M),U.current=!1,A({type:`saved`,value:M}),R({type:`patch`,patch:{saveOk:!0,auditRefreshToken:se+1}})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:r.saveError}})}finally{R({type:`patch`,patch:{saving:!1}})}},[M,z,r.saveError]),Be=(0,V.useCallback)(()=>{N&&(U.current=!1,A({type:`discard`}),R({type:`patch`,patch:{error:null,saveOk:!1}}))},[N]),He=x(r),We=(0,V.useCallback)(async()=>{if(!ce){R({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await E();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):R({type:`patch`,patch:{error:e.message||r.restartGatewayFailed}})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{R({type:`patch`,patch:{restarting:!1}})}}},[ce,r.restartGatewayFailed]);return D?ge?(0,X.jsx)(ae,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,X.jsx)(w,{sections:3})}):M?(0,X.jsxs)(ae,{gap:`gap-6`,children:[(0,X.jsx)(ie,{title:n.settingsSections.gateway,docsLink:ne(t,`gateway`),docsLabel:r.docsLink,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(y,{type:`button`,variant:`secondary`,disabled:!Y||z,onClick:Be,children:r.discard}),(0,X.jsx)(y,{type:`button`,variant:`primary`,disabled:!Y||z,onClick:()=>void ze(),children:z?r.saving:r.save})]})}),C?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-red-50 px-4 py-3 dark:bg-red-950/40`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,X.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:r.tokenExpired})]}),(0,X.jsx)(`div`,{children:(0,X.jsx)(y,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>T(),children:r.updateToken})})]}):null,oe?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:oe}):null,ve?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-amber-50 px-3 py-2 dark:bg-amber-950/40`,children:[(0,X.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:r.restartHint}),(0,X.jsxs)(y,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:ce,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[ce?(0,X.jsx)(v,{className:`size-3.5 animate-spin`}):(0,X.jsx)(ee,{className:`size-3.5`}),r.restartGatewayButton]})]}):null,(0,X.jsx)(j,{open:H,title:r.restartGatewayButton,description:r.restartGatewayConfirm,confirmLabel:r.restartGatewayButton,cancelLabel:r.discard,destructive:!0,onConfirm:()=>void We(),onCancel:()=>R({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,X.jsx)(je,{enabled:D,refreshToken:se}),(0,X.jsx)($e,{g:r,activeTab:h,visibleTabs:_,onChange:b}),(0,X.jsxs)(Q,{g:r,id:`network`,activeTab:h,children:[(0,X.jsxs)(`section`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`zh`?`当前服务连接`:`Current service connection`}),(0,X.jsx)(`p`,{className:`break-all text-sm text-fg-muted`,children:e}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:r.retry}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>T(),children:r.updateToken}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:r.restartGatewayButton})]})]}),(0,X.jsxs)(g,{title:t===`zh`?`服务监听配置`:`Service listener configuration`,summary:`${M.bind} · ${M.port}`,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:r.bindMode}),(0,X.jsxs)(F,{id:`gateway-bind-mode`,className:Z(),value:M.bind,onChange:e=>Ee(e.target.value),children:[(0,X.jsx)(L,{value:`loopback`,children:r.bindLoopback}),p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{value:`lan`,children:r.bindLan}),(0,X.jsx)(L,{value:`auto`,children:r.bindAuto}),(0,X.jsx)(L,{value:`custom`,children:r.bindCustom}),(0,X.jsx)(L,{value:`tailnet`,children:r.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:r.customBindHost}),(0,X.jsx)(`input`,{id:`gateway-custom-bind-host`,className:o(Z(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>De(e.target.value),placeholder:r.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:r.listenPort}),(0,X.jsx)(B,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:o(Z(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);Oe(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]})]}),(0,X.jsx)(le,{children:(0,X.jsx)(rt,{g:r,origins:M.corsOrigins,candidates:he.data??[],onChange:Ce})})]})]}),(0,X.jsxs)(Q,{g:r,id:`access`,activeTab:h,children:[M.auth.mode===`none`?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:r.authModeNone}):null,(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:r.authMode}),(0,X.jsxs)(F,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>ye({mode:e.target.value}),className:Z(),children:[(0,X.jsx)(L,{value:`token`,children:r.authModeToken}),(0,X.jsx)(L,{value:`password`,children:r.authModePassword}),p||M.auth.mode===`trusted-proxy`||M.auth.mode===`none`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{value:`trusted-proxy`,children:r.authModeTrustedProxy}),(0,X.jsx)(L,{value:`none`,children:r.authModeNoneLabel})]}):null]})]}),(0,X.jsx)(le,{children:M.auth.mode===`trusted-proxy`?(0,X.jsx)(tt,{g:r,form:M,onTrustedProxyChange:Fe,onTrustedProxiesChange:Pe,onAllowRealIpFallbackChange:Le}):null}),M.auth.mode===`token`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(st,{id:`gateway-access-token`,label:r.accessToken,help:r.tokenHelp,placeholder:r.tokenPlaceholder,value:M.auth.token,labels:He,reveal:()=>ue(`token`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>ye({token:e})}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>T(),children:r.changeToken})]}):null,M.auth.mode===`password`?(0,X.jsx)(st,{id:`gateway-auth-password`,label:r.authPassword,help:r.authPasswordHelp,placeholder:r.authPasswordPlaceholder,value:M.auth.password,labels:He,reveal:()=>ue(`password`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>ye({password:e})}):null,(0,X.jsx)(le,{children:M.auth.mode===`none`?null:(0,X.jsx)(ot,{g:r,rateLimit:M.auth.rateLimit,onChange:ke})})]}),(0,X.jsxs)(Q,{g:r,id:`updates`,activeTab:h,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:r.updateChannel}),(0,X.jsxs)(F,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>be(e.target.value),className:Z(),children:[(0,X.jsx)(L,{value:`stable`,children:r.channelStable}),p||M.updateChannel===`beta`?(0,X.jsx)(L,{value:`beta`,children:r.channelBeta}):null,p||M.updateChannel===`dev`?(0,X.jsx)(L,{value:`dev`,children:r.channelDev}):null]})]}),(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.updateAutoSection}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.updateCheckOnStart}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateCheckOnStartHint})]})]}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.updateAutoEnabled}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateAutoEnabledHint})]})]}),(0,X.jsx)(le,{children:(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:r.updateAutoStableDelayHours}),(0,X.jsx)(B,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableDelayHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableDelayHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:r.updateAutoStableJitterHours}),(0,X.jsx)(B,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableJitterHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableJitterHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:r.updateAutoBetaCheckIntervalHours}),(0,X.jsx)(B,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoBetaCheckIntervalHoursHint})]})]})})]})]}),(0,X.jsx)(Q,{g:r,id:`security`,activeTab:h,children:(0,X.jsx)(et,{g:r,form:M,onSecurityStrictChange:Ie,onDangerouslyAllowHostHeaderOriginFallbackChange:Re})}),(0,X.jsx)(Q,{g:r,id:`proxy`,activeTab:h,children:(0,X.jsx)(Te,{value:M.outboundProxy,g:r,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,outboundProxy:e})})}})}),(0,X.jsx)(Q,{g:r,id:`advanced`,activeTab:h,children:(0,X.jsx)(nt,{g:r,form:M,onDeferModeChange:Ae,onDeferIdsChange:Me,onSkipIdsChange:Ne})})]}):(0,X.jsxs)(ae,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:oe??_e??r.loadError}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:r.retry})]}):(0,X.jsxs)(ae,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(ie,{title:n.settingsSections.gateway}),(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function $e(e){let t=(0,H.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Je(n,e),icon:Ke[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,X.jsx)(R,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Q(e){let t=(0,H.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Je(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Ye(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,X.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,X.jsx)(oe,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,showHeading:!1,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function et(e){let t=(0,H.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,X.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,X.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,X.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function tt(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,X.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,X.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==c.requiredHeaders?(_=(0,X.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==c.allowUsers?(y=(0,X.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,X.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,X.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,X.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,X.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,X.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function nt(e){let t=(0,H.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:a,onSkipIdsChange:o}=e,s;t[0]===n.channelConnectDeferMode?s=t[1]:(s=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=s);let c=r.channelConnectDeferMode,l;t[2]===i?l=t[3]:(l=e=>i(e.target.value),t[2]=i,t[3]=l);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=Z(),t[4]=u):u=t[4];let d;t[5]===n.channelConnectDeferModeAuto?d=t[6]:(d=(0,X.jsx)(L,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=d);let f;t[7]===n.channelConnectDeferModeOff?f=t[8]:(f=(0,X.jsx)(L,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=f);let p;t[9]===n.channelConnectDeferModeExplicit?p=t[10]:(p=(0,X.jsx)(L,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=p);let m;t[11]!==r.channelConnectDeferMode||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,X.jsxs)(F,{id:`gateway-channel-defer-mode`,value:c,onChange:l,className:u,children:[d,f,p]}),t[11]=r.channelConnectDeferMode,t[12]=l,t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;t[17]===n.channelConnectDeferModeHint?h=t[18]:(h=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=h);let g;t[19]!==s||t[20]!==m||t[21]!==h?(g=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[s,m,h]}),t[19]=s,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;t[23]!==r.channelConnectDeferIds||t[24]!==r.channelConnectDeferMode||t[25]!==n.channelConnectDeferIds||t[26]!==n.channelConnectDeferIdsHint||t[27]!==n.channelIdListEmpty||t[28]!==n.channelIdListPlaceholder||t[29]!==a?(_=r.channelConnectDeferMode===`explicit`?(0,X.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:a}):null,t[23]=r.channelConnectDeferIds,t[24]=r.channelConnectDeferMode,t[25]=n.channelConnectDeferIds,t[26]=n.channelConnectDeferIdsHint,t[27]=n.channelIdListEmpty,t[28]=n.channelIdListPlaceholder,t[29]=a,t[30]=_):_=t[30];let v;t[31]!==r.channelConnectDeferMode||t[32]!==r.channelConnectDeferSkipIds||t[33]!==n.channelConnectDeferSkipIds||t[34]!==n.channelConnectDeferSkipIdsHint||t[35]!==n.channelIdListEmpty||t[36]!==n.channelIdListPlaceholder||t[37]!==o?(v=r.channelConnectDeferMode===`off`?null:(0,X.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:o}),t[31]=r.channelConnectDeferMode,t[32]=r.channelConnectDeferSkipIds,t[33]=n.channelConnectDeferSkipIds,t[34]=n.channelConnectDeferSkipIdsHint,t[35]=n.channelIdListEmpty,t[36]=n.channelIdListPlaceholder,t[37]=o,t[38]=v):v=t[38];let y;return t[39]!==g||t[40]!==_||t[41]!==v?(y=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[g,_,v]}),t[39]=g,t[40]=_,t[41]=v,t[42]=y):y=t[42],y}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==l||t[10]!==s?(h=s.length===0?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:o(`text-fg-muted hover:text-fg`,_.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=o(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let v=s.length>=c,y;t[13]===f?y=t[14]:(y=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=y);let b;t[15]!==a||t[16]!==v||t[17]!==y?(b=(0,X.jsx)(`input`,{className:g,placeholder:a,disabled:v,onKeyDown:y}),t[15]=a,t[16]=v,t[17]=y,t[18]=b):b=t[18];let x;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==b?(x=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[p,m,h,b,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=b,t[24]=x):x=t[24],x}function rt(e){let t=(0,H.c)(36),{g:n,origins:r,candidates:i,onChange:a}=e,o;t[0]===r?o=t[1]:(o=r.includes(`*`),t[0]=r,t[1]=o);let s=o,c,l,u,d,f,p,m,h,g;if(t[2]!==i||t[3]!==n.corsAddDetectedOrigins||t[4]!==n.corsDetectedOrigins||t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==a||t[10]!==r){let e;t[20]===r?e=t[21]:(e=e=>!r.includes(e.url),t[20]=r,t[21]=e);let o=i.filter(e);c=$,l=n.corsOrigins,u=n.corsOriginsHint,d=n.corsOriginsEmpty,f=n.corsOriginsPlaceholder,p=r,m=128,h=a,g=o.length>0?(0,X.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.corsDetectedOrigins}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(at)}),(0,X.jsx)(y,{type:`button`,variant:`secondary`,className:`mt-2 text-xs`,onClick:()=>a([...r,...o.map(it)]),children:n.corsAddDetectedOrigins})]}):null,t[2]=i,t[3]=n.corsAddDetectedOrigins,t[4]=n.corsDetectedOrigins,t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=a,t[10]=r,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h,t[19]=g}else c=t[11],l=t[12],u=t[13],d=t[14],f=t[15],p=t[16],m=t[17],h=t[18],g=t[19];let _;t[22]!==n.corsOriginsWildcardWarning||t[23]!==s?(_=s?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[22]=n.corsOriginsWildcardWarning,t[23]=s,t[24]=_):_=t[24];let v;return t[25]!==c||t[26]!==_||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==h||t[34]!==g?(v=(0,X.jsxs)(c,{title:l,hint:u,emptyText:d,placeholder:f,values:p,maxItems:m,onChange:h,children:[g,_]}),t[25]=c,t[26]=_,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m,t[33]=h,t[34]=g,t[35]=v):v=t[35],v}function it(e){return e.url}function at(e){return(0,X.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e.url,` · `,e.interfaceName]},e.url)}function ot(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,X.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Z(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,X.jsx)(B,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,X.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Z(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,X.jsx)(B,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,X.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Z(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,X.jsx)(B,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,X.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,X.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function st(e){let t=(0,H.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,X.jsx)(S,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{Qe as GatewaySettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{Hc as r,Uc as i,Wc as a}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{Hc as r,Uc as i,Wc as a}from"./index-K2cy4f-3.js";var o=e(t(),1),s=n(),c=({code:e,isIncomplete:t=!1,language:n,maxHeight:c,raw:l,className:u,startLine:d,lineNumbers:f,...p})=>{let{shikiTheme:m}=(0,o.useContext)(i),h=r(),[g,_]=(0,o.useState)(l);return(0,o.useEffect)(()=>{if(!h){_(l);return}let r=!0,i=h.highlight({code:e,isIncomplete:t,language:n,themes:m},e=>{r&&_(e)});return i&&_(i),()=>{r=!1}},[e,t,n,m,h,l]),(0,s.jsx)(a,{className:u,language:n,lineNumbers:f,maxHeight:c,result:g,startLine:d,...p})};export{c as HighlightedCodeBlockBody};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,g as o}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./external-link-DjqjBmc3.js";import{M as l}from"./markdown-view-CthsQiiO.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-Bwv-AOYl.js";import{t as p}from"./cn-0WouolD0.js";import{n as m}from"./locale-store-D5h-Ha6-.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{s as S}from"./tasks-PuIUgF9L.js";import{An as C,Ao as w,Ds as T,Du as E,Es as D,Go as O,Jc as k,Jl as A,Kc as j,Mn as M,Ni as N,Nn as P,Qd as F,Rc as I,Ts as L,Ui as R,Us as z,Uu as ee,Wi as te,Yc as ne,Zc as B,al as V,ao as H,cl as U,df as re,dl as ie,du as W,gl as ae,hf as oe,jn as se,ll as ce,nl as le,nu as ue,oa as de,ol as fe,pf as G,r as pe,rl as K,sl as me,ta as he,tl as ge,uf as _e,ws as q,yd as J}from"./index-DmURUvvA.js";import{n as Y}from"./tab-completion-input-CxtEp0aP.js";import{n as X,t as ve}from"./task-expandable-content-BZCJqajv.js";var Z=n(),Q=e(t(),1);function ye(e,t){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(0),l=(0,Q.useCallback)(async()=>{let t=++c.current;s(null);try{let n=await ge(e);t===c.current&&r(n)}catch(e){t===c.current&&s(e instanceof Error?e.message:String(e))}finally{t===c.current&&a(!1)}},[e]);return(0,Q.useEffect)(()=>(l(),()=>{c.current++}),[l,t]),(0,Q.useEffect)(()=>{let e,t=1/0,n=n=>{let r=Date.now()+n;r>=t||(window.clearTimeout(e),t=r,e=window.setTimeout(()=>{e=void 0,t=1/0,l()},n))},r=()=>n(100),i=()=>n(750),a=()=>{document.visibilityState===`visible`&&r()},o=[`task-changed-v2`,`task-updated`,`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`,`home-advisor-updated`,`gateway-realtime-connected`,`realtime-gap`,`focus`],s=[`session-updated`,`session-transcript-updated`];return o.forEach(e=>window.addEventListener(e,r)),s.forEach(e=>window.addEventListener(e,i)),document.addEventListener(`visibilitychange`,a),()=>{o.forEach(e=>window.removeEventListener(e,r)),s.forEach(e=>window.removeEventListener(e,i)),document.removeEventListener(`visibilitychange`,a),window.clearTimeout(e)}},[l]),{home:n,loading:i,loadError:o,setLoadError:s,load:l}}var $=r(),be=12e3;function xe(e){let t=(0,Z.c)(107),{variant:n,inputId:r,inputRef:i,intent:a,labels:o,attachments:s,isDragging:c,attachmentBusy:l,attachmentsFull:u,voice:d,chat:f,cancelAction:m,onIntentChange:h,onPickFiles:g,onRemoveAttachment:_,onPaste:v,onDragOver:y,onDragLeave:b,onDrop:x,onSubmit:S}=e,C=n===`inline`,w;t[0]!==s||t[1]!==a?(w=!!a.trim()||s.length>0,t[0]=s,t[1]=a,t[2]=w):w=t[2];let T=w,D=d.voiceActive&&d.phase!==`error`,O;t[3]!==S||t[4]!==d.voiceActive?(O=e=>{if(d.voiceActive){e.preventDefault();return}S(e)},t[3]=S,t[4]=d.voiceActive,t[5]=O):O=t[5];let k=C?`mx-auto mt-6 w-full overflow-hidden rounded-xl border border-edge bg-surface-base p-2 text-left shadow-surface transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/15 sm:mt-8`:`flex min-h-0 flex-1 flex-col`,N;t[6]===k?N=t[7]:(N=p(`relative`,k),t[6]=k,t[7]=N);let P;t[8]!==C||t[9]!==c||t[10]!==o.dropFiles?(P=c?(0,$.jsx)(`div`,{className:p(`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-accent-soft/90 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,C&&`rounded-2xl`),children:o.dropFiles}):null,t[8]=C,t[9]=c,t[10]=o.dropFiles,t[11]=P):P=t[11];let F=!C&&`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,I;t[12]===F?I=t[13]:(I=p(F),t[12]=F,t[13]=I);let L=C?`sr-only`:`mb-2 shrink-0 text-sm font-medium text-fg`,R;t[14]!==r||t[15]!==o.intentLabel||t[16]!==L?(R=(0,$.jsx)(`label`,{htmlFor:r,className:L,children:o.intentLabel}),t[14]=r,t[15]=o.intentLabel,t[16]=L,t[17]=R):R=t[17];let z;t[18]!==l||t[19]!==f||t[20]!==d.audioLevel||t[21]!==d.cancelVoiceInput||t[22]!==d.confirmVoiceInput||t[23]!==d.elapsedLabel||t[24]!==d.error||t[25]!==d.finalTranscript||t[26]!==d.partialTranscript||t[27]!==d.phase||t[28]!==d.recordedDictation||t[29]!==d.retryVoiceInput||t[30]!==d.settingsRequired||t[31]!==d.voiceActive?(z=d.voiceActive?(0,$.jsx)(M,{phase:d.phase,elapsedLabel:d.elapsedLabel,recordedDictation:d.recordedDictation,audioLevel:d.audioLevel,partialTranscript:d.partialTranscript,finalTranscript:d.finalTranscript,error:d.error,settingsRequired:d.settingsRequired,disabled:l,chat:f,onCancel:d.cancelVoiceInput,onConfirm:d.confirmVoiceInput,onRetry:d.retryVoiceInput}):null,t[18]=l,t[19]=f,t[20]=d.audioLevel,t[21]=d.cancelVoiceInput,t[22]=d.confirmVoiceInput,t[23]=d.elapsedLabel,t[24]=d.error,t[25]=d.finalTranscript,t[26]=d.partialTranscript,t[27]=d.phase,t[28]=d.recordedDictation,t[29]=d.retryVoiceInput,t[30]=d.settingsRequired,t[31]=d.voiceActive,t[32]=z):z=t[32];let ee=D&&`hidden`,ne=C?`min-h-24 bg-transparent px-3 py-2`:`min-h-32 flex-1 rounded-xl border border-edge bg-surface-base p-3 focus:border-accent focus:ring-2 focus:ring-accent/20`,B;t[33]!==ee||t[34]!==ne?(B=p(`w-full resize-none text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle`,ee,ne),t[33]=ee,t[34]=ne,t[35]=B):B=t[35];let V;t[36]===h?V=t[37]:(V=e=>h(e.target.value),t[36]=h,t[37]=V);let H=!C,U;t[38]!==r||t[39]!==i||t[40]!==a||t[41]!==o.intentPlaceholder||t[42]!==o.intentSuggestion||t[43]!==h||t[44]!==v||t[45]!==B||t[46]!==V||t[47]!==H?(U=(0,$.jsx)(Y,{ref:i,id:r,className:B,value:a,onChange:V,onPaste:v,suggestion:o.intentSuggestion,onAcceptSuggestion:h,onKeyDown:Se,placeholder:o.intentPlaceholder,maxLength:be,autoFocus:H}),t[38]=r,t[39]=i,t[40]=a,t[41]=o.intentPlaceholder,t[42]=o.intentSuggestion,t[43]=h,t[44]=v,t[45]=B,t[46]=V,t[47]=H,t[48]=U):U=t[48];let re=C?`border-b-0 bg-transparent px-3 pb-2 pt-0`:`mt-3 border-b-0 bg-transparent px-0 pb-0`,ie;t[49]!==s||t[50]!==_||t[51]!==re?(ie=(0,$.jsx)(he,{attachments:s,topPadded:!1,onRemove:_,className:re}),t[49]=s,t[50]=_,t[51]=re,t[52]=ie):ie=t[52];let W;t[53]!==C||t[54]!==a.length||t[55]!==o.shortcut?(W=C?null:(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:o.shortcut}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[a.length.toLocaleString(),` / `,be.toLocaleString()]})]}),t[53]=C,t[54]=a.length,t[55]=o.shortcut,t[56]=W):W=t[56];let ae;t[57]!==z||t[58]!==U||t[59]!==ie||t[60]!==W||t[61]!==I||t[62]!==R?(ae=(0,$.jsxs)(`div`,{className:I,children:[R,z,U,ie,W]}),t[57]=z,t[58]=U,t[59]=ie,t[60]=W,t[61]=I,t[62]=R,t[63]=ae):ae=t[63];let oe=C?`border-edge-subtle px-1 pt-2`:`border-edge px-5 py-4`,se;t[64]===oe?se=t[65]:(se=p(`flex shrink-0 items-center gap-2 border-t`,oe),t[64]=oe,t[65]=se);let ce=!C&&`mr-auto`,le;t[66]===ce?le=t[67]:(le=p(`flex items-center gap-1`,ce),t[66]=ce,t[67]=le);let ue=l||u,de;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t[68]=de):de=t[68];let fe;t[69]!==o.attachTitle||t[70]!==g||t[71]!==ue?(fe=(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`size-9 rounded-lg p-0`,disabled:ue,title:o.attachTitle,"aria-label":o.attachTitle,onClick:g,children:de}),t[69]=o.attachTitle,t[70]=g,t[71]=ue,t[72]=fe):fe=t[72];let G;t[73]!==l||t[74]!==f||t[75]!==d.startVoiceInput||t[76]!==d.voiceActive?(G=d.voiceActive?null:(0,$.jsx)(te,{disabled:l,chat:f,onStart:d.startVoiceInput}),t[73]=l,t[74]=f,t[75]=d.startVoiceInput,t[76]=d.voiceActive,t[77]=G):G=t[77];let pe;t[78]!==le||t[79]!==fe||t[80]!==G?(pe=(0,$.jsxs)(`div`,{className:le,children:[fe,G]}),t[78]=le,t[79]=fe,t[80]=G,t[81]=pe):pe=t[81];let K;t[82]!==m||t[83]!==C||t[84]!==o.shortcut?(K=C?(0,$.jsx)(`span`,{className:`hidden text-[11px] text-fg-subtle sm:inline`,children:o.shortcut}):m,t[82]=m,t[83]=C,t[84]=o.shortcut,t[85]=K):K=t[85];let me=C?`ml-auto h-9 rounded-lg px-3.5 text-xs`:`min-w-32`,ge=!T||l||d.voiceActive,_e=C?`size-3.5`:`size-4`,q;t[86]===_e?q=t[87]:(q=(0,$.jsx)(A,{className:_e,"aria-hidden":!0}),t[86]=_e,t[87]=q);let J;t[88]!==o.submit||t[89]!==me||t[90]!==ge||t[91]!==q?(J=(0,$.jsxs)(j,{type:`submit`,variant:`primary`,className:me,disabled:ge,children:[q,o.submit]}),t[88]=o.submit,t[89]=me,t[90]=ge,t[91]=q,t[92]=J):J=t[92];let X;t[93]!==se||t[94]!==pe||t[95]!==K||t[96]!==J?(X=(0,$.jsxs)(`div`,{className:se,children:[pe,K,J]}),t[93]=se,t[94]=pe,t[95]=K,t[96]=J,t[97]=X):X=t[97];let ve;return t[98]!==b||t[99]!==y||t[100]!==x||t[101]!==O||t[102]!==ae||t[103]!==X||t[104]!==N||t[105]!==P?(ve=(0,$.jsxs)(`form`,{onSubmit:O,onDragOver:y,onDragLeave:b,onDrop:x,className:N,children:[P,ae,X]}),t[98]=b,t[99]=y,t[100]=x,t[101]=O,t[102]=ae,t[103]=X,t[104]=N,t[105]=P,t[106]=ve):ve=t[106],ve}function Se(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}function Ce(e){let t=(0,Z.c)(4),{label:n,onClick:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(J,{className:`size-3.5`,"aria-hidden":!0}),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==r?(a=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-lg px-2 text-xs font-medium text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:r,children:[i,n]}),t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function we(e){let t=(0,Z.c)(65),{opportunity:n,copy:r,onOpenHistory:i}=e,a,o,s,c,l,u;if(t[0]!==r.aiLabel||t[1]!==r.automationAction||t[2]!==r.automationHint||t[3]!==r.history||t[4]!==r.minutes||t[5]!==r.needsSetup||t[6]!==r.why||t[7]!==i||t[8]!==n.capabilities||t[9]!==n.continuation||t[10]!==n.estimatedMinutes||t[11]!==n.outcome||t[12]!==n.rationale||t[13]!==n.title){let e=n.capabilities.filter(Ee),d;t[20]===r.aiLabel?d=t[21]:(d=(0,$.jsx)(`span`,{children:r.aiLabel}),t[20]=r.aiLabel,t[21]=d);let f;t[22]!==r.minutes||t[23]!==n.estimatedMinutes?(f=n.estimatedMinutes?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),n.estimatedMinutes,` `,r.minutes]}):null,t[22]=r.minutes,t[23]=n.estimatedMinutes,t[24]=f):f=t[24];let p;t[25]!==d||t[26]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[d,f]}),t[25]=d,t[26]=f,t[27]=p):p=t[27];let m;t[28]!==r.history||t[29]!==i?(m=(0,$.jsx)(Ce,{label:r.history,onClick:i}),t[28]=r.history,t[29]=i,t[30]=m):m=t[30],t[31]!==m||t[32]!==p?(a=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[p,m]}),t[31]=m,t[32]=p,t[33]=a):a=t[33],t[34]===n.title?o=t[35]:(o=(0,$.jsx)(`h3`,{className:`mt-3 text-xl font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[34]=n.title,t[35]=o),t[36]===n.outcome?s=t[37]:(s=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.outcome}),t[36]=n.outcome,t[37]=s);let h;t[38]===r.why?h=t[39]:(h=(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.why,`:`]}),t[38]=r.why,t[39]=h),t[40]!==n.rationale||t[41]!==h?(c=(0,$.jsxs)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:[h,n.rationale]}),t[40]=n.rationale,t[41]=h,t[42]=c):c=t[42],t[43]!==r.automationAction||t[44]!==r.automationHint||t[45]!==n.continuation?(l=n.continuation?.kind===`automation`?(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 rounded-xl border border-edge bg-surface-subtle p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:r.automationHint}),(0,$.jsx)(`a`,{href:`#${n.continuation.href}`,className:`inline-flex min-h-11 shrink-0 items-center rounded-lg px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.automationAction})]}):null,t[43]=r.automationAction,t[44]=r.automationHint,t[45]=n.continuation,t[46]=l):l=t[46],u=e.length>0?(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,"aria-label":r.needsSetup,children:e.map(e=>(0,$.jsxs)(`a`,{href:`#${e.recoveryPath??`/settings`}`,className:`rounded-full border border-accent/25 bg-accent-soft px-2.5 py-1 text-xs text-accent hover:border-accent/50`,children:[r.needsSetup,` · `,e.capability]},`${e.kind}:${e.capability}`))}):null,t[0]=r.aiLabel,t[1]=r.automationAction,t[2]=r.automationHint,t[3]=r.history,t[4]=r.minutes,t[5]=r.needsSetup,t[6]=r.why,t[7]=i,t[8]=n.capabilities,t[9]=n.continuation,t[10]=n.estimatedMinutes,t[11]=n.outcome,t[12]=n.rationale,t[13]=n.title,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l,t[19]=u}else a=t[14],o=t[15],s=t[16],c=t[17],l=t[18],u=t[19];let d;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(G,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[47]=d):d=t[47];let f;t[48]===r.evidence?f=t[49]:(f=(0,$.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.evidence,d]}),t[48]=r.evidence,t[49]=f);let p;t[50]===n.evidence?p=t[51]:(p=n.evidence.map(Te),t[50]=n.evidence,t[51]=p);let m;t[52]===p?m=t[53]:(m=(0,$.jsx)(`ul`,{className:`mt-2 space-y-2 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:p}),t[52]=p,t[53]=m);let h;t[54]!==m||t[55]!==f?(h=(0,$.jsxs)(`details`,{className:`mt-4 group`,children:[f,m]}),t[54]=m,t[55]=f,t[56]=h):h=t[56];let g;return t[57]!==a||t[58]!==h||t[59]!==o||t[60]!==s||t[61]!==c||t[62]!==l||t[63]!==u?(g=(0,$.jsxs)($.Fragment,{children:[a,o,s,c,l,u,h]}),t[57]=a,t[58]=h,t[59]=o,t[60]=s,t[61]=c,t[62]=l,t[63]=u,t[64]=g):g=t[64],g}function Te(e){return(0,$.jsx)(`li`,{children:e.href?(0,$.jsx)(`a`,{href:`#${e.href}`,className:`hover:text-accent hover:underline`,children:e.observation}):e.observation},e.id)}function Ee(e){return e.readiness!==`ready`}function De(e){let t=(0,Z.c)(130),{advisor:n,copy:r,busy:i,onRefresh:a,onAction:o,onFeedback:c,onClarification:l,onOpenHistory:u,preflight:d,receipt:f}=e,[p,m]=(0,Q.useState)(),h;t[0]!==n.alternatives||t[1]!==n.primary||t[2]!==n.state?(h=n.state===`ready`?[n.primary,...n.alternatives]:[],t[0]=n.alternatives,t[1]=n.primary,t[2]=n.state,t[3]=h):h=t[3];let g=h,_;t[4]!==g||t[5]!==p?(_=g.find(e=>e.id===p)??g[0],t[4]=g,t[5]=p,t[6]=_):_=t[6];let v=_,y;t[7]===g[0]?.id?y=t[8]:(y=()=>m(g[0]?.id),t[7]=g[0]?.id,t[8]=y);let b=g[0]?.id,x;if(t[9]!==n.state||t[10]!==b?(x=[n.state,b],t[9]=n.state,t[10]=b,t[11]=x):x=t[11],(0,Q.useEffect)(y,x),n.state===`disabled`)return null;if(f){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(s,{className:`size-5 shrink-0 text-success`,"aria-hidden":!0}),t[12]=e):e=t[12];let n;t[13]===f.title?n=t[14]:(n=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:f.title}),t[13]=f.title,t[14]=n);let i;t[15]===f.detail?i=t[16]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:f.detail}),t[15]=f.detail,t[16]=i);let a;t[17]!==n||t[18]!==i?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[n,i]}),t[17]=n,t[18]=i,t[19]=a):a=t[19];let o;t[20]!==r.history||t[21]!==u?(o=(0,$.jsx)(Ce,{label:r.history,onClick:u}),t[20]=r.history,t[21]=u,t[22]=o):o=t[22];let c=`#${f.href}`,l;t[23]!==r.viewProgress||t[24]!==c?(l=(0,$.jsx)(j,{asChild:!0,variant:`secondary`,className:`min-h-10 text-xs`,children:(0,$.jsx)(`a`,{href:c,children:r.viewProgress})}),t[23]=r.viewProgress,t[24]=c,t[25]=l):l=t[25];let d;t[26]!==o||t[27]!==l?(d=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[o,l]}),t[26]=o,t[27]=l,t[28]=d):d=t[28];let p;return t[29]!==d||t[30]!==a?(p=(0,$.jsx)(`section`,{className:`mt-7 rounded-2xl border border-success/25 bg-success-soft px-5 py-4`,role:`status`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[e,a,d]})}),t[29]=d,t[30]=a,t[31]=p):p=t[31],p}if(n.state===`quiet`||n.state===`refreshing`)return null;if(n.state===`clarification`){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t[32]=e):e=t[32];let i;t[33]===r.aiLabel?i=t[34]:(i=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-accent`,children:[e,r.aiLabel]}),t[33]=r.aiLabel,t[34]=i);let a;t[35]!==r.history||t[36]!==u?(a=(0,$.jsx)(Ce,{label:r.history,onClick:u}),t[35]=r.history,t[36]=u,t[37]=a):a=t[37];let o;t[38]!==i||t[39]!==a?(o=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[i,a]}),t[38]=i,t[39]=a,t[40]=o):o=t[40];let s;t[41]===n.question.question?s=t[42]:(s=(0,$.jsx)(`h3`,{id:`home-advisor-question`,className:`mt-3 text-lg font-semibold text-fg`,children:n.question.question}),t[41]=n.question.question,t[42]=s);let c;if(t[43]!==n.question.options||t[44]!==n.question.question||t[45]!==l){let e;t[47]!==n.question.question||t[48]!==l?(e=e=>(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`min-h-11`,onClick:()=>l(n.question.question,e.label),children:e.label},e.id),t[47]=n.question.question,t[48]=l,t[49]=e):e=t[49],c=n.question.options.map(e),t[43]=n.question.options,t[44]=n.question.question,t[45]=l,t[46]=c}else c=t[46];let d;t[50]===c?d=t[51]:(d=(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:c}),t[50]=c,t[51]=d);let f;return t[52]!==s||t[53]!==d||t[54]!==o?(f=(0,$.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base px-5 py-5`,"aria-labelledby":`home-advisor-question`,children:[o,s,d]}),t[52]=s,t[53]=d,t[54]=o,t[55]=f):f=t[55],f}if(!v)return null;let S=d?.opportunityId===v.id?d.value:void 0,C;t[56]!==n.stale||t[57]!==r.refreshing?(C=n.stale?(0,$.jsxs)(`p`,{className:`mb-3 inline-flex items-center gap-2 text-xs text-accent`,children:[(0,$.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.refreshing]}):null,t[56]=n.stale,t[57]=r.refreshing,t[58]=C):C=t[58];let w;t[59]!==r||t[60]!==u||t[61]!==v?(w=(0,$.jsx)(we,{opportunity:v,copy:r,onOpenHistory:u}),t[59]=r,t[60]=u,t[61]=v,t[62]=w):w=t[62];let T;t[63]!==i||t[64]!==r.configure||t[65]!==r.degradedStart||t[66]!==r.setupHint||t[67]!==r.setupTitle||t[68]!==o||t[69]!==v||t[70]!==S?(T=S?.state===`needs_setup`?(0,$.jsx)(`div`,{className:`mt-5 rounded-xl border border-accent/25 bg-accent-soft/40 p-4`,role:`alert`,"aria-live":`polite`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(ue,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:r.setupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r.setupHint}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:S.blockers.map(Oe)}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[S.recoveryActions.map(e=>(0,$.jsxs)(`a`,{href:`#${e.href}`,className:`inline-flex min-h-11 items-center rounded-lg border border-accent/30 px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.configure,` · `,e.capability]},e.capability)),S.degradedAction?(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`degraded_start`),children:r.degradedStart}):null]})]})]})}):null,t[63]=i,t[64]=r.configure,t[65]=r.degradedStart,t[66]=r.setupHint,t[67]=r.setupTitle,t[68]=o,t[69]=v,t[70]=S,t[71]=T):T=t[71];let E;t[72]!==i||t[73]!==r.start||t[74]!==o||t[75]!==v?(E=v.actions.canStart?(0,$.jsxs)(j,{type:`button`,variant:`primary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`start`),children:[(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0}),r.start]}):null,t[72]=i,t[73]=r.start,t[74]=o,t[75]=v,t[76]=E):E=t[76];let D;t[77]!==i||t[78]!==r.discuss||t[79]!==o||t[80]!==v?(D=v.actions.canDiscuss?(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`discuss`),children:[(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),r.discuss]}):null,t[77]=i,t[78]=r.discuss,t[79]=o,t[80]=v,t[81]=D):D=t[81];let O;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(W,{className:`size-4`,"aria-hidden":!0}),t[82]=O):O=t[82];let k;t[83]!==i||t[84]!==r.refresh||t[85]!==a?(k=(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`min-h-11`,disabled:i,onClick:a,title:r.refresh,children:[O,r.refresh]}),t[83]=i,t[84]=r.refresh,t[85]=a,t[86]=k):k=t[86];let M;t[87]===r.feedback?M=t[88]:(M=(0,$.jsx)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center rounded-lg px-3 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.feedback}),t[87]=r.feedback,t[88]=M);let N;t[89]===r.alreadyDone?N=t[90]:(N=[`already_done`,r.alreadyDone],t[89]=r.alreadyDone,t[90]=N);let P;t[91]===r.irrelevant?P=t[92]:(P=[`irrelevant`,r.irrelevant],t[91]=r.irrelevant,t[92]=P);let F;t[93]===r.later?F=t[94]:(F=[`too_early`,r.later],t[93]=r.later,t[94]=F);let I;t[95]===r.sourceIncorrect?I=t[96]:(I=[`source_incorrect`,r.sourceIncorrect],t[95]=r.sourceIncorrect,t[96]=I);let L;t[97]===r.lessLikeThis?L=t[98]:(L=[`less_like_this`,r.lessLikeThis],t[97]=r.lessLikeThis,t[98]=L);let R;t[99]!==N||t[100]!==P||t[101]!==F||t[102]!==I||t[103]!==L?(R=[N,P,F,I,L],t[99]=N,t[100]=P,t[101]=F,t[102]=I,t[103]=L,t[104]=R):R=t[104];let z=R,te;t[105]!==c||t[106]!==v||t[107]!==z?(te=(0,$.jsx)(`div`,{className:`absolute right-0 z-20 mt-1 w-44 rounded-xl border border-edge bg-surface-overlay p-1 shadow-float`,children:z.map(e=>{let[t,n]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-10 w-full rounded-lg px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>c(v,t),children:n},t)})}),t[105]=c,t[106]=v,t[107]=z,t[108]=te):te=t[108];let ne;t[109]!==M||t[110]!==te?(ne=(0,$.jsxs)(`details`,{className:`relative ml-auto`,children:[M,te]}),t[109]=M,t[110]=te,t[111]=ne):ne=t[111];let B;t[112]!==D||t[113]!==k||t[114]!==ne||t[115]!==E?(B=(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[E,D,k,ne]}),t[112]=D,t[113]=k,t[114]=ne,t[115]=E,t[116]=B):B=t[116];let V;t[117]!==B||t[118]!==C||t[119]!==w||t[120]!==T?(V=(0,$.jsxs)(`div`,{className:`px-5 py-5 sm:px-6`,children:[C,w,T,B]}),t[117]=B,t[118]=C,t[119]=w,t[120]=T,t[121]=V):V=t[121];let H;t[122]!==r.alternatives||t[123]!==g||t[124]!==v.id?(H=g.length>1?(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:r.alternatives}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:g.filter(e=>e.id!==v.id).map(e=>(0,$.jsx)(`button`,{type:`button`,className:`min-h-10 rounded-lg border border-edge px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>m(e.id),children:e.title},e.id))})]}):null,t[122]=r.alternatives,t[123]=g,t[124]=v.id,t[125]=H):H=t[125];let U;return t[126]!==r.aiLabel||t[127]!==V||t[128]!==H?(U=(0,$.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base`,"aria-label":r.aiLabel,children:[V,H]}),t[126]=r.aiLabel,t[127]=V,t[128]=H,t[129]=U):U=t[129],U}function Oe(e){return(0,$.jsx)(`li`,{children:e.message},`${e.kind}:${e.capability}`)}var ke=new Set([`started`,`discussing`,`completed`]);function Ae(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[0,1,2].map(je)}),e[0]=t):t=e[0],t}function je(e){return(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge-subtle p-4`,children:[(0,$.jsx)(I,{className:`h-4 w-24 rounded`}),(0,$.jsx)(I,{className:`h-5 w-4/5 rounded`}),(0,$.jsx)(I,{className:`h-4 w-3/5 rounded`})]},e)}function Me(e){let t=(0,Z.c)(11),{open:n,refreshKey:r,onOpenChange:i,onReevaluate:o}=e,s=m(Pe),u=f(s).projectsPage.home,p=a(),[S,C]=(0,Q.useState)(`all`),T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[0]=T):T=t[0];let[E,D]=(0,Q.useState)(T),[O,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(),N;t[1]===n?N=t[2]:(N=()=>{if(!n)return;let e=!0;return k(!0),M(void 0),le().then(t=>{e&&D(t.items)}).catch(t=>{e&&M(t instanceof Error?t.message:String(t))}).finally(()=>{e&&k(!1)}),()=>{e=!1}},t[1]=n,t[2]=N);let P;t[3]!==n||t[4]!==r?(P=[n,r],t[3]=n,t[4]=r,t[5]=P):P=t[5],(0,Q.useEffect)(N,P);let I=E.filter(e=>S===`all`||(S===`adopted`?ke.has(e.status):!ke.has(e.status))),L=new Intl.DateTimeFormat(s===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}),R=new Intl.DateTimeFormat(s===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),z=new Map;for(let e of I){let t=L.format(new Date(e.updatedAt));z.set(t,[...z.get(t)??[],e])}let ee=[...z.entries()],te=e=>e.feedbackKind===`already_done`?u.advisorHistoryStatusCompleted:e.feedbackKind===`irrelevant`?u.advisorHistoryStatusIrrelevant:e.feedbackKind===`source_incorrect`?u.advisorHistoryStatusSourceIncorrect:e.feedbackKind===`less_like_this`?u.advisorHistoryStatusLessLikeThis:{available:u.advisorHistoryStatusAvailable,started:u.advisorHistoryStatusStarted,discussing:u.advisorHistoryStatusDiscussing,completed:u.advisorHistoryStatusCompleted,snoozed:u.advisorHistoryStatusSnoozed,dismissed:u.advisorHistoryStatusDismissed,expired:u.advisorHistoryStatusExpired,superseded:u.advisorHistoryStatusSuperseded}[e.status],ne=e=>{if(e.href){i(!1),p(l(`/`,e.href));return}e.status===`discussing`&&(i(!1),p(`/chat/new?${new URLSearchParams({draft:e.opportunity.actionPrompt}).toString()}`))},B;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[6]=B):B=t[6];let V;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(J,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=V):V=t[7];let H;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[8]=H):H=t[8];let U=O?(0,$.jsx)(Ae,{}):A?(0,$.jsxs)(`div`,{className:`rounded-xl border border-danger/25 bg-danger-soft p-4 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:u.advisorHistoryLoadFailed}),(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`mt-2`,onClick:()=>i(!1),children:u.advisorHistoryClose})]}):ee.length===0?(0,$.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,$.jsx)(J,{className:`mx-auto size-6 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:u.advisorHistoryEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.advisorHistoryEmptyHint})]}):(0,$.jsx)(`div`,{className:`space-y-6`,children:ee.map(e=>{let[t,n]=e;return(0,$.jsxs)(`section`,{"aria-label":t,children:[(0,$.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-subtle`,children:t}),(0,$.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=!!e.href||e.status===`discussing`,n=[`snoozed`,`dismissed`,`expired`,`superseded`].includes(e.status);return(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:te(e)}),(0,$.jsx)(`h4`,{className:`mt-1.5 text-sm font-semibold leading-5 text-fg`,children:e.opportunity.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.opportunity.outcome})]}),(0,$.jsx)(`time`,{className:`shrink-0 text-[11px] text-fg-subtle`,dateTime:new Date(e.updatedAt).toISOString(),children:R.format(new Date(e.updatedAt))})]}),e.snoozedUntil?(0,$.jsxs)(`p`,{className:`mt-2 inline-flex items-center gap-1 text-xs text-fg-muted`,children:[(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),u.advisorHistoryReturnsAt,` `,R.format(new Date(e.snoozedUntil))]}):null,(0,$.jsxs)(`details`,{className:`group mt-3`,children:[(0,$.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1 text-xs font-medium text-fg-muted hover:text-fg`,children:[u.advisorHistoryEvidence,(0,$.jsx)(G,{className:`size-3.5 transition-transform duration-200 group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1.5 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:e.opportunity.evidence.map(Ne)})]}),t||n?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[t?(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`min-h-9 text-xs`,onClick:()=>ne(e),children:[(0,$.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),e.status===`discussing`?u.advisorHistoryContinueDiscussion:u.advisorHistoryViewProgress]}):null,n?(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`min-h-9 text-xs`,onClick:()=>{i(!1),o()},children:[(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),u.advisorHistoryReevaluate]}):null]}):null]},e.opportunity.id)})})]},t)})}),re;return t[9]===U?re=t[10]:(re=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:U}),t[9]=U,t[10]=re),(0,$.jsx)(x,{open:n,onOpenChange:i,children:(0,$.jsxs)(v,{children:[B,(0,$.jsxs)(y,{className:`xopc-drawer-right fixed right-0 top-0 z-[90] flex size-full max-w-lg flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none`,"aria-describedby":`home-advisor-history-description`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b border-edge px-5 py-4`,children:[V,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(b,{className:`text-base font-semibold text-fg`,children:u.advisorHistoryTitle}),(0,$.jsx)(g,{id:`home-advisor-history-description`,className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.advisorHistoryDescription})]}),(0,$.jsx)(_,{asChild:!0,children:(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`-mr-2 size-9 shrink-0 p-0`,"aria-label":u.advisorHistoryClose,children:H})})]}),(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-3`,children:(0,$.jsx)(w,{className:`inline-flex rounded-lg bg-surface-inset p-1`,role:`group`,"aria-label":u.advisorHistoryFilterLabel,indicatorClassName:`rounded-md bg-surface-panel shadow-surface`,children:[[`all`,u.advisorHistoryFilterAll],[`adopted`,u.advisorHistoryFilterAdopted],[`other`,u.advisorHistoryFilterOther]].map(e=>{let[t,n]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md px-3 text-xs font-medium transition-colors duration-150 ${S===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`}`,"aria-pressed":S===t,onClick:()=>C(t),children:n},t)})})}),re]})]})})}function Ne(e){return(0,$.jsx)(`li`,{children:e.observation},e.id)}function Pe(e){return e.language}function Fe(e,t){return e.replace(`{{count}}`,String(t))}function Ie(e,t){if(e.state===`disabled`)return null;if(e.state===`ready`){let n=1+e.alternatives.length;return{label:Fe(t.ready,n),detail:e.primary.title,tone:`accent`,refreshing:!!e.stale}}return e.state===`clarification`?{label:t.clarification,detail:e.question.question,tone:`accent`,refreshing:!1}:e.state===`refreshing`?{label:t.refreshing,detail:e.previous?.title??t.refreshingDetail,tone:`accent`,refreshing:!0}:e.reason===`generation_failed`?{label:t.generationFailed,detail:t.generationFailedDetail,tone:`danger`,refreshing:!1}:e.reason===`budget_exhausted`?{label:t.budgetExhausted,detail:t.budgetExhaustedDetail,tone:`warning`,refreshing:!1}:e.reason===`model_unavailable`?{label:t.modelUnavailable,detail:t.modelUnavailableDetail,tone:`warning`,refreshing:!1}:{label:t.idle,detail:t.idleDetail,tone:`neutral`,refreshing:!1}}var Le={accent:`bg-accent`,danger:`bg-danger`,neutral:`bg-fg-subtle`,warning:`bg-warning`};function Re(e){let t=(0,Z.c)(50),{advisor:n,busy:r,copy:i,onOpenHistory:a,onRefresh:o}=e,[s,c]=(0,Q.useState)(!1),l;t[0]!==n||t[1]!==i?(l=Ie(n,i),t[0]=n,t[1]=i,t[2]=l):l=t[2];let u=l;if(!u)return null;let d=n.state!==`refreshing`,f=n.state===`ready`?i.findAnother:i.retry,m=`${i.label}:${u.label}`,h;t[3]===u.refreshing?h=t[4]:(h=u.refreshing?(0,$.jsx)(W,{className:`size-3.5 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(A,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=u.refreshing,t[4]=h);let g=Le[u.tone],_;t[5]===g?_=t[6]:(_=p(`size-1.5 shrink-0 rounded-full`,g),t[5]=g,t[6]=_);let v;t[7]===_?v=t[8]:(v=(0,$.jsx)(`span`,{className:_,"aria-hidden":!0}),t[7]=_,t[8]=v);let y;t[9]!==i.label||t[10]!==u.label?(y=(0,$.jsxs)(`span`,{className:`truncate`,children:[i.label,` · `,u.label]}),t[9]=i.label,t[10]=u.label,t[11]=y):y=t[11];let b;t[12]!==m||t[13]!==h||t[14]!==v||t[15]!==y?(b=(0,$.jsx)(T,{asChild:!0,children:(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-9 max-w-56 rounded-lg px-2.5`,"aria-label":m,children:[h,v,y]})}),t[12]=m,t[13]=h,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]===u.refreshing?x=t[18]:(x=(0,$.jsx)(`span`,{className:`mt-1 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:u.refreshing?(0,$.jsx)(W,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0})}),t[17]=u.refreshing,t[18]=x);let S;t[19]===u.label?S=t[20]:(S=(0,$.jsx)(`p`,{className:`font-semibold text-fg`,children:u.label}),t[19]=u.label,t[20]=S);let C;t[21]===u.detail?C=t[22]:(C=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.detail}),t[21]=u.detail,t[22]=C);let w;t[23]!==S||t[24]!==C?(w=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[23]=S,t[24]=C,t[25]=w):w=t[25];let E;t[26]!==w||t[27]!==x?(E=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[x,w]}),t[26]=w,t[27]=x,t[28]=E):E=t[28];let O;t[29]===a?O=t[30]:(O=()=>{c(!1),a()},t[29]=a,t[30]=O);let k;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(J,{className:`size-3.5`,"aria-hidden":!0}),t[31]=k):k=t[31];let M;t[32]!==i.history||t[33]!==O?(M=(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:O,children:[k,i.history]}),t[32]=i.history,t[33]=O,t[34]=M):M=t[34];let N;t[35]!==r||t[36]!==d||t[37]!==o||t[38]!==f?(N=d?(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg text-xs`,disabled:r,onClick:()=>{c(!1),o()},children:[(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),f]}):null,t[35]=r,t[36]=d,t[37]=o,t[38]=f,t[39]=N):N=t[39];let P;t[40]!==M||t[41]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3`,children:[M,N]}),t[40]=M,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==E||t[44]!==P?(F=(0,$.jsx)(L,{children:(0,$.jsxs)(q,{side:`bottom`,align:`end`,sideOffset:6,className:`z-[70] w-[min(21rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay p-4 text-sm text-fg shadow-popover outline-none`,onOpenAutoFocus:ze,children:[E,P]})}),t[43]=E,t[44]=P,t[45]=F):F=t[45];let I;return t[46]!==s||t[47]!==F||t[48]!==b?(I=(0,$.jsxs)(D,{open:s,onOpenChange:c,children:[b,F]}),t[46]=s,t[47]=F,t[48]=b,t[49]=I):I=t[49],I}function ze(e){return e.preventDefault()}function Be({taskId:e,language:t,onComplete:n}){let r=t===`zh`,[i,a]=(0,Q.useState)(),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let t=!0;return s(void 0),a(void 0),K(e).then(e=>{t&&a(e)}).catch(e=>{t&&s(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e,u]);let f=i?X(i):[],p=i?.task.phase===`review`&&i.allowedCommands.includes(`close`)&&i.waits.length===0&&f.length>0&&f.every(e=>e.status===`passed`);async function m(e,t=!1){if(!c){l(!0),s(void 0);try{a(await e()),t&&n()}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}}let h=i?.receipts[0];return(0,$.jsxs)(`section`,{className:`mt-4 space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,"aria-label":r?`任务验收`:`Task review`,children:[o?(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center justify-between gap-3 text-sm text-danger`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(j,{variant:`ghost`,disabled:c,onClick:()=>d(e=>e+1),children:r?`刷新`:`Refresh`})]}):null,!i&&!o?(0,$.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,$.jsx)(I,{className:`h-5 w-1/3`}),(0,$.jsx)(I,{className:`h-24 w-full`})]}):null,i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r?`执行结果`:`Result`}),h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ve,{content:h.summary,contentKey:`home:${e}:result`,language:t,previewHeight:180}),h.remainingWork.length>0?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm text-fg-muted`,children:[r?`尚待完成:`:`Remaining work: `,h.remainingWork.join(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,g as o}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./external-link-DjqjBmc3.js";import{M as l}from"./markdown-view-CthsQiiO.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-Bwv-AOYl.js";import{t as p}from"./cn-0WouolD0.js";import{n as m}from"./locale-store-D5h-Ha6-.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{s as S}from"./tasks-B4bZpO6O.js";import{An as C,Ao as w,Ds as T,Du as E,Es as D,Go as O,Jc as k,Jl as A,Kc as j,Mn as M,Ni as N,Nn as P,Qd as F,Rc as I,Ts as L,Ui as R,Us as z,Uu as ee,Wi as te,Yc as ne,Zc as B,al as V,ao as H,cl as U,df as re,dl as ie,du as W,gl as ae,hf as oe,jn as se,ll as ce,nl as le,nu as ue,oa as de,ol as fe,pf as G,r as pe,rl as K,sl as me,ta as he,tl as ge,uf as _e,ws as q,yd as J}from"./index-K2cy4f-3.js";import{n as Y}from"./tab-completion-input-CxtEp0aP.js";import{n as X,t as ve}from"./task-expandable-content-BoGtWYbk.js";var Z=n(),Q=e(t(),1);function ye(e,t){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(0),l=(0,Q.useCallback)(async()=>{let t=++c.current;s(null);try{let n=await ge(e);t===c.current&&r(n)}catch(e){t===c.current&&s(e instanceof Error?e.message:String(e))}finally{t===c.current&&a(!1)}},[e]);return(0,Q.useEffect)(()=>(l(),()=>{c.current++}),[l,t]),(0,Q.useEffect)(()=>{let e,t=1/0,n=n=>{let r=Date.now()+n;r>=t||(window.clearTimeout(e),t=r,e=window.setTimeout(()=>{e=void 0,t=1/0,l()},n))},r=()=>n(100),i=()=>n(750),a=()=>{document.visibilityState===`visible`&&r()},o=[`task-changed-v2`,`task-updated`,`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`,`home-advisor-updated`,`gateway-realtime-connected`,`realtime-gap`,`focus`],s=[`session-updated`,`session-transcript-updated`];return o.forEach(e=>window.addEventListener(e,r)),s.forEach(e=>window.addEventListener(e,i)),document.addEventListener(`visibilitychange`,a),()=>{o.forEach(e=>window.removeEventListener(e,r)),s.forEach(e=>window.removeEventListener(e,i)),document.removeEventListener(`visibilitychange`,a),window.clearTimeout(e)}},[l]),{home:n,loading:i,loadError:o,setLoadError:s,load:l}}var $=r(),be=12e3;function xe(e){let t=(0,Z.c)(107),{variant:n,inputId:r,inputRef:i,intent:a,labels:o,attachments:s,isDragging:c,attachmentBusy:l,attachmentsFull:u,voice:d,chat:f,cancelAction:m,onIntentChange:h,onPickFiles:g,onRemoveAttachment:_,onPaste:v,onDragOver:y,onDragLeave:b,onDrop:x,onSubmit:S}=e,C=n===`inline`,w;t[0]!==s||t[1]!==a?(w=!!a.trim()||s.length>0,t[0]=s,t[1]=a,t[2]=w):w=t[2];let T=w,D=d.voiceActive&&d.phase!==`error`,O;t[3]!==S||t[4]!==d.voiceActive?(O=e=>{if(d.voiceActive){e.preventDefault();return}S(e)},t[3]=S,t[4]=d.voiceActive,t[5]=O):O=t[5];let k=C?`mx-auto mt-6 w-full overflow-hidden rounded-xl border border-edge bg-surface-base p-2 text-left shadow-surface transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/15 sm:mt-8`:`flex min-h-0 flex-1 flex-col`,N;t[6]===k?N=t[7]:(N=p(`relative`,k),t[6]=k,t[7]=N);let P;t[8]!==C||t[9]!==c||t[10]!==o.dropFiles?(P=c?(0,$.jsx)(`div`,{className:p(`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-accent-soft/90 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,C&&`rounded-2xl`),children:o.dropFiles}):null,t[8]=C,t[9]=c,t[10]=o.dropFiles,t[11]=P):P=t[11];let F=!C&&`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,I;t[12]===F?I=t[13]:(I=p(F),t[12]=F,t[13]=I);let L=C?`sr-only`:`mb-2 shrink-0 text-sm font-medium text-fg`,R;t[14]!==r||t[15]!==o.intentLabel||t[16]!==L?(R=(0,$.jsx)(`label`,{htmlFor:r,className:L,children:o.intentLabel}),t[14]=r,t[15]=o.intentLabel,t[16]=L,t[17]=R):R=t[17];let z;t[18]!==l||t[19]!==f||t[20]!==d.audioLevel||t[21]!==d.cancelVoiceInput||t[22]!==d.confirmVoiceInput||t[23]!==d.elapsedLabel||t[24]!==d.error||t[25]!==d.finalTranscript||t[26]!==d.partialTranscript||t[27]!==d.phase||t[28]!==d.recordedDictation||t[29]!==d.retryVoiceInput||t[30]!==d.settingsRequired||t[31]!==d.voiceActive?(z=d.voiceActive?(0,$.jsx)(M,{phase:d.phase,elapsedLabel:d.elapsedLabel,recordedDictation:d.recordedDictation,audioLevel:d.audioLevel,partialTranscript:d.partialTranscript,finalTranscript:d.finalTranscript,error:d.error,settingsRequired:d.settingsRequired,disabled:l,chat:f,onCancel:d.cancelVoiceInput,onConfirm:d.confirmVoiceInput,onRetry:d.retryVoiceInput}):null,t[18]=l,t[19]=f,t[20]=d.audioLevel,t[21]=d.cancelVoiceInput,t[22]=d.confirmVoiceInput,t[23]=d.elapsedLabel,t[24]=d.error,t[25]=d.finalTranscript,t[26]=d.partialTranscript,t[27]=d.phase,t[28]=d.recordedDictation,t[29]=d.retryVoiceInput,t[30]=d.settingsRequired,t[31]=d.voiceActive,t[32]=z):z=t[32];let ee=D&&`hidden`,ne=C?`min-h-24 bg-transparent px-3 py-2`:`min-h-32 flex-1 rounded-xl border border-edge bg-surface-base p-3 focus:border-accent focus:ring-2 focus:ring-accent/20`,B;t[33]!==ee||t[34]!==ne?(B=p(`w-full resize-none text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle`,ee,ne),t[33]=ee,t[34]=ne,t[35]=B):B=t[35];let V;t[36]===h?V=t[37]:(V=e=>h(e.target.value),t[36]=h,t[37]=V);let H=!C,U;t[38]!==r||t[39]!==i||t[40]!==a||t[41]!==o.intentPlaceholder||t[42]!==o.intentSuggestion||t[43]!==h||t[44]!==v||t[45]!==B||t[46]!==V||t[47]!==H?(U=(0,$.jsx)(Y,{ref:i,id:r,className:B,value:a,onChange:V,onPaste:v,suggestion:o.intentSuggestion,onAcceptSuggestion:h,onKeyDown:Se,placeholder:o.intentPlaceholder,maxLength:be,autoFocus:H}),t[38]=r,t[39]=i,t[40]=a,t[41]=o.intentPlaceholder,t[42]=o.intentSuggestion,t[43]=h,t[44]=v,t[45]=B,t[46]=V,t[47]=H,t[48]=U):U=t[48];let re=C?`border-b-0 bg-transparent px-3 pb-2 pt-0`:`mt-3 border-b-0 bg-transparent px-0 pb-0`,ie;t[49]!==s||t[50]!==_||t[51]!==re?(ie=(0,$.jsx)(he,{attachments:s,topPadded:!1,onRemove:_,className:re}),t[49]=s,t[50]=_,t[51]=re,t[52]=ie):ie=t[52];let W;t[53]!==C||t[54]!==a.length||t[55]!==o.shortcut?(W=C?null:(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:o.shortcut}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[a.length.toLocaleString(),` / `,be.toLocaleString()]})]}),t[53]=C,t[54]=a.length,t[55]=o.shortcut,t[56]=W):W=t[56];let ae;t[57]!==z||t[58]!==U||t[59]!==ie||t[60]!==W||t[61]!==I||t[62]!==R?(ae=(0,$.jsxs)(`div`,{className:I,children:[R,z,U,ie,W]}),t[57]=z,t[58]=U,t[59]=ie,t[60]=W,t[61]=I,t[62]=R,t[63]=ae):ae=t[63];let oe=C?`border-edge-subtle px-1 pt-2`:`border-edge px-5 py-4`,se;t[64]===oe?se=t[65]:(se=p(`flex shrink-0 items-center gap-2 border-t`,oe),t[64]=oe,t[65]=se);let ce=!C&&`mr-auto`,le;t[66]===ce?le=t[67]:(le=p(`flex items-center gap-1`,ce),t[66]=ce,t[67]=le);let ue=l||u,de;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t[68]=de):de=t[68];let fe;t[69]!==o.attachTitle||t[70]!==g||t[71]!==ue?(fe=(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`size-9 rounded-lg p-0`,disabled:ue,title:o.attachTitle,"aria-label":o.attachTitle,onClick:g,children:de}),t[69]=o.attachTitle,t[70]=g,t[71]=ue,t[72]=fe):fe=t[72];let G;t[73]!==l||t[74]!==f||t[75]!==d.startVoiceInput||t[76]!==d.voiceActive?(G=d.voiceActive?null:(0,$.jsx)(te,{disabled:l,chat:f,onStart:d.startVoiceInput}),t[73]=l,t[74]=f,t[75]=d.startVoiceInput,t[76]=d.voiceActive,t[77]=G):G=t[77];let pe;t[78]!==le||t[79]!==fe||t[80]!==G?(pe=(0,$.jsxs)(`div`,{className:le,children:[fe,G]}),t[78]=le,t[79]=fe,t[80]=G,t[81]=pe):pe=t[81];let K;t[82]!==m||t[83]!==C||t[84]!==o.shortcut?(K=C?(0,$.jsx)(`span`,{className:`hidden text-[11px] text-fg-subtle sm:inline`,children:o.shortcut}):m,t[82]=m,t[83]=C,t[84]=o.shortcut,t[85]=K):K=t[85];let me=C?`ml-auto h-9 rounded-lg px-3.5 text-xs`:`min-w-32`,ge=!T||l||d.voiceActive,_e=C?`size-3.5`:`size-4`,q;t[86]===_e?q=t[87]:(q=(0,$.jsx)(A,{className:_e,"aria-hidden":!0}),t[86]=_e,t[87]=q);let J;t[88]!==o.submit||t[89]!==me||t[90]!==ge||t[91]!==q?(J=(0,$.jsxs)(j,{type:`submit`,variant:`primary`,className:me,disabled:ge,children:[q,o.submit]}),t[88]=o.submit,t[89]=me,t[90]=ge,t[91]=q,t[92]=J):J=t[92];let X;t[93]!==se||t[94]!==pe||t[95]!==K||t[96]!==J?(X=(0,$.jsxs)(`div`,{className:se,children:[pe,K,J]}),t[93]=se,t[94]=pe,t[95]=K,t[96]=J,t[97]=X):X=t[97];let ve;return t[98]!==b||t[99]!==y||t[100]!==x||t[101]!==O||t[102]!==ae||t[103]!==X||t[104]!==N||t[105]!==P?(ve=(0,$.jsxs)(`form`,{onSubmit:O,onDragOver:y,onDragLeave:b,onDrop:x,className:N,children:[P,ae,X]}),t[98]=b,t[99]=y,t[100]=x,t[101]=O,t[102]=ae,t[103]=X,t[104]=N,t[105]=P,t[106]=ve):ve=t[106],ve}function Se(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}function Ce(e){let t=(0,Z.c)(4),{label:n,onClick:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(J,{className:`size-3.5`,"aria-hidden":!0}),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==r?(a=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-lg px-2 text-xs font-medium text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:r,children:[i,n]}),t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function we(e){let t=(0,Z.c)(65),{opportunity:n,copy:r,onOpenHistory:i}=e,a,o,s,c,l,u;if(t[0]!==r.aiLabel||t[1]!==r.automationAction||t[2]!==r.automationHint||t[3]!==r.history||t[4]!==r.minutes||t[5]!==r.needsSetup||t[6]!==r.why||t[7]!==i||t[8]!==n.capabilities||t[9]!==n.continuation||t[10]!==n.estimatedMinutes||t[11]!==n.outcome||t[12]!==n.rationale||t[13]!==n.title){let e=n.capabilities.filter(Ee),d;t[20]===r.aiLabel?d=t[21]:(d=(0,$.jsx)(`span`,{children:r.aiLabel}),t[20]=r.aiLabel,t[21]=d);let f;t[22]!==r.minutes||t[23]!==n.estimatedMinutes?(f=n.estimatedMinutes?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),n.estimatedMinutes,` `,r.minutes]}):null,t[22]=r.minutes,t[23]=n.estimatedMinutes,t[24]=f):f=t[24];let p;t[25]!==d||t[26]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[d,f]}),t[25]=d,t[26]=f,t[27]=p):p=t[27];let m;t[28]!==r.history||t[29]!==i?(m=(0,$.jsx)(Ce,{label:r.history,onClick:i}),t[28]=r.history,t[29]=i,t[30]=m):m=t[30],t[31]!==m||t[32]!==p?(a=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[p,m]}),t[31]=m,t[32]=p,t[33]=a):a=t[33],t[34]===n.title?o=t[35]:(o=(0,$.jsx)(`h3`,{className:`mt-3 text-xl font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[34]=n.title,t[35]=o),t[36]===n.outcome?s=t[37]:(s=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.outcome}),t[36]=n.outcome,t[37]=s);let h;t[38]===r.why?h=t[39]:(h=(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.why,`:`]}),t[38]=r.why,t[39]=h),t[40]!==n.rationale||t[41]!==h?(c=(0,$.jsxs)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:[h,n.rationale]}),t[40]=n.rationale,t[41]=h,t[42]=c):c=t[42],t[43]!==r.automationAction||t[44]!==r.automationHint||t[45]!==n.continuation?(l=n.continuation?.kind===`automation`?(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 rounded-xl border border-edge bg-surface-subtle p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:r.automationHint}),(0,$.jsx)(`a`,{href:`#${n.continuation.href}`,className:`inline-flex min-h-11 shrink-0 items-center rounded-lg px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.automationAction})]}):null,t[43]=r.automationAction,t[44]=r.automationHint,t[45]=n.continuation,t[46]=l):l=t[46],u=e.length>0?(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,"aria-label":r.needsSetup,children:e.map(e=>(0,$.jsxs)(`a`,{href:`#${e.recoveryPath??`/settings`}`,className:`rounded-full border border-accent/25 bg-accent-soft px-2.5 py-1 text-xs text-accent hover:border-accent/50`,children:[r.needsSetup,` · `,e.capability]},`${e.kind}:${e.capability}`))}):null,t[0]=r.aiLabel,t[1]=r.automationAction,t[2]=r.automationHint,t[3]=r.history,t[4]=r.minutes,t[5]=r.needsSetup,t[6]=r.why,t[7]=i,t[8]=n.capabilities,t[9]=n.continuation,t[10]=n.estimatedMinutes,t[11]=n.outcome,t[12]=n.rationale,t[13]=n.title,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l,t[19]=u}else a=t[14],o=t[15],s=t[16],c=t[17],l=t[18],u=t[19];let d;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(G,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[47]=d):d=t[47];let f;t[48]===r.evidence?f=t[49]:(f=(0,$.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.evidence,d]}),t[48]=r.evidence,t[49]=f);let p;t[50]===n.evidence?p=t[51]:(p=n.evidence.map(Te),t[50]=n.evidence,t[51]=p);let m;t[52]===p?m=t[53]:(m=(0,$.jsx)(`ul`,{className:`mt-2 space-y-2 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:p}),t[52]=p,t[53]=m);let h;t[54]!==m||t[55]!==f?(h=(0,$.jsxs)(`details`,{className:`mt-4 group`,children:[f,m]}),t[54]=m,t[55]=f,t[56]=h):h=t[56];let g;return t[57]!==a||t[58]!==h||t[59]!==o||t[60]!==s||t[61]!==c||t[62]!==l||t[63]!==u?(g=(0,$.jsxs)($.Fragment,{children:[a,o,s,c,l,u,h]}),t[57]=a,t[58]=h,t[59]=o,t[60]=s,t[61]=c,t[62]=l,t[63]=u,t[64]=g):g=t[64],g}function Te(e){return(0,$.jsx)(`li`,{children:e.href?(0,$.jsx)(`a`,{href:`#${e.href}`,className:`hover:text-accent hover:underline`,children:e.observation}):e.observation},e.id)}function Ee(e){return e.readiness!==`ready`}function De(e){let t=(0,Z.c)(130),{advisor:n,copy:r,busy:i,onRefresh:a,onAction:o,onFeedback:c,onClarification:l,onOpenHistory:u,preflight:d,receipt:f}=e,[p,m]=(0,Q.useState)(),h;t[0]!==n.alternatives||t[1]!==n.primary||t[2]!==n.state?(h=n.state===`ready`?[n.primary,...n.alternatives]:[],t[0]=n.alternatives,t[1]=n.primary,t[2]=n.state,t[3]=h):h=t[3];let g=h,_;t[4]!==g||t[5]!==p?(_=g.find(e=>e.id===p)??g[0],t[4]=g,t[5]=p,t[6]=_):_=t[6];let v=_,y;t[7]===g[0]?.id?y=t[8]:(y=()=>m(g[0]?.id),t[7]=g[0]?.id,t[8]=y);let b=g[0]?.id,x;if(t[9]!==n.state||t[10]!==b?(x=[n.state,b],t[9]=n.state,t[10]=b,t[11]=x):x=t[11],(0,Q.useEffect)(y,x),n.state===`disabled`)return null;if(f){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(s,{className:`size-5 shrink-0 text-success`,"aria-hidden":!0}),t[12]=e):e=t[12];let n;t[13]===f.title?n=t[14]:(n=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:f.title}),t[13]=f.title,t[14]=n);let i;t[15]===f.detail?i=t[16]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:f.detail}),t[15]=f.detail,t[16]=i);let a;t[17]!==n||t[18]!==i?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[n,i]}),t[17]=n,t[18]=i,t[19]=a):a=t[19];let o;t[20]!==r.history||t[21]!==u?(o=(0,$.jsx)(Ce,{label:r.history,onClick:u}),t[20]=r.history,t[21]=u,t[22]=o):o=t[22];let c=`#${f.href}`,l;t[23]!==r.viewProgress||t[24]!==c?(l=(0,$.jsx)(j,{asChild:!0,variant:`secondary`,className:`min-h-10 text-xs`,children:(0,$.jsx)(`a`,{href:c,children:r.viewProgress})}),t[23]=r.viewProgress,t[24]=c,t[25]=l):l=t[25];let d;t[26]!==o||t[27]!==l?(d=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[o,l]}),t[26]=o,t[27]=l,t[28]=d):d=t[28];let p;return t[29]!==d||t[30]!==a?(p=(0,$.jsx)(`section`,{className:`mt-7 rounded-2xl border border-success/25 bg-success-soft px-5 py-4`,role:`status`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[e,a,d]})}),t[29]=d,t[30]=a,t[31]=p):p=t[31],p}if(n.state===`quiet`||n.state===`refreshing`)return null;if(n.state===`clarification`){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t[32]=e):e=t[32];let i;t[33]===r.aiLabel?i=t[34]:(i=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-accent`,children:[e,r.aiLabel]}),t[33]=r.aiLabel,t[34]=i);let a;t[35]!==r.history||t[36]!==u?(a=(0,$.jsx)(Ce,{label:r.history,onClick:u}),t[35]=r.history,t[36]=u,t[37]=a):a=t[37];let o;t[38]!==i||t[39]!==a?(o=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[i,a]}),t[38]=i,t[39]=a,t[40]=o):o=t[40];let s;t[41]===n.question.question?s=t[42]:(s=(0,$.jsx)(`h3`,{id:`home-advisor-question`,className:`mt-3 text-lg font-semibold text-fg`,children:n.question.question}),t[41]=n.question.question,t[42]=s);let c;if(t[43]!==n.question.options||t[44]!==n.question.question||t[45]!==l){let e;t[47]!==n.question.question||t[48]!==l?(e=e=>(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`min-h-11`,onClick:()=>l(n.question.question,e.label),children:e.label},e.id),t[47]=n.question.question,t[48]=l,t[49]=e):e=t[49],c=n.question.options.map(e),t[43]=n.question.options,t[44]=n.question.question,t[45]=l,t[46]=c}else c=t[46];let d;t[50]===c?d=t[51]:(d=(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:c}),t[50]=c,t[51]=d);let f;return t[52]!==s||t[53]!==d||t[54]!==o?(f=(0,$.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base px-5 py-5`,"aria-labelledby":`home-advisor-question`,children:[o,s,d]}),t[52]=s,t[53]=d,t[54]=o,t[55]=f):f=t[55],f}if(!v)return null;let S=d?.opportunityId===v.id?d.value:void 0,C;t[56]!==n.stale||t[57]!==r.refreshing?(C=n.stale?(0,$.jsxs)(`p`,{className:`mb-3 inline-flex items-center gap-2 text-xs text-accent`,children:[(0,$.jsx)(W,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.refreshing]}):null,t[56]=n.stale,t[57]=r.refreshing,t[58]=C):C=t[58];let w;t[59]!==r||t[60]!==u||t[61]!==v?(w=(0,$.jsx)(we,{opportunity:v,copy:r,onOpenHistory:u}),t[59]=r,t[60]=u,t[61]=v,t[62]=w):w=t[62];let T;t[63]!==i||t[64]!==r.configure||t[65]!==r.degradedStart||t[66]!==r.setupHint||t[67]!==r.setupTitle||t[68]!==o||t[69]!==v||t[70]!==S?(T=S?.state===`needs_setup`?(0,$.jsx)(`div`,{className:`mt-5 rounded-xl border border-accent/25 bg-accent-soft/40 p-4`,role:`alert`,"aria-live":`polite`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(ue,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:r.setupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r.setupHint}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:S.blockers.map(Oe)}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[S.recoveryActions.map(e=>(0,$.jsxs)(`a`,{href:`#${e.href}`,className:`inline-flex min-h-11 items-center rounded-lg border border-accent/30 px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.configure,` · `,e.capability]},e.capability)),S.degradedAction?(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`degraded_start`),children:r.degradedStart}):null]})]})]})}):null,t[63]=i,t[64]=r.configure,t[65]=r.degradedStart,t[66]=r.setupHint,t[67]=r.setupTitle,t[68]=o,t[69]=v,t[70]=S,t[71]=T):T=t[71];let E;t[72]!==i||t[73]!==r.start||t[74]!==o||t[75]!==v?(E=v.actions.canStart?(0,$.jsxs)(j,{type:`button`,variant:`primary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`start`),children:[(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0}),r.start]}):null,t[72]=i,t[73]=r.start,t[74]=o,t[75]=v,t[76]=E):E=t[76];let D;t[77]!==i||t[78]!==r.discuss||t[79]!==o||t[80]!==v?(D=v.actions.canDiscuss?(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`discuss`),children:[(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),r.discuss]}):null,t[77]=i,t[78]=r.discuss,t[79]=o,t[80]=v,t[81]=D):D=t[81];let O;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(W,{className:`size-4`,"aria-hidden":!0}),t[82]=O):O=t[82];let k;t[83]!==i||t[84]!==r.refresh||t[85]!==a?(k=(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`min-h-11`,disabled:i,onClick:a,title:r.refresh,children:[O,r.refresh]}),t[83]=i,t[84]=r.refresh,t[85]=a,t[86]=k):k=t[86];let M;t[87]===r.feedback?M=t[88]:(M=(0,$.jsx)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center rounded-lg px-3 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.feedback}),t[87]=r.feedback,t[88]=M);let N;t[89]===r.alreadyDone?N=t[90]:(N=[`already_done`,r.alreadyDone],t[89]=r.alreadyDone,t[90]=N);let P;t[91]===r.irrelevant?P=t[92]:(P=[`irrelevant`,r.irrelevant],t[91]=r.irrelevant,t[92]=P);let F;t[93]===r.later?F=t[94]:(F=[`too_early`,r.later],t[93]=r.later,t[94]=F);let I;t[95]===r.sourceIncorrect?I=t[96]:(I=[`source_incorrect`,r.sourceIncorrect],t[95]=r.sourceIncorrect,t[96]=I);let L;t[97]===r.lessLikeThis?L=t[98]:(L=[`less_like_this`,r.lessLikeThis],t[97]=r.lessLikeThis,t[98]=L);let R;t[99]!==N||t[100]!==P||t[101]!==F||t[102]!==I||t[103]!==L?(R=[N,P,F,I,L],t[99]=N,t[100]=P,t[101]=F,t[102]=I,t[103]=L,t[104]=R):R=t[104];let z=R,te;t[105]!==c||t[106]!==v||t[107]!==z?(te=(0,$.jsx)(`div`,{className:`absolute right-0 z-20 mt-1 w-44 rounded-xl border border-edge bg-surface-overlay p-1 shadow-float`,children:z.map(e=>{let[t,n]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-10 w-full rounded-lg px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>c(v,t),children:n},t)})}),t[105]=c,t[106]=v,t[107]=z,t[108]=te):te=t[108];let ne;t[109]!==M||t[110]!==te?(ne=(0,$.jsxs)(`details`,{className:`relative ml-auto`,children:[M,te]}),t[109]=M,t[110]=te,t[111]=ne):ne=t[111];let B;t[112]!==D||t[113]!==k||t[114]!==ne||t[115]!==E?(B=(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[E,D,k,ne]}),t[112]=D,t[113]=k,t[114]=ne,t[115]=E,t[116]=B):B=t[116];let V;t[117]!==B||t[118]!==C||t[119]!==w||t[120]!==T?(V=(0,$.jsxs)(`div`,{className:`px-5 py-5 sm:px-6`,children:[C,w,T,B]}),t[117]=B,t[118]=C,t[119]=w,t[120]=T,t[121]=V):V=t[121];let H;t[122]!==r.alternatives||t[123]!==g||t[124]!==v.id?(H=g.length>1?(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:r.alternatives}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:g.filter(e=>e.id!==v.id).map(e=>(0,$.jsx)(`button`,{type:`button`,className:`min-h-10 rounded-lg border border-edge px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>m(e.id),children:e.title},e.id))})]}):null,t[122]=r.alternatives,t[123]=g,t[124]=v.id,t[125]=H):H=t[125];let U;return t[126]!==r.aiLabel||t[127]!==V||t[128]!==H?(U=(0,$.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base`,"aria-label":r.aiLabel,children:[V,H]}),t[126]=r.aiLabel,t[127]=V,t[128]=H,t[129]=U):U=t[129],U}function Oe(e){return(0,$.jsx)(`li`,{children:e.message},`${e.kind}:${e.capability}`)}var ke=new Set([`started`,`discussing`,`completed`]);function Ae(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[0,1,2].map(je)}),e[0]=t):t=e[0],t}function je(e){return(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge-subtle p-4`,children:[(0,$.jsx)(I,{className:`h-4 w-24 rounded`}),(0,$.jsx)(I,{className:`h-5 w-4/5 rounded`}),(0,$.jsx)(I,{className:`h-4 w-3/5 rounded`})]},e)}function Me(e){let t=(0,Z.c)(11),{open:n,refreshKey:r,onOpenChange:i,onReevaluate:o}=e,s=m(Pe),u=f(s).projectsPage.home,p=a(),[S,C]=(0,Q.useState)(`all`),T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[0]=T):T=t[0];let[E,D]=(0,Q.useState)(T),[O,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(),N;t[1]===n?N=t[2]:(N=()=>{if(!n)return;let e=!0;return k(!0),M(void 0),le().then(t=>{e&&D(t.items)}).catch(t=>{e&&M(t instanceof Error?t.message:String(t))}).finally(()=>{e&&k(!1)}),()=>{e=!1}},t[1]=n,t[2]=N);let P;t[3]!==n||t[4]!==r?(P=[n,r],t[3]=n,t[4]=r,t[5]=P):P=t[5],(0,Q.useEffect)(N,P);let I=E.filter(e=>S===`all`||(S===`adopted`?ke.has(e.status):!ke.has(e.status))),L=new Intl.DateTimeFormat(s===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}),R=new Intl.DateTimeFormat(s===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),z=new Map;for(let e of I){let t=L.format(new Date(e.updatedAt));z.set(t,[...z.get(t)??[],e])}let ee=[...z.entries()],te=e=>e.feedbackKind===`already_done`?u.advisorHistoryStatusCompleted:e.feedbackKind===`irrelevant`?u.advisorHistoryStatusIrrelevant:e.feedbackKind===`source_incorrect`?u.advisorHistoryStatusSourceIncorrect:e.feedbackKind===`less_like_this`?u.advisorHistoryStatusLessLikeThis:{available:u.advisorHistoryStatusAvailable,started:u.advisorHistoryStatusStarted,discussing:u.advisorHistoryStatusDiscussing,completed:u.advisorHistoryStatusCompleted,snoozed:u.advisorHistoryStatusSnoozed,dismissed:u.advisorHistoryStatusDismissed,expired:u.advisorHistoryStatusExpired,superseded:u.advisorHistoryStatusSuperseded}[e.status],ne=e=>{if(e.href){i(!1),p(l(`/`,e.href));return}e.status===`discussing`&&(i(!1),p(`/chat/new?${new URLSearchParams({draft:e.opportunity.actionPrompt}).toString()}`))},B;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[6]=B):B=t[6];let V;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(J,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=V):V=t[7];let H;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[8]=H):H=t[8];let U=O?(0,$.jsx)(Ae,{}):A?(0,$.jsxs)(`div`,{className:`rounded-xl border border-danger/25 bg-danger-soft p-4 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:u.advisorHistoryLoadFailed}),(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`mt-2`,onClick:()=>i(!1),children:u.advisorHistoryClose})]}):ee.length===0?(0,$.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,$.jsx)(J,{className:`mx-auto size-6 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:u.advisorHistoryEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.advisorHistoryEmptyHint})]}):(0,$.jsx)(`div`,{className:`space-y-6`,children:ee.map(e=>{let[t,n]=e;return(0,$.jsxs)(`section`,{"aria-label":t,children:[(0,$.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-subtle`,children:t}),(0,$.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=!!e.href||e.status===`discussing`,n=[`snoozed`,`dismissed`,`expired`,`superseded`].includes(e.status);return(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:te(e)}),(0,$.jsx)(`h4`,{className:`mt-1.5 text-sm font-semibold leading-5 text-fg`,children:e.opportunity.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.opportunity.outcome})]}),(0,$.jsx)(`time`,{className:`shrink-0 text-[11px] text-fg-subtle`,dateTime:new Date(e.updatedAt).toISOString(),children:R.format(new Date(e.updatedAt))})]}),e.snoozedUntil?(0,$.jsxs)(`p`,{className:`mt-2 inline-flex items-center gap-1 text-xs text-fg-muted`,children:[(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),u.advisorHistoryReturnsAt,` `,R.format(new Date(e.snoozedUntil))]}):null,(0,$.jsxs)(`details`,{className:`group mt-3`,children:[(0,$.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1 text-xs font-medium text-fg-muted hover:text-fg`,children:[u.advisorHistoryEvidence,(0,$.jsx)(G,{className:`size-3.5 transition-transform duration-200 group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1.5 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:e.opportunity.evidence.map(Ne)})]}),t||n?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[t?(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`min-h-9 text-xs`,onClick:()=>ne(e),children:[(0,$.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),e.status===`discussing`?u.advisorHistoryContinueDiscussion:u.advisorHistoryViewProgress]}):null,n?(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`min-h-9 text-xs`,onClick:()=>{i(!1),o()},children:[(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),u.advisorHistoryReevaluate]}):null]}):null]},e.opportunity.id)})})]},t)})}),re;return t[9]===U?re=t[10]:(re=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:U}),t[9]=U,t[10]=re),(0,$.jsx)(x,{open:n,onOpenChange:i,children:(0,$.jsxs)(v,{children:[B,(0,$.jsxs)(y,{className:`xopc-drawer-right fixed right-0 top-0 z-[90] flex size-full max-w-lg flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none`,"aria-describedby":`home-advisor-history-description`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b border-edge px-5 py-4`,children:[V,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(b,{className:`text-base font-semibold text-fg`,children:u.advisorHistoryTitle}),(0,$.jsx)(g,{id:`home-advisor-history-description`,className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.advisorHistoryDescription})]}),(0,$.jsx)(_,{asChild:!0,children:(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`-mr-2 size-9 shrink-0 p-0`,"aria-label":u.advisorHistoryClose,children:H})})]}),(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-3`,children:(0,$.jsx)(w,{className:`inline-flex rounded-lg bg-surface-inset p-1`,role:`group`,"aria-label":u.advisorHistoryFilterLabel,indicatorClassName:`rounded-md bg-surface-panel shadow-surface`,children:[[`all`,u.advisorHistoryFilterAll],[`adopted`,u.advisorHistoryFilterAdopted],[`other`,u.advisorHistoryFilterOther]].map(e=>{let[t,n]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md px-3 text-xs font-medium transition-colors duration-150 ${S===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`}`,"aria-pressed":S===t,onClick:()=>C(t),children:n},t)})})}),re]})]})})}function Ne(e){return(0,$.jsx)(`li`,{children:e.observation},e.id)}function Pe(e){return e.language}function Fe(e,t){return e.replace(`{{count}}`,String(t))}function Ie(e,t){if(e.state===`disabled`)return null;if(e.state===`ready`){let n=1+e.alternatives.length;return{label:Fe(t.ready,n),detail:e.primary.title,tone:`accent`,refreshing:!!e.stale}}return e.state===`clarification`?{label:t.clarification,detail:e.question.question,tone:`accent`,refreshing:!1}:e.state===`refreshing`?{label:t.refreshing,detail:e.previous?.title??t.refreshingDetail,tone:`accent`,refreshing:!0}:e.reason===`generation_failed`?{label:t.generationFailed,detail:t.generationFailedDetail,tone:`danger`,refreshing:!1}:e.reason===`budget_exhausted`?{label:t.budgetExhausted,detail:t.budgetExhaustedDetail,tone:`warning`,refreshing:!1}:e.reason===`model_unavailable`?{label:t.modelUnavailable,detail:t.modelUnavailableDetail,tone:`warning`,refreshing:!1}:{label:t.idle,detail:t.idleDetail,tone:`neutral`,refreshing:!1}}var Le={accent:`bg-accent`,danger:`bg-danger`,neutral:`bg-fg-subtle`,warning:`bg-warning`};function Re(e){let t=(0,Z.c)(50),{advisor:n,busy:r,copy:i,onOpenHistory:a,onRefresh:o}=e,[s,c]=(0,Q.useState)(!1),l;t[0]!==n||t[1]!==i?(l=Ie(n,i),t[0]=n,t[1]=i,t[2]=l):l=t[2];let u=l;if(!u)return null;let d=n.state!==`refreshing`,f=n.state===`ready`?i.findAnother:i.retry,m=`${i.label}:${u.label}`,h;t[3]===u.refreshing?h=t[4]:(h=u.refreshing?(0,$.jsx)(W,{className:`size-3.5 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(A,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=u.refreshing,t[4]=h);let g=Le[u.tone],_;t[5]===g?_=t[6]:(_=p(`size-1.5 shrink-0 rounded-full`,g),t[5]=g,t[6]=_);let v;t[7]===_?v=t[8]:(v=(0,$.jsx)(`span`,{className:_,"aria-hidden":!0}),t[7]=_,t[8]=v);let y;t[9]!==i.label||t[10]!==u.label?(y=(0,$.jsxs)(`span`,{className:`truncate`,children:[i.label,` · `,u.label]}),t[9]=i.label,t[10]=u.label,t[11]=y):y=t[11];let b;t[12]!==m||t[13]!==h||t[14]!==v||t[15]!==y?(b=(0,$.jsx)(T,{asChild:!0,children:(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-9 max-w-56 rounded-lg px-2.5`,"aria-label":m,children:[h,v,y]})}),t[12]=m,t[13]=h,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]===u.refreshing?x=t[18]:(x=(0,$.jsx)(`span`,{className:`mt-1 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:u.refreshing?(0,$.jsx)(W,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0})}),t[17]=u.refreshing,t[18]=x);let S;t[19]===u.label?S=t[20]:(S=(0,$.jsx)(`p`,{className:`font-semibold text-fg`,children:u.label}),t[19]=u.label,t[20]=S);let C;t[21]===u.detail?C=t[22]:(C=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.detail}),t[21]=u.detail,t[22]=C);let w;t[23]!==S||t[24]!==C?(w=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[23]=S,t[24]=C,t[25]=w):w=t[25];let E;t[26]!==w||t[27]!==x?(E=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[x,w]}),t[26]=w,t[27]=x,t[28]=E):E=t[28];let O;t[29]===a?O=t[30]:(O=()=>{c(!1),a()},t[29]=a,t[30]=O);let k;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(J,{className:`size-3.5`,"aria-hidden":!0}),t[31]=k):k=t[31];let M;t[32]!==i.history||t[33]!==O?(M=(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:O,children:[k,i.history]}),t[32]=i.history,t[33]=O,t[34]=M):M=t[34];let N;t[35]!==r||t[36]!==d||t[37]!==o||t[38]!==f?(N=d?(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg text-xs`,disabled:r,onClick:()=>{c(!1),o()},children:[(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),f]}):null,t[35]=r,t[36]=d,t[37]=o,t[38]=f,t[39]=N):N=t[39];let P;t[40]!==M||t[41]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3`,children:[M,N]}),t[40]=M,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==E||t[44]!==P?(F=(0,$.jsx)(L,{children:(0,$.jsxs)(q,{side:`bottom`,align:`end`,sideOffset:6,className:`z-[70] w-[min(21rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-overlay p-4 text-sm text-fg shadow-popover outline-none`,onOpenAutoFocus:ze,children:[E,P]})}),t[43]=E,t[44]=P,t[45]=F):F=t[45];let I;return t[46]!==s||t[47]!==F||t[48]!==b?(I=(0,$.jsxs)(D,{open:s,onOpenChange:c,children:[b,F]}),t[46]=s,t[47]=F,t[48]=b,t[49]=I):I=t[49],I}function ze(e){return e.preventDefault()}function Be({taskId:e,language:t,onComplete:n}){let r=t===`zh`,[i,a]=(0,Q.useState)(),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let t=!0;return s(void 0),a(void 0),K(e).then(e=>{t&&a(e)}).catch(e=>{t&&s(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e,u]);let f=i?X(i):[],p=i?.task.phase===`review`&&i.allowedCommands.includes(`close`)&&i.waits.length===0&&f.length>0&&f.every(e=>e.status===`passed`);async function m(e,t=!1){if(!c){l(!0),s(void 0);try{a(await e()),t&&n()}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}}let h=i?.receipts[0];return(0,$.jsxs)(`section`,{className:`mt-4 space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,"aria-label":r?`任务验收`:`Task review`,children:[o?(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center justify-between gap-3 text-sm text-danger`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(j,{variant:`ghost`,disabled:c,onClick:()=>d(e=>e+1),children:r?`刷新`:`Refresh`})]}):null,!i&&!o?(0,$.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,$.jsx)(I,{className:`h-5 w-1/3`}),(0,$.jsx)(I,{className:`h-24 w-full`})]}):null,i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r?`执行结果`:`Result`}),h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ve,{content:h.summary,contentKey:`home:${e}:result`,language:t,previewHeight:180}),h.remainingWork.length>0?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm text-fg-muted`,children:[r?`尚待完成:`:`Remaining work: `,h.remainingWork.join(`
|
|
2
2
|
`)]}):null,h.evidence.map((e,t)=>(0,$.jsxs)(`div`,{className:`text-sm text-fg-muted`,children:[e.uri&&/^https?:\/\//.test(e.uri)?(0,$.jsx)(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,className:`text-accent-fg hover:underline`,children:e.title}):(0,$.jsx)(`span`,{children:e.title}),e.summary?(0,$.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.summary}):null]},t))]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r?`暂无执行结果,请查看任务详情。`:`No result yet. View the task details.`}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r?`验收条件`:`Acceptance criteria`}),f.map((t,n)=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2 border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 text-sm text-fg`,children:[(0,$.jsx)(`p`,{className:`break-words`,children:t.text}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r?{passed:`已通过`,failed:`未通过`,unverified:`待判定`}[t.status]:{passed:`Passed`,failed:`Failed`,unverified:`Not reviewed`}[t.status]})]}),i.task.phase!==`closed`&&i.task.contract?.acceptancePolicy!==`verified_auto`?(0,$.jsx)(`div`,{className:`flex gap-2`,children:[`passed`,`failed`].map(a=>(0,$.jsx)(j,{variant:`secondary`,disabled:c||t.status===a,onClick:()=>void m(()=>U(e,n,a,i.task.version,i.task.latestContractVersion)),children:r?a===`passed`?`确认通过`:`未通过`:a===`passed`?`Mark passed`:`Mark failed`},a))}):null]},n)),p?null:(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r?`所有验收条件通过且任务无等待事项后,可完成验收。`:`Accept once all criteria pass and the task has no pending waits.`}),(0,$.jsx)(j,{variant:`primary`,disabled:c||!p,onClick:()=>void m(()=>B(e,{type:`close`,resolution:`done`},i.task.version),!0),children:r?`验收完成`:`Accept task`})]}):null]})}async function Ve(e,t=`en`){let n=await K(e),r=n.runs.filter(e=>!e.parentRunId).sort((e,t)=>t.queuedAt-e.queuedAt)[0];if(!n.allowedCommands.includes(`start`)||r?.status!==`failed`)throw Error(t===`zh`?`任务状态已变化,暂时无法重试。请刷新并查看当前状态。`:`Task is no longer available for retry. Refresh and review its current state.`);await B(e,{type:`start`,executor:S.parse({...r.executorRef,kind:r.executorKind})},n.task.version)}function He(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Ue(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`space-y-8`,"aria-busy":!0,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(I,{className:`h-10 w-3/5 rounded-xl`}),(0,$.jsx)(I,{className:`h-5 w-4/5 rounded-lg`})]}),(0,$.jsx)(I,{className:`h-64 rounded-2xl`}),(0,$.jsx)(I,{className:`h-32 rounded-xl`})]}),e[0]=t):t=e[0],t}function We(e){let t=(0,Z.c)(50),{item:n,busy:r,recommendationLabel:i,dueLabel:a,failureLabel:s,locale:c,onAction:l,onComplete:u}=e,[d,f]=o(),p=n.primaryAction?.type===`task_review`?n.primaryAction:void 0,m;t[0]!==p||t[1]!==d?(m=p&&d.get(`reviewTask`)===p.taskId,t[0]=p,t[1]=d,t[2]=m):m=t[2];let h=!!m,g;t[3]!==p||t[4]!==d||t[5]!==f?(g=e=>{let t=new URLSearchParams(d);e&&p?t.set(`reviewTask`,p.taskId):t.delete(`reviewTask`),f(t)},t[3]=p,t[4]=d,t[5]=f,t[6]=g):g=t[6];let _=g,v;t[7]!==a||t[8]!==n.dueAt||t[9]!==c?(v=n.dueAt?`${a} ${N(new Date(n.dueAt),c)}`:null,t[7]=a,t[8]=n.dueAt,t[9]=c,t[10]=v):v=t[10];let y=v,b=n.kind===`failure`?s:y,x;t[11]===b?x=t[12]:(x=b?(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:b})]}):null,t[11]=b,t[12]=x);let S=!n.openAction,C;t[13]!==n.id||t[14]!==n.openAction||t[15]!==l?(C=()=>n.openAction&&l(n.openAction,n.id),t[13]=n.id,t[14]=n.openAction,t[15]=l,t[16]=C):C=t[16];let w;t[17]===n.title?w=t[18]:(w=(0,$.jsx)(`span`,{className:`block text-lg font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[17]=n.title,t[18]=w);let T;t[19]===n.summary?T=t[20]:(T=(0,$.jsx)(`span`,{className:`mt-1.5 block text-sm leading-6 text-fg-muted`,children:n.summary}),t[19]=n.summary,t[20]=T);let E;t[21]!==S||t[22]!==C||t[23]!==w||t[24]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,className:`block w-full text-left outline-none focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:S,onClick:C,children:[w,T]}),t[21]=S,t[22]=C,t[23]=w,t[24]=T,t[25]=E):E=t[25];let D;t[26]!==n.recommendation||t[27]!==i?(D=n.recommendation?(0,$.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-semibold text-fg`,children:[i,`:`]}),n.recommendation]}):null,t[26]=n.recommendation,t[27]=i,t[28]=D):D=t[28];let O;t[29]!==r||t[30]!==n.id||t[31]!==n.primaryAction||t[32]!==n.secondaryActions||t[33]!==l||t[34]!==p||t[35]!==h||t[36]!==_?(O=n.primaryAction||n.secondaryActions.length>0?(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[n.primaryAction?(0,$.jsx)(j,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3.5 text-xs`,disabled:r,"aria-expanded":p?h:void 0,onClick:()=>p?_(!h):l(n.primaryAction,n.id),children:n.primaryAction.label}):null,n.secondaryActions.map(e=>(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3.5 text-xs shadow-none`,disabled:r,onClick:()=>l(e,n.id),children:e.label},`${e.type}:${e.label}`))]}):null,t[29]=r,t[30]=n.id,t[31]=n.primaryAction,t[32]=n.secondaryActions,t[33]=l,t[34]=p,t[35]=h,t[36]=_,t[37]=O):O=t[37];let k;t[38]!==c||t[39]!==u||t[40]!==p||t[41]!==h||t[42]!==_?(k=h&&p?(0,$.jsx)(Be,{taskId:p.taskId,language:c,onComplete:()=>{_(!1),u()}}):null,t[38]=c,t[39]=u,t[40]=p,t[41]=h,t[42]=_,t[43]=k):k=t[43];let A;return t[44]!==D||t[45]!==O||t[46]!==k||t[47]!==x||t[48]!==E?(A=(0,$.jsxs)(`article`,{className:`px-5 py-5 sm:px-6 sm:py-6`,children:[x,E,D,O,k]}),t[44]=D,t[45]=O,t[46]=k,t[47]=x,t[48]=E,t[49]=A):A=t[49],A}function Ge(e){let t=(0,Z.c)(26),{item:n,onAction:r}=e,i;t[0]===n.kind?i=t[1]:(i=n.kind===`scheduled`?(0,$.jsx)(oe,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`,"aria-hidden":!0}),t[0]=n.kind,t[1]=i);let a=i,o=!n.openAction,s;t[2]!==n.id||t[3]!==n.openAction||t[4]!==r?(s=()=>n.openAction&&r(n.openAction,n.id),t[2]=n.id,t[3]=n.openAction,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center text-fg-subtle`,children:a}),t[6]=a,t[7]=c);let l;t[8]===n.title?l=t[9]:(l=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.title}),t[8]=n.title,t[9]=l);let u;t[10]===n.summary?u=t[11]:(u=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.summary}),t[10]=n.summary,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===n.statusLabel?f=t[16]:(f=n.statusLabel?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.statusLabel}):null,t[15]=n.statusLabel,t[16]=f);let p;t[17]===n.openAction?p=t[18]:(p=n.openAction?(0,$.jsx)(re,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[17]=n.openAction,t[18]=p);let m;return t[19]!==o||t[20]!==s||t[21]!==c||t[22]!==d||t[23]!==f||t[24]!==p?(m=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-16 w-full items-center gap-3 py-3 text-left outline-none hover:text-fg focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:o,onClick:s,children:[c,d,f,p]}),t[19]=o,t[20]=s,t[21]=c,t[22]=d,t[23]=f,t[24]=p,t[25]=m):m=t[25],m}function Ke(){let e=m(e=>e.language),t=f(e),n=t.projectsPage,r=ae(e),o=a(),s=i(),c=O(e=>e.setPageHeader),p=O(e=>e.clearPageHeader),{home:S,loading:w,loadError:T,setLoadError:E,load:D}=ye(e,s.key),[A,M]=(0,Q.useState)(!1),[N,F]=(0,Q.useState)(``),I=(0,Q.useRef)(!1),[L,ee]=(0,Q.useState)(null),[te,B]=(0,Q.useState)(!1),[U,re]=(0,Q.useState)(),[W,oe]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)(0),[G,K]=(0,Q.useState)(),[he,ge]=(0,Q.useState)(),[q,J]=(0,Q.useState)(!1),Y=R({chat:t.chat}),X=(0,Q.useRef)(null),ve=z({disabled:q,chat:t.chat,onTranscript:e=>{F(t=>P(t,e)),window.setTimeout(()=>X.current?.focus(),0)}}),{phase:Z,voiceActive:be,startVoiceInput:Se,cancelVoiceInput:Ce,confirmVoiceInput:we,retryVoiceInput:Te}=ve;(0,Q.useEffect)(()=>{if(!G)return;let e=window.setTimeout(()=>K(void 0),8e3);return()=>window.clearTimeout(e)},[G]);let Ee=(0,Q.useCallback)(async e=>{if(!(e.length===0||q)){J(!0);try{await Y.processFiles(e)}finally{J(!1)}}},[q,Y.processFiles]),Oe=(0,Q.useCallback)(async e=>{let t=de(e.clipboardData);t.length!==0&&(e.preventDefault(),await Ee(t))},[Ee]),ke=(0,Q.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Y.setIsDragging(!0))},[Y.setIsDragging]),Ae=(0,Q.useCallback)(e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&Y.setIsDragging(!1)},[Y.setIsDragging]),je=(0,Q.useCallback)(async e=>{e.preventDefault(),Y.setIsDragging(!1),await Ee(Array.from(e.dataTransfer.files))},[Y.setIsDragging,Ee]),Ne=(0,Q.useCallback)(e=>{e.preventDefault();let t=Y.wireAttachmentsPayload(),n=H(N,t.length>0?pe(t):void 0,{projectScope:`none`});n&&(M(!1),F(``),Y.clearAttachments(),o(n))},[Y.clearAttachments,Y.wireAttachmentsPayload,N,o]),Pe=Y.attachments.length>=10,Fe={attachTitle:Pe?He(t.chat.maxAttachmentsReached,{max:10}):`${t.chat.attachFile} (${Y.attachments.length}/10)`,dropFiles:t.chat.dropFiles,intentLabel:r.intentLabel,intentPlaceholder:r.intentPlaceholder,intentSuggestion:r.intentSuggestion,shortcut:n.home.submitShortcut,submit:r.newWork},Ie=(0,Q.useMemo)(()=>({label:n.home.advisorStatusLabel,ready:n.home.advisorStatusReady,clarification:n.home.advisorStatusClarification,refreshing:n.home.advisorStatusRefreshing,refreshingDetail:n.home.advisorRefreshing,idle:n.home.advisorStatusIdle,idleDetail:n.home.advisorUnavailableTitle,generationFailed:n.home.advisorStatusGenerationFailed,budgetExhausted:n.home.advisorStatusBudgetExhausted,modelUnavailable:n.home.advisorStatusModelUnavailable,generationFailedDetail:n.home.advisorGenerationFailed,budgetExhaustedDetail:n.home.advisorBudgetExhausted,modelUnavailableDetail:n.home.advisorModelUnavailable,history:n.home.advisorHistory,retry:n.home.retry,findAnother:n.home.advisorRefresh}),[n.home]),Le=!!(S&&S.needsUser.length===0&&S.backgroundCount===0),ze=!!(S&&S.needsUser.length===0),Be=ze||A;(0,Q.useEffect)(()=>{!Be&&be&&Ce()},[Ce,Be,be]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail?.target;t&&t!==`chat`||!Be||q||(e.preventDefault(),Z===`recording`?we():Z===`idle`?(X.current?.focus(),Se()):Z===`error`&&Te())},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!Be||!be||(e.preventDefault(),Ce(),X.current?.focus())};return window.addEventListener(se,e),window.addEventListener(C,t),()=>{window.removeEventListener(se,e),window.removeEventListener(C,t)}},[q,Ce,Be,we,Te,Se,be,Z]);let Ke=(0,Q.useCallback)(e=>{e||Ce(),M(e)},[Ce]),qe=(0,Q.useCallback)((t,n)=>{if(t.type===`open`){o(l(`/`,t.href));return}t.type===`task_review`||I.current||(I.current=!0,ee(n),E(null),(async()=>{try{t.type===`retry_task`?await Ve(t.taskId,e):t.type===`connector_decision`?await fe({kind:`connector_approval`,approvalId:t.approvalId},t.decision):t.type===`retry_run`?await me({kind:t.subjectKind,runId:t.runId}):t.type===`acknowledge_run`&&await k({kind:t.subjectKind,runId:t.runId}),await D()}catch(e){E(e instanceof Error?e.message:String(e))}finally{I.current=!1,ee(null)}})())},[e,D,o]),Je=(0,Q.useCallback)(()=>{B(!0),re(void 0),ge(void 0),E(null),V(e).then(()=>D()).catch(e=>E(e instanceof Error?e.message:String(e))).finally(()=>B(!1))},[e,D]),Ye=(0,Q.useCallback)((e,t)=>{B(!0),E(null),ne(e,t).then(async t=>{if(t.outcome===`needs_setup`){ge({opportunityId:e.id,value:t.preflight});return}if(ge(void 0),ue(e=>e+1),t.outcome===`task`){re({title:n.home.advisorStartedTitle,detail:He(n.home.advisorStartedDetail,{title:e.title}),href:l(`/`,t.href)}),await D();return}o(t.href)}).catch(e=>E(e instanceof Error?e.message:String(e))).finally(()=>B(!1))},[D,o,n.home.advisorStartedDetail,n.home.advisorStartedTitle]),Xe=(0,Q.useCallback)((e,t)=>{B(!0),re(void 0),ge(void 0),E(null),ce(e,{kind:t,snoozedUntil:t===`too_early`?Date.now()+4320*6e4:void 0}).then(({idempotencyKey:t})=>(K({opportunityId:e.id,idempotencyKey:t}),ue(e=>e+1),D())).catch(e=>E(e instanceof Error?e.message:String(e))).finally(()=>B(!1))},[D]),Ze=(0,Q.useCallback)(()=>{if(!G)return;let e=G;K(void 0),B(!0),E(null),ie(e.opportunityId,e.idempotencyKey).then(()=>(ue(e=>e+1),D())).catch(t=>{K(e),E(t instanceof Error?t.message:String(t))}).finally(()=>B(!1))},[G,D]),Qe=(0,Q.useCallback)((e,t)=>{o(`/chat/new?${new URLSearchParams({draft:`${e}\n\n${t}`}).toString()}`)},[o]),$e=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[S?(0,$.jsx)(Re,{advisor:S.advisor,busy:te,copy:Ie,onOpenHistory:()=>oe(!0),onRefresh:Je}):null,ze?null:(0,$.jsxs)(j,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>M(!0),children:[(0,$.jsx)(u,{className:`size-4`,"aria-hidden":!0}),r.newWork]})]}),[te,Ie,r.newWork,S,Je,ze]);(0,Q.useLayoutEffect)(()=>(c({startExtra:null,main:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:$e}),()=>p()),[p,$e,c,n.title]);let et=S?.needsUser.length??0,tt=S?.backgroundCount??0,nt=et>0?He(n.home.attentionTitle,{count:et}):tt>0?n.home.clearTitle:n.home.idleTitle,rt=et>0?tt>0?He(n.home.attentionIntroWithBackground,{count:tt}):n.home.attentionIntro:tt>0?He(n.home.clearIntro,{count:tt}):n.home.idleIntro;return(0,$.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[920px] flex-1 flex-col px-4 pb-8 pt-3 sm:px-6 lg:px-8 lg:pb-12 lg:pt-4`,children:[(0,$.jsx)(`input`,{ref:Y.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&Ee(Array.from(t)),e.target.value=``}}),(0,$.jsx)(x,{open:A,onOpenChange:Ke,children:(0,$.jsxs)(v,{children:[(0,$.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(y,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(b,{className:`text-base font-semibold text-fg`,children:r.dialogTitle}),(0,$.jsx)(g,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r.dialogDescription})]}),(0,$.jsx)(_,{asChild:!0,children:(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsx)(xe,{variant:`dialog`,inputId:`new-conversation-intent`,inputRef:X,intent:N,labels:{...Fe,submit:r.submit},attachments:Y.attachments,isDragging:Y.isDragging,attachmentBusy:q,attachmentsFull:Pe,voice:ve,chat:t.chat,cancelAction:(0,$.jsx)(_,{asChild:!0,children:(0,$.jsx)(j,{type:`button`,variant:`ghost`,children:n.cancel})}),onIntentChange:F,onPickFiles:()=>Y.fileInputRef.current?.click(),onRemoveAttachment:Y.removeAttachment,onPaste:e=>void Oe(e),onDragOver:ke,onDragLeave:Ae,onDrop:e=>void je(e),onSubmit:Ne})]})]})}),(0,$.jsx)(Me,{open:W,refreshKey:le,onOpenChange:oe,onReevaluate:Je}),T?(0,$.jsxs)(`div`,{className:`mb-6 flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,$.jsx)(`span`,{children:T}),(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void D(),children:n.home.retry})]}):null,w?(0,$.jsx)(Ue,{}):S?(0,$.jsxs)(`div`,{className:Le?`mx-auto my-auto w-full max-w-[640px]`:`w-full`,children:[(0,$.jsxs)(`section`,{className:Le?`w-full text-center`:`max-w-3xl`,children:[(0,$.jsx)(`h2`,{className:`text-3xl font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:nt}),(0,$.jsx)(`p`,{className:Le?`mx-auto mt-3 max-w-xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`:`mt-3 max-w-2xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`,children:rt})]}),ze?(0,$.jsx)(xe,{variant:`inline`,inputId:`home-conversation-intent`,inputRef:X,intent:N,labels:Fe,attachments:Y.attachments,isDragging:Y.isDragging,attachmentBusy:q,attachmentsFull:Pe,voice:ve,chat:t.chat,onIntentChange:F,onPickFiles:()=>Y.fileInputRef.current?.click(),onRemoveAttachment:Y.removeAttachment,onPaste:e=>void Oe(e),onDragOver:ke,onDragLeave:Ae,onDrop:e=>void je(e),onSubmit:Ne}):null,(0,$.jsx)(De,{advisor:S.advisor,busy:te,copy:{aiLabel:n.home.advisorAiLabel,why:n.home.advisorWhy,evidence:n.home.advisorEvidence,needsSetup:n.home.advisorNeedsSetup,start:n.home.advisorStart,discuss:n.home.advisorDiscuss,refresh:n.home.advisorRefresh,refreshing:n.home.advisorRefreshing,history:n.home.advisorHistory,viewProgress:n.home.advisorViewProgress,alternatives:n.home.advisorAlternatives,feedback:n.home.advisorFeedback,alreadyDone:n.home.advisorAlreadyDone,irrelevant:n.home.advisorIrrelevant,later:n.home.advisorLater,lessLikeThis:n.home.advisorLessLikeThis,sourceIncorrect:n.home.advisorSourceIncorrect,minutes:n.home.advisorMinutes,setupTitle:n.home.advisorSetupTitle,setupHint:n.home.advisorSetupHint,configure:n.home.advisorConfigure,degradedStart:n.home.advisorDegradedStart,automationHint:n.home.advisorAutomationHint,automationAction:n.home.advisorAutomationAction},onRefresh:Je,onAction:Ye,onFeedback:Xe,onClarification:Qe,onOpenHistory:()=>oe(!0),preflight:he,receipt:U}),S.needsUser.length>0?(0,$.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-needs-user-title`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(_e,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{id:`home-needs-user-title`,className:`text-sm font-semibold text-fg`,children:n.home.needsUserTitle})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base`,children:S.needsUser.map(t=>(0,$.jsx)(We,{item:t,busy:L!==null,recommendationLabel:n.home.recommendationLabel,dueLabel:n.home.dueLabel,failureLabel:r.runAttention,locale:e,onAction:qe,onComplete:()=>void D()},t.id))})]}):null,S.background.length>0?(0,$.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-background-title`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,$.jsx)(`h2`,{id:`home-background-title`,className:`text-sm font-semibold text-fg`,children:n.home.backgroundTitle}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:He(n.home.backgroundCount,{count:S.backgroundCount})})]}),(0,$.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle border-y border-edge-subtle`,children:S.background.map(e=>(0,$.jsx)(Ge,{item:e,onAction:qe},e.id))})]}):null]}):null,G?(0,$.jsxs)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-[100] flex -translate-x-1/2 items-center gap-4 rounded-lg border border-edge bg-surface-panel px-4 py-3 text-sm text-fg shadow-float`,children:[(0,$.jsx)(`span`,{children:n.home.advisorFeedbackSaved}),(0,$.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:Ze,children:n.home.advisorUndo})]}):null]})}export{Ke as HomePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./x-B_N4OPjy.js";import{a as i,r as a}from"./locale-store-D5h-Ha6-.js";import{$i as o,Rc as s}from"./index-
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./x-B_N4OPjy.js";import{a as i,r as a}from"./locale-store-D5h-Ha6-.js";import{$i as o,Rc as s}from"./index-K2cy4f-3.js";var c=t();e();var l=n();function u(e){let t=(0,c.c)(30),{primary:n,value:i,models:a,loading:u,error:d,zh:f,onChange:p}=e,m;if(t[0]!==a||t[1]!==n||t[2]!==i){let e;t[4]!==n||t[5]!==i?(e=e=>e.id!==n&&!i.includes(e.id),t[4]=n,t[5]=i,t[6]=e):e=t[6],m=a.filter(e),t[0]=a,t[1]=n,t[2]=i,t[3]=m}else m=t[3];let h=m,g=f?`回退顺序`:`Fallback order`,_;t[7]===g?_=t[8]:(_=(0,l.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:g}),t[7]=g,t[8]=_);let v=f?`主模型不可用时,按从左到右的顺序尝试。`:`Tried from left to right when the primary model is unavailable.`,y;t[9]===v?y=t[10]:(y=(0,l.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v}),t[9]=v,t[10]=y);let b;t[11]!==_||t[12]!==y?(b=(0,l.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,l.jsxs)(`div`,{children:[_,y]})}),t[11]=_,t[12]=y,t[13]=b):b=t[13];let x;t[14]!==a||t[15]!==p||t[16]!==i||t[17]!==f?(x=i.length>0?(0,l.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:i.map((e,t)=>(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full bg-surface-base/70 py-1 pl-2.5 pr-1 text-xs text-fg`,children:[(0,l.jsx)(`span`,{className:`text-fg-subtle`,children:t+1}),(0,l.jsx)(`span`,{children:a.find(t=>t.id===e)?.name??e}),(0,l.jsx)(`button`,{type:`button`,"aria-label":f?`移除 ${e}`:`Remove ${e}`,className:`rounded-full p-1 text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>p(i.filter(t=>t!==e)),children:(0,l.jsx)(r,{className:`size-3`})})]},e))}):(0,l.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:f?`未设置回退模型。`:`No fallback models configured.`}),t[14]=a,t[15]=p,t[16]=i,t[17]=f,t[18]=x):x=t[18];let S;t[19]!==h||t[20]!==d||t[21]!==u||t[22]!==p||t[23]!==i||t[24]!==f?(S=u?(0,l.jsx)(s,{className:`mt-3 h-11 w-full max-w-md rounded-lg`}):(0,l.jsx)(o,{value:``,models:h,modelsLoading:u,modelsError:d,placeholder:f?`添加回退模型`:`Add fallback model`,searchPlaceholder:f?`搜索模型或服务商`:`Search models or providers`,noMatches:f?`没有可添加的模型`:`No models available to add`,showProviderInTrigger:!1,contentAlign:`start`,className:`mt-3 w-full max-w-md`,ariaLabel:f?`添加回退模型`:`Add fallback model`,onChange:e=>{e&&p([...i,e])}}),t[19]=h,t[20]=d,t[21]=u,t[22]=p,t[23]=i,t[24]=f,t[25]=S):S=t[25];let C;return t[26]!==b||t[27]!==x||t[28]!==S?(C=(0,l.jsxs)(`div`,{children:[b,x,S]}),t[26]=b,t[27]=x,t[28]=S,t[29]=C):C=t[29],C}async function d(){let e=await i(a(`/api/image-generation/catalog`));if(!Array.isArray(e.payload?.providers))throw Error(`Invalid image provider catalog`);return e.payload.providers}async function f(){let e=await i(a(`/api/image-generation/custom-providers`));if(!Array.isArray(e.payload?.providers))throw Error(`Invalid custom image provider list`);return e.payload.providers}async function p(e,t){await i(a(`/api/image-generation/custom-providers/${encodeURIComponent(e)}`),{method:`PUT`,body:JSON.stringify(t)})}async function m(e){await i(a(`/api/image-generation/custom-providers/${encodeURIComponent(e)}`),{method:`DELETE`})}async function h(e,t){await i(a(`/api/image-generation/providers/${encodeURIComponent(e)}/credential`),{method:`PUT`,body:JSON.stringify({apiKey:t})})}async function g(e,t){let n=await i(a(`/api/image-generation/providers/${encodeURIComponent(e)}/test`),{method:`POST`,body:JSON.stringify({modelId:t})});if(!Array.isArray(n.payload?.images))throw Error(`Invalid image generation test response`);return{images:n.payload.images}}export{h as a,p as i,f as n,g as o,d as r,u as s,m as t};
|