@xopcai/xopc 0.0.208 → 0.0.210
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/{activity-store-D0mYZqhc.js → activity-store-JLmEb1p0.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-MWLQWL_i.js → agent-avatar-dicebear-CI1zQfzY.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DqGMj3QJ.js +68 -0
- package/dist/gateway/static/root/assets/{api-DZA1yVzM.js → api-C6MmWfcb.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B2X6quAF.js → app-management-settings-panel-Cd02GGpV.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BZW-c38q.js → appearance-settings-Db-h2I3G.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BT7F4WBI.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CK-gsjsJ.js → archive-plugin-CMHzJT2a.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-EJGP4rCw.js → attachment-load-BzhI2LoH.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-CwOXGV9z.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Tbss_4P-.js → binary-plugins-DsUeHvZO.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C-dOWigw.js → block-editor-CFfsIeZ4.js} +47 -47
- package/dist/gateway/static/root/assets/{browser-settings-page-NlvDyMwD.js → browser-settings-page-CyRLhCod.js} +4 -4
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-DW06Zo1N.js → browser-workflow-inputs-BiWghvJ0.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-B6RnRGwm.js → browser-workflows-page-DPLdT6Zn.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-jRKcS7lZ.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-Cc3BtQar.js → capability-presets-api-CTxGFvsS.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-D0loEbzq.js → capability-presets-settings-panel-B3bKdtwU.js} +2 -2
- package/dist/gateway/static/root/assets/{channel-recipient-api-BvZO5FaO.js → channel-recipient-api-BklVUOxC.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-yZBWH02s.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-C3zlimZd.js +1 -0
- package/dist/gateway/static/root/assets/chat-terminal-dock-0F4Jmma2.js +36 -0
- package/dist/gateway/static/root/assets/{connectors-api-CUl6_EQJ.js → connectors-api-BvIZ51ty.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-OX4KvUkA.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-BD9MgoE_.js → cron-expression-BHmwaMbO.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-ChqNmoxw.js → date-picker-fj_pPCv5.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CDUmFs6H.js → dependency-picker-DsWvwOv-.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-D61gqxaD.js → desktop-pet-mjkF0Xxh.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-QvuJvIX_.js → desktop-pet-settings-ClwUpRYu.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DvXMvDNY.js → directory-picker-path-field-OkqRFyRL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DMdVTAQ3.js → extension-debug-page-DC69wplH.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BNzxZtaK.js → extension-page-DCtk6zdJ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DoEfyizU.js → extension-settings-page-Bkm4zzv-.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-o7AKvthC.js → gateway-config-api-Dr_NQt7v.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BQbkUP5X.js → gateway-config-swr-CEfv8N1J.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-V1XVxjHa.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DIgdpHgk.js → gateway-startup-retry-B8hebJ7s.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-UZAn1aAQ.js → heartbeat-settings-CWUBAQrE.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-D57cYRd3.js +1 -0
- package/dist/gateway/static/root/assets/index-DJ7HSgKs.js +85 -0
- package/dist/gateway/static/root/assets/index-PNBFdxHb.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-4xaM3jjU.js → keyboard-shortcuts-settings-DCQvf05d.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-D9bguWRo.js → local-app-workbench-page-BbAiMZE1.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-C1xDicdr.js → local-apps-page-B3Ugd0my.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-pByvK12G.js → locale-store-hDBVeG3G.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Gr-nE4nW.js → logs-page-nXdF3wOT.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-D1XdHm7v.js → management-settings-C-S5Llq3.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-B_Ijq1Fr.js → markdown-split-DuVq37Uh.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-CyJlGUxB.js → markdown-view-D8eO_6h3.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CXXNRROJ.js → media-plugins-C1V6pkX3.js} +1 -1
- package/dist/gateway/static/root/assets/messages-1qg_hOOd.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-rkePB4CB.js → notes-page-Dn71ZV8c.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-BYPoZeRw.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-gw-RMQCV.js → page-tabs-B5a5aSoS.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-B8aMScJ2.js → preview-open-alternatives-5041AIBX.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CjcpkWAz.js → product-open-page-7UkouFQU.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-D27nOKbo.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-DPRxKGbs.js → projects-page-CdB5cJJ-.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DFoZ3UNS.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Ch5qq86o.js → runtime-tools-settings-panel-DvaXzHYS.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DHYWYUFt.js → schema-form-Dlxl_5X0.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-C1cbIcJ7.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DnXRlQXS.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DlzZx0-i.js → settings-form-section-CSaiuuer.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BVLhreQi.js → settings-loading-skeleton-H3mJwt3r.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BJU-kUnN.js → settings-page-Cs7zA4BS.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CwgMODfJ.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-hvIuZXMe.js → share-preview-page-Bdpw5m7M.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-hlUgIkrp.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DR31B_Gz.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Dlvuh7D-.js → skills-page-Bup3Lg1Z.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-B6ddOpnf.js → skills-page.utils-D22ORR21.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BdbCAyoA.js → system-settings-panel-GmtWsfjB.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CTKDpxhf.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BtdGacMI.js → theme-store-CtY8RwMX.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-CL6qHYJA.js → typed-models-lib-C2aOdlEA.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-DysNnqCS.js → use-autosave-DOj5i8d_.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-Bwg4KV8B.js → user-context-page-keJJYpix.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-UEsO9Jr-.js → voice-api-key-field-5WfurWYa.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B9disASf.js → work-discovery-overlay-D5_MH3n3.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-CmPfOfHl.js → work-discovery-page-BcvBiebt.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-A0zTQHFQ.js → workflow-run-setup-panel-bBA8LinI.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-Cz2VpWdj.js +5 -0
- package/dist/gateway/static/root/index.html +9 -9
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +2 -2
- package/dist/src/agent/background-review/coordinator.d.ts +1 -1
- package/dist/src/agent/background-review/coordinator.js +4 -5
- package/dist/src/agent/background-review/run-background-review.js +0 -1
- package/dist/src/agent/background-review/settings.d.ts +1 -2
- package/dist/src/agent/background-review/settings.js +3 -4
- package/dist/src/agent/external-tools/composio-provider.js +8 -4
- package/dist/src/agent/memory/builtin-provider.js +1 -1
- package/dist/src/agent/memory/create-memory-manager.js +1 -1
- package/dist/src/agent/memory/manager.js +2 -0
- package/dist/src/agent/memory/sensitivity.js +1 -1
- package/dist/src/agent/memory/understanding/service.js +43 -19
- package/dist/src/agent/memory/user-context-coordinator.js +1 -1
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/automations/domain/validation.d.ts +7 -7
- package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -2
- package/dist/src/connectors/auth-provider-registry.d.ts +2 -1
- package/dist/src/connectors/auth-provider-registry.js +5 -2
- package/dist/src/connectors/composio-sessions.d.ts +38 -0
- package/dist/src/connectors/composio-sessions.js +64 -6
- package/dist/src/connectors/composio.d.ts +4 -1
- package/dist/src/connectors/composio.js +26 -4
- package/dist/src/connectors/runtime-adapter-registry.js +14 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/routes/agent-stream.js +4 -1
- package/dist/src/gateway/hono/routes/connectors.js +15 -2
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +60 -0
- package/dist/src/gateway/hono/routes/session-input-handler.js +75 -1
- package/dist/src/gateway/service/agent-runner.d.ts +9 -1
- package/dist/src/gateway/service/agent-runner.js +9 -0
- package/dist/src/gateway/service/session-input-coordinator.d.ts +12 -0
- package/dist/src/gateway/service/session-input-coordinator.js +64 -6
- package/dist/src/gateway/service.d.ts +8 -0
- package/dist/src/gateway/service.js +8 -5
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/retrieval/audit.d.ts +1 -0
- package/dist/src/retrieval/audit.js +8 -0
- package/dist/src/retrieval/candidateFusion.d.ts +5 -0
- package/dist/src/retrieval/candidateFusion.js +20 -0
- package/dist/src/retrieval/queryProfile.d.ts +16 -0
- package/dist/src/retrieval/queryProfile.js +66 -0
- package/dist/src/retrieval/textFeatures.d.ts +5 -0
- package/dist/src/retrieval/textFeatures.js +71 -0
- package/dist/src/session/client-history.d.ts +1 -0
- package/dist/src/session/client-history.js +4 -0
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +1 -1
- package/dist/src/storage/sqlite/fts.d.ts +0 -4
- package/dist/src/storage/sqlite/fts.js +2 -49
- package/dist/src/storage/sqlite/index.d.ts +3 -2
- package/dist/src/storage/sqlite/index.js +6 -5
- package/dist/src/storage/sqlite/memory-records-repository.js +60 -38
- package/dist/src/storage/sqlite/row-mappers.js +2 -2
- package/dist/src/storage/sqlite/session-repository.js +2 -2
- package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +34 -0
- package/dist/src/storage/sqlite/session-turn-replace-repository.js +110 -0
- package/dist/src/storage/sqlite/transcript-repository.js +1 -1
- package/dist/src/storage/sqlite/user-context-quality-repository.d.ts +7 -0
- package/dist/src/storage/sqlite/user-context-quality-repository.js +25 -1
- package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -0
- package/dist/src/storage/sqlite/user-context-repository.js +29 -3
- package/dist/src/tasks/home-query-service.d.ts +3 -1
- package/dist/src/tasks/home-query-service.js +73 -70
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/user-context/planner.d.ts +1 -0
- package/dist/src/user-context/planner.js +16 -29
- package/dist/src/user-context/retriever.d.ts +15 -0
- package/dist/src/user-context/retriever.js +65 -0
- package/dist/src/user-context/scope.d.ts +7 -0
- package/dist/src/user-context/scope.js +9 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-Bl8FQZxW.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-CRUgTO10.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-DrSwolhG.js +0 -6
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BWXUznw5.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-CcivCw8U.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DkHAD2Zn.js +0 -1
- package/dist/gateway/static/root/assets/chat-terminal-dock-DVedGAeX.js +0 -36
- package/dist/gateway/static/root/assets/connectors-page-DlBSlfkv.js +0 -2
- package/dist/gateway/static/root/assets/gateway-settings-TO5YYZ9a.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CRJDpy5E.js +0 -3
- package/dist/gateway/static/root/assets/index-BSjP0Wsx.css +0 -2
- package/dist/gateway/static/root/assets/index-C2ZYFBGL.js +0 -85
- package/dist/gateway/static/root/assets/messages-yG5P43Q9.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-CpbD4XG2.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-GvSYDbjR.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-WIzeu-gB.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-2XEJM0YE.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-g1GThZ0O.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-C6qj2L-q.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BBpE1bep.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DXORBJNk.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DC0hc8hp.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DhQNh7W6.js +0 -5
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as o,r as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./markdown-view-CyJlGUxB.js";import{t as l}from"./plus-Q2yW6OE7.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{t as p}from"./messages-yG5P43Q9.js";import{n as m}from"./locale-store-pByvK12G.js";import{a as h,n as g,o as _,r as v,s as y,t as b}from"./dist-BPoKqzeH.js";import{i as x}from"./vendor-swr-BIWyz7Rc.js";import{Bl as S,Cc as ee,Cr as te,Er as ne,Fa as C,Fl as w,Hn as T,Ia as E,Il as D,Ls as O,Ms as re,Nl as ie,Or as k,Qi as A,Rl as j,Tr as M,Us as N,Xc as ae,ac as oe,ba as P,bc as F,dl as I,is as L,ou as se,qa as R,qs as z,sc as ce,tc as B,u as V,v as H,vs as le,wr as ue}from"./index-C2ZYFBGL.js";import{a as U,i as W,o as G,r as K}from"./cron-expression-BD9MgoE_.js";import{a as q,i as de,n as fe,r as J,t as pe}from"./workflow-run-setup-panel-A0zTQHFQ.js";import{i as me,n as he,r as ge,t as _e}from"./browser-workflow-inputs-DW06Zo1N.js";var Y=e(t(),1),ve=n(),ye=U();function be(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function xe(e,t){let n=e===7?0:e;return new Date(Date.UTC(2023,0,1)+n*864e5).toLocaleDateString(t,{weekday:`short`,timeZone:`UTC`})}function Se(e,t){return e.length<=1?e[0]??``:t.startsWith(`zh`)?e.join(`、`):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Ce(e){return e.length===5&&e.every((e,t)=>e===t+1)}function we(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function Te(e,t,n,r){try{let i=ye.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=K(i.minute.values),o=K(i.hour.values),s=K(i.dayOfWeek.values),c=K(i.dayOfMonth.values);if(a.length===60&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.everyMinute;if(!i.minute.isWildcard&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&a.length>1){let e=W(a);if(e!=null&&e>0)return n.everyNMinutes.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length>1&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard){let e=W(o);if(e!=null&&e>0)return n.everyNHours.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&o.length===24)return n.hourly;let l=!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length===1?be(o[0],a[0],t):``;if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.dailyAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Ce(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&we(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=xe(s[0],t);return n.weeklyOn.replace(`{{day}}`,e).replace(`{{time}}`,l)}if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length>1){let e=Se(s.map(e=>xe(e,t)),t);return n.daysAt.replace(`{{days}}`,e).replace(`{{time}}`,l)}return l&&!i.dayOfMonth.isWildcard&&c.length===1&&i.month.isWildcard&&i.dayOfWeek.isWildcard?n.monthlyAt.replace(`{{day}}`,String(c[0])).replace(`{{time}}`,l):n.customSchedule}catch{return null}}function Ee(e,t,n,r){let i=e.trim();return i?Te(i,t,n,r)||De(r?.nextRun,t)||n.customSchedule:De(r?.nextRun,t)||`—`}function De(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleString(t,{weekday:`short`,hour:`numeric`,minute:`2-digit`})}var Oe=1e3,X=60*Oe,ke=60*X,Ae=24*ke,je=7*Ae,Me=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Ne=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),Pe={en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},Fe={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Ie={minute:X,hour:ke,day:Ae,week:je};function Le(e){return e===`zh`?`zh-CN`:`en-US`}function Re(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Ne[String(t)].format(e)}function ze(e,t){return t===`zh`?e.join(` `):Me.format(e)}function Be(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(X,Math.round((Number.isFinite(n)&&n>0?n:1)*Ie[t]))}function Ve(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*Ie[t]/Ie[n]).toFixed(6)))}function He(e,t){let n=Math.max(Oe,Math.round(e)),r=n===Ae?[{unit:`hour`,ms:ke}]:n>=je&&n%je===0?[{unit:`week`,ms:je}]:n>=Ae?[{unit:`day`,ms:Ae},{unit:`hour`,ms:ke},{unit:`minute`,ms:X},{unit:`second`,ms:Oe}]:n>=ke?[{unit:`hour`,ms:ke},{unit:`minute`,ms:X},{unit:`second`,ms:Oe}]:n>=X?[{unit:`minute`,ms:X},{unit:`second`,ms:Oe}]:[{unit:`second`,ms:Oe}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Re(r,e,t)),i%=n)}return ze(a,t)}function Ue(e,t){let n=He(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function We(e,t){return Pe[t].format(new Date(e))}function Ge(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Ke(e,t,n=Date.now()){let r=new Date(e),i=Math.round((Ge(r)-Ge(new Date(n)))/Ae),a=Fe[t].format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:We(e,t)}function qe(e,t){return e.eventType===`task.attention_required.v2`&&e.payloadMatch?.reason===`blocked`?t.trigger.taskBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function Je(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return qe(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Ke(Date.parse(i.at),r)):i.kind===`interval`?Ue(i.everyMs,r):Ee(i.expr,Le(r),n.scheduleBadge,{timezone:i.tz})}function Ye(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Ke(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function Xe(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Ke(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Ze={name:``,description:``,projectId:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,browserWorkflowId:``,browserWorkflowInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`1800`,conversationMode:`new_session`,notificationPolicy:`attention`,completionWebhookUrl:``,disableAfterFailures:`3`},Qe=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function $e(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`taskBlocked`)o={kind:`event`,eventType:`task.attention_required.v2`,source:`tasks`,payloadMatch:{reason:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Be(e.intervalValue,e.intervalUnit)}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=J(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_recipe`?`auto_apply`:e.safetyMode,u;return u=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{}}:e.actionMode===`browser_recipe`?{kind:`browser_recipe`,recipeId:e.browserWorkflowId.trim(),args:e.browserWorkflowInputs}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{}},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},...e.projectId.trim()?{projectId:e.projectId.trim()}:{},trigger:o,action:u,safety:{mode:l},conversationMode:e.conversationMode,notificationPolicy:e.notificationPolicy,...l===`auto_apply`&&e.completionWebhookUrl.trim()?{completionWebhookUrl:e.completionWebhookUrl.trim()}:{},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function et(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:Ze.time,weekday:Ze.weekday,cronExpr:e}}function tt(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function nt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function rt(e){let t=e.payloadMatch;return e.eventType===`task.attention_required.v2`&&e.source===`tasks`&&t?.reason===`blocked`?{triggerMode:`taskBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function it(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function at(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function ot(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=rt(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=et(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...tt(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:nt(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?it(r.input):{},o=e.reliability?.executionTimeoutSeconds??r.timeoutSeconds??e.reliability?.timeoutSeconds??(r.kind===`browser_recipe`?600:1800);return{...Ze,...n,name:e.name,description:e.description??``,projectId:e.projectId??``,actionMode:r.kind,agentId:r.kind===`browser_recipe`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserWorkflowId:r.kind===`browser_recipe`?r.recipeId:``,browserWorkflowInputs:r.kind===`browser_recipe`?r.args??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?fe(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(o),conversationMode:e.conversationMode??`new_session`,notificationPolicy:e.notificationPolicy??`attention`,completionWebhookUrl:e.completionWebhookUrl??``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function st(e,t,n){let r=$e(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`?a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}:e.action.kind===`browser_recipe`&&r.action.kind===`browser_recipe`&&(a={...e.action,...r.action}),{...r,description:t.description.trim(),projectId:t.projectId.trim(),completionWebhookUrl:t.completionWebhookUrl.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function ct(e,t,n){return e?We(e,n):t.never}function lt(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_recipe`?`Browser automation: ${e.recipeId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function ut(e){return e.safety?.mode??`auto_apply`}function dt(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`||e===`cancelling`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function ft(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function pt(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function mt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function ht(e,t){if((e.state.consecutiveFailures??0)>0)return!0;let n=t.reduce((t,n)=>n.automationId===e.id&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0);return n?mt(n):!1}function gt(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||lt(e.action,t)}function _t(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function vt(e){return!!_t(e)}function yt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function bt(e){return pt(e)?0:mt(e)?1:e.status===`succeeded`?2:3}function xt(e){return[...e].sort((e,t)=>{let n=bt(e)-bt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function St(){let e=(0,ve.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsx)(E,{className:`h-4 w-36`}),(0,Z.jsx)(E,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(E,{className:`h-7 w-20 rounded-full`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(Ct)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(E,{className:`h-4 w-32`}),i=(0,Z.jsx)(E,{className:`mt-4 h-24 rounded-lg`}),e[2]=r,e[3]=i):(r=e[2],i=e[3]);let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,Z.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,Z.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,Z.jsx)(E,{className:`h-12 rounded-lg`}),(0,Z.jsx)(E,{className:`h-12 rounded-lg`}),(0,Z.jsx)(E,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function Ct(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(E,{className:`size-4 rounded-full`}),(0,Z.jsx)(E,{className:`h-4 w-32`}),(0,Z.jsx)(E,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(E,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(E,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(E,{className:`h-8 w-24 rounded-md`})]})},t)}function wt(){let e=m(e=>e.language),t=p(e),n=t.automations,r=t.cron,a=R(e=>e.setPageHeader),c=R(e=>e.clearPageHeader),[S,ee]=i(),w=S.get(`run`)?.trim()??``,T=S.get(`automation`)?.trim()??``,E=S.get(`draft`)?.trim()??``,D=S.get(`action`)?.trim()??``,O=S.get(`projectId`)?.trim()??``,re=S.get(`autogenerate`)===`1`,ie=(0,Y.useRef)(``),[j,ae]=(0,Y.useState)(`all`),[oe,F]=(0,Y.useState)(``),[se,z]=(0,Y.useState)(!1),[ce,B]=(0,Y.useState)(`blank`),[le,U]=(0,Y.useState)(null),[W,G]=(0,Y.useState)(!1),[K,q]=(0,Y.useState)(Ze),[fe,J]=(0,Y.useState)(null),[pe,ge]=(0,Y.useState)(null),[_e,ve]=(0,Y.useState)(!1),[ye,be]=(0,Y.useState)(null),[xe,Se]=(0,Y.useState)(``),[Ce,we]=(0,Y.useState)(null),[Te,Ee]=(0,Y.useState)(!1),[De,Oe]=(0,Y.useState)(!1),[X,ke]=(0,Y.useState)(O),[Ae,je]=(0,Y.useState)(`new_session`),[Me,Ne]=(0,Y.useState)(`attention`),[Pe,Fe]=(0,Y.useState)(null),[Ie,Le]=(0,Y.useState)(!1),[Re,ze]=(0,Y.useState)(!1),[Be,Ve]=(0,Y.useState)(!1),[He,Ue]=(0,Y.useState)(null),We=x([`automations`,O],()=>V.list(O?{projectId:O}:void 0),{refreshInterval:15e3}),Ge=x([`automation-runs`,O],()=>V.runs(50,void 0,O?{projectId:O}:void 0),{refreshInterval:1e4}),Ke=x(pe?`automation-run-events:${pe}`:null,()=>V.runEvents(pe),{refreshInterval:5e3}),qe=x(`automation-workflow-definitions`,H),Ye=x(`automation-browser-workflows`,()=>me.list()),Xe=x(`automation-chat-agents`,C),Qe=x(`automation-projects`,()=>P({sortBy:`name`,sortOrder:`asc`,limit:200})),et=We.isLoading&&!We.data||Ge.isLoading&&!Ge.data,tt=We.data?.automations??[],nt=(0,Y.useMemo)(()=>xt(Ge.data?.runs??[]),[Ge.data?.runs]),rt=(0,Y.useMemo)(()=>tt.filter(e=>!vt(e)),[tt]),it=(0,Y.useMemo)(()=>tt.filter(vt),[tt]),ct=(0,Y.useMemo)(()=>new Set(it.map(e=>e.id)),[it]),lt=(0,Y.useMemo)(()=>nt.filter(e=>!ct.has(e.automationId)),[nt,ct]),ut=(0,Y.useMemo)(()=>nt.find(e=>e.id===pe)??null,[nt,pe]),dt=(0,Y.useMemo)(()=>tt.find(e=>e.id===ye)??null,[tt,ye]),ft=(0,Y.useMemo)(()=>tt.find(e=>e.id===le)??null,[tt,le]),mt=(0,Y.useMemo)(()=>nt.filter(e=>e.automationId===ye).sort((e,t)=>t.createdAtMs-e.createdAtMs),[nt,ye]),ht=Ke.data?.events??[],_t=(0,Y.useMemo)(()=>lt.filter(e=>!pt(e)&&e.readAtMs==null),[lt]),bt=oe.trim().toLocaleLowerCase(),Ct=(0,Y.useMemo)(()=>(j===`system`?it:rt).filter(t=>j===`active`&&!t.enabled||j===`paused`&&t.enabled?!1:bt?[t.name,yt(t),gt(t,n),Je(t.trigger,n,r,e)].some(e=>e.toLocaleLowerCase().includes(bt)):!0),[r,j,n,e,bt,it,rt,lt]),wt=(0,Y.useMemo)(()=>qe.data??[],[qe.data]),Et=(0,Y.useMemo)(()=>(Ye.data?.workflows??[]).filter(e=>e.enabled),[Ye.data]),Dt=Xe.data?.items??[],Ot=Qe.data?.items??[],At=(0,Y.useMemo)(()=>wt.find(e=>e.id===K.workflowId.trim())??null,[K.workflowId,wt]),jt=(0,Y.useMemo)(()=>Et.find(e=>e.id===K.browserWorkflowId.trim())??null,[Et,K.browserWorkflowId]),Mt=K.actionMode===`workflow`&&(!K.workflowId.trim()||wt.length>0&&!wt.some(e=>e.id===K.workflowId)),Nt=K.actionMode===`workflow`&&At?!de(At,K.workflowInput,K.workflowInputValid).valid:!1,It=!!K.name.trim()&&(K.triggerMode!==`once`||Number.isFinite(new Date(K.onceAt).getTime()))&&(K.triggerMode!==`event`||!!K.eventType.trim()&&at(K.eventPayloadMatch))&&(K.actionMode===`workflow`?!Mt&&!Nt:K.actionMode===`browser_recipe`?jt!==null&&he(jt,K.browserWorkflowInputs):!!K.instruction.trim()),Lt=(0,Y.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...Ze,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...Ze,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:wt[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...Ze,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedTask.name,description:n.templates.blockedTask.description,form:{...Ze,name:n.templates.blockedTask.formName,triggerMode:`taskBlocked`,instruction:n.templates.blockedTask.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...Ze,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,wt]);(0,Y.useEffect)(()=>{if(Ct.length===0){be(null);return}ye&&Ct.some(e=>e.id===ye)||be(Ct[0].id)},[Ct,ye]);let Rt=(0,Y.useCallback)(async()=>{await Promise.all([We.mutate(),Ge.mutate(),Ke.mutate()])},[We.mutate,Ke.mutate,Ge.mutate]),zt=(0,Y.useCallback)(e=>{ee(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),be(null),ge(null)},[ee]),Bt=(0,Y.useCallback)(e=>{if(U(null),G(!1),B(e),z(!0),e===`blank`){q({...Ze,projectId:O});return}Se(``),we(null),Oe(!1),ke(O),je(`new_session`),Ne(`attention`)},[O]),Vt=(0,Y.useCallback)(e=>{q(ot(e,wt)),U(e.id),G(!1),be(null),B(`blank`),z(!0)},[wt]),Ht=(0,Y.useCallback)(()=>{Ce&&(q({...ot(Ce.automation,wt),projectId:X,conversationMode:Ae,notificationPolicy:Me}),U(null),G(!0),B(`blank`))},[Ce,Ae,Me,X,wt]),Gt=(0,Y.useCallback)(async()=>{Ve(!0),J(null);try{await Rt()}catch(e){J(e instanceof Error?e.message:String(e))}finally{Ve(!1)}},[n.feedback.actionFailed,Rt]);(0,Y.useEffect)(()=>{if(!T)return;let e=tt.find(e=>e.id===T);e&&(ae(vt(e)?`system`:`all`),be(e.id),ee(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[T,tt,ee]),(0,Y.useEffect)(()=>{D===`create`&&(Bt(`blank`),ee(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[D,Bt,ee]),(0,Y.useEffect)(()=>{if(!E)return;let t=`${e}:${re?`auto`:`seed`}:${E}`;ie.current!==t&&(ie.current=t,Se(E),we(null),Oe(!1),ke(O),B(`draft`),z(!0),ee(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),re&&(J(null),Ee(!0),V.draft({prompt:E,language:e}).then(e=>{we(e.draft),Oe(!1)}).catch(e=>{J(e instanceof Error?e.message:String(e))}).finally(()=>{Ee(!1)})))},[re,E,e,O,ee]);let Kt=(0,Y.useCallback)(e=>{let t=nt.find(t=>t.id===e);if(!t||pt(t)||t.readAtMs!=null)return;let n=Date.now();Ge.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),V.markRunRead(e).catch(e=>{J(e instanceof Error?e.message:String(e)),Ge.mutate()})},[nt,Ge.mutate]),qt=(0,Y.useCallback)(e=>{Kt(e),ge(e),ve(!0),ee(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[Kt,ee]),$=(0,Y.useCallback)(e=>{be(e);let t=nt.find(t=>t.automationId===e);t&&t.readAtMs==null&&!pt(t)&&Kt(t.id)},[Kt,nt]);(0,Y.useEffect)(()=>{w&&(Kt(w),ge(w),ve(!0))},[Kt,w]),(0,Y.useEffect)(()=>{Fe(null),ze(!1)},[pe]);async function Jt(){if(J(null),It){if(W&&Ce){Ue(`draft:edit`);try{let e=$e(K,At),{simulation:t}=await V.simulate(e);we({...Ce,automation:e,simulation:t}),ke(K.projectId),je(K.conversationMode),Ne(K.notificationPolicy),Oe(!1),G(!1),B(`draft`)}catch(e){J(e instanceof Error?e.message:String(e))}finally{Ue(null)}return}if(ft){let e=ft.id;await Yt(`automation:${e}:edit`,()=>V.update(e,st(ft,K,At)))&&(z(!1),U(null),be(e));return}try{let e=$e(K,At),{automation:t}=await V.create(e);q(Ze),z(!1),ae(`all`),F(``),zt(t.projectId??``),await Rt(),be(t.id)}catch(e){J(e instanceof Error?e.message:String(e))}}}async function Yt(e,t){J(null),Ue(e);try{return await t(),await Rt(),!0}catch(e){return J(e instanceof Error?e.message:String(e)),!1}finally{Ue(null)}}async function Xt(){await Yt(`runs:read-all`,()=>V.markAllRunsRead(O||void 0))}async function Zt(){let t=xe.trim();if(t){J(null),Ee(!0);try{we((await V.draft({prompt:t,language:e})).draft),Oe(!1)}catch(e){J(e instanceof Error?e.message:String(e))}finally{Ee(!1)}}}async function Qt(){if(!Ce)return;let e=``,t=``;await Yt(`draft:publish`,async()=>{let{automation:n}=await V.create({...Ce.automation,...X?{projectId:X}:{projectId:void 0},conversationMode:Ae,notificationPolicy:Me});we(null),Se(``),Oe(!1),z(!1),ae(`all`),F(``),e=n.id,t=n.projectId??``})&&e&&(zt(t),be(e))}async function $t(){if(!Ce)return;let e=``,t=``,n=``;await Yt(`draft:test`,async()=>{let{automation:r}=await V.create({...Ce.automation,...X?{projectId:X}:{projectId:void 0},conversationMode:Ae,notificationPolicy:Me,enabled:!1}),{run:i}=await V.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,we(null),Se(``),Oe(!1),z(!1),ae(`all`),F(``)})&&e&&n&&(zt(t),be(e),qt(n))}async function en(t){J(null),Le(!0),Fe(null),ze(!1);try{Fe((await V.repairDraft(t.id,{language:e})).repair)}catch(e){J(e instanceof Error?e.message:String(e))}finally{Le(!1)}}async function tn(e){Pe&&await Yt(`run:${e.id}:repair`,async()=>{await V.update(e.automationId,Pe.patch),Fe(null),ze(!1)})}let nn=(0,Y.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(A,{className:`size-9 shrink-0 p-0`,loading:Be,label:n.refresh,onClick:Gt}),(0,Z.jsxs)(f,{variant:`primary`,onClick:()=>Bt(`draft`),children:[(0,Z.jsx)(l,{className:`size-4`}),n.new]})]}),[n.new,n.refresh,Bt,Be,Gt]);return(0,Y.useLayoutEffect)(()=>(a({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:nn}),()=>c()),[c,nn,n.subtitle,n.title,a]),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[fe?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:fe}):null,et?(0,Z.jsx)(St,{}):(0,Z.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle p-3`,children:[(0,Z.jsxs)(o,{"aria-label":n.filters.project,className:Q,value:O,onChange:e=>zt(e.target.value),children:[(0,Z.jsx)(s,{value:``,children:n.filters.allProjects}),Ot.map(e=>(0,Z.jsx)(s,{value:e.id,children:e.name},e.id))]}),(0,Z.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg-muted focus-within:border-accent`,children:[(0,Z.jsx)(N,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:oe,onChange:e=>F(e.target.value),placeholder:n.filters.search})]}),(0,Z.jsxs)(`nav`,{className:`mt-3 flex items-center gap-1`,"aria-label":n.filters.status,children:[[{id:`all`,label:n.filters.all},{id:`active`,label:n.filters.active},{id:`paused`,label:n.paused}].map(e=>(0,Z.jsx)(`button`,{type:`button`,className:d(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,j===e.id&&`bg-surface-hover text-fg`),onClick:()=>ae(e.id),children:e.label},e.id)),(0,Z.jsxs)(ne,{children:[(0,Z.jsx)(k,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:d(`ml-auto rounded-md p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,j===`system`&&`bg-surface-hover text-fg`),"aria-label":n.system.title,children:(0,Z.jsx)(I,{className:`size-4`})})}),(0,Z.jsx)(M,{children:(0,Z.jsx)(te,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,Z.jsxs)(ue,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ae(`system`),children:[n.system.title,` `,it.length]})})})]})]}),_t.length>0&&j!==`system`?(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 rounded-md bg-accent/8 px-2.5 py-1.5 text-xs text-accent-fg`,children:[(0,Z.jsxs)(`span`,{children:[n.filters.unread,` · `,_t.length]}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:He===`runs:read-all`,onClick:()=>void Xt(),children:n.filters.markAllRead})]}):null]}),(0,Z.jsx)(kt,{automations:Ct,runs:j===`system`?nt:lt,labels:n,cronLabels:r,language:e,selectedAutomationId:ye,onOpenDetails:$})]}),dt?(0,Z.jsx)(Ft,{automation:dt,runs:mt,labels:n,cronLabels:r,language:e,projects:Ot,busyAction:He,onEdit:Vt,onSelectRun:qt,onAction:Yt}):(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(L,{className:`size-5`}),title:n.empty.filtered})]})]}),(0,Z.jsx)(b,{open:se,onOpenChange:e=>{z(e),e||(U(null),G(!1))},children:(0,Z.jsxs)(_,{children:[(0,Z.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(v,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(y,{className:`text-base font-semibold text-fg`,children:ce===`draft`?n.draft.title:ft?n.editTitle:W?n.draft.editTitle:n.createTitle}),(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsx)(f,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(u,{className:`size-4`})})})]}),ce===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(Tt,{labels:n,prompt:xe,draft:Ce,loading:Te,approved:De,publishBusy:He===`draft:publish`,testBusy:He===`draft:test`,templates:Lt,projects:Ot,projectId:X,conversationMode:Ae,notificationPolicy:Me,onPromptChange:Se,onGenerate:Zt,onEdit:Ht,onPublish:Qt,onTest:$t,onProjectChange:ke,onConversationModeChange:je,onNotificationPolicyChange:Ne,onApprovedChange:Oe,onDiscard:()=>{we(null),Oe(!1)},onTemplateSelect:e=>{q({...e,projectId:X}),B(`blank`)},onOpenAdvanced:()=>{q({...Ze,projectId:X,conversationMode:Ae,notificationPolicy:Me}),B(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Wt,{form:K,labels:n,setForm:q,projects:Ot,workflowDefinitions:wt,selectedWorkflow:At,workflowsLoading:qe.isLoading,browserWorkflows:Et,selectedBrowserWorkflow:jt,browserWorkflowsLoading:Ye.isLoading,agentOptions:Dt,agentsLoading:Xe.isLoading,language:e}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[W?(0,Z.jsx)(f,{variant:`ghost`,onClick:()=>{G(!1),B(`draft`)},children:n.cancel}):(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsx)(f,{variant:`ghost`,children:n.cancel})}),(0,Z.jsx)(f,{variant:`primary`,onClick:Jt,disabled:!It||He===`draft:edit`||!!(ft&&He),children:He===`draft:edit`||ft&&He===`automation:${ft.id}:edit`?n.feedback.working:ft||W?n.save:n.create})]})]})]})]})}),(0,Z.jsx)(b,{open:_e&&!!ut,onOpenChange:e=>{ve(e),!e&&ee(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(_,{children:[(0,Z.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(v,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(y,{className:`truncate text-base font-semibold text-fg`,children:ut?.automationName??n.dashboard.result}),(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsx)(f,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(u,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(Pt,{className:`rounded-none border-0`,run:ut,events:ht,labels:n,cronLabels:r,language:e,loading:Ke.isLoading,repairDraft:Pe,repairLoading:Ie,repairApproved:Re,busyAction:He,onRepairApprovedChange:ze,onSuggestRepair:en,onApplyRepair:tn})})]})]})})]})}function Tt(e){let t=(0,ve.c)(112),{labels:n,prompt:r,draft:i,loading:a,approved:c,publishBusy:l,testBusy:u,templates:d,projects:p,projectId:m,conversationMode:h,notificationPolicy:g,onPromptChange:_,onGenerate:v,onEdit:y,onPublish:b,onTest:x,onProjectChange:S,onConversationModeChange:ee,onNotificationPolicyChange:te,onApprovedChange:ne,onDiscard:C,onTemplateSelect:w,onOpenAdvanced:T}=e,E=l===void 0?!1:l,D=u===void 0?!1:u,O=!!(i&&i.simulation.requiredConfirmations.length>0),ie;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(re,{className:`size-4 text-accent`}),t[0]=ie):ie=t[0];let k;t[1]===n.draft.title?k=t[2]:(k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[ie,n.draft.title]}),t[1]=n.draft.title,t[2]=k);let A;t[3]===n.draft.subtitle?A=t[4]:(A=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=A);let j;t[5]!==k||t[6]!==A?(j=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[k,A]}),t[5]=k,t[6]=A,t[7]=j):j=t[7];let M;t[8]!==a||t[9]!==r?(M=a||!r.trim(),t[8]=a,t[9]=r,t[10]=M):M=t[10];let N;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(re,{className:`size-4`}),t[11]=N):N=t[11];let ae=a?n.draft.generating:n.draft.generate,P;t[12]!==v||t[13]!==M||t[14]!==ae?(P=(0,Z.jsxs)(f,{variant:`primary`,onClick:v,disabled:M,children:[N,ae]}),t[12]=v,t[13]=M,t[14]=ae,t[15]=P):P=t[15];let F;t[16]!==P||t[17]!==j?(F=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[j,P]}),t[16]=P,t[17]=j,t[18]=F):F=t[18];let I;t[19]===_?I=t[20]:(I=e=>_(e.target.value),t[19]=_,t[20]=I);let L;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==I?(L=(0,Z.jsx)(`textarea`,{className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:I,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=I,t[24]=L):L=t[24];let se=n.draft.project,R;t[25]===S?R=t[26]:(R=e=>S(e.target.value),t[25]=S,t[26]=R);let z;t[27]===n.draft.noProject?z=t[28]:(z=(0,Z.jsx)(s,{value:``,children:n.draft.noProject}),t[27]=n.draft.noProject,t[28]=z);let ce;t[29]===p?ce=t[30]:(ce=p.map(Et),t[29]=p,t[30]=ce);let V;t[31]!==m||t[32]!==R||t[33]!==z||t[34]!==ce?(V=(0,Z.jsxs)(o,{className:Q,value:m,onChange:R,children:[z,ce]}),t[31]=m,t[32]=R,t[33]=z,t[34]=ce,t[35]=V):V=t[35];let H;t[36]!==n.draft.project||t[37]!==V?(H=(0,Z.jsx)($,{label:se,children:V}),t[36]=n.draft.project,t[37]=V,t[38]=H):H=t[38];let le;t[39]===ee?le=t[40]:(le=e=>ee(e.target.value),t[39]=ee,t[40]=le);let ue;t[41]===n.draft.newConversation?ue=t[42]:(ue=(0,Z.jsx)(s,{value:`new_session`,children:n.draft.newConversation}),t[41]=n.draft.newConversation,t[42]=ue);let U;t[43]===n.draft.continuousConversation?U=t[44]:(U=(0,Z.jsx)(s,{value:`continuous`,children:n.draft.continuousConversation}),t[43]=n.draft.continuousConversation,t[44]=U);let W;t[45]!==h||t[46]!==le||t[47]!==ue||t[48]!==U?(W=(0,Z.jsxs)(o,{className:Q,value:h,onChange:le,children:[ue,U]}),t[45]=h,t[46]=le,t[47]=ue,t[48]=U,t[49]=W):W=t[49];let G;t[50]!==n.draft.conversation||t[51]!==W?(G=(0,Z.jsx)($,{label:n.draft.conversation,children:W}),t[50]=n.draft.conversation,t[51]=W,t[52]=G):G=t[52];let K;t[53]===te?K=t[54]:(K=e=>te(e.target.value),t[53]=te,t[54]=K);let q;t[55]===n.draft.notifyAttention?q=t[56]:(q=(0,Z.jsx)(s,{value:`attention`,children:n.draft.notifyAttention}),t[55]=n.draft.notifyAttention,t[56]=q);let de;t[57]===n.draft.notifyAll?de=t[58]:(de=(0,Z.jsx)(s,{value:`all`,children:n.draft.notifyAll}),t[57]=n.draft.notifyAll,t[58]=de);let fe;t[59]===n.draft.notifyNone?fe=t[60]:(fe=(0,Z.jsx)(s,{value:`none`,children:n.draft.notifyNone}),t[59]=n.draft.notifyNone,t[60]=fe);let J;t[61]!==g||t[62]!==K||t[63]!==q||t[64]!==de||t[65]!==fe?(J=(0,Z.jsxs)(o,{className:Q,value:g,onChange:K,children:[q,de,fe]}),t[61]=g,t[62]=K,t[63]=q,t[64]=de,t[65]=fe,t[66]=J):J=t[66];let pe;t[67]!==n.draft.notifications||t[68]!==J?(pe=(0,Z.jsx)($,{label:n.draft.notifications,children:J}),t[67]=n.draft.notifications,t[68]=J,t[69]=pe):pe=t[69];let me;t[70]!==H||t[71]!==G||t[72]!==pe?(me=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[H,G,pe]}),t[70]=H,t[71]=G,t[72]=pe,t[73]=me):me=t[73];let he;t[74]!==i||t[75]!==n.draft.advancedCreate||t[76]!==n.draft.suggestions||t[77]!==n.draft.suggestionsDescription||t[78]!==T||t[79]!==w||t[80]!==d?(he=i?null:(0,Z.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.draft.suggestions}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n.draft.suggestionsDescription})]}),(0,Z.jsx)(f,{variant:`ghost`,onClick:T,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:d.slice(0,4).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>w(e.form),children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.name))})]}),t[74]=i,t[75]=n.draft.advancedCreate,t[76]=n.draft.suggestions,t[77]=n.draft.suggestionsDescription,t[78]=T,t[79]=w,t[80]=d,t[81]=he):he=t[81];let ge;t[82]!==c||t[83]!==i||t[84]!==n.draft.approval||t[85]!==n.draft.assumptions||t[86]!==n.draft.discard||t[87]!==n.draft.edit||t[88]!==n.draft.publish||t[89]!==n.draft.review||t[90]!==n.draft.risks||t[91]!==n.draft.safety||t[92]!==n.draft.testOnce||t[93]!==n.draft.testing||t[94]!==n.feedback||t[95]!==n.info||t[96]!==n.none||t[97]!==ne||t[98]!==C||t[99]!==y||t[100]!==b||t[101]!==x||t[102]!==E||t[103]!==O||t[104]!==D?(ge=i?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Z.jsx)(Ht,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Ht,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Z.jsx)(Dt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.risks,items:i.risks,empty:n.none}),O?(0,Z.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:c,onChange:e=>ne(e.target.checked)}),(0,Z.jsx)(`span`,{children:n.draft.approval})]}):null,(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(f,{variant:`ghost`,onClick:C,children:n.draft.discard}),(0,Z.jsxs)(f,{variant:`secondary`,onClick:y,children:[(0,Z.jsx)(oe,{className:`size-4`}),n.draft.edit]}),(0,Z.jsxs)(f,{variant:`secondary`,onClick:x,disabled:D||E||O&&!c,children:[(0,Z.jsx)(B,{className:`size-4`}),D?n.draft.testing:n.draft.testOnce]}),(0,Z.jsx)(f,{variant:`primary`,onClick:b,disabled:E||O&&!c,children:E?n.feedback.working:n.draft.publish})]})]})]}):null,t[82]=c,t[83]=i,t[84]=n.draft.approval,t[85]=n.draft.assumptions,t[86]=n.draft.discard,t[87]=n.draft.edit,t[88]=n.draft.publish,t[89]=n.draft.review,t[90]=n.draft.risks,t[91]=n.draft.safety,t[92]=n.draft.testOnce,t[93]=n.draft.testing,t[94]=n.feedback,t[95]=n.info,t[96]=n.none,t[97]=ne,t[98]=C,t[99]=y,t[100]=b,t[101]=x,t[102]=E,t[103]=O,t[104]=D,t[105]=ge):ge=t[105];let _e;return t[106]!==F||t[107]!==L||t[108]!==me||t[109]!==he||t[110]!==ge?(_e=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[F,L,me,he,ge]}),t[106]=F,t[107]=L,t[108]=me,t[109]=he,t[110]=ge,t[111]=_e):_e=t[111],_e}function Et(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function Dt(e){let t=(0,ve.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(Ot):(0,Z.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Ot(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function kt(e){let t=(0,ve.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:o,selectedAutomationId:s,onOpenDetails:c}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(L,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Ut,{icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let l;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==r||t[9]!==s){let e;t[11]!==a||t[12]!==i||t[13]!==o||t[14]!==c||t[15]!==r||t[16]!==s?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(At),n=t.find(pt),l=t[0];return(0,Z.jsxs)(`button`,{type:`button`,className:d(`block w-full p-3 text-left outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,s===e.id&&`bg-surface-hover`),onClick:()=>c(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:d(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:ht(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),l&&l.readAtMs==null&&!pt(l)?(0,Z.jsx)(`span`,{className:`ml-auto size-2 shrink-0 rounded-full bg-blue-500`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:i.filters.unread})}):null]}),(0,Z.jsx)(`div`,{className:`mt-1 truncate pl-4 text-xs text-fg-muted`,children:Je(e.trigger,i,a,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 pl-4 text-xs text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:d(`truncate`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.enabled?`${i.next}: ${ct(e.state.nextRunAtMs,i,o)}`:i.paused}),l?.status?(0,Z.jsx)(`span`,{className:d(`shrink-0 rounded-full px-1.5 py-0.5`,dt(l.status)),children:i.status[l.status]}):null]})]},e.id)},t[11]=a,t[12]=i,t[13]=o,t[14]=c,t[15]=r,t[16]=s,t[17]=e):e=t[17],l=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=o,t[7]=c,t[8]=r,t[9]=s,t[10]=l}else l=t[10];let u;return t[18]===l?u=t[19]:(u=(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:l}),t[18]=l,t[19]=u),u}function At(e,t){return t.createdAtMs-e.createdAtMs}function jt(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`completion_hook.started`:return n.completionHookStarted;case`completion_hook.completed`:return n.completionHookCompleted;case`completion_hook.failed`:return n.completionHookFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function Mt(e){let t=(0,ve.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,s]=(0,Y.useState)(a===void 0?!1:a),c;t[0]===n?c=t[1]:(c=JSON.stringify(n,null,2),t[0]=n,t[1]=c);let l=c,u;t[2]===l?u=t[3]:(u=l.split(`
|
|
2
|
-
`),t[2]=l,t[3]=u);let f=u.length,p=l.length>720||f>18,m;t[4]!==p||t[5]!==l?(m=p?`${l.split(`
|
|
3
|
-
`).slice(0,10).join(`
|
|
4
|
-
`).trimEnd()}...`:l,t[4]=p,t[5]=l,t[6]=m):m=t[6];let h=m,g;t[7]!==o||t[8]!==p||t[9]!==r||t[10]!==i?(g=p?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>s(Nt),"aria-expanded":o,children:[(0,Z.jsx)(`span`,{children:i}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[o?r.details.hideDetails:r.details.showDetails,(0,Z.jsx)(j,{className:d(`size-3.5 transition-transform`,o&&`rotate-180`),"aria-hidden":!0})]})]}):(0,Z.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:i}),t[7]=o,t[8]=p,t[9]=r,t[10]=i,t[11]=g):g=t[11];let _=o||!p?l:h,v;t[12]===_?v=t[13]:(v=(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:_}),t[12]=_,t[13]=v);let y;return t[14]!==g||t[15]!==v?(y=(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[g,v]}),t[14]=g,t[15]=v,t[16]=y):y=t[16],y}function Nt(e){return!e}function Pt(e){let t=(0,ve.c)(148),{className:n,run:r,events:i,labels:o,cronLabels:s,language:l,loading:u,repairDraft:p,repairLoading:m,repairApproved:h,busyAction:g,onRepairApprovedChange:_,onSuggestRepair:v,onApplyRepair:y}=e;if(!r){let e;t[0]===n?e=t[1]:(e=d(`flex min-h-64 flex-col justify-center rounded-lg border border-edge-subtle bg-surface-base px-4 text-center text-sm text-fg-muted shadow-surface`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(se,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===o.selectRun?i=t[4]:(i=(0,Z.jsx)(`div`,{className:`mt-2`,children:o.selectRun}),t[3]=o.selectRun,t[4]=i);let a;return t[5]!==e||t[6]!==i?(a=(0,Z.jsxs)(`aside`,{className:e,children:[r,i]}),t[5]=e,t[6]=i,t[7]=a):a=t[7],a}let b=r.error||r.summary,x=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,S=r.sessionKey?o.runDetail.openConversation:o.runDetail.openWorkflow,te=r.sessionKey?F:ae,ne=pt(r)?se:mt(r)?w:ie,C;t[8]===n?C=t[9]:(C=d(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=C);let T;t[10]===r.automationName?T=t[11]:(T=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=T);let O;t[12]===r.id?O=t[13]:(O=r.id.slice(0,8),t[12]=r.id,t[13]=O);let k;t[14]===O?k=t[15]:(k=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:O}),t[14]=O,t[15]=k);let A;t[16]!==T||t[17]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[T,k]}),t[16]=T,t[17]=k,t[18]=A):A=t[18];let M;t[19]===r.status?M=t[20]:(M=d(`shrink-0 rounded-full px-2 py-0.5 text-xs`,dt(r.status)),t[19]=r.status,t[20]=M);let N=o.status[r.status],oe;t[21]!==M||t[22]!==N?(oe=(0,Z.jsx)(`span`,{className:M,children:N}),t[21]=M,t[22]=N,t[23]=oe):oe=t[23];let P;t[24]!==A||t[25]!==oe?(P=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[A,oe]}),t[24]=A,t[25]=oe,t[26]=P):P=t[26];let I;t[27]!==o||t[28]!==l||t[29]!==r.createdAtMs?(I=ct(r.createdAtMs,o,l),t[27]=o,t[28]=l,t[29]=r.createdAtMs,t[30]=I):I=t[30];let L;t[31]===I?L=t[32]:(L=(0,Z.jsx)(`span`,{children:I}),t[31]=I,t[32]=L);let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=R):R=t[33];let z=o.details.duration,ce;t[34]!==o||t[35]!==r.durationMs?(ce=ft(r.durationMs,o),t[34]=o,t[35]=r.durationMs,t[36]=ce):ce=t[36];let B;t[37]!==o.details.duration||t[38]!==ce?(B=(0,Z.jsxs)(`span`,{children:[z,` `,ce]}),t[37]=o.details.duration,t[38]=ce,t[39]=B):B=t[39];let V;t[40]!==L||t[41]!==B?(V=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[L,R,B]}),t[40]=L,t[41]=B,t[42]=V):V=t[42];let H;t[43]!==o.repair||t[44]!==v||t[45]!==m||t[46]!==r?(H=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(f,{variant:`secondary`,onClick:()=>v(r),disabled:m,children:[(0,Z.jsx)(re,{className:`size-4`}),m?o.repair.generating:o.repair.suggest]})}):null,t[43]=o.repair,t[44]=v,t[45]=m,t[46]=r,t[47]=H):H=t[47];let le;t[48]!==V||t[49]!==H||t[50]!==P?(le=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[P,V,H]}),t[48]=V,t[49]=H,t[50]=P,t[51]=le):le=t[51];let ue;t[52]===r?ue=t[53]:(ue=pt(r)?`text-blue-500`:mt(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=ue);let U;t[54]===ue?U=t[55]:(U=d(`size-4`,ue),t[54]=ue,t[55]=U);let W;t[56]!==ne||t[57]!==U?(W=(0,Z.jsx)(ne,{className:U}),t[56]=ne,t[57]=U,t[58]=W):W=t[58];let G;t[59]!==o.runDetail.resultTitle||t[60]!==W?(G=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[W,o.runDetail.resultTitle]}),t[59]=o.runDetail.resultTitle,t[60]=W,t[61]=G):G=t[61];let K;t[62]!==te||t[63]!==S||t[64]!==x?(K=x?(0,Z.jsx)(f,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Z.jsxs)(a,{to:x,children:[(0,Z.jsx)(te,{className:`size-3.5`}),S,(0,Z.jsx)(D,{className:`size-3.5`})]})}):null,t[62]=te,t[63]=S,t[64]=x,t[65]=K):K=t[65];let q;t[66]!==G||t[67]!==K?(q=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[G,K]}),t[66]=G,t[67]=K,t[68]=q):q=t[68];let de=r.error&&`border-red-500/25 bg-red-500/5`,fe;t[69]===de?fe=t[70]:(fe=d(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,de),t[69]=de,t[70]=fe);let J;t[71]!==o.runDetail.noResult||t[72]!==o.runDetail.resultPending||t[73]!==b||t[74]!==r?(J=b?r.error?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:b}):(0,Z.jsx)(c,{content:b,compact:!0,className:`text-sm`,openHttpLinksInNewTab:!0}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:pt(r)?o.runDetail.resultPending:o.runDetail.noResult}),t[71]=o.runDetail.noResult,t[72]=o.runDetail.resultPending,t[73]=b,t[74]=r,t[75]=J):J=t[75];let pe;t[76]!==fe||t[77]!==J?(pe=(0,Z.jsx)(`div`,{className:fe,children:J}),t[76]=fe,t[77]=J,t[78]=pe):pe=t[78];let me;t[79]!==q||t[80]!==pe?(me=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[q,pe]}),t[79]=q,t[80]=pe,t[81]=me):me=t[81];let he;t[82]===o.runDetail.runInfo?he=t[83]:(he=(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.runDetail.runInfo}),t[82]=o.runDetail.runInfo,t[83]=he);let ge;t[84]!==s||t[85]!==o||t[86]!==l||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(ge=r.manual?o.trigger.manual:Je(r.triggerSnapshot,o,s,l),t[84]=s,t[85]=o,t[86]=l,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=ge):ge=t[89];let _e;t[90]!==o.explain.whyRan||t[91]!==ge?(_e=(0,Z.jsx)(Bt,{label:o.explain.whyRan,value:ge}),t[90]=o.explain.whyRan,t[91]=ge,t[92]=_e):_e=t[92];let Y=o.details.started,ye;t[93]!==o||t[94]!==l||t[95]!==r.startedAtMs?(ye=ct(r.startedAtMs,o,l),t[93]=o,t[94]=l,t[95]=r.startedAtMs,t[96]=ye):ye=t[96];let be;t[97]!==o.details.started||t[98]!==ye?(be=(0,Z.jsx)(Bt,{label:Y,value:ye}),t[97]=o.details.started,t[98]=ye,t[99]=be):be=t[99];let xe;t[100]!==o.details.model||t[101]!==r.model?(xe=r.model?(0,Z.jsx)(Bt,{label:o.details.model,value:r.model}):null,t[100]=o.details.model,t[101]=r.model,t[102]=xe):xe=t[102];let Se;t[103]!==_e||t[104]!==be||t[105]!==xe?(Se=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[_e,be,xe]}),t[103]=_e,t[104]=be,t[105]=xe,t[106]=Se):Se=t[106];let Ce;t[107]!==he||t[108]!==Se?(Ce=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[he,Se]}),t[107]=he,t[108]=Se,t[109]=Ce):Ce=t[109];let we;t[110]!==g||t[111]!==o||t[112]!==y||t[113]!==_||t[114]!==h||t[115]!==p||t[116]!==r?(we=p?(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.repair.title}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:p.explanation}),p.expectedEffect?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:p.expectedEffect}):null,(0,Z.jsx)(Dt,{title:o.repair.risks,items:p.risks,empty:o.none}),(0,Z.jsx)(Mt,{value:p.patch,labels:o,title:o.details.repairPatch}),p.requiresApproval?(0,Z.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:h,onChange:e=>_(e.target.checked)}),(0,Z.jsx)(`span`,{children:o.repair.approval})]}):null,(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsx)(f,{variant:`primary`,onClick:()=>y(r),disabled:g===`run:${r.id}:repair`||p.requiresApproval&&!h,children:g===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[110]=g,t[111]=o,t[112]=y,t[113]=_,t[114]=h,t[115]=p,t[116]=r,t[117]=we):we=t[117];let Te;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,Z.jsx)(ee,{className:`size-4 shrink-0`}),t[118]=Te):Te=t[118];let Ee;t[119]===o.runDetail.technicalEvents?Ee=t[120]:(Ee=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[Te,o.runDetail.technicalEvents]}),t[119]=o.runDetail.technicalEvents,t[120]=Ee);let De;t[121]!==i.length||t[122]!==o.runDetail.eventCount?(De=o.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=o.runDetail.eventCount,t[123]=De):De=t[123];let Oe;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Z.jsx)(j,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=Oe):Oe=t[124];let X;t[125]===De?X=t[126]:(X=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[De,Oe]}),t[125]=De,t[126]=X);let ke;t[127]!==Ee||t[128]!==X?(ke=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 rounded-md outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[Ee,X]}),t[127]=Ee,t[128]=X,t[129]=ke):ke=t[129];let Ae;t[130]===o.runDetail.technicalEventsDescription?Ae=t[131]:(Ae=(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:o.runDetail.technicalEventsDescription}),t[130]=o.runDetail.technicalEventsDescription,t[131]=Ae);let je;t[132]!==i||t[133]!==o||t[134]!==l||t[135]!==u?(je=(0,Z.jsx)(`div`,{className:`mt-4`,children:u?(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-label":o.loading,children:[(0,Z.jsx)(E,{className:`h-10 w-full`}),(0,Z.jsx)(E,{className:`h-10 w-4/5`}),(0,Z.jsx)(E,{className:`h-10 w-11/12`})]}):i.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.empty.events}):(0,Z.jsx)(`ol`,{className:`space-y-3`,children:i.map(e=>(0,Z.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,Z.jsx)(`span`,{className:d(`mt-1 size-2 rounded-full`,Vt(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:jt(e,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[ct(e.createdAtMs,o,l),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,Z.jsxs)(`details`,{className:`group/event mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-2.5 py-2 text-xs font-medium text-fg-muted outline-none hover:text-fg`,children:[o.details.eventData,(0,Z.jsx)(j,{className:`size-3.5 transition-transform group-open/event:rotate-180`})]}),(0,Z.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-all border-t border-edge/70 px-2.5 py-2 text-xs leading-relaxed text-fg-muted`,children:JSON.stringify(e.data,null,2)})]}):null]})]},e.id))})}),t[132]=i,t[133]=o,t[134]=l,t[135]=u,t[136]=je):je=t[136];let Me;t[137]!==ke||t[138]!==Ae||t[139]!==je?(Me=(0,Z.jsxs)(`details`,{className:`group px-4 py-3`,children:[ke,Ae,je]}),t[137]=ke,t[138]=Ae,t[139]=je,t[140]=Me):Me=t[140];let Ne;return t[141]!==C||t[142]!==le||t[143]!==me||t[144]!==Ce||t[145]!==we||t[146]!==Me?(Ne=(0,Z.jsxs)(`aside`,{className:C,children:[le,me,Ce,we,Me]}),t[141]=C,t[142]=le,t[143]=me,t[144]=Ce,t[145]=we,t[146]=Me,t[147]=Ne):Ne=t[147],Ne}function Ft(e){let t=(0,ve.c)(83),{automation:n,runs:r,labels:i,cronLabels:a,language:o,projects:s,busyAction:l,onEdit:u,onSelectRun:p,onAction:m}=e,h=l===`automation:${n.id}:run`,g=l===`automation:${n.id}:toggle`,_=l===`automation:${n.id}:delete`,v;t[0]===n?v=t[1]:(v=vt(n),t[0]=n,t[1]=v);let y=v,b;t[2]===n.name?b=t[3]:(b=(0,Z.jsx)(`h2`,{className:`truncate text-lg font-semibold text-fg`,children:n.name}),t[2]=n.name,t[3]=b);let x=n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`,S;t[4]===x?S=t[5]:(S=d(`shrink-0 rounded-full px-2 py-0.5 text-xs`,x),t[4]=x,t[5]=S);let ee=n.enabled?i.enabled:i.paused,C;t[6]!==S||t[7]!==ee?(C=(0,Z.jsx)(`span`,{className:S,children:ee}),t[6]=S,t[7]=ee,t[8]=C):C=t[8];let w;t[9]!==b||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b,C]}),t[9]=b,t[10]=C,t[11]=w):w=t[11];let T;t[12]===n?T=t[13]:(T=yt(n)?(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:yt(n)}):null,t[12]=n,t[13]=T);let E;t[14]!==w||t[15]!==T?(E=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[w,T]}),t[14]=w,t[15]=T,t[16]=E):E=t[16];let D;t[17]!==n||t[18]!==l||t[19]!==_||t[20]!==i.dashboard.delete||t[21]!==i.dashboard.deleted||t[22]!==i.dashboard.pause||t[23]!==i.dashboard.resume||t[24]!==i.dashboard.resumed||t[25]!==i.dashboard.runNow||t[26]!==i.details||t[27]!==i.edit||t[28]!==i.feedback||t[29]!==m||t[30]!==u||t[31]!==y||t[32]!==h||t[33]!==g?(D=y?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(f,{variant:`secondary`,disabled:l!==null,onClick:()=>void m(`automation:${n.id}:toggle`,()=>n.enabled?V.pause(n.id):V.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[g?(0,Z.jsx)(z,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(ce,{className:`size-4`}):(0,Z.jsx)(B,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Z.jsxs)(f,{variant:`primary`,disabled:l!==null,onClick:()=>void m(`automation:${n.id}:run`,()=>V.runNow(n.id),i.feedback.rerunQueued),children:[h?(0,Z.jsx)(z,{className:`size-4 animate-spin`}):(0,Z.jsx)(B,{className:`size-4`}),i.dashboard.runNow]}),(0,Z.jsxs)(ne,{children:[(0,Z.jsx)(k,{asChild:!0,children:(0,Z.jsx)(f,{variant:`ghost`,className:`size-9 p-0`,"aria-label":i.details.moreActions,children:(0,Z.jsx)(I,{className:`size-4`})})}),(0,Z.jsx)(M,{children:(0,Z.jsxs)(te,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsxs)(ue,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>u(n),children:[(0,Z.jsx)(oe,{className:`size-4`}),i.edit]}),(0,Z.jsxs)(ue,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-red-700 outline-none hover:bg-red-500/10 dark:text-red-300`,disabled:l!==null,onSelect:()=>void m(`automation:${n.id}:delete`,()=>V.remove(n.id),i.dashboard.deleted),children:[_?(0,Z.jsx)(z,{className:`size-4 animate-spin`}):(0,Z.jsx)(le,{className:`size-4`}),i.dashboard.delete]})]})})]})]}),t[17]=n,t[18]=l,t[19]=_,t[20]=i.dashboard.delete,t[21]=i.dashboard.deleted,t[22]=i.dashboard.pause,t[23]=i.dashboard.resume,t[24]=i.dashboard.resumed,t[25]=i.dashboard.runNow,t[26]=i.details,t[27]=i.edit,t[28]=i.feedback,t[29]=m,t[30]=u,t[31]=y,t[32]=h,t[33]=g,t[34]=D):D=t[34];let O;t[35]!==D||t[36]!==E?(O=(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[E,D]}),t[35]=D,t[36]=E,t[37]=O):O=t[37];let re;t[38]===i.info.task?re=t[39]:(re=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.info.task}),t[38]=i.info.task,t[39]=re);let A;t[40]!==n||t[41]!==i?(A=gt(n,i),t[40]=n,t[41]=i,t[42]=A):A=t[42];let j;t[43]===A?j=t[44]:(j=(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:(0,Z.jsx)(c,{content:A,compact:!0,openHttpLinksInNewTab:!0})}),t[43]=A,t[44]=j);let N;t[45]!==re||t[46]!==j?(N=(0,Z.jsxs)(`section`,{children:[re,j]}),t[45]=re,t[46]=j,t[47]=N):N=t[47];let ae;t[48]!==n||t[49]!==a||t[50]!==i||t[51]!==o||t[52]!==s?(ae=(0,Z.jsx)(Lt,{automation:n,labels:i,cronLabels:a,language:o,projects:s}),t[48]=n,t[49]=a,t[50]=i,t[51]=o,t[52]=s,t[53]=ae):ae=t[53];let P;t[54]===i.dashboard.runHistory?P=t[55]:(P=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),t[54]=i.dashboard.runHistory,t[55]=P);let F;t[56]===i.dashboard.runHistoryDescription?F=t[57]:(F=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription}),t[56]=i.dashboard.runHistoryDescription,t[57]=F);let L;t[58]!==P||t[59]!==F?(L=(0,Z.jsxs)(`div`,{children:[P,F]}),t[58]=P,t[59]=F,t[60]=L):L=t[60];let R;t[61]===r.length?R=t[62]:(R=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[61]=r.length,t[62]=R);let H;t[63]!==L||t[64]!==R?(H=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[L,R]}),t[63]=L,t[64]=R,t[65]=H):H=t[65];let U;t[66]!==i||t[67]!==o||t[68]!==p||t[69]!==r?(U=r.length===0?(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(se,{className:`size-5`}),title:i.empty.runs}):(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:r.slice(0,8).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`block w-full p-3 text-left hover:bg-surface-hover`,onClick:()=>p(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,Z.jsx)(ie,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Z.jsx)(se,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:ct(e.createdAtMs,i,o)})]}),(0,Z.jsx)(`span`,{className:d(`shrink-0 rounded-full px-2 py-0.5 text-xs`,dt(e.status)),children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:d(`mt-1 line-clamp-2 pl-6 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||lt(e.actionSnapshot,i)})]},e.id))}),t[66]=i,t[67]=o,t[68]=p,t[69]=r,t[70]=U):U=t[70];let W;t[71]!==H||t[72]!==U?(W=(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[H,U]}),t[71]=H,t[72]=U,t[73]=W):W=t[73];let G;t[74]!==ae||t[75]!==W?(G=(0,Z.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[20rem_minmax(0,1fr)]`,children:[ae,W]}),t[74]=ae,t[75]=W,t[76]=G):G=t[76];let K;t[77]!==N||t[78]!==G?(K=(0,Z.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[N,G]}),t[77]=N,t[78]=G,t[79]=K):K=t[79];let q;return t[80]!==O||t[81]!==K?(q=(0,Z.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[O,K]}),t[80]=O,t[81]=K,t[82]=q):q=t[82],q}function It(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function Lt(e){let t=(0,ve.c)(146),{automation:n,labels:r,cronLabels:i,language:a,projects:o}=e,s,c,l,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=ut(n),o;t[15]!==n||t[16]!==r||t[17]!==a?(o=Ye(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=o):o=t[18];let v=o,y;t[19]!==n.state.nextRunAtMs||t[20]!==a?(y=n.state.nextRunAtMs?We(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=y):y=t[21];let b=y;if(t[22]!==n.trigger.eventType||t[23]!==n.trigger.kind||t[24]!==n.trigger.schedule||t[25]!==n.trigger.secretId||t[26]!==n.trigger.source||t[27]!==r.info.anchor||t[28]!==r.info.calendarSchedule||t[29]!==r.info.eventSource||t[30]!==r.info.eventType||t[31]!==r.info.expression||t[32]!==r.info.fixedInterval||t[33]!==r.info.oneTimeSchedule||t[34]!==r.info.rawInterval||t[35]!==r.info.scheduleType||t[36]!==r.info.timezone||t[37]!==r.info.webhookSecret||t[38]!==a){if(_=[],n.trigger.kind===`schedule`){let e=n.trigger.schedule,i=e.kind===`interval`?r.info.fixedInterval:e.kind===`cron`?r.info.calendarSchedule:r.info.oneTimeSchedule,o;if(t[40]!==r.info.scheduleType||t[41]!==i?(o={label:r.info.scheduleType,value:i},t[40]=r.info.scheduleType,t[41]=i,t[42]=o):o=t[42],_.push(o),e.kind===`interval`){let n=`${e.everyMs} ms`,i;if(t[43]!==r.info.rawInterval||t[44]!==n?(i={label:r.info.rawInterval,value:n},t[43]=r.info.rawInterval,t[44]=n,t[45]=i):i=t[45],_.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=We(e.anchorMs,a),t[46]=a,t[47]=e.anchorMs,t[48]=i):i=t[48];let o;t[49]!==r.info.anchor||t[50]!==i?(o={label:n,value:i},t[49]=r.info.anchor,t[50]=i,t[51]=o):o=t[51],_.push(o)}}else if(e.kind===`cron`){let n;if(t[52]!==r.info.expression||t[53]!==e.expr?(n={label:r.info.expression,value:e.expr},t[52]=r.info.expression,t[53]=e.expr,t[54]=n):n=t[54],_.push(n),e.tz){let n;t[55]!==r.info.timezone||t[56]!==e.tz?(n={label:r.info.timezone,value:e.tz},t[55]=r.info.timezone,t[56]=e.tz,t[57]=n):n=t[57],_.push(n)}}else{let n;t[58]!==r.info.oneTimeSchedule||t[59]!==e.at?(n={label:r.info.oneTimeSchedule,value:e.at},t[58]=r.info.oneTimeSchedule,t[59]=e.at,t[60]=n):n=t[60],_.push(n)}}else if(n.trigger.kind===`event`){let e;if(t[61]!==n.trigger.eventType||t[62]!==r.info.eventType?(e={label:r.info.eventType,value:n.trigger.eventType},t[61]=n.trigger.eventType,t[62]=r.info.eventType,t[63]=e):e=t[63],_.push(e),n.trigger.source){let e;t[64]!==n.trigger.source||t[65]!==r.info.eventSource?(e={label:r.info.eventSource,value:n.trigger.source},t[64]=n.trigger.source,t[65]=r.info.eventSource,t[66]=e):e=t[66],_.push(e)}}else if(n.trigger.kind===`webhook`&&n.trigger.secretId){let e;t[67]!==n.trigger.secretId||t[68]!==r.info.webhookSecret?(e={label:r.info.webhookSecret,value:n.trigger.secretId},t[67]=n.trigger.secretId,t[68]=r.info.webhookSecret,t[69]=e):e=t[69],_.push(e)}t[22]=n.trigger.eventType,t[23]=n.trigger.kind,t[24]=n.trigger.schedule,t[25]=n.trigger.secretId,t[26]=n.trigger.source,t[27]=r.info.anchor,t[28]=r.info.calendarSchedule,t[29]=r.info.eventSource,t[30]=r.info.eventType,t[31]=r.info.expression,t[32]=r.info.fixedInterval,t[33]=r.info.oneTimeSchedule,t[34]=r.info.rawInterval,t[35]=r.info.scheduleType,t[36]=r.info.timezone,t[37]=r.info.webhookSecret,t[38]=a,t[39]=_}else _=t[39];h=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?g=t[71]:(g=(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.info.overview})}),t[70]=r.info.overview,t[71]=g),f=`grid gap-4 p-4`;let x;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t[72]=x):x=t[72];let te=r.info.schedule,ne;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(ne=Je(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=ne):ne=t[77];let C=n.enabled?`${r.info.nextRun}:${v}`:v;t[78]!==r.info.schedule||t[79]!==b||t[80]!==ne||t[81]!==C?(p=(0,Z.jsx)(zt,{icon:x,label:te,value:ne,description:C,descriptionTitle:b}),t[78]=r.info.schedule,t[79]=b,t[80]=ne,t[81]=C,t[82]=p):p=t[82];let w;t[83]===n.action.kind?w=t[84]:(w=n.action.kind===`workflow`?(0,Z.jsx)(ae,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_recipe`?(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(L,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=w);let T=r.info.action,E;t[85]!==n.action||t[86]!==r?(E=lt(n.action,r),t[85]=n.action,t[86]=r,t[87]=E):E=t[87],t[88]!==r.info.action||t[89]!==w||t[90]!==E?(m=(0,Z.jsx)(zt,{icon:w,label:T,value:E}),t[88]=r.info.action,t[89]=w,t[90]=E,t[91]=m):m=t[91],s=zt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[92]=c):c=t[92],l=r.info.permission,u=r.safety[e],d=It(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_}else s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];let v;t[93]!==s||t[94]!==c||t[95]!==l||t[96]!==u||t[97]!==d?(v=(0,Z.jsx)(s,{icon:c,label:l,value:u,description:d}),t[93]=s,t[94]=c,t[95]=l,t[96]=u,t[97]=d,t[98]=v):v=t[98];let y;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),t[99]=y):y=t[99];let b;t[100]!==n.projectId||t[101]!==r.info.noProject||t[102]!==o?(b=o.find(e=>e.id===n.projectId)?.name??r.info.noProject,t[100]=n.projectId,t[101]=r.info.noProject,t[102]=o,t[103]=b):b=t[103];let x;t[104]!==r.info.project||t[105]!==b?(x=(0,Z.jsx)(zt,{icon:y,label:r.info.project,value:b}),t[104]=r.info.project,t[105]=b,t[106]=x):x=t[106];let te;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(F,{className:`size-4`,"aria-hidden":!0}),t[107]=te):te=t[107];let ne=n.conversationMode===`continuous`?r.info.continuousConversation:r.info.newConversation,C;t[108]!==r.info.conversation||t[109]!==ne?(C=(0,Z.jsx)(zt,{icon:te,label:r.info.conversation,value:ne}),t[108]=r.info.conversation,t[109]=ne,t[110]=C):C=t[110];let T;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[111]=T):T=t[111];let E=n.notificationPolicy===`all`?r.info.notifyAll:n.notificationPolicy===`none`?r.info.notifyNone:r.info.notifyAttention,D;t[112]!==r.info.notifications||t[113]!==E?(D=(0,Z.jsx)(zt,{icon:T,label:r.info.notifications,value:E}),t[112]=r.info.notifications,t[113]=E,t[114]=D):D=t[114];let re;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t[115]=re):re=t[115];let ie=r.info.lastRun,k;t[116]!==n||t[117]!==r||t[118]!==a?(k=Xe(n,r,a),t[116]=n,t[117]=r,t[118]=a,t[119]=k):k=t[119];let A=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,M;t[120]!==r.info.lastRun||t[121]!==k||t[122]!==A?(M=(0,Z.jsx)(zt,{icon:re,label:ie,value:k,valueTone:A}),t[120]=r.info.lastRun,t[121]=k,t[122]=A,t[123]=M):M=t[123];let N;t[124]!==n.state.consecutiveFailures||t[125]!==n.state.lastError||t[126]!==r.dashboard?(N=n.state.consecutiveFailures?(0,Z.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:[r.dashboard.failures,`:`,n.state.consecutiveFailures,n.state.lastError?(0,Z.jsx)(`p`,{className:`mt-1 break-words text-xs`,children:n.state.lastError}):null]}):n.state.lastError?(0,Z.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null,t[124]=n.state.consecutiveFailures,t[125]=n.state.lastError,t[126]=r.dashboard,t[127]=N):N=t[127];let oe;t[128]!==r.info.technicalDetails||t[129]!==_?(oe=_.length>0?(0,Z.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(`span`,{children:r.info.technicalDetails}),(0,Z.jsx)(j,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:_.map(Rt)})]}):null,t[128]=r.info.technicalDetails,t[129]=_,t[130]=oe):oe=t[130];let P;t[131]!==v||t[132]!==x||t[133]!==C||t[134]!==D||t[135]!==M||t[136]!==N||t[137]!==oe||t[138]!==f||t[139]!==p||t[140]!==m?(P=(0,Z.jsxs)(`div`,{className:f,children:[p,m,v,x,C,D,M,N,oe]}),t[131]=v,t[132]=x,t[133]=C,t[134]=D,t[135]=M,t[136]=N,t[137]=oe,t[138]=f,t[139]=p,t[140]=m,t[141]=P):P=t[141];let I;return t[142]!==P||t[143]!==h||t[144]!==g?(I=(0,Z.jsxs)(`aside`,{className:h,children:[g,P]}),t[142]=P,t[143]=h,t[144]=g,t[145]=I):I=t[145],I}function Rt(e){return(0,Z.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.label}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-xs text-fg-muted`,children:e.value})]},`${e.label}:${e.value}`)}function zt(e){let t=(0,ve.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:o,valueTone:s}=e,c=s===void 0?`default`:s,l;t[0]===n?l=t[1]:(l=(0,Z.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=u);let f=c===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,p;t[4]===f?p=t[5]:(p=d(`mt-1 text-sm font-medium leading-5`,f),t[4]=f,t[5]=p);let m;t[6]!==p||t[7]!==i?(m=(0,Z.jsx)(`div`,{className:p,children:i}),t[6]=p,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==a||t[10]!==o?(h=a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,title:o,children:a}):null,t[9]=a,t[10]=o,t[11]=h):h=t[11];let g;t[12]!==u||t[13]!==m||t[14]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[u,m,h]}),t[12]=u,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==l||t[17]!==g?(_=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[l,g]}),t[16]=l,t[17]=g,t[18]=_):_=t[18],_}function Bt(e){let t=(0,ve.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5rem_1fr] gap-2`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Vt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Ht(e){let t=(0,ve.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Ut(e){let t=(0,ve.c)(5),{icon:n,title:r}=e,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`mt-2 text-sm`,children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,Z.jsxs)(`div`,{className:`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge-subtle bg-surface-base text-fg-muted shadow-surface`,children:[n,i]}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Wt(e){let t=(0,ve.c)(281),{form:n,labels:r,setForm:i,projects:a,workflowDefinitions:c,selectedWorkflow:l,workflowsLoading:u,browserWorkflows:f,selectedBrowserWorkflow:m,browserWorkflowsLoading:h,agentOptions:g,agentsLoading:_,language:v}=e,y=p(v).agentsSettings,b;t[0]===i?b=t[1]:(b=e=>i(t=>({...t,...e})),t[0]=i,t[1]=b);let x=b,S=Be(n.intervalValue,n.intervalUnit),ee=Date.now(),te;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(te=[1,2,3],t[2]=te):te=t[2];let ne;t[3]!==S||t[4]!==ee||t[5]!==v?(ne=te.map(e=>Ke(ee+S*e,v,ee)),t[3]=S,t[4]=ee,t[5]=v,t[6]=ne):ne=t[6];let C=ne,w,E;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==c?(w=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=c[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},E=[n.actionMode,n.workflowId,i,c],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=c,t[11]=w,t[12]=E):(w=t[11],E=t[12]),(0,Y.useEffect)(w,E);let D,O;t[13]!==f||t[14]!==n.actionMode||t[15]!==n.browserWorkflowId||t[16]!==i?(D=()=>{if(n.actionMode!==`browser_recipe`||n.browserWorkflowId.trim())return;let e=f[0];e&&i(t=>({...t,browserWorkflowId:e.id,browserWorkflowInputs:ge(e)}))},O=[f,n.actionMode,n.browserWorkflowId,i],t[13]=f,t[14]=n.actionMode,t[15]=n.browserWorkflowId,t[16]=i,t[17]=D,t[18]=O):(D=t[17],O=t[18]),(0,Y.useEffect)(D,O);let re;t[19]===x?re=t[20]:(re=e=>x({name:e.target.value}),t[19]=x,t[20]=re);let ie;t[21]!==n.name||t[22]!==re?(ie=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:re}),t[21]=n.name,t[22]=re,t[23]=ie):ie=t[23];let k;t[24]!==r.form.name||t[25]!==ie?(k=(0,Z.jsx)($,{label:r.form.name,children:ie}),t[24]=r.form.name,t[25]=ie,t[26]=k):k=t[26];let A;t[27]===x?A=t[28]:(A=e=>x({description:e.target.value}),t[27]=x,t[28]=A);let M;t[29]!==n.description||t[30]!==A?(M=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:A}),t[29]=n.description,t[30]=A,t[31]=M):M=t[31];let N;t[32]!==r.form.description||t[33]!==M?(N=(0,Z.jsx)($,{label:r.form.description,children:M}),t[32]=r.form.description,t[33]=M,t[34]=N):N=t[34];let ae=r.form.project,oe=n.projectId,P;t[35]===x?P=t[36]:(P=e=>x({projectId:e.target.value}),t[35]=x,t[36]=P);let F;t[37]===r.form.noProject?F=t[38]:(F=(0,Z.jsx)(s,{value:``,children:r.form.noProject}),t[37]=r.form.noProject,t[38]=F);let I;t[39]===a?I=t[40]:(I=a.map(qt),t[39]=a,t[40]=I);let L;t[41]!==n.projectId||t[42]!==P||t[43]!==F||t[44]!==I?(L=(0,Z.jsxs)(o,{className:Q,value:oe,onChange:P,children:[F,I]}),t[41]=n.projectId,t[42]=P,t[43]=F,t[44]=I,t[45]=L):L=t[45];let se;t[46]!==r.form.project||t[47]!==L?(se=(0,Z.jsx)($,{label:ae,children:L}),t[46]=r.form.project,t[47]=L,t[48]=se):se=t[48];let R;t[49]===r.form.trigger?R=t[50]:(R=(0,Z.jsx)(Jt,{title:r.form.trigger}),t[49]=r.form.trigger,t[50]=R);let z;t[51]===x?z=t[52]:(z=e=>x({triggerMode:e.target.value}),t[51]=x,t[52]=z);let ce;t[53]===r.trigger.manual?ce=t[54]:(ce=(0,Z.jsx)(s,{value:`manual`,children:r.trigger.manual}),t[53]=r.trigger.manual,t[54]=ce);let B;t[55]===r.trigger.once?B=t[56]:(B=(0,Z.jsx)(s,{value:`once`,children:r.trigger.once}),t[55]=r.trigger.once,t[56]=B);let V;t[57]===r.trigger.daily?V=t[58]:(V=(0,Z.jsx)(s,{value:`daily`,children:r.trigger.daily}),t[57]=r.trigger.daily,t[58]=V);let H;t[59]===r.trigger.weekly?H=t[60]:(H=(0,Z.jsx)(s,{value:`weekly`,children:r.trigger.weekly}),t[59]=r.trigger.weekly,t[60]=H);let le;t[61]===r.trigger.interval?le=t[62]:(le=(0,Z.jsx)(s,{value:`interval`,children:r.trigger.interval}),t[61]=r.trigger.interval,t[62]=le);let ue;t[63]===r.trigger.customCron?ue=t[64]:(ue=(0,Z.jsx)(s,{value:`cron`,children:r.trigger.customCron}),t[63]=r.trigger.customCron,t[64]=ue);let U;t[65]===r.trigger.webhook?U=t[66]:(U=(0,Z.jsx)(s,{value:`webhook`,children:r.trigger.webhook}),t[65]=r.trigger.webhook,t[66]=U);let W;t[67]===r.trigger.taskBlocked?W=t[68]:(W=(0,Z.jsx)(s,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[67]=r.trigger.taskBlocked,t[68]=W);let K;t[69]===r.trigger.noteCreated?K=t[70]:(K=(0,Z.jsx)(s,{value:`noteCreated`,children:r.trigger.noteCreated}),t[69]=r.trigger.noteCreated,t[70]=K);let de;t[71]===r.trigger.workflowFailed?de=t[72]:(de=(0,Z.jsx)(s,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[71]=r.trigger.workflowFailed,t[72]=de);let fe;t[73]===r.trigger.sessionUpdated?fe=t[74]:(fe=(0,Z.jsx)(s,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[73]=r.trigger.sessionUpdated,t[74]=fe);let J;t[75]===r.trigger.customEvent?J=t[76]:(J=(0,Z.jsx)(s,{value:`event`,children:r.trigger.customEvent}),t[75]=r.trigger.customEvent,t[76]=J);let me;t[77]!==n.triggerMode||t[78]!==z||t[79]!==ce||t[80]!==B||t[81]!==V||t[82]!==H||t[83]!==le||t[84]!==ue||t[85]!==U||t[86]!==W||t[87]!==K||t[88]!==de||t[89]!==fe||t[90]!==J?(me=(0,Z.jsxs)(o,{className:Q,value:n.triggerMode,onChange:z,children:[ce,B,V,H,le,ue,U,W,K,de,fe,J]}),t[77]=n.triggerMode,t[78]=z,t[79]=ce,t[80]=B,t[81]=V,t[82]=H,t[83]=le,t[84]=ue,t[85]=U,t[86]=W,t[87]=K,t[88]=de,t[89]=fe,t[90]=J,t[91]=me):me=t[91];let he;t[92]!==n.onceAt||t[93]!==n.triggerMode||t[94]!==r.form.onceAt||t[95]!==x?(he=n.triggerMode===`once`?(0,Z.jsx)($,{label:r.form.onceAt,children:(0,Z.jsx)(`input`,{className:Q,type:`datetime-local`,value:n.onceAt,onChange:e=>x({onceAt:e.target.value})})}):null,t[92]=n.onceAt,t[93]=n.triggerMode,t[94]=r.form.onceAt,t[95]=x,t[96]=he):he=t[96];let ye;t[97]!==n.time||t[98]!==n.triggerMode||t[99]!==n.weekday||t[100]!==r.form.day||t[101]!==r.form.time||t[102]!==r.weekdays||t[103]!==x?(ye=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.time,children:(0,Z.jsx)(G,{value:n.time,onChange:e=>x({time:e}),ariaLabel:r.form.time})}),n.triggerMode===`weekly`?(0,Z.jsx)($,{label:r.form.day,children:(0,Z.jsxs)(o,{className:Q,value:n.weekday,onChange:e=>x({weekday:e.target.value}),children:[(0,Z.jsx)(s,{value:`1`,children:r.weekdays.monday}),(0,Z.jsx)(s,{value:`2`,children:r.weekdays.tuesday}),(0,Z.jsx)(s,{value:`3`,children:r.weekdays.wednesday}),(0,Z.jsx)(s,{value:`4`,children:r.weekdays.thursday}),(0,Z.jsx)(s,{value:`5`,children:r.weekdays.friday}),(0,Z.jsx)(s,{value:`6`,children:r.weekdays.saturday}),(0,Z.jsx)(s,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[97]=n.time,t[98]=n.triggerMode,t[99]=n.weekday,t[100]=r.form.day,t[101]=r.form.time,t[102]=r.weekdays,t[103]=x,t[104]=ye):ye=t[104];let be=n.triggerMode===`interval`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsx)($,{label:r.form.intervalEvery,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Z.jsx)(`input`,{className:Q,type:`number`,min:6e4/Be(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>x({intervalValue:e.target.value})}),(0,Z.jsxs)(o,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;x({intervalValue:Ve(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,Z.jsx)(s,{value:`minute`,children:r.form.intervalUnits.minute}),(0,Z.jsx)(s,{value:`hour`,children:r.form.intervalUnits.hour}),(0,Z.jsx)(s,{value:`day`,children:r.form.intervalUnits.day}),(0,Z.jsx)(s,{value:`week`,children:r.form.intervalUnits.week})]})]})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.form.commonIntervals}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Qe.map(e=>{let t=Be(e.value,e.unit),n=t===S;return(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:d(`rounded-full border px-2.5 py-1 text-xs transition-colors`,n?`border-accent bg-accent/10 text-accent`:`border-edge-subtle text-fg-muted hover:border-edge hover:bg-surface-hover hover:text-fg`),onClick:()=>x({intervalValue:e.value,intervalUnit:e.unit}),children:He(t,v)},`${e.value}:${e.unit}`)})})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:Ue(S,v)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,C.join(v===`zh`?`、`:`, `)]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,xe;t[105]!==n.cronExpr||t[106]!==n.triggerMode||t[107]!==r.form.expression||t[108]!==x?(xe=n.triggerMode===`cron`?(0,Z.jsx)($,{label:r.form.expression,children:(0,Z.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>x({cronExpr:e.target.value})})}):null,t[105]=n.cronExpr,t[106]=n.triggerMode,t[107]=r.form.expression,t[108]=x,t[109]=xe):xe=t[109];let Se;t[110]!==n.triggerMode||t[111]!==n.webhookSecretId||t[112]!==r.form.secretId||t[113]!==x?(Se=n.triggerMode===`webhook`?(0,Z.jsx)($,{label:r.form.secretId,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>x({webhookSecretId:e.target.value})})}):null,t[110]=n.triggerMode,t[111]=n.webhookSecretId,t[112]=r.form.secretId,t[113]=x,t[114]=Se):Se=t[114];let Ce;t[115]!==n.eventPayloadMatch||t[116]!==n.eventSource||t[117]!==n.eventType||t[118]!==n.triggerMode||t[119]!==r.form.eventPayloadMatch||t[120]!==r.form.eventSource||t[121]!==r.form.eventType||t[122]!==r.form.invalidJsonObject||t[123]!==x?(Ce=n.triggerMode===`event`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.eventType,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventType,onChange:e=>x({eventType:e.target.value})})}),(0,Z.jsx)($,{label:r.form.eventSource,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>x({eventSource:e.target.value})})})]}),(0,Z.jsxs)($,{label:r.form.eventPayloadMatch,children:[(0,Z.jsx)(`textarea`,{className:d(Q,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>x({eventPayloadMatch:e.target.value}),placeholder:`{
|
|
5
|
-
"status": "blocked"
|
|
6
|
-
}`}),at(n.eventPayloadMatch)?null:(0,Z.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[115]=n.eventPayloadMatch,t[116]=n.eventSource,t[117]=n.eventType,t[118]=n.triggerMode,t[119]=r.form.eventPayloadMatch,t[120]=r.form.eventSource,t[121]=r.form.eventType,t[122]=r.form.invalidJsonObject,t[123]=x,t[124]=Ce):Ce=t[124];let we;t[125]===r.form.action?we=t[126]:(we=(0,Z.jsx)(Jt,{title:r.form.action}),t[125]=r.form.action,t[126]=we);let Te;t[127]!==n.timeoutSeconds||t[128]!==n.workflowId||t[129]!==x||t[130]!==c?(Te=e=>{let t=e.target.value,r=Number.parseInt(n.timeoutSeconds,10);x({actionMode:t,...r===600||r===1800?{timeoutSeconds:t===`browser_recipe`?`600`:`1800`}:{},...t===`browser_recipe`?{safetyMode:`auto_apply`}:{},...t===`workflow`&&!n.workflowId.trim()&&c[0]?{workflowId:c[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[127]=n.timeoutSeconds,t[128]=n.workflowId,t[129]=x,t[130]=c,t[131]=Te):Te=t[131];let Ee;t[132]===r.action.runAgent?Ee=t[133]:(Ee=(0,Z.jsx)(s,{value:`agent`,children:r.action.runAgent}),t[132]=r.action.runAgent,t[133]=Ee);let De;t[134]===r.action.runWorkflow?De=t[135]:(De=(0,Z.jsx)(s,{value:`workflow`,children:r.action.runWorkflow}),t[134]=r.action.runWorkflow,t[135]=De);let Oe=v===`zh`?`浏览器自动化`:`Browser automation`,X;t[136]===Oe?X=t[137]:(X=(0,Z.jsx)(s,{value:`browser_recipe`,children:Oe}),t[136]=Oe,t[137]=X);let ke;t[138]!==n.actionMode||t[139]!==Te||t[140]!==Ee||t[141]!==De||t[142]!==X?(ke=(0,Z.jsxs)(o,{className:Q,value:n.actionMode,onChange:Te,children:[Ee,De,X]}),t[138]=n.actionMode,t[139]=Te,t[140]=Ee,t[141]=De,t[142]=X,t[143]=ke):ke=t[143];let Ae=n.actionMode===`browser_recipe`?null:(0,Z.jsx)($,{label:r.form.agent,children:(0,Z.jsxs)(o,{className:Q,value:n.agentId,onChange:e=>x({agentId:e.target.value}),children:[(0,Z.jsx)(s,{value:``,children:_?r.form.loadingAgents:r.form.defaultAgent}),g.map(e=>(0,Z.jsx)(s,{value:e.id,children:T(e,y)},e.id))]})}),je;t[144]!==f||t[145]!==h||t[146]!==n.actionMode||t[147]!==n.agentId||t[148]!==n.browserWorkflowId||t[149]!==n.browserWorkflowInputs||t[150]!==n.description||t[151]!==n.instruction||t[152]!==n.name||t[153]!==n.triggerMode||t[154]!==n.workflowId||t[155]!==n.workflowInput||t[156]!==r.form.instruction||t[157]!==r.form.loadingWorkflows||t[158]!==r.form.noWorkflows||t[159]!==r.form.triggeredRun||t[160]!==r.form.workflow||t[161]!==v||t[162]!==m||t[163]!==l||t[164]!==x||t[165]!==c||t[166]!==u?(je=n.actionMode===`agent`?(0,Z.jsxs)($,{label:r.form.instruction,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(q,{value:n.instruction,onApply:e=>x({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:v,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,Z.jsx)(`textarea`,{className:d(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>x({instruction:e.target.value})})]}):n.actionMode===`workflow`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:r.form.workflow,children:(0,Z.jsxs)(o,{className:Q,value:n.workflowId,onChange:e=>x({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:u||c.length===0,children:[u?(0,Z.jsx)(s,{value:``,children:r.form.loadingWorkflows}):null,!u&&c.length===0?(0,Z.jsx)(s,{value:``,children:r.form.noWorkflows}):null,c.map(Kt)]})}),l?(0,Z.jsx)(pe,{definition:l,language:v,value:n.workflowInput,onChange:e=>x({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>x({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:l.id,workflowTitle:l.title,workflowDescription:l.description}},inputClassName:`rounded-lg`}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:v===`zh`?`浏览器自动化`:`Browser automation`,children:(0,Z.jsxs)(o,{className:Q,value:n.browserWorkflowId,onChange:e=>{let t=f.find(t=>t.id===e.target.value);x({browserWorkflowId:e.target.value,browserWorkflowInputs:t?ge(t):{}})},disabled:h||f.length===0,children:[f.length===0?(0,Z.jsx)(s,{value:``,children:v===`zh`?`没有已启用的浏览器自动化`:`No enabled browser automations`}):null,f.map(Gt)]})}),m&&Object.keys(m.inputs).length>0?(0,Z.jsx)($,{label:v===`zh`?`运行时填写`:`Run inputs`,children:(0,Z.jsx)(_e,{workflow:m,values:n.browserWorkflowInputs,language:v,onChange:e=>x({browserWorkflowInputs:e})})}):null]}),t[144]=f,t[145]=h,t[146]=n.actionMode,t[147]=n.agentId,t[148]=n.browserWorkflowId,t[149]=n.browserWorkflowInputs,t[150]=n.description,t[151]=n.instruction,t[152]=n.name,t[153]=n.triggerMode,t[154]=n.workflowId,t[155]=n.workflowInput,t[156]=r.form.instruction,t[157]=r.form.loadingWorkflows,t[158]=r.form.noWorkflows,t[159]=r.form.triggeredRun,t[160]=r.form.workflow,t[161]=v,t[162]=m,t[163]=l,t[164]=x,t[165]=c,t[166]=u,t[167]=je):je=t[167];let Me;t[168]===r.form.advancedDescription?Me=t[169]:(Me=(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:r.form.advancedDescription}),t[168]=r.form.advancedDescription,t[169]=Me);let Ne;t[170]!==r.form.advanced||t[171]!==Me?(Ne=(0,Z.jsxs)(`span`,{children:[r.form.advanced,Me]}),t[170]=r.form.advanced,t[171]=Me,t[172]=Ne):Ne=t[172];let Pe;t[173]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,Z.jsx)(j,{className:`size-4 transition-transform group-open:rotate-180`}),t[173]=Pe):Pe=t[173];let Fe;t[174]===Ne?Fe=t[175]:(Fe=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[Ne,Pe]}),t[174]=Ne,t[175]=Fe);let Ie;t[176]!==n.actionMode||t[177]!==n.safetyMode||t[178]!==r.form.safety||t[179]!==r.safety||t[180]!==x?(Ie=n.actionMode===`browser_recipe`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Jt,{title:r.form.safety}),(0,Z.jsxs)($,{label:r.form.safety,children:[(0,Z.jsxs)(o,{className:Q,value:n.safetyMode,onChange:e=>{let t=e.target.value;x({safetyMode:t})},children:[(0,Z.jsx)(s,{value:`suggest_only`,children:r.safety.suggest_only}),(0,Z.jsx)(s,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),(0,Z.jsx)(s,{value:`auto_apply`,children:r.safety.auto_apply})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription})]})]}),t[176]=n.actionMode,t[177]=n.safetyMode,t[178]=r.form.safety,t[179]=r.safety,t[180]=x,t[181]=Ie):Ie=t[181];let Le;t[182]===r.form.results?Le=t[183]:(Le=(0,Z.jsx)(Jt,{title:r.form.results}),t[182]=r.form.results,t[183]=Le);let Re;t[184]===x?Re=t[185]:(Re=e=>x({conversationMode:e.target.value}),t[184]=x,t[185]=Re);let ze;t[186]===r.form.newConversation?ze=t[187]:(ze=(0,Z.jsx)(s,{value:`new_session`,children:r.form.newConversation}),t[186]=r.form.newConversation,t[187]=ze);let We;t[188]===r.form.continuousConversation?We=t[189]:(We=(0,Z.jsx)(s,{value:`continuous`,children:r.form.continuousConversation}),t[188]=r.form.continuousConversation,t[189]=We);let Ge;t[190]!==n.conversationMode||t[191]!==Re||t[192]!==ze||t[193]!==We?(Ge=(0,Z.jsxs)(o,{className:Q,value:n.conversationMode,onChange:Re,children:[ze,We]}),t[190]=n.conversationMode,t[191]=Re,t[192]=ze,t[193]=We,t[194]=Ge):Ge=t[194];let qe;t[195]!==r.form.conversation||t[196]!==Ge?(qe=(0,Z.jsx)($,{label:r.form.conversation,children:Ge}),t[195]=r.form.conversation,t[196]=Ge,t[197]=qe):qe=t[197];let Je;t[198]===x?Je=t[199]:(Je=e=>x({notificationPolicy:e.target.value}),t[198]=x,t[199]=Je);let Ye;t[200]===r.form.notifyAttention?Ye=t[201]:(Ye=(0,Z.jsx)(s,{value:`attention`,children:r.form.notifyAttention}),t[200]=r.form.notifyAttention,t[201]=Ye);let Xe;t[202]===r.form.notifyAll?Xe=t[203]:(Xe=(0,Z.jsx)(s,{value:`all`,children:r.form.notifyAll}),t[202]=r.form.notifyAll,t[203]=Xe);let Ze;t[204]===r.form.notifyNone?Ze=t[205]:(Ze=(0,Z.jsx)(s,{value:`none`,children:r.form.notifyNone}),t[204]=r.form.notifyNone,t[205]=Ze);let $e;t[206]!==n.notificationPolicy||t[207]!==Je||t[208]!==Ye||t[209]!==Xe||t[210]!==Ze?($e=(0,Z.jsxs)(o,{className:Q,value:n.notificationPolicy,onChange:Je,children:[Ye,Xe,Ze]}),t[206]=n.notificationPolicy,t[207]=Je,t[208]=Ye,t[209]=Xe,t[210]=Ze,t[211]=$e):$e=t[211];let et;t[212]!==r.form.notifications||t[213]!==$e?(et=(0,Z.jsx)($,{label:r.form.notifications,children:$e}),t[212]=r.form.notifications,t[213]=$e,t[214]=et):et=t[214];let tt;t[215]!==n.completionWebhookUrl||t[216]!==n.safetyMode||t[217]!==r.form.completionWebhook||t[218]!==x?(tt=n.safetyMode===`auto_apply`?(0,Z.jsx)($,{label:r.form.completionWebhook,children:(0,Z.jsx)(`input`,{className:Q,value:n.completionWebhookUrl,onChange:e=>x({completionWebhookUrl:e.target.value})})}):null,t[215]=n.completionWebhookUrl,t[216]=n.safetyMode,t[217]=r.form.completionWebhook,t[218]=x,t[219]=tt):tt=t[219];let nt;t[220]===r.form.reliability?nt=t[221]:(nt=(0,Z.jsx)(Jt,{title:r.form.reliability}),t[220]=r.form.reliability,t[221]=nt);let rt;t[222]===x?rt=t[223]:(rt=e=>x({timeoutSeconds:e.target.value}),t[222]=x,t[223]=rt);let it;t[224]!==n.timeoutSeconds||t[225]!==rt?(it=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:rt}),t[224]=n.timeoutSeconds,t[225]=rt,t[226]=it):it=t[226];let ot;t[227]!==r.form.timeoutSeconds||t[228]!==it?(ot=(0,Z.jsx)($,{label:r.form.timeoutSeconds,children:it}),t[227]=r.form.timeoutSeconds,t[228]=it,t[229]=ot):ot=t[229];let st;t[230]===x?st=t[231]:(st=e=>x({disableAfterFailures:e.target.value}),t[230]=x,t[231]=st);let ct;t[232]!==n.disableAfterFailures||t[233]!==st?(ct=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:st}),t[232]=n.disableAfterFailures,t[233]=st,t[234]=ct):ct=t[234];let lt;t[235]!==r.form.disableAfterFailures||t[236]!==ct?(lt=(0,Z.jsx)($,{label:r.form.disableAfterFailures,children:ct}),t[235]=r.form.disableAfterFailures,t[236]=ct,t[237]=lt):lt=t[237];let ut;t[238]!==ot||t[239]!==lt?(ut=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ot,lt]}),t[238]=ot,t[239]=lt,t[240]=ut):ut=t[240];let dt;t[241]===r.form.effectivePolicy?dt=t[242]:(dt=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.form.effectivePolicy}),t[241]=r.form.effectivePolicy,t[242]=dt);let ft=n.timeoutSeconds||`—`,pt;t[243]!==r.form.executionDeadline||t[244]!==ft?(pt=(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[r.form.executionDeadline,`: `,ft,`s`]}),t[243]=r.form.executionDeadline,t[244]=ft,t[245]=pt):pt=t[245];let mt;t[246]===r.form.downstreamTimeoutHint?mt=t[247]:(mt=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-fg-subtle`,children:r.form.downstreamTimeoutHint}),t[246]=r.form.downstreamTimeoutHint,t[247]=mt);let ht;t[248]!==dt||t[249]!==pt||t[250]!==mt?(ht=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-muted/40 px-3 py-2.5`,children:[dt,pt,mt]}),t[248]=dt,t[249]=pt,t[250]=mt,t[251]=ht):ht=t[251];let gt;t[252]!==Ie||t[253]!==Le||t[254]!==qe||t[255]!==et||t[256]!==tt||t[257]!==nt||t[258]!==ut||t[259]!==ht?(gt=(0,Z.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[Ie,Le,qe,et,tt,nt,ut,ht]}),t[252]=Ie,t[253]=Le,t[254]=qe,t[255]=et,t[256]=tt,t[257]=nt,t[258]=ut,t[259]=ht,t[260]=gt):gt=t[260];let _t;t[261]!==Fe||t[262]!==gt?(_t=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base`,children:[Fe,gt]}),t[261]=Fe,t[262]=gt,t[263]=_t):_t=t[263];let vt;return t[264]!==k||t[265]!==N||t[266]!==se||t[267]!==R||t[268]!==me||t[269]!==he||t[270]!==ye||t[271]!==be||t[272]!==xe||t[273]!==Se||t[274]!==Ce||t[275]!==we||t[276]!==ke||t[277]!==Ae||t[278]!==je||t[279]!==_t?(vt=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[k,N,se,R,me,he,ye,be,xe,Se,Ce,we,ke,Ae,je,_t]})}),t[264]=k,t[265]=N,t[266]=se,t[267]=R,t[268]=me,t[269]=he,t[270]=ye,t[271]=be,t[272]=xe,t[273]=Se,t[274]=Ce,t[275]=we,t[276]=ke,t[277]=Ae,t[278]=je,t[279]=_t,t[280]=vt):vt=t[280],vt}function Gt(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}function Kt(e){return(0,Z.jsx)(s,{value:e.id,children:e.title||e.name},e.id)}function qt(e){return(0,Z.jsx)(s,{value:e.id,children:e.name},e.id)}var Q=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`;function $(e){let t=(0,ve.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Jt(e){let t=(0,ve.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(ae,{className:`size-4 text-fg-muted`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 text-sm font-semibold text-fg`,children:[r,n]}),t[1]=n,t[2]=i),i}export{wt as AutomationsPage};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,l as o,r as s,t as c}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as l,r as u,t as d}from"./popover-select-BzdnTy3h.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./globe-DSSGFWFn.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./plus-Q2yW6OE7.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-JdwAhgNB.js";import{t as v}from"./button-CSEbl4zT.js";import{t as y}from"./messages-yG5P43Q9.js";import{l as b,n as x,o as S,r as C,s as w}from"./locale-store-pByvK12G.js";import{i as T,o as E}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as D,i as O,n as k,o as A,r as j,s as M,t as N}from"./dist-BPoKqzeH.js";import{i as P}from"./vendor-swr-BIWyz7Rc.js";import{n as F,r as I}from"./gateway-config-swr-BQbkUP5X.js";import{$l as L,At as R,Bc as z,Bo as ee,Bs as B,Bt as te,Ct as V,Dt as H,Et as ne,Ft as U,Go as W,Gt as G,Hn as re,Ia as K,Ic as q,Il as J,It as ie,Jo as ae,Jt as Y,Ko as oe,Kt as se,Lo as ce,Lt as le,Mt as ue,Nl as de,Nt as fe,Os as X,Ot as pe,Ps as me,Pt as he,Ro as ge,Rt as _e,Si as ve,St as ye,Tt as be,Us as xe,Ut as Se,Vo as Ce,Vt as we,Wt as Te,Xl as Ee,Xo as De,Xt as Oe,Yn as ke,Yo as Ae,Yt as je,Zo as Me,_s as Ne,_t as Pe,ac as Fe,bl as Ie,bt as Le,cs as Re,dt as ze,ec as Be,en as Ve,es as He,ft as Ue,gc as We,gt as Ge,ht as Ke,jt as qe,kt as Je,ls as Ye,mt as Xe,ns as Ze,pt as Qe,qs as $e,qt as et,tc as tt,tn as nt,ts as rt,ul as it,vi as at,vs as ot,vt as st,wt as ct,xc as lt,xt as ut,yi as dt,yt as ft,zt as pt}from"./index-C2ZYFBGL.js";import{n as mt,r as ht}from"./settings-page-layout-BRQNel6r.js";import{t as gt}from"./settings-loading-skeleton-BVLhreQi.js";import{n as _t,t as vt}from"./use-autosave-DysNnqCS.js";import{a as yt,c as bt,d as xt,f as St,i as Ct,l as wt,n as Tt,r as Et,s as Dt,t as Ot,u as kt}from"./voice-api-key-field-UEsO9Jr-.js";import{t as At}from"./settings-advanced-gate-g1GThZ0O.js";import{n as jt,t as Mt}from"./settings-form-section-DlzZx0-i.js";import{t as Nt}from"./page-tabs-gw-RMQCV.js";var Z=n(),Q=e(t(),1),$=r(),Pt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Ft=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function It(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Lt(e){let t=e.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Rt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Pt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`bearer`),[x,S]=(0,Q.useState)(`x-api-key`),[C,w]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(``),[I,R]=(0,Q.useState)(``),[z,ee]=(0,Q.useState)(`/images/generations`),[B,te]=(0,Q.useState)(`/images/edits`),[V,H]=(0,Q.useState)(``),[ne,U]=(0,Q.useState)(``),[W,G]=(0,Q.useState)([It()]),[re,K]=(0,Q.useState)(``),[q,J]=(0,Q.useState)(),[ie,Y]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(),[ce,le]=(0,Q.useState)(),[ue,de]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),p(n?.baseUrl??``),b(t?.auth.type??`bearer`),S(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),w(r?`••••••••••••`:``),F(t?.apiKeyUrl??``),R(t?.documentationUrl??``),ee(t?.paths?.generations??`/images/generations`),te(t?.paths?.edits??`/images/edits`),H(t?.network?.allowedHosts.join(`
|
|
3
|
-
`)??``),U(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
4
|
-
`)),G(t?.models.map(It)??[It()]),K(t?.defaultModel??``),le(void 0),J(void 0),Y(!1),se(void 0),de(void 0)},[r,e,n]);let fe=(0,Q.useMemo)(()=>W.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[W]),X=(e,t)=>{G(n=>n.map((n,r)=>r===e?{...n,...t}:n))},pe=()=>{let e=s.trim(),t=W.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!f.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=re||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Lt(ne)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:f.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...I.trim()?{documentationUrl:I.trim()}:{},...P.trim()?{apiKeyUrl:P.trim()}:{},defaultModel:n,auth:y===`header`?{type:`header`,headerName:x.trim()}:{type:y},paths:{...z.trim()?{generations:z.trim()}:{},...B.trim()?{edits:B.trim()}:{}},...V.trim()?{network:{allowedHosts:V.split(`
|
|
5
|
-
`).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},me=async()=>{let e=pe();return await Pe(e.providerId,e.input),y!==`none`&&C.trim()&&!Ae(C)&&await st(e.providerId,C.trim()),await a(e.providerId),e},he=async()=>{J(`save`),se(void 0),le(void 0);try{await me(),w(y===`none`?``:`••••••••••••`),le(o.saved)}catch(e){se(e instanceof Error?e.message:String(e))}finally{J(void 0)}},ge=async()=>{J(`test`),se(void 0),le(void 0),de(void 0);try{let e=await me();de((await ft(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),le(o.testReady)}catch(e){se(e instanceof Error?e.message:String(e))}finally{J(void 0)}},_e=async()=>{if(n){if(!ie){Y(!0);return}J(`delete`),se(void 0);try{await Xe(n.providerId),await a(),t(!1)}catch(e){se(e instanceof Error?e.message:String(e))}finally{J(void 0)}}};return(0,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{children:[(0,$.jsx)(D,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim`,E)}),(0,$.jsxs)(j,{className:_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover`,T),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(O,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(k,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-subtle hover:text-fg`,"aria-label":o.cancel,children:(0,$.jsx)(g,{className:`size-5`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.providerId,(0,$.jsx)(`input`,{value:s,disabled:!!n,onChange:e=>c(e.target.value),placeholder:`my-image-service`,className:Ft}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.name,(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`My Image Service`,className:Ft})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`https://api.example.com/v1`,className:Ft})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.auth,(0,$.jsx)(d,{value:y,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>b(e),triggerClassName:`mt-1.5`})]}),y===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:x,onChange:e=>S(e.target.value),className:Ft})]}):null]}),y===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:o.apiKey}),P.trim()?(0,$.jsxs)(`a`,{href:P.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(L,{className:`size-3.5`})]}):null]}),(0,$.jsx)(ae,{id:`custom-image-api-key`,value:C,onChange:e=>w(Ae(C)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>et(s).then(e=>e.apiKey),loadFailedLabel:o.revealFailed,notInConfigFile:o.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.apiKeyUrl,(0,$.jsx)(`input`,{value:P,onChange:e=>F(e.target.value),placeholder:`https://…`,className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:I,onChange:e=>R(e.target.value),placeholder:`https://…`,className:Ft})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:o.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.generationsPath,(0,$.jsx)(`input`,{value:z,onChange:e=>ee(e.target.value),className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:B,onChange:e=>te(e.target.value),className:Ft})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:V,onChange:e=>H(e.target.value),rows:2,placeholder:`127.0.0.1
|
|
6
|
-
image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.staticHeaders,(0,$.jsx)(`textarea`,{value:ne,onChange:e=>U(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.models}),(0,$.jsxs)(v,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>G(e=>[...e,It()]),children:[(0,$.jsx)(h,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(d,{value:re||fe[0]?.value||``,options:fe,placeholder:o.defaultModel,allowEmpty:!1,onChange:K,triggerClassName:`mt-1.5 max-w-sm`})]}),W.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>X(t,{id:e.target.value}),placeholder:`image-1`,className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>X(t,{name:e.target.value}),className:Ft})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>X(t,{maxCount:e.target.value}),className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>X(t,{defaultCount:e.target.value}),className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>X(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Ft})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(d,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>X(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>X(t,{supportsSize:e.target.checked})}),o.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>X(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:W.length===1,onClick:()=>G(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(ot,{className:`size-3.5`}),o.remove]})]})]},t))]}),ue?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(it,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:ue,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,ce?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:ce}):null,oe?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:oe}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(v,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!q,onClick:()=>void _e(),children:[q===`delete`?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(ot,{className:`size-4`}),ie?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(k,{asChild:!0,children:(0,$.jsx)(v,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(v,{variant:`secondary`,disabled:!!q,onClick:()=>void ge(),children:[q===`test`?(0,$.jsx)(m,{className:`size-4 animate-spin`}):null,q===`test`?o.testing:o.test]}),(0,$.jsxs)(v,{variant:`primary`,disabled:!!q,onClick:()=>void he(),children:[q===`save`?(0,$.jsx)(m,{className:`size-4 animate-spin`}):null,q===`save`?o.saving:o.save]})]})]})]})]})})}var zt=`••••••••••••`,Bt={en:{title:`Image generation`,intro:`Choose an agent and image model, or connect an OpenAI Images service of your own.`,agent:`Agent`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectAgent:`Select an agent`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`为 Agent 选择图片模型,也可以连接你自己的 OpenAI Images 服务。`,agent:`Agent`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectAgent:`选择 Agent`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function Vt(e){let t=await w(C(`/api/agents/${encodeURIComponent(e)}/image-generation`));if(!t.payload)throw Error(`Invalid agent image generation response`);return t.payload}function Ht(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Ut(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Wt(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function Gt(e){let t=(0,Z.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(d,{value:r,options:(n.options??[]).map(Kt),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function Kt(e){return{value:e.value,label:e.label}}function qt(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(K,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(Jt)}),(0,$.jsx)(K,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function Jt(e,t){return(0,$.jsx)(K,{className:`h-24 rounded-xl`},t)}function Yt(){let e=x(e=>e.language),t=Bt[e],n=y(e),r=!!b(e=>e.token),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(``),[p,g]=(0,Q.useState)({}),[_,S]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(),{data:N,isLoading:F,error:I}=P(r?`image-generation-agents`:null,ke,{revalidateOnFocus:!1}),{data:R,isLoading:ee,error:te,mutate:V}=P(r?C(`/api/image-generation/catalog`):null,Ge,{revalidateOnFocus:!1}),{data:H,isLoading:ne,error:U,mutate:W}=P(r?C(`/api/image-generation/custom-providers`):null,Ke,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{!N||i||a(N.defaultId||N.agents[0]?.id||``)},[i,N]);let{data:G,isLoading:K,error:J,mutate:ie}=P(r&&i?[`agent-image-generation`,i]:null,()=>Vt(i),{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!R||!G)return;let e=Ht(G.model?.primary),t=R.find(t=>t.id===e)??R.find(e=>e.configured)??R[0];t&&(s(t.id),l(t.id===e&&Ut(G.model?.primary)||t.defaultModel),f(t.configured?zt:``),g(Wt(t)))},[G,R]),(0,Q.useEffect)(()=>{E(void 0)},[i]);let Y=R?.find(e=>e.id===o),oe=Y?Y.apiKeyUrl??Ue(Y.id,e)[0]?.href:void 0,se=(0,Q.useMemo)(()=>(N?.agents??[]).map(e=>({value:e.id,label:re(e,n.agentsSettings)})),[N?.agents,n.agentsSettings]),ce=(0,Q.useMemo)(()=>(Y?.models??[]).map(e=>({value:e,label:e})),[Y?.models]),le=G?.model?.primary,ue=!!(i&&Y&&c&&(Y.credentialMode!==`api-key`||Y.configured||u.trim())&&Y.configFields.every(e=>!e.required||p[e.key]?.trim()));if(!r)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(F||ee||ne||K)return(0,$.jsx)(qt,{});if(I||te||U||J||!R||!N||!H)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let fe=e=>{s(e.id),l(e.defaultModel),f(e.configured?zt:``),g(Wt(e)),E(void 0)},X=()=>{M(void 0),A(!0)},pe=()=>{let e=H.find(e=>e.providerId===Y?.id);e&&(M(e),A(!0))},he=async e=>{let[t,n]=await Promise.all([W(),V()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);s(r.id),l(r.defaultModel),f(r.configured?zt:``),g(Wt(r)),M(t?.find(t=>t.providerId===e))}},ge=async()=>{if(!(!Y||!ue)){S(!0),E(void 0),O(!1);try{let e=await w(C(`/api/agents/${encodeURIComponent(i)}/image-generation/setup`),{method:`POST`,body:JSON.stringify({providerId:Y.id,modelId:c,...u.trim()&&!Ae(u)?{apiKey:u.trim()}:{},providerConfig:Object.fromEntries(Object.entries(p).filter(([,e])=>e.trim()))})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([ie(e.payload.agent,{revalidate:!1}),V(e.payload.providers,{revalidate:!1})]),f(zt),O(!0)}catch(e){E(e instanceof Error?e.message:String(e))}finally{S(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(z,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.intro})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[t.agent,(0,$.jsx)(d,{value:i,options:se,placeholder:t.selectAgent,allowEmpty:!1,onChange:a,triggerClassName:`mt-1.5 max-w-md`})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:t.provider}),(0,$.jsxs)(v,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:X,children:[(0,$.jsx)(h,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:R.map(e=>{let n=e.id===o,r=e.id===Ht(le);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>fe(e),className:`min-h-24 rounded-xl border p-4 text-left transition-colors ${n?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-base hover:border-edge-strong`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!r,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${r?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(de,{className:`size-3.5`}):(0,$.jsx)(q,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),Y?(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(d,{value:c,options:ce,placeholder:t.selectModel,allowEmpty:!1,onChange:l,triggerClassName:`mt-1.5`})]}),Y.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(Gt,{field:e,value:p[e.key]??``,onChange:t=>g(n=>({...n,[e.key]:t}))},e.key))]}),Y.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(v,{variant:`secondary`,onClick:pe,children:[(0,$.jsx)(B,{className:`size-4`}),t.manageService]})}):null,Y.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:t.apiKey}),oe?(0,$.jsxs)(`a`,{href:oe,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(L,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(ae,{id:`image-generation-api-key`,value:u,onChange:e=>f(Ae(u)?e.replace(/^•+/,``):e),placeholder:Y.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>et(Y.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},Y.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:Y.configured?t.savedKey:t.apiKeyHint})]}):null,Y.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(me,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:Y.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(Gt,{field:e,value:p[e.key]??``,onChange:t=>g(n=>({...n,[e.key]:t}))},e.key))})]}):null,D?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:t.enabled}):null,T?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:T}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(v,{variant:`primary`,disabled:!ue||_,onClick:()=>void ge(),children:[_?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(de,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:_?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(Rt,{open:k,onOpenChange:A,provider:j,configured:!!(j&&R.find(e=>e.id===j.providerId)?.configured),language:e,onSaved:he})]})}var Xt=He;function Zt(){return _(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ze,`dark:border-edge`)}function Qt(){return _(rt,He)}function $t(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function en(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function tn(e,t){switch(e){case`xopc-local`:return t.stt.localProvider;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function nn(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function rn(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function an(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function on(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function sn(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function cn(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function ln(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function un(){let e=x(e=>e.language),t=y(e).voiceSettings,n=!!b(e=>e.token),[r,i]=(0,Q.useReducer)(ln,{form:null,baseline:null}),a=r.form,o=r.baseline,[s,c]=(0,Q.useState)(null),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(a);u.current=a;let d=(0,Q.useRef)({parsed:null,models:void 0}),{data:f,error:p,isLoading:m,mutate:h}=I(n),{data:g,error:_,isLoading:S,mutate:w}=P(n?C(`/api/voice/models`):null,Ct,{revalidateOnFocus:!1}),{data:T,error:E,isLoading:D}=P(n?C(`/api/voice/providers`):null,yt,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=P(n?C(`/api/voice/stt-providers`):null,Dt,{revalidateOnFocus:!1}),j=(0,Q.useMemo)(()=>T?.providers??[],[T]),M=(0,Q.useMemo)(()=>O?.providers??[],[O]),N=(0,Q.useMemo)(()=>f?.payload?.config===void 0?null:wt(f.payload.config),[f]),F=(0,Q.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);n?N!==null&&g!==void 0&&!l.current&&(d.current.parsed!==N||d.current.models!==g)&&(d.current={parsed:N,models:g},i({type:`sync`,value:N}),c(g)):(d.current.parsed!==null||d.current.models!==void 0)&&(d.current={parsed:null,models:void 0},i({type:`reset`}),c(null),l.current=!1);let L=!!(n&&(N===null||g===void 0||T===void 0||O===void 0)&&(m||S||D||A)),R=p instanceof Error?p.message:p?String(p):_ instanceof Error?_.message:_?String(_):E instanceof Error?E.message:E?String(E):k instanceof Error?k.message:k?String(k):null,z=(0,Q.useCallback)(e=>{l.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),ee=(0,Q.useCallback)(e=>{l.current=!0,i({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[`xopc-local`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),B=(0,Q.useCallback)(e=>{l.current=!0,i({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),te=(0,Q.useCallback)(t=>{l.current=!0,i({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),V=(0,Q.useCallback)(e=>{l.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),H=vt({value:a,dirty:F,onSave:(0,Q.useCallback)(async e=>{try{await kt(e),i({type:`saved`,value:e}),l.current=!!(u.current&&JSON.stringify(u.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});if(!n)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(L)return(0,$.jsx)(gt,{rows:4});if(!a||s===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:R??t.loadError}),(0,$.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>{h(),w()},children:t.retry})]});let ne=a.stt,U=a.tts,W=a.voice.input.refinement,G=on(t);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,onBlurCapture:H.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(_t,{status:H.status,error:H.error})}),H.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:H.error}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(dn,{v:t,voice:a.voice,updateLanguageMode:te}),(0,$.jsx)(fn,{v:t,stt:ne,tts:U}),(0,$.jsx)(mn,{v:t,apiKeyLabels:G,stt:ne,models:s,sttProviders:M,refinement:W,updateStt:z,updateSttFallback:ee,updateRefinement:B}),(0,$.jsx)(vn,{v:t,apiKeyLabels:G,tts:U,models:s,ttsProviders:j,updateTts:V})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,$.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,$.jsx)(`strong`,{className:`text-accent`,children:t.notes.title}),` `,t.notes.duration]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.notes.envVars})]})]})}function dn(e){let t=(0,Z.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=Qt(),t[7]=d):d=t[7];let f;t[8]===i?f=t[9]:(f=e=>i(e.target.value),t[8]=i,t[9]=f);let p;t[10]===n.language.auto?p=t[11]:(p=(0,$.jsx)(u,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,$.jsx)(u,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==f||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,$.jsxs)(l,{className:d,value:r.languageMode,onChange:f,children:[p,m]}),t[14]=f,t[15]=p,t[16]=m,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,$.jsx)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function fn(e){let t=(0,Z.c)(39),{v:n,stt:r,tts:i}=e,a=i.providers?.[i.provider]?.voice,o=typeof a==`string`?a:void 0,s;t[0]===n.overview.title?s=t[1]:(s=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=s);let c;t[2]===n.overview.description?c=t[3]:(c=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,$.jsxs)(`div`,{className:`mb-4`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(u=r.enabled?`${n.overview.ready} · ${tn(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=u):u=t[10];let d;t[11]!==r.enabled||t[12]!==u||t[13]!==n.overview.input?(d=(0,$.jsx)(pn,{label:n.overview.input,value:u,ready:r.enabled}),t[11]=r.enabled,t[12]=u,t[13]=n.overview.input,t[14]=d):d=t[14];let f;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(f=i.enabled?rn(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=f):f=t[18];let p=i.enabled&&i.trigger!==`off`,m;t[19]!==f||t[20]!==p||t[21]!==n.overview.replies?(m=(0,$.jsx)(pn,{label:n.overview.replies,value:f,ready:p}),t[19]=f,t[20]=p,t[21]=n.overview.replies,t[22]=m):m=t[22];let h;t[23]!==o||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(h=i.enabled?`${nn(i.provider,n)}${o?` · ${o}`:``}`:n.overview.off,t[23]=o,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=h):h=t[27];let g;t[28]!==h||t[29]!==i.enabled||t[30]!==n.overview.voice?(g=(0,$.jsx)(pn,{label:n.overview.voice,value:h,ready:i.enabled}),t[28]=h,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=g):g=t[31];let _;t[32]!==g||t[33]!==d||t[34]!==m?(_=(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[d,m,g]}),t[32]=g,t[33]=d,t[34]=m,t[35]=_):_=t[35];let v;return t[36]!==_||t[37]!==l?(v=(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[l,_]}),t[36]=_,t[37]=l,t[38]=v):v=t[38],v}function pn(e){let t=(0,Z.c)(10),{label:n,value:r,ready:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o=i?`text-fg`:`text-fg-muted`,s;t[2]===o?s=t[3]:(s=_(`mt-1 text-sm font-medium`,o),t[2]=o,t[3]=s);let c;t[4]!==s||t[5]!==r?(c=(0,$.jsx)(`div`,{className:s,children:r}),t[4]=s,t[5]=r,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[a,c]}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function mn(e){let t=(0,Z.c)(62),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,refinement:s,updateStt:c,updateSttFallback:d,updateRefinement:f}=e,p;if(t[0]!==o){let e=new Set;p=[];for(let t of o)e.has(t.id)||(e.add(t.id),p.push(t));t[0]=o,t[1]=p}else p=t[1];let m=p,h,g,v,y;if(t[2]!==a||t[3]!==m||t[4]!==i.provider||t[5]!==i.providers){h=m.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],v=e,g=a?.stt?.[i.provider]?.length?a.stt[i.provider]:h?.models??[],y=h?.fields.find(hn),t[2]=a,t[3]=m,t[4]=i.provider,t[5]=i.providers,t[6]=h,t[7]=g,t[8]=v,t[9]=y}else h=t[6],g=t[7],v=t[8],y=t[9];let b=y,x=typeof v.model==`string`?v.model:void 0,S=x??(typeof b?.defaultValue==`string`?b.defaultValue:g[0]?.id),C;t[13]!==i.provider||t[14]!==i.providers||t[15]!==c?(C=e=>{c({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=c,t[16]=C):C=t[16];let w=C,T,E;t[17]!==x||t[18]!==S||t[19]!==b||t[20]!==w?(T=()=>{b&&S&&x!==S&&w({model:S})},E=[x,S,b,w],t[17]=x,t[18]=S,t[19]=b,t[20]=w,t[21]=T,t[22]=E):(T=t[21],E=t[22]),(0,Q.useEffect)(T,E);let D;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(We,{className:`size-4 text-accent`,strokeWidth:1.75}),t[23]=D):D=t[23];let O;t[24]===n.stt.title?O=t[25]:(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[D,n.stt.title]}),t[24]=n.stt.title,t[25]=O);let k;t[26]===n.stt.description?k=t[27]:(k=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[26]=n.stt.description,t[27]=k);let A;t[28]!==O||t[29]!==k?(A=(0,$.jsxs)(`div`,{className:`mb-4`,children:[O,k]}),t[28]=O,t[29]=k,t[30]=A):A=t[30];let j;t[31]===c?j=t[32]:(j=e=>c({enabled:e}),t[31]=c,t[32]=j);let M;t[33]!==i.enabled||t[34]!==j||t[35]!==n.overview.off||t[36]!==n.overview.ready||t[37]!==n.stt.enable||t[38]!==n.stt.enableDesc?(M=(0,$.jsx)(bn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:j}),t[33]=i.enabled,t[34]=j,t[35]=n.overview.off,t[36]=n.overview.ready,t[37]=n.stt.enable,t[38]=n.stt.enableDesc,t[39]=M):M=t[39];let N;t[40]!==h?.fields||t[41]!==r||t[42]!==S||t[43]!==g||t[44]!==m||t[45]!==v||t[46]!==s||t[47]!==i.enabled||t[48]!==i.fallback?.enabled||t[49]!==i.provider||t[50]!==w||t[51]!==f||t[52]!==c||t[53]!==d||t[54]!==n?(N=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:_(`flex flex-col gap-1.5`,Xt),children:[(0,$.jsx)(Cn,{children:n.stt.provider}),(0,$.jsx)(l,{className:Qt(),value:i.provider,onChange:e=>c({provider:e.target.value}),children:m.map(e=>(0,$.jsxs)(u,{value:e.id,children:[tn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(yn,{kind:`stt`,providerId:i.provider,fields:h?.fields??[],providerSlice:v,models:g,currentModel:S,apiKeyLabels:r,onPatch:w})]}),i.provider===`xopc-local`?(0,$.jsx)(_n,{v:n}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>d({enabled:e.target.checked})})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.refinementDesc})]}),(0,$.jsxs)(l,{className:Qt(),value:s.mode,onChange:e=>f({mode:e.target.value}),children:[(0,$.jsx)(u,{value:`off`,children:n.stt.refinementOff}),(0,$.jsx)(u,{value:`punctuation`,children:n.stt.refinementPunctuation}),(0,$.jsx)(u,{value:`light`,children:n.stt.refinementLight})]})]})]}):null,t[40]=h?.fields,t[41]=r,t[42]=S,t[43]=g,t[44]=m,t[45]=v,t[46]=s,t[47]=i.enabled,t[48]=i.fallback?.enabled,t[49]=i.provider,t[50]=w,t[51]=f,t[52]=c,t[53]=d,t[54]=n,t[55]=N):N=t[55];let P;t[56]!==M||t[57]!==N?(P=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[M,N]}),t[56]=M,t[57]=N,t[58]=P):P=t[58];let F;return t[59]!==P||t[60]!==A?(F=(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[A,P]}),t[59]=P,t[60]=A,t[61]=F):F=t[61],F}function hn(e){return e.key===`model`}function gn(e){return`${Math.round(e/1024/1024)} MB`}function _n({v:e}){let{data:t,error:n,mutate:r}=P(C(`/api/voice/local/status`),Tt,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await bt(e.id):await xt(e.id),await r()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(null)}},[r]);return(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel/60 p-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.localModels}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.localModelsDesc}),n?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:String(n)}):null,o?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:o}):null,(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:(t?.models??[]).map(t=>{let n=i===t.id||t.state===`downloading`;return(0,$.jsxs)(`div`,{className:_(`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2.5`,t.recommended?`ring-1 ring-accent/40`:``),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-fg`,children:[t.name,t.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent`,children:e.stt.localRecommended}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[gn(t.approximateBytes),` · `,t.description]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:[t.engine,` · `,t.languages.join(` / `)]}),t.state===`downloading`?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-accent`,children:[e.stt.localDownloading,` `,Math.round((t.progress??0)*100),`%`]}):t.state===`error`?(0,$.jsx)(`div`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:t.error}):null]}),(0,$.jsx)(v,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void c(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(m,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function vn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a}){let[o,s]=(0,Q.useState)(e.tts.test.sampleText),[c,d]=(0,Q.useState)({status:`idle`}),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),h=(0,Q.useCallback)(()=>{f.current?.pause(),f.current=null,p.current&&=(URL.revokeObjectURL(p.current),null)},[]),g=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),y=g.find(e=>e.id===n.provider),b=n.providers?.[n.provider]??{},x=r?.tts?.[n.provider]?.length?r.tts[n.provider]:y?.models??[],S=y?.fields.find(e=>e.key===`model`),C=y?.fields.find(e=>e.key===`voice`),w=typeof b.model==`string`?b.model:void 0,T=w??(typeof S?.defaultValue==`string`?S.defaultValue:x[0]?.id),E=x.find(e=>e.id===T),D=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:y?.voices??[],{data:O=[]}=P(T?`voice:tts:${n.provider}:${T}`:null,()=>Et(n.provider,T??``),{revalidateOnFocus:!1}),k=O.length>0?O:D,A=typeof b.voice==`string`?b.voice:void 0,j=A??k.find(e=>e.id===E?.tts?.defaultVoice)?.id??(typeof C?.defaultValue==`string`?C.defaultValue:k[0]?.id),M=(y?.fields??[]).filter(e=>(e.key!==`speed`||E?.tts?.speed!==!1)&&(e.key!==`instructions`||E?.tts?.instructions!==!1)),N=!!y?.diagnostics.requiresApiKey,F=!!y?.configured||!N,I=n.enabled?F?`ready`:`action`:`muted`,L=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{let e={};S&&T&&w!==T&&(e.model=T),C&&j&&A!==j&&(e.voice=j),Object.keys(e).length>0&&L(e)},[w,A,T,j,S,L,C]),(0,Q.useEffect)(()=>()=>h(),[h]);let R=(0,Q.useCallback)(e=>{a({provider:e}),d({status:`idle`})},[a]),z=(0,Q.useCallback)(async()=>{let t=o.trim();if(!t){d({status:`error`,message:e.tts.test.emptyText});return}h(),d({status:`loading`});try{let r=await St({text:t,provider:n.provider,providerConfig:b,...T?{model:T}:{},...j?{voice:j}:{}}),i=en(r.audio,r.mimeType);p.current=i;let a=new Audio(i);f.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,$t(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>d({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>d({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),d({status:`playing`,summary:o})}catch(e){h(),d({status:`error`,message:e instanceof Error?e.message:String(e)})}},[T,j,b,h,o,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Re,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(bn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>a({enabled:e})}),(0,$.jsxs)(`div`,{className:_(`rounded-xl border px-3 py-2.5 text-sm`,I===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:I===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,$.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?F?`${e.tts.statusReady} ${nn(n.provider,e)}${j?` · ${j}`:``}`:`${e.tts.statusNeedsSetup} ${nn(n.provider,e)} · ${y?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:_(`flex flex-col gap-1.5`,Xt),children:[(0,$.jsx)(Cn,{children:e.tts.trigger}),(0,$.jsxs)(l,{className:Qt(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(u,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(u,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(u,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(u,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:_(`flex flex-col gap-1.5`,Xt),children:[(0,$.jsx)(Cn,{children:e.tts.provider}),(0,$.jsx)(l,{className:Qt(),value:n.provider,onChange:e=>R(e.target.value),children:g.map(t=>(0,$.jsx)(u,{value:t.id,children:nn(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[y?.configured?e.tts.configured:y?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${y.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,y?.description??an(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!F||n.provider===`tts-local-cli`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(yn,{kind:`tts`,providerId:n.provider,fields:M,providerSlice:b,models:x,voices:k,currentModel:T,currentVoice:j,apiKeyLabels:t,onPatch:L,resetVoiceOnModelChange:!0})})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(v,{type:`button`,variant:`primary`,onClick:()=>void z(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(tt,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(v,{type:`button`,variant:`secondary`,onClick:()=>{h(),d(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:c.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(X,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsx)(`textarea`,{className:_(Zt(),`mt-3 min-h-20 resize-y`),value:o,onChange:e=>s(e.target.value),maxLength:1e3}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[o.length,`/1000`]}),c.status===`playing`||c.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[c.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,c.summary]}):null,c.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:c.message}):null]})]})]}):null]})]})}function yn({kind:e,providerId:t,fields:n,providerSlice:r,models:i,voices:a=[],currentModel:o,currentVoice:s,apiKeyLabels:c,onPatch:d,resetVoiceOnModelChange:f=!1}){return n.map(n=>n.key===`apiKey`?(0,$.jsxs)(`div`,{className:_(`flex flex-col gap-1.5`,Xt),children:[(0,$.jsx)(Cn,{children:n.label}),(0,$.jsx)(Ot,{kind:e,providerId:t,fieldId:`voice-${e}-${t}-api-key`,value:typeof r.apiKey==`string`?r.apiKey:``,onChange:e=>d({apiKey:e}),labels:c,placeholder:n.placeholder}),n.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.description}):null]},n.key):n.key===`model`&&i.length>0?(0,$.jsxs)(`div`,{className:_(`flex flex-col gap-1.5`,Xt),children:[(0,$.jsx)(Cn,{children:n.label}),(0,$.jsx)(l,{className:Qt(),value:o??``,onChange:e=>d({model:e.target.value,...f?{voice:void 0}:{}}),children:i.map(e=>(0,$.jsx)(u,{value:e.id,children:e.name},e.id))})]},n.key):n.key===`voice`&&a.length>0?(0,$.jsxs)(`div`,{className:_(`flex flex-col gap-1.5`,Xt),children:[(0,$.jsx)(Cn,{children:n.label}),(0,$.jsx)(l,{className:Qt(),value:s??``,onChange:e=>d({voice:e.target.value}),children:a.map(e=>(0,$.jsx)(u,{value:e.id,children:e.name},e.id))})]},n.key):(0,$.jsx)(xn,{field:n,value:sn(r,n),onChange:e=>d({[n.key]:e}),className:n.type===`textarea`?`sm:col-span-2`:Xt},n.key))}function bn(e){let t=(0,Z.c)(33),{checked:n,title:r,description:i,onLabel:a,offLabel:o,onChange:s}=e,c;t[0]!==n||t[1]!==s?(c=()=>s(!n),t[0]=n,t[1]=s,t[2]=c):c=t[2];let l=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,u;t[3]===l?u=t[4]:(u=_(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,Ze,l),t[3]=l,t[4]=u);let d=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,f;t[5]===d?f=t[6]:(f=_(`rounded-full px-2 py-0.5 text-[11px] font-medium`,d),t[5]=d,t[6]=f);let p=n?a:o,m;t[7]!==f||t[8]!==p?(m=(0,$.jsx)(`span`,{className:f,children:p}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]!==m||t[11]!==r?(h=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,m]}),t[10]=m,t[11]=r,t[12]=h):h=t[12];let g;t[13]===i?g=t[14]:(g=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[13]=i,t[14]=g);let v;t[15]!==h||t[16]!==g?(v=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[h,g]}),t[15]=h,t[16]=g,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=_(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=_(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let C;t[22]===S?C=t[23]:(C=(0,$.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,$.jsx)(`span`,{className:b,"aria-hidden":!0,children:C}),t[24]=b,t[25]=C,t[26]=w):w=t[26];let T;return t[27]!==n||t[28]!==c||t[29]!==v||t[30]!==w||t[31]!==u?(T=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:c,className:u,children:[v,w]}),t[27]=n,t[28]=c,t[29]=v,t[30]=w,t[31]=u,t[32]=T):T=t[32],T}function xn(e){let t=(0,Z.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=_(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=!!r,d;t[9]!==n||t[10]!==i?(d=e=>i(cn(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let c=typeof r==`boolean`?``:String(r),u;t[19]===a?u=t[20]:(u=_(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(Cn,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(l,{id:o,className:Qt(),value:c,required:n.required,onChange:e=>i(cn(n,e.target.value)),children:(n.options??[]).map(Sn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:_(Zt(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(cn(n,e.target.value))}):n.type===`password`?(0,$.jsx)(ae,{id:o,className:a,value:c,onChange:e=>i(cn(n,e)),placeholder:n.placeholder,labels:W}):(0,$.jsx)(`input`,{id:o,className:Zt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(cn(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Sn(e){return(0,$.jsx)(u,{value:e.id,children:e.name},e.id)}function Cn(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function wn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Tn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await w(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),F()}async function En(e){let t=await w(C(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Dn(e){let t=(0,Z.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function On(){return _(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ze,`dark:border-edge`)}function kn(){return _(rt,He)}var An=[`brave`,`tavily`,`bing`,`searxng`];function jn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Mn=at();function Nn(){let e=y(x(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!b(e=>e.token),[i,a]=(0,Q.useReducer)(Mn,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),d=(0,Q.useRef)(o);d.current=o;let f=(0,Q.useRef)(null),{data:p,error:m,isLoading:g,mutate:S}=I(r);dt({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:wn(p.payload.config),[p]),dirty:c.current,trackedParsedRef:f,dispatch:a,onResetDirty:()=>{c.current=!1}});let C=!!(r&&g&&p===void 0&&!m),w=m instanceof Error?m.message:m?String(m):null,T=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),E=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),D=vt({value:o,dirty:T,onSave:(0,Q.useCallback)(async e=>{try{await Tn(e),a({type:`saved`,value:e}),c.current=!!(d.current&&JSON.stringify(d.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return r?C?(0,$.jsx)(gt,{rows:3}):o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,onBlurCapture:D.onBlurCapture,children:[D.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:D.error}):null,(0,$.jsxs)(Mt,{children:[(0,$.jsx)(jt,{icon:xe,title:t.sectionRegion,subtitle:t.sectionRegionHint,trailing:(0,$.jsx)(_t,{status:D.status,error:D.error})}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(Dn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(l,{className:kn(),value:o.regionMode,onChange:e=>E({regionMode:e.target.value}),children:[(0,$.jsx)(u,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(u,{value:`cn`,children:t.regionCn}),(0,$.jsx)(u,{value:`global`,children:t.regionGlobal})]})})})]}),(0,$.jsx)(At,{children:(0,$.jsxs)(Mt,{children:[(0,$.jsx)(jt,{icon:Ee,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>E({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,$.jsx)(Dn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:_(On(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
|
|
7
|
-
`),placeholder:t.blocklistDomainsPlaceholder,disabled:!o.blocklistEnabled,onChange:e=>{E({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(Mt,{children:[(0,$.jsx)(jt,{icon:xe,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(Dn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:On(),value:o.maxResults,onChange:e=>E({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Pn,{row:n,providerIndex:r,labels:t,secretLabels:oe(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,E({providers:t})},onRemove:()=>{E({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(v,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>E({providers:[...o.providers,jn()]}),children:[(0,$.jsx)(h,{className:`size-4`}),t.addProvider]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w??t.loadError}),(0,$.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>void S(),children:n.refresh})]}):(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function Pn(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>En(r).then(Fn),t[0]=r,t[1]=c);let d=c,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=_(kn(),`min-w-[8rem]`),t[2]=f):f=t[2];let p=n.type,m;t[3]!==o||t[4]!==n?(m=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=m):m=t[5];let h;t[6]===i.providerTypes?h=t[7]:(h=An.map(e=>(0,$.jsx)(u,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let g;t[8]!==n.type||t[9]!==m||t[10]!==h?(g=(0,$.jsx)(l,{className:f,value:p,onChange:m,children:h}),t[8]=n.type,t[9]=m,t[10]=h,t[11]=g):g=t[11];let y;t[12]!==o||t[13]!==n?(y=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=y):y=t[14];let b;t[15]!==n.disabled||t[16]!==y?(b=(0,$.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:y}),t[15]=n.disabled,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==i.disabled||t[19]!==b?(x=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[b,i.disabled]}),t[18]=i.disabled,t[19]=b,t[20]=x):x=t[20];let S;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(ot,{className:`size-4`}),t[21]=S):S=t[21];let C;t[22]===s?C=t[23]:(C=(0,$.jsx)(v,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:S}),t[22]=s,t[23]=C);let w;t[24]!==C||t[25]!==x?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x,C]}),t[24]=C,t[25]=x,t[26]=w):w=t[26];let T;t[27]!==w||t[28]!==g?(T=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,w]}),t[27]=w,t[28]=g,t[29]=T):T=t[29];let E;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(E=n.type===`searxng`?(0,$.jsx)(Dn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:On(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=E):E=t[34];let D;t[35]!==o||t[36]!==n?(D=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=D):D=t[37];let O;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==d||t[42]!==n.apiKey||t[43]!==a||t[44]!==D?(O=(0,$.jsx)(ae,{value:n.apiKey,onChange:D,placeholder:i.keyPlaceholder,labels:a,reveal:d,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=d,t[42]=n.apiKey,t[43]=a,t[44]=D,t[45]=O):O=t[45];let k;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==O?(k=(0,$.jsx)(Dn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:O}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=O,t[49]=k):k=t[49];let A;return t[50]!==T||t[51]!==E||t[52]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[T,E,k]}),t[50]=T,t[51]=E,t[52]=k,t[53]=A):A=t[53],A}function Fn(e){return e.apiKey??null}function In(){if(ce())return null;let e=window.open(`about:blank`,`xopc-oauth`);return e&&(e.opener=null),e}async function Ln(e,t){return ce()?(await window.electronAPI?.shell?.openExternalUrl(e))?.ok===!0:!t||t.closed?!1:(t.location.replace(e),!0)}function Rn(e){e&&!e.closed&&e.close()}var zn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function Bn(e){let t=new Map;for(let e of zn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function Vn(e){let t=(0,Z.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={type:`pick`},t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(``),m;t[1]===r?m=t[2]:(m=e=>{e||window.setTimeout(()=>{d({type:`pick`}),p(``)},200),r(e)},t[1]=r,t[2]=m);let h=m,g;t[3]!==h||t[4]!==c?(g=()=>{c(),h(!1)},t[3]=h,t[4]=c,t[5]=g):g=t[5];let v=g,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(D,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,E)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=_(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,T),t[7]=b):b=t[7];let x;t[8]!==i||t[9]!==a||t[10]!==v||t[11]!==o||t[12]!==s||t[13]!==f||t[14]!==u.presetKey||t[15]!==u.providerId||t[16]!==u.type?(x=(0,$.jsxs)(A,{children:[y,(0,$.jsx)(j,{className:b,children:u.type===`pick`?(0,$.jsx)(Un,{builtinRows:i,searchQuery:f,onSearchChange:p,labels:o,onPickBuiltin:e=>{let t=qe(e);d(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>d({type:`custom`})}):u.type===`builtin`?(0,$.jsx)(Wn,{providerId:u.providerId,builtinRows:i,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:v}):(0,$.jsx)(qn,{initialPresetKey:u.presetKey,customConfig:a,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:v})})]}),t[8]=i,t[9]=a,t[10]=v,t[11]=o,t[12]=s,t[13]=f,t[14]=u.presetKey,t[15]=u.providerId,t[16]=u.type,t[17]=x):x=t[17];let S;return t[18]!==h||t[19]!==n||t[20]!==x?(S=(0,$.jsx)(N,{open:n,onOpenChange:h,children:x}),t[18]=h,t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function Hn(e){let t=(0,Z.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=_(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Me.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(k,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function Un(e){let t=(0,Z.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:o,onPickCustom:s}=e,c;t[0]===r?c=t[1]:(c=r.trim().toLowerCase(),t[0]=r,t[1]=c);let l=c,u;bb0:{if(!l){u=n;break bb0}let e;if(t[2]!==n||t[3]!==l){let r;t[5]===l?r=t[6]:(r=e=>{let t=ze[e.id]?.aliases??[];return e.id.toLowerCase().includes(l)||e.name.toLowerCase().includes(l)||t.some(e=>e.toLowerCase().includes(l))},t[5]=l,t[6]=r),e=n.filter(r),t[2]=n,t[3]=l,t[4]=e}else e=t[4];u=e}let d=u,f;t[7]===d?f=t[8]:(f=Bn(d),t[7]=d,t[8]=f);let m=f,h;t[9]===a.step1Title?h=t[10]:(h=(0,$.jsx)(M,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:a.step1Title}),t[9]=a.step1Title,t[10]=h);let g;t[11]===a.close?g=t[12]:(g=(0,$.jsx)(Hn,{label:a.close}),t[11]=a.close,t[12]=g);let v;t[13]!==h||t[14]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(xe,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=y):y=t[16];let b;t[17]===i?b=t[18]:(b=e=>i(e.target.value),t[17]=i,t[18]=b);let x=a.searchPlaceholder,S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=_(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,Ze),t[19]=S):S=t[19];let C;t[20]!==a.searchPlaceholder||t[21]!==r||t[22]!==b?(C=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[y,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:b,placeholder:x,autoComplete:`off`,className:S})]})}),t[20]=a.searchPlaceholder,t[21]=r,t[22]=b,t[23]=C):C=t[23];let w;t[24]!==a.addCustom||t[25]!==a.customDescription||t[26]!==s||t[27]!==l?(w=l?null:(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:_(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Me.press),children:[(0,$.jsx)(p,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.customDescription})]}),(0,$.jsx)(J,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=a.addCustom,t[25]=a.customDescription,t[26]=s,t[27]=l,t[28]=w):w=t[28];let T;t[29]!==d.length||t[30]!==m||t[31]!==a.categories||t[32]!==a.noResults||t[33]!==o?(T=d.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:zn.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),className:_(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Me.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(de,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=d.length,t[30]=m,t[31]=a.categories,t[32]=a.noResults,t[33]=o,t[34]=T):T=t[34];let E;t[35]!==w||t[36]!==T?(E=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[w,T]}),t[35]=w,t[36]=T,t[37]=E):E=t[37];let D;return t[38]!==C||t[39]!==E||t[40]!==v?(D=(0,$.jsxs)($.Fragment,{children:[v,C,E]}),t[38]=C,t[39]=E,t[40]=v,t[41]=D):D=t[41],D}function Wn({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),s=ze[e],[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),b=(0,Q.useRef)(null),x=y(r).providersSettings,S=oe(x),C=(0,Q.useMemo)(()=>Ue(e,r),[e,r]),w=o?.supportsApiKey!==!1,T=o?.supportsOAuth===!0,[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(`idle`),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),[z,ee]=(0,Q.useState)(``),B=(0,Q.useRef)(null),V=(0,Q.useRef)(null),H=A===`waiting`||A===`waiting_code`;(0,Q.useEffect)(()=>{if(!E||!H)return;let t=window.setInterval(()=>{(async()=>{try{let n=await le(E);n.status===`waiting_auth`||n.status===`waiting_code`?(j(n.status===`waiting_code`?`waiting_code`:`waiting`),k(n.message??null),P(n.authUrl??null),I(n.instructions??null),R(n.deviceCode??null),n.authUrl&&n.authUrl!==V.current&&(V.current=n.authUrl,Ln(n.authUrl,B.current).catch(()=>{}))):n.status===`completed`?(window.clearInterval(t),Rn(B.current),B.current=null,e===`xopc-cloud`&&await Oe(),j(`success`),k(n.message??x.saved),window.setTimeout(a,600)):(n.status===`failed`||n.status===`cancelled`)&&(window.clearInterval(t),Rn(B.current),B.current=null,j(`error`),k(n.error??n.message??x.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(t)},[E,H,a,e,x.revokeFailed,x.saved]),(0,Q.useEffect)(()=>()=>{E&&ie(E).catch(()=>{})},[E]),(0,Q.useEffect)(()=>()=>{Rn(B.current),B.current=null},[]);let ne=async()=>{Rn(B.current),B.current=In(),V.current=null,j(`waiting`),k(x.oauthStarting),P(null),I(null),R(null),p(null);try{D((await pt(e)).sessionId)}catch(e){Rn(B.current),B.current=null,j(`error`),k(e instanceof Error?e.message:x.revokeFailed)}},W=async()=>{if(E){try{await U(E)}catch{}Rn(B.current),B.current=null,V.current=null,j(`idle`),k(null),D(null),P(null),I(null),R(null)}},re=async()=>{if(!(!E||!z.trim()))try{await te(E,z.trim()),ee(``),k(x.oauthProcessingCode)}catch(e){j(`error`),k(e instanceof Error?e.message:x.revokeFailed)}},K=async()=>{let t=c.trim();if(!(!t||!w)){d(!0),p(null);try{await G({[e]:t}),g(!0),window.setTimeout(a,600)}catch(e){p(e instanceof Error?e.message:n.saveError)}finally{d(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:_(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Me.press),"aria-label":n.back,children:(0,$.jsx)(J,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(M,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)(Hn,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.description}):null,w?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(ae,{id:`builtin-api-key`,value:c,onChange:l,placeholder:n.apiKeyPlaceholder,labels:S,inputRef:b,onKeyDown:e=>{e.key===`Enter`&&K()}})]}):null,T?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:x.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:x.oauthHint})]}),(0,$.jsxs)(v,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:H,onClick:()=>void ne(),children:[H?(0,$.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,x.oauth]})]}),O?(0,$.jsx)(`p`,{className:_(`text-xs`,A===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:O}):null,A===`waiting`||A===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N?(0,$.jsxs)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[x.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>void W(),children:x.cancelOAuth})]}):null,F?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:F}):null,L?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:x.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:L}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:x.deviceCodeHint})]}):null,A===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:z,onChange:e=>ee(e.target.value),onKeyDown:e=>e.key===`Enter`&&void re(),placeholder:x.pasteRedirectUrl,className:_(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ze)}),(0,$.jsx)(v,{type:`button`,variant:`primary`,onClick:()=>void re(),children:x.submitCode})]}):null]}):null,C.length>0&&w?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[Qe(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,f?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(v,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),w?(0,$.jsx)(v,{type:`button`,variant:`primary`,disabled:!c.trim()||u||h,onClick:()=>void K(),children:h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):u?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Gn(e=`custom`){if(e!==`custom`&&H[e]){let t=H[e].config;return{preset:e,providerId:fe(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Kn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:H[t.key]?Gn(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function qn({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[o,s]=(0,Q.useReducer)(Kn,void 0,()=>Gn(e)),[c,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),b=oe(y(r).providersSettings),{preset:x,providerId:S,baseUrl:C,api:w,apiKey:T,modelIds:E,error:D}=o,O=async()=>{let e=S.trim(),r=C.trim();if(!e){s({type:`setError`,value:n.providerIdRequired});return}if(!r){s({type:`setError`,value:n.baseUrlRequired});return}let i=E.map(e=>e.trim()).filter(Boolean);d(!0),s({type:`setError`,value:null});try{let n=t?.providers??{},o=x===`custom`?void 0:H[x]?.config,s={...o??{},baseUrl:r,api:w,apiKey:T.trim()||void 0,models:i.map(e=>o?.models?.find(t=>t.id===e)??{id:e})};await be({providers:{...n,[e]:s}}),a()}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},k=async()=>{let e=S.trim()||fe(x)||`custom`,t=C.trim();if(!t){s({type:`setError`,value:n.baseUrlRequired});return}p(!0),s({type:`setError`,value:null});try{let r=x===`custom`?void 0:H[x]?.config,i=(await ye({providerId:e,baseUrl:t,apiKey:T.trim()||void 0,api:w,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));s({type:`setModelIds`,values:i}),i.length===0&&s({type:`setError`,value:n.discoverModelsHint})}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},A=S.trim()&&C.trim(),j=(w===`openai-completions`||w===`openai-responses`)&&C.trim();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:_(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Me.press),"aria-label":n.back,children:(0,$.jsx)(J,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(M,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,$.jsx)(Hn,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,$.jsxs)(l,{id:`custom-preset`,value:x,onChange:e=>s({type:`applyPreset`,key:e.target.value}),className:he(),children:[(0,$.jsx)(u,{value:`custom`,children:n.presetCustom}),pe.map(e=>(0,$.jsx)(u,{value:e.key,children:e.label},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,value:S,onChange:e=>s({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:_(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ze)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:C,onChange:e=>s({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:_(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ze)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,$.jsx)(l,{id:`custom-api-type`,value:w,onChange:e=>s({type:`setApi`,value:e.target.value}),className:he(),children:Le.map(e=>(0,$.jsx)(u,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(ae,{id:`custom-api-key`,value:T,onChange:e=>s({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:b})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,$.jsxs)(v,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!j||f,onClick:()=>void k(),children:[f?(0,$.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),E.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>s({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:_(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ze)}),E.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({type:`removeModelSlot`,index:t}),className:_(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,Me.press),children:(0,$.jsx)(g,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,$.jsxs)(v,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>s({type:`addModelSlot`}),children:[(0,$.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),D?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:D}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(v,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,$.jsx)(v,{type:`button`,variant:`primary`,disabled:!A||c,onClick:()=>void O(),children:c?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function Jn(){let e=(0,Z.c)(31),t=b($n),n=!!t,{data:r,isLoading:i}=I(n),a;e[0]===n?a=e[1]:(a=n?C(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let{data:c,isLoading:l}=P(a,o,s),u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1},e[5]=u):u=e[5];let{data:d,isLoading:f}=P(n?Ve:null,Qn,u),p;e[6]===d?p=e[7]:(p=d===void 0?[]:d,e[6]=d,e[7]=p);let m=p,h;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},e[8]=h):h=e[8];let{data:g}=P(n?Y:null,Zn,h),_;bb0:{if(!c||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],_=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==c||e[12]!==m?(t=Te(c,se(r?.payload?.config),m),e[10]=r?.payload?.config,e[11]=c,e[12]=m,e[13]=t):t=e[13],_=t}let v=_,y;bb1:{if(!g){y=null;break bb1}let t;e[14]===g.config?t=e[15]:(t=ct(g.config),e[14]=g.config,e[15]=t),y=t}let x=y,S;if(e[16]!==v||e[17]!==x||e[18]!==c||e[19]!==m){S=[];let t=new Set((c??[]).filter(Xn).map(Yn)),n;e[21]===x?n=e[22]:(n=new Set(x?Object.keys(x.providers):[]),e[21]=x,e[22]=n);let r=n;for(let e of v){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?x.providers[e.id]?.models?.length??0:m.filter(t=>t.provider===e.id).length;S.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(x){let t;e[23]===x.providers?t=e[24]:(t=Object.entries(x.providers),e[23]=x.providers,e[24]=t);for(let[e,n]of t)S.some(t=>t.id===e)||S.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=v,e[17]=x,e[18]=c,e[19]=m,e[20]=S}else S=e[20];let w=S,T=i||l||f,E;return e[25]!==v||e[26]!==w||e[27]!==x||e[28]!==T||e[29]!==m?(E={cards:w,loading:T,builtinRows:v,customConfig:x,allModels:m},e[25]=v,e[26]=w,e[27]=x,e[28]=T,e[29]=m,e[30]=E):E=e[30],E}function Yn(e){return e.id}function Xn(e){return e.configured}function Zn(){return V()}function Qn(){return nt()}function $n(e){return e.token}function er(e){let t=(0,Z.c)(16),{labels:n,data:r,onAdd:i,onManage:a}=e,{cards:o,loading:s}=r;if(s){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(K,{className:`h-6 w-48 max-w-full`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(nr)})]}),t[1]=n):n=t[1],n}let c;if(t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==a){let e=o.filter(tr),r=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,s;t[7]===r?s=t[8]:(s=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[7]=r,t[8]=s);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(h,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==i?(u=(0,$.jsxs)(v,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:i,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=i,t[12]=u):u=t[12];let d;t[13]!==s||t[14]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[s,u]}),t[13]=s,t[14]=u,t[15]=d):d=t[15],c=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,$.jsxs)(v,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:i,children:[(0,$.jsx)(h,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,$.jsx)(rr,{card:e,labels:n,onManage:()=>a(e.id,e.isCustom)},e.id))})]}),t[2]=o,t[3]=n,t[4]=i,t[5]=a,t[6]=c}else c=t[6];return c}function tr(e){return e.configured}function nr(e){return(0,$.jsx)(K,{className:`h-32 rounded-2xl`},e)}function rr(e){let t=(0,Z.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=_(`group relative flex flex-col justify-between rounded-2xl bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Me.pressCard),t[0]=a):a=t[0];let o;t[1]===n.name?o=t[2]:(o=(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=o);let s;t[3]!==n.isCustom||t[4]!==r.custom?(s=n.isCustom?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=s):s=t[5];let c;t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(de,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]===c?u=t[11]:(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,l]}),t[10]=c,t[11]=u);let d;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(d=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=d):d=t[15];let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:d}),t[16]=d,t[17]=f);let p;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(B,{className:`size-3`,"aria-hidden":!0}),t[18]=p):p=t[18];let m;t[19]===r.manage?m=t[20]:(m=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[p,r.manage]}),t[19]=r.manage,t[20]=m);let h;t[21]!==m||t[22]!==f?(h=(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[f,m]}),t[21]=m,t[22]=f,t[23]=h):h=t[23];let g;return t[24]!==i||t[25]!==h||t[26]!==u?(g=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[u,h]}),t[24]=i,t[25]=h,t[26]=u,t[27]=g):g=t[27],g}function ir(e){let t=(0,Z.c)(156),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c;t[0]===n?c=t[1]:(c=()=>n?{...n}:ut(``),t[0]=n,t[1]=c);let[d,f]=(0,Q.useState)(c),[p,m]=(0,Q.useState)(ar),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{f(n=>({...n,[e]:t})),m(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=h):h=t[2];let y=h,b;t[3]!==d.contextWindow||t[4]!==d.id||t[5]!==d.maxTokens||t[6]!==s.modelIdRequired||t[7]!==s.mustBePositive?(b=()=>{let e=new Map;return(d.id||``).trim()||e.set(`id`,s.modelIdRequired),d.contextWindow!==void 0&&d.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),d.maxTokens!==void 0&&d.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),m(e),e.size===0},t[3]=d.contextWindow,t[4]=d.id,t[5]=d.maxTokens,t[6]=s.modelIdRequired,t[7]=s.mustBePositive,t[8]=b):b=t[8];let x=b,S;t[9]!==d||t[10]!==o||t[11]!==a||t[12]!==x?(S=()=>{if(!x())return;let e=(d.id||``).trim();a({...d,id:e,name:d.name?.trim()||e,reasoning:d.reasoning||!1,input:d.input||[`text`],contextWindow:d.contextWindow??128e3,maxTokens:d.maxTokens??16384,cost:{input:d.cost?.input??0,output:d.cost?.output??0,cacheRead:d.cost?.cacheRead??0,cacheWrite:d.cost?.cacheWrite??0}}),o()},t[9]=d,t[10]=o,t[11]=a,t[12]=x,t[13]=S):S=t[13];let C=S,w=d,T;t[14]===w?T=t[15]:(T=ue(w),t[14]=w,t[15]=T);let E=T,D=r?s.addModelTitle:s.editModelTitle,O;t[16]===D?O=t[17]:(O=(0,$.jsx)(M,{className:`text-base font-semibold text-fg`,children:D}),t[16]=D,t[17]=O);let A;t[18]!==s.modelProviderLabel||t[19]!==i?(A=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[18]=s.modelProviderLabel,t[19]=i,t[20]=A):A=t[20];let j;t[21]!==O||t[22]!==A?(j=(0,$.jsxs)(`div`,{children:[O,A]}),t[21]=O,t[22]=A,t[23]=j):j=t[23];let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=_(De,`p-1.5 hover:bg-surface-base`),t[24]=N):N=t[24];let P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(g,{className:`size-4`}),t[25]=P):P=t[25];let F;t[26]===s.close?F=t[27]:(F=(0,$.jsx)(k,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:N,"aria-label":s.close,children:P})}),t[26]=s.close,t[27]=F);let I;t[28]!==j||t[29]!==F?(I=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[j,F]}),t[28]=j,t[29]=F,t[30]=I):I=t[30];let L;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=L):L=t[31];let z;t[32]===s.modelId?z=t[33]:(z=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,L]}),t[32]=s.modelId,t[33]=z);let ee;t[34]===p?ee=t[35]:(ee=_(Je(),p.has(`id`)&&`border-red-500`),t[34]=p,t[35]=ee);let B=d.id||``,te;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>y(`id`,e.target.value),t[36]=te):te=t[36];let V=!r,H;t[37]!==ee||t[38]!==B||t[39]!==V?(H=(0,$.jsx)(`input`,{className:ee,value:B,onChange:te,placeholder:`e.g. llama3.1:8b`,disabled:V}),t[37]=ee,t[38]=B,t[39]=V,t[40]=H):H=t[40];let U;t[41]===p?U=t[42]:(U=p.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:p.get(`id`)}):null,t[41]=p,t[42]=U);let W;t[43]!==z||t[44]!==H||t[45]!==U?(W=(0,$.jsxs)(`div`,{children:[z,H,U]}),t[43]=z,t[44]=H,t[45]=U,t[46]=W):W=t[46];let G;t[47]===s.displayName?G=t[48]:(G=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[47]=s.displayName,t[48]=G);let re;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(re=Je(),t[49]=re):re=t[49];let K=d.name||``,q;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>y(`name`,e.target.value),t[50]=q):q=t[50];let J;t[51]===K?J=t[52]:(J=(0,$.jsx)(`input`,{className:re,value:K,onChange:q}),t[51]=K,t[52]=J);let ie;t[53]!==G||t[54]!==J?(ie=(0,$.jsxs)(`div`,{children:[G,J]}),t[53]=G,t[54]=J,t[55]=ie):ie=t[55];let ae;t[56]===s.inputTypes?ae=t[57]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[56]=s.inputTypes,t[57]=ae);let Y;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(Y=he(),t[58]=Y):Y=t[58];let oe;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>y(`input`,R(e.target.value)),t[59]=oe):oe=t[59];let se;t[60]===s?se=t[61]:(se=ne.map(e=>(0,$.jsx)(u,{value:e.value,children:s[e.labelKey]},e.value)),t[60]=s,t[61]=se);let ce;t[62]!==E||t[63]!==se?(ce=(0,$.jsx)(l,{className:Y,value:E,onChange:oe,children:se}),t[62]=E,t[63]=se,t[64]=ce):ce=t[64];let le;t[65]!==ae||t[66]!==ce?(le=(0,$.jsxs)(`div`,{children:[ae,ce]}),t[65]=ae,t[66]=ce,t[67]=le):le=t[67];let de=d.reasoning||!1,fe;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>y(`reasoning`,e.target.checked),t[68]=fe):fe=t[68];let X;t[69]===de?X=t[70]:(X=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:de,onChange:fe}),t[69]=de,t[70]=X);let pe;t[71]!==s.reasoning||t[72]!==X?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[X,s.reasoning]}),t[71]=s.reasoning,t[72]=X,t[73]=pe):pe=t[73];let me;t[74]!==le||t[75]!==pe?(me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[le,pe]}),t[74]=le,t[75]=pe,t[76]=me):me=t[76];let ge;t[77]===s.contextWindow?ge=t[78]:(ge=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[77]=s.contextWindow,t[78]=ge);let _e;t[79]===p?_e=t[80]:(_e=_(Je(),p.has(`contextWindow`)&&`border-red-500`),t[79]=p,t[80]=_e);let ve=d.contextWindow??128e3,ye;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>y(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=ye):ye=t[81];let be;t[82]!==_e||t[83]!==ve?(be=(0,$.jsx)(`input`,{type:`number`,min:1,className:_e,value:ve,onChange:ye}),t[82]=_e,t[83]=ve,t[84]=be):be=t[84];let xe;t[85]===p?xe=t[86]:(xe=p.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:p.get(`contextWindow`)}):null,t[85]=p,t[86]=xe);let Se;t[87]!==ge||t[88]!==be||t[89]!==xe?(Se=(0,$.jsxs)(`div`,{children:[ge,be,xe]}),t[87]=ge,t[88]=be,t[89]=xe,t[90]=Se):Se=t[90];let Ce;t[91]===s.maxOutputTokens?Ce=t[92]:(Ce=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[91]=s.maxOutputTokens,t[92]=Ce);let we;t[93]===p?we=t[94]:(we=_(Je(),p.has(`maxTokens`)&&`border-red-500`),t[93]=p,t[94]=we);let Te=d.maxTokens??16384,Ee;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>y(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Ee):Ee=t[95];let Oe;t[96]!==we||t[97]!==Te?(Oe=(0,$.jsx)(`input`,{type:`number`,min:1,className:we,value:Te,onChange:Ee}),t[96]=we,t[97]=Te,t[98]=Oe):Oe=t[98];let ke;t[99]===p?ke=t[100]:(ke=p.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:p.get(`maxTokens`)}):null,t[99]=p,t[100]=ke);let Ae;t[101]!==Ce||t[102]!==Oe||t[103]!==ke?(Ae=(0,$.jsxs)(`div`,{children:[Ce,Oe,ke]}),t[101]=Ce,t[102]=Oe,t[103]=ke,t[104]=Ae):Ae=t[104];let je;t[105]!==Se||t[106]!==Ae?(je=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Se,Ae]}),t[105]=Se,t[106]=Ae,t[107]=je):je=t[107];let Me;t[108]===s.costSection?Me=t[109]:(Me=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[108]=s.costSection,t[109]=Me);let Ne;t[110]===s.costInput?Ne=t[111]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[110]=s.costInput,t[111]=Ne);let Pe;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=Je(),t[112]=Pe):Pe=t[112];let Fe=d.cost?.input??0,Ie;t[113]===d.cost?Ie=t[114]:(Ie=e=>y(`cost`,{...d.cost,input:parseFloat(e.target.value)||0,output:d.cost?.output??0,cacheRead:d.cost?.cacheRead??0,cacheWrite:d.cost?.cacheWrite??0}),t[113]=d.cost,t[114]=Ie);let Le;t[115]!==Fe||t[116]!==Ie?(Le=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[115]=Fe,t[116]=Ie,t[117]=Le):Le=t[117];let Re;t[118]!==Ne||t[119]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[118]=Ne,t[119]=Le,t[120]=Re):Re=t[120];let ze;t[121]===s.costOutput?ze=t[122]:(ze=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[121]=s.costOutput,t[122]=ze);let Be;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Be=Je(),t[123]=Be):Be=t[123];let Ve=d.cost?.output??0,He;t[124]===d.cost?He=t[125]:(He=e=>y(`cost`,{...d.cost,input:d.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:d.cost?.cacheRead??0,cacheWrite:d.cost?.cacheWrite??0}),t[124]=d.cost,t[125]=He);let Ue;t[126]!==Ve||t[127]!==He?(Ue=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Be,value:Ve,onChange:He}),t[126]=Ve,t[127]=He,t[128]=Ue):Ue=t[128];let We;t[129]!==ze||t[130]!==Ue?(We=(0,$.jsxs)(`div`,{children:[ze,Ue]}),t[129]=ze,t[130]=Ue,t[131]=We):We=t[131];let Ge;t[132]!==Re||t[133]!==We?(Ge=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Re,We]}),t[132]=Re,t[133]=We,t[134]=Ge):Ge=t[134];let Ke;t[135]!==Me||t[136]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Me,Ge]}),t[135]=Me,t[136]=Ge,t[137]=Ke):Ke=t[137];let qe;t[138]!==W||t[139]!==ie||t[140]!==me||t[141]!==je||t[142]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[W,ie,me,je,Ke]}),t[138]=W,t[139]=ie,t[140]=me,t[141]=je,t[142]=Ke,t[143]=qe):qe=t[143];let Ye;t[144]===s.cancel?Ye=t[145]:(Ye=(0,$.jsx)(k,{asChild:!0,children:(0,$.jsx)(v,{type:`button`,variant:`secondary`,children:s.cancel})}),t[144]=s.cancel,t[145]=Ye);let Xe=r?s.addModelConfirm:s.saveModelConfirm,Ze;t[146]!==C||t[147]!==Xe?(Ze=(0,$.jsx)(v,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:C,children:Xe}),t[146]=C,t[147]=Xe,t[148]=Ze):Ze=t[148];let Qe;t[149]!==Ye||t[150]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Ye,Ze]}),t[149]=Ye,t[150]=Ze,t[151]=Qe):Qe=t[151];let $e;return t[152]!==I||t[153]!==qe||t[154]!==Qe?($e=(0,$.jsxs)($.Fragment,{children:[I,qe,Qe]}),t[152]=I,t[153]=qe,t[154]=Qe,t[155]=$e):$e=t[155],$e}function ar(){return new Map}function or(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(D,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim`,E)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=_(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,T,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)(ir,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(A,{children:[l,(0,$.jsx)(j,{className:u,onOpenAutoFocus:sr,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(N,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function sr(e){return e.preventDefault()}function cr(e){let t=(0,Z.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>et(n).then(lr),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(ae,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function lr(e){return e.apiKey??null}function ur(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(D,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,E)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=_(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,T),t[1]=p):p=t[1];let m;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==l||t[7]!==u||t[8]!==r||t[9]!==d||t[10]!==i?(m=(0,$.jsxs)(A,{children:[f,(0,$.jsx)(j,{className:p,children:a?(0,$.jsx)(fr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d}):(0,$.jsx)(dr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=u,t[8]=r,t[9]=d,t[10]=i,t[11]=m):m=t[11];let h;return t[12]!==r||t[13]!==n||t[14]!==m?(h=(0,$.jsx)(N,{open:n,onOpenChange:r,children:m}),t[12]=r,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function dr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),l=ze[e],u=n.filter(t=>t.provider===e),[d,p]=(0,Q.useState)(s?.apiKey??``),[h,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),D=y(i).providersSettings,O=s?.supportsApiKey!==!1,A=s?.supportsOAuth===!0,j=s?.authMode===`oauth`&&s.authStatus===`connected`,N=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(`idle`),[ee,B]=(0,Q.useState)(null),[V,H]=(0,Q.useState)(null),[ne,W]=(0,Q.useState)(null),[re,K]=(0,Q.useState)(``),q=(0,Q.useRef)(null),J=(0,Q.useRef)(null),ae=R===`waiting`||R===`waiting_code`,Y=(0,Q.useMemo)(()=>Ue(e,i),[e,i]),oe=d!==(s?.apiKey??``),se=async()=>{let t=d.trim();if(!(!t||!O||Se(t))){b(!0),w(null);try{await G({[e]:t}),S(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){w(e instanceof Error?e.message:r.saveError)}finally{b(!1)}}};(0,Q.useEffect)(()=>{if(!P||!ae)return;let e=window.setInterval(()=>{(async()=>{try{let t=await le(P);t.status===`waiting_auth`||t.status===`waiting_code`?(z(t.status===`waiting_code`?`waiting_code`:`waiting`),L(t.message??null),B(t.authUrl??null),H(t.instructions??null),W(t.deviceCode??null),t.authUrl&&t.authUrl!==J.current&&(J.current=t.authUrl,Ln(t.authUrl,q.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),Rn(q.current),q.current=null,z(`success`),L(t.message??D.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),Rn(q.current),q.current=null,z(`error`),L(t.error??t.message??D.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,ae,a,o,D.revokeFailed,D.saved]),(0,Q.useEffect)(()=>()=>{P&&ie(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{Rn(q.current),q.current=null},[]);let ce=async()=>{try{await we(e),o(),a()}catch{}},ue=async()=>{Rn(q.current),q.current=In(),J.current=null,z(`waiting`),L(D.oauthStarting),B(null),H(null),W(null),w(null);try{F((await pt(e)).sessionId)}catch(e){Rn(q.current),q.current=null,z(`error`),L(e instanceof Error?e.message:D.revokeFailed)}},fe=async()=>{if(P){try{await U(P)}catch{}Rn(q.current),q.current=null,J.current=null,z(`idle`),L(null),F(null),B(null),H(null),W(null)}},X=async()=>{if(!(!P||!re.trim()))try{await te(P,re.trim()),K(``),L(D.oauthProcessingCode)}catch(e){z(`error`),L(e instanceof Error?e.message:D.revokeFailed)}},pe=async()=>{try{await _e(e),o(),a()}catch(e){w(e instanceof Error?e.message:D.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(M,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(k,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:_(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Me.press),children:(0,$.jsx)(g,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[l?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,s?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:s.baseUrl})]}):s?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,O?(0,$.jsx)(cr,{providerId:e,inputId:`manage-api-key`,value:d,onChange:e=>{p(e),S(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):s?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),s?.extensionId?(0,$.jsxs)(c,{to:`/settings/ext/${encodeURIComponent(s.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(f,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,A?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:D.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:j?D.sourceOauth:D.oauthHint})]}),j?(0,$.jsx)(v,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void pe(),children:D.revoke}):(0,$.jsxs)(v,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ae,onClick:()=>void ue(),children:[ae?(0,$.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(lt,{className:`size-3.5`,"aria-hidden":!0}),D.oauth]})]}),I?(0,$.jsx)(`p`,{className:_(`text-xs`,R===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:I}):null,R===`waiting`||R===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ee?(0,$.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,$.jsx)(f,{className:`size-4`,"aria-hidden":!0}),D.openAuthPage]}):null,(0,$.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:D.cancelOAuth})]}):null,V?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:V}):null,ne?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:D.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:ne}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:D.deviceCodeHint})]}):null,R===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:re,onChange:e=>K(e.target.value),onKeyDown:e=>e.key===`Enter`&&void X(),placeholder:D.pasteRedirectUrl,className:_(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ze)}),(0,$.jsx)(v,{type:`button`,variant:`primary`,onClick:()=>void X(),children:D.submitCode})]}):null]}):null,Y.length>0&&O?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Y.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[Qe(e,r),(0,$.jsx)(f,{className:`size-3`,"aria-hidden":!0})]},e))}):null,u.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,u.length,`)`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(e=>(0,$.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),C?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,$.jsxs)(v,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>E(!0),children:[(0,$.jsx)(ot,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:O&&oe&&!Se(d.trim())?(0,$.jsx)(v,{type:`button`,variant:`primary`,disabled:!d.trim()||h||x,onClick:()=>void se(),children:x?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(ve,{open:T,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ce(),onCancel:()=>E(!1)})]})}function fr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=y(r).modelsSettings,s=t?.providers[e],[c,l]=(0,Q.useState)(s?.baseUrl??``),[u,d]=(0,Q.useState)(s?.apiKey??``),[f,p]=(0,Q.useState)(s?.models??[]),[b,x]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,A]=(0,Q.useState)(null),[j,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(null),I=n=>{if(!t)return null;let r=u.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:Se(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},L=async()=>{let e=I({models:f,modelDiscovery:{enabled:b}});if(e){C(!0),T(null);try{await be(e),a(),i()}catch(e){T(e instanceof Error?e.message:n.saveError)}finally{C(!1)}}},R=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await be({providers:r}),a(),i()}catch{}},z=(e,t)=>{F({model:e,isNew:t}),N(!0)},ee=async e=>{if(!P)return;let t=P.isNew?[...f,e]:f.map(t=>t.id===e.id?e:t);p(t);let r=I({models:t});if(r)try{await be(r),a()}catch(e){T(e instanceof Error?e.message:n.saveError)}},B=async e=>{let t=f.filter(t=>t.id!==e);p(t),A(null);let r=I({models:t});if(r)try{await be(r),a()}catch(e){T(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(M,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(k,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:_(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Me.press),children:(0,$.jsx)(g,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:c,onChange:e=>l(e.target.value),className:_(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ze)})]}),(0,$.jsx)(cr,{providerId:e,inputId:`manage-custom-api-key`,value:u,onChange:d,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[o.modelsSection,f.length>0?` (${f.length})`:``]}),(0,$.jsxs)(v,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>z(null,!0),children:[(0,$.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),f.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:f.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:_(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Me.press),onClick:()=>z(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(Fe,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:_(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Me.press),onClick:()=>A(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(ot,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(v,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>D(!0),children:[(0,$.jsx)(ot,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(v,{type:`button`,variant:`primary`,disabled:S,onClick:()=>void L(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(ve,{open:E,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void R(),onCancel:()=>D(!1)}),(0,$.jsx)(ve,{open:O!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,O??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{O&&B(O)},onCancel:()=>A(null)}),(0,$.jsx)(or,{open:j,onOpenChange:e=>{N(e),e||F(null)},providerId:e,model:P?.model??null,isNew:P?.isNew??!1,onSave:e=>void ee(e),m:o})]})}async function pr(){let e=await S(C(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function mr(){let e=x(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=P(je,pr,{revalidateOnFocus:!1}),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null);if(r)return(0,$.jsx)(K,{className:`h-24 w-full rounded-2xl`});let c=Object.values(t?.sources??{}),l=c.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),u=(t?.references??[]).filter(e=>e.availability===`unavailable`),d=t?.sync.lastSuccessAt??Math.max(0,...c.map(e=>e.lastSuccessAt)),f=o??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),p=async()=>{a(!0),s(null);try{let e=await S(C(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await Oe()}catch(t){s(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{a(!1)}};return(0,$.jsx)(`div`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f||u.length>0?(0,$.jsx)(Ne,{className:`size-4 text-amber-500`,"aria-hidden":!0}):(0,$.jsx)(de,{className:`size-4 text-emerald-500`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e?`模型目录同步`:`Model catalog sync`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e?`${c.length} 个来源,${l} 个可用模型${d?` · 最近同步 ${new Date(d).toLocaleString()}`:``}`:`${c.length} sources, ${l} available models${d?` · Last synced ${new Date(d).toLocaleString()}`:``}`}),u.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:u.slice(0,3).map(t=>(0,$.jsxs)(`p`,{children:[t.ref,` `,e?`不可用`:`is unavailable`,t.suggestedRef?` · ${e?`建议`:`Suggested`} ${t.suggestedRef}`:``,` · ${t.locations.length} ${e?`处引用`:`references`}`]},t.ref))}):null,f?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:f}):null]}),(0,$.jsxs)(v,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void p(),children:[i?(0,$.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)($e,{className:`size-4`,"aria-hidden":!0}),i?e?`刷新中…`:`Refreshing…`:e?`立即刷新`:`Refresh now`]})]})})}async function hr(){return(await w(C(`/api/models/xopc-cloud/account-summary`))).payload}function gr(e){let t=(0,Z.c)(93),{labels:n}=e,r=x(_r)===`zh`?`zh-CN`:`en-US`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:6e4,revalidateOnFocus:!0},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,isValidating:c,mutate:l}=P(`/api/models/xopc-cloud/account-summary`,hr,i);if(s){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(K,{className:`h-48 w-full rounded-2xl`}),t[1]=e):e=t[1],e}if(o||!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ne,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),t[2]=e):e=t[2];let r;t[3]===n.title?r=t[4]:(r=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=r);let i;t[5]===n.unavailable?i=t[6]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.unavailable}),t[5]=n.unavailable,t[6]=i);let a;t[7]!==r||t[8]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[e,(0,$.jsxs)(`div`,{children:[r,i]})]}),t[7]=r,t[8]=i,t[9]=a):a=t[9];let o;t[10]===l?o=t[11]:(o=()=>void l(),t[10]=l,t[11]=o);let s=c?`size-4 animate-spin`:`size-4`,u;t[12]===s?u=t[13]:(u=(0,$.jsx)($e,{className:s,"aria-hidden":!0}),t[12]=s,t[13]=u);let d;t[14]!==c||t[15]!==n.retry||t[16]!==o||t[17]!==u?(d=(0,$.jsxs)(v,{type:`button`,variant:`secondary`,disabled:c,onClick:o,children:[u,n.retry]}),t[14]=c,t[15]=n.retry,t[16]=o,t[17]=u,t[18]=d):d=t[18];let f;return t[19]!==a||t[20]!==d?(f=(0,$.jsx)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[a,d]})}),t[19]=a,t[20]=d,t[21]=f):f=t[21],f}let u,d,p,m,h,g,_,y;if(t[22]!==a.balance.credits||t[23]!==a.usage.chargedCredits||t[24]!==a.usage.requests||t[25]!==a.usage.totalTokens||t[26]!==n.availableCredits||t[27]!==n.connected||t[28]!==n.title||t[29]!==n.usageSummary||t[30]!==r){let e=new Intl.NumberFormat(r);y=n.usageSummary.replace(`{{tokens}}`,e.format(a.usage.totalTokens)).replace(`{{credits}}`,e.format(a.usage.chargedCredits)).replace(`{{requests}}`,e.format(a.usage.requests)),_=`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-5`,g=`flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between`,p=`min-w-0 flex-1`;let i;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Ie,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),t[39]=i):i=t[39];let o;t[40]===n.title?o=t[41]:(o=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[40]=n.title,t[41]=o);let s;t[42]===n.connected?s=t[43]:(s=(0,$.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:text-emerald-300`,children:n.connected}),t[42]=n.connected,t[43]=s),t[44]!==o||t[45]!==s?(m=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i,o,s]}),t[44]=o,t[45]=s,t[46]=m):m=t[46],t[47]===n.availableCredits?h=t[48]:(h=(0,$.jsx)(`p`,{className:`mt-5 text-xs font-medium text-fg-subtle`,children:n.availableCredits}),t[47]=n.availableCredits,t[48]=h),u=`mt-1 text-3xl font-semibold tracking-tight text-fg`,d=e.format(a.balance.credits),t[22]=a.balance.credits,t[23]=a.usage.chargedCredits,t[24]=a.usage.requests,t[25]=a.usage.totalTokens,t[26]=n.availableCredits,t[27]=n.connected,t[28]=n.title,t[29]=n.usageSummary,t[30]=r,t[31]=u,t[32]=d,t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_,t[38]=y}else u=t[31],d=t[32],p=t[33],m=t[34],h=t[35],g=t[36],_=t[37],y=t[38];let b;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{className:`ml-2 text-sm font-medium text-fg-muted`,children:`credits`}),t[49]=b):b=t[49];let S;t[50]!==u||t[51]!==d?(S=(0,$.jsxs)(`p`,{className:u,children:[d,b]}),t[50]=u,t[51]=d,t[52]=S):S=t[52];let C;t[53]!==a.balance.credits||t[54]!==n.zeroBalance?(C=a.balance.credits===0?(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium text-danger`,children:n.zeroBalance}):null,t[53]=a.balance.credits,t[54]=n.zeroBalance,t[55]=C):C=t[55];let w;t[56]===n.recentUsage?w=t[57]:(w=(0,$.jsx)(`p`,{className:`mt-5 text-xs font-medium text-fg-subtle`,children:n.recentUsage}),t[56]=n.recentUsage,t[57]=w);let T;t[58]===y?T=t[59]:(T=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[58]=y,t[59]=T);let E;t[60]!==a.balance.updatedAt||t[61]!==n.updatedAt||t[62]!==r?(E=n.updatedAt.replace(`{{time}}`,new Date(a.balance.updatedAt).toLocaleString(r)),t[60]=a.balance.updatedAt,t[61]=n.updatedAt,t[62]=r,t[63]=E):E=t[63];let D;t[64]===E?D=t[65]:(D=(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:E}),t[64]=E,t[65]=D);let O;t[66]!==S||t[67]!==C||t[68]!==w||t[69]!==T||t[70]!==D||t[71]!==p||t[72]!==m||t[73]!==h?(O=(0,$.jsxs)(`div`,{className:p,children:[m,h,S,C,w,T,D]}),t[66]=S,t[67]=C,t[68]=w,t[69]=T,t[70]=D,t[71]=p,t[72]=m,t[73]=h,t[74]=O):O=t[74];let k;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[75]=k):k=t[75];let A;t[76]!==a.links.purchase||t[77]!==n.purchase?(A=(0,$.jsx)(v,{asChild:!0,variant:`primary`,children:(0,$.jsxs)(`a`,{href:a.links.purchase,target:`_blank`,rel:`noreferrer`,children:[n.purchase,k]})}),t[76]=a.links.purchase,t[77]=n.purchase,t[78]=A):A=t[78];let j;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[79]=j):j=t[79];let M;t[80]!==a.links.details||t[81]!==n.details?(M=(0,$.jsx)(v,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(`a`,{href:a.links.details,target:`_blank`,rel:`noreferrer`,children:[n.details,j]})}),t[80]=a.links.details,t[81]=n.details,t[82]=M):M=t[82];let N;t[83]!==A||t[84]!==M?(N=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[A,M]}),t[83]=A,t[84]=M,t[85]=N):N=t[85];let F;t[86]!==O||t[87]!==N||t[88]!==g?(F=(0,$.jsxs)(`div`,{className:g,children:[O,N]}),t[86]=O,t[87]=N,t[88]=g,t[89]=F):F=t[89];let I;return t[90]!==F||t[91]!==_?(I=(0,$.jsx)(`section`,{className:_,children:F}),t[90]=F,t[91]=_,t[92]=I):I=t[92],I}function _r(e){return e.language}function vr(e){return ge.includes(e)}function yr(){let e=(0,Z.c)(71),t=x(Sr),n;e[0]===t?n=e[1]:(n=y(t),e[0]=t,e[1]=n);let r=n,l=r.capabilitiesSettings,u=o(),[d,f]=a(),{capability:p}=i(),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),b=Jn(),S;e[2]===b.cards?S=e[3]:(S=b.cards.some(xr),e[2]=b.cards,e[3]=S);let C=S,w,T;e[4]!==p||e[5]!==d||e[6]!==f?(w=()=>{if(p!==`models`||d.get(`add`)!==`1`)return;h(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},T=[p,d,f],e[4]=p,e[5]=d,e[6]=f,e[7]=w,e[8]=T):(w=e[7],T=e[8]),(0,Q.useEffect)(w,T);let E;e[9]!==l.modelsHint||e[10]!==l.tabs.models?(E={id:`models`,icon:Be,label:l.tabs.models,hint:l.modelsHint},e[9]=l.modelsHint,e[10]=l.tabs.models,e[11]=E):E=e[11];let D;e[12]!==l.imageHint||e[13]!==l.tabs.image?(D={id:`image`,icon:z,label:l.tabs.image,hint:l.imageHint},e[12]=l.imageHint,e[13]=l.tabs.image,e[14]=D):D=e[14];let O;e[15]!==l.tabs.voice||e[16]!==l.voiceHint?(O={id:`voice`,icon:We,label:l.tabs.voice,hint:l.voiceHint},e[15]=l.tabs.voice,e[16]=l.voiceHint,e[17]=O):O=e[17];let k;e[18]!==l.searchHint||e[19]!==l.tabs.search?(k={id:`search`,icon:xe,label:l.tabs.search,hint:l.searchHint},e[18]=l.searchHint,e[19]=l.tabs.search,e[20]=k):k=e[20];let A;e[21]!==E||e[22]!==D||e[23]!==O||e[24]!==k?(A=[E,D,O,k],e[21]=E,e[22]=D,e[23]=O,e[24]=k,e[25]=A):A=e[25];let j=A,M;e[26]===u?M=e[27]:(M=e=>u(ee(e)),e[26]=u,e[27]=M);let N=M,P=br;if(!vr(p)){let t;return e[28]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(s,{to:ee(`models`),replace:!0}),e[28]=t):t=e[28],t}let F=r.nav.settingsCapabilities,I=l.subtitle,L;e[29]===t?L=e[30]:(L=Ce(t,`configuration`),e[29]=t,e[30]=L);let R;e[31]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Ye,{className:`size-4`,"aria-hidden":!0}),e[31]=R):R=e[31];let B;e[32]===l.agentSettingsLink?B=e[33]:(B=(0,$.jsx)(v,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(c,{to:`/agents`,children:[R,l.agentSettingsLink]})}),e[32]=l.agentSettingsLink,e[33]=B);let te;e[34]!==l.docsLink||e[35]!==l.subtitle||e[36]!==r.nav.settingsCapabilities||e[37]!==L||e[38]!==B?(te=(0,$.jsx)(mt,{title:F,subtitle:I,docsLink:L,docsLabel:l.docsLink,actions:B}),e[34]=l.docsLink,e[35]=l.subtitle,e[36]=r.nav.settingsCapabilities,e[37]=L,e[38]=B,e[39]=te):te=e[39];let V;e[40]!==l.tabsAria||e[41]!==p||e[42]!==j||e[43]!==N?(V=(0,$.jsx)(Nt,{items:j,activeTab:p,onChange:N,ariaLabel:l.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}),e[40]=l.tabsAria,e[41]=p,e[42]=j,e[43]=N,e[44]=V):V=e[44];let H;e[45]!==l.connectedProviders||e[46]!==l.xopcCloudAccount||e[47]!==p||e[48]!==b||e[49]!==j||e[50]!==C?(H=j.map(e=>(0,$.jsx)(wr,{id:e.id,activeSection:p,hint:e.hint,children:e.id===`models`?(0,$.jsxs)($.Fragment,{children:[C?(0,$.jsx)(gr,{labels:l.xopcCloudAccount}):null,(0,$.jsx)(mr,{}),(0,$.jsx)(er,{labels:l.connectedProviders,data:b,onAdd:()=>h(!0),onManage:(e,t)=>_({providerId:e,isCustom:t})})]}):(0,$.jsx)(Cr,{section:e.id})},e.id)),e[45]=l.connectedProviders,e[46]=l.xopcCloudAccount,e[47]=p,e[48]=b,e[49]=j,e[50]=C,e[51]=H):H=e[51];let ne;e[52]!==m||e[53]!==l.addProviderDialog||e[54]!==t||e[55]!==b.builtinRows||e[56]!==b.customConfig?(ne=(0,$.jsx)(Vn,{open:m,onOpenChange:h,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:l.addProviderDialog,language:t,onSaved:P}),e[52]=m,e[53]=l.addProviderDialog,e[54]=t,e[55]=b.builtinRows,e[56]=b.customConfig,e[57]=ne):ne=e[57];let U;e[58]!==l.manageProviderDialog||e[59]!==t||e[60]!==g||e[61]!==b.allModels||e[62]!==b.builtinRows||e[63]!==b.customConfig?(U=g?(0,$.jsx)(ur,{open:!0,onOpenChange:e=>{e||_(null)},providerId:g.providerId,isCustom:g.isCustom,builtinRows:b.builtinRows,customConfig:b.customConfig,allModels:b.allModels,labels:l.manageProviderDialog,language:t,onSaved:P}):null,e[58]=l.manageProviderDialog,e[59]=t,e[60]=g,e[61]=b.allModels,e[62]=b.builtinRows,e[63]=b.customConfig,e[64]=U):U=e[64];let W;return e[65]!==te||e[66]!==V||e[67]!==H||e[68]!==ne||e[69]!==U?(W=(0,$.jsxs)(ht,{children:[te,V,H,ne,U]}),e[65]=te,e[66]=V,e[67]=H,e[68]=ne,e[69]=U,e[70]=W):W=e[70],W}function br(){Oe()}function xr(e){return e.id===`xopc-cloud`&&!e.isCustom}function Sr(e){return e.language}function Cr(e){let t=(0,Z.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Yt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(un,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nn,{}),t[2]=e):e=t[2],e}}}function wr({id:e,activeSection:t,hint:n,children:r}){let i=e===t,a=(0,Q.useRef)(i);return i&&(a.current=!0),a.current?(0,$.jsxs)(`div`,{role:`tabpanel`,id:`capability-panel-${e}`,"aria-labelledby":`capability-tab-${e}`,hidden:!i,className:_(`min-w-0 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,i?`flex flex-col gap-3`:void 0),children:[i?(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{yr as CapabilitiesSettingsPanel};
|