@xopcai/xopc 0.0.166 → 0.0.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DkALQFJT.js → activity-store-DjEDu38T.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Tr2hgn4j.js → agent-avatar-dicebear-DQULz7qY.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CnzkBgKC.js +2 -0
- package/dist/gateway/static/root/assets/{api-DPIXEcIq.js → api-DwVCuPOb.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D7Nrbhez.js → app-management-settings-panel-DOjWALVF.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DNNbABFj.js → appearance-settings-C31COUIC.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-0zXIeywq.js → apps-page-lSC486eu.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CizqFy4G.js → archive-plugin-DQPvLqfx.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DU8KjTua.js → attachment-load-DwT1x1rc.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-3pqyIveW.js → automation-suggestion-card-ByYBiiMR.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DSz3xDsi.js → automations-page-iZTnc1YZ.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-CipUnsOr.js → binary-plugins-CRXiHoZS.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-XoEq6qiv.js → block-editor-CHO6ILiz.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-COYvq3y5.js → browser-settings-page-C-OOPZcJ.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-DRH995XI.js → browser-workflow-inputs-3UaarfXS.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-65edjhpz.js → browser-workflows-page-BFaa-N_D.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BayH0Uom.js +7 -0
- package/dist/gateway/static/root/assets/capability-presets-api-DdCHSzcA.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-JlhjAhT7.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-B5rLegwk.js → channel-recipient-api-BOkLI89e.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-D8nH0mve.js → channels-settings-C-Spmwr5.js} +1 -1
- package/dist/gateway/static/root/assets/channels-status-swr-ZrqadU60.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-n4Hg41iD.js → connector-logo-CbcC0T6i.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-jvRWZn3Y.js → connectors-page-DpDmJ3Nx.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-D4OzBOwm.js → desktop-pet-CR7RGQff.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CDGezbaf.js → desktop-pet-settings-BudmCcPE.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DmL4AUXQ.js → directory-picker-path-field-BLG2Oe6z.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-ClUcBKnd.js → dreaming-settings-BwBGC0SG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DsV_KUDM.js → extension-debug-page-Pr65_hLC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DJv_G1jY.js → extension-page-BuJDcoKn.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DUAlJ4CU.js → extension-settings-page-B3802tn5.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-SVYgzqv7.js → gateway-config-api-D-NVkfts.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-YL6f2C_F.js → gateway-settings-DIdsKVXv.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-ulwTJovP.js → gateway-startup-retry-qnEmj-vL.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-CJJe-4Co.js → goal-create-dialog-51j_DxgV.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-Da9VMWRd.js → goal-detail-page-CeqMr5GF.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-st_Itxa9.js → goals-config-api-BkVBh7ct.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-B6pC7PYZ.js → goals-page-lf3oM4Xa.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-BEZePZ5m.js → goals-settings-Cg7MJLvx.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DpeD9GQ9.js → heartbeat-settings-BV3kJOcX.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BhQMnKH1.js → index-B24B26og.js} +9 -9
- package/dist/gateway/static/root/assets/index-DfE2j0g8.css +1 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-B9K5rTZZ.js +1 -0
- package/dist/gateway/static/root/assets/{local-app-workbench-page-Ctia6lSG.js → local-app-workbench-page-ehzr9CBG.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-DWF9rpWQ.js → local-apps-page-BBx6mfAD.js} +1 -1
- package/dist/gateway/static/root/assets/locale-store-tnRLWdx2.js +1 -0
- package/dist/gateway/static/root/assets/{logs-page-D3gL6vHX.js → logs-page-xuwEkusZ.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-BuduJ0Ev.js → markdown-split-DRDddIt8.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CLASZjhT.js → media-plugins-Dn3hxhOV.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-C96Zjb0V.js → messages-B1EG4gdu.js} +2 -4
- package/dist/gateway/static/root/assets/{notes-page-ve3XiBDF.js → notes-page-BtKHSb4z.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-oHU532lp.js → notes-workbench-DXGXn5XF.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-DU85jn98.js → page-tabs-P2BEd1D8.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CtchTuRQ.js → preview-open-alternatives-DrkjmW0F.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DFT6Fx6y.js → product-open-page-CGzMEowb.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Ceu0NoC1.js → project-detail-page-IiE2ddWb.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-CdpqOmO8.js → projects-page-DGOVhaYI.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-D1NKLyiR.js → remote-access-hub-l_y_Shgl.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-CmcrHpMc.js → save-bar-controls-BkGrufxl.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-DmIkP6JV.js → schedule-field-A8tDpL-9.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Dkk9blN0.js → schema-form-N6_hDWgx.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CMj_JaOk.js → sessions-page-CAX4ipPv.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-eVlH9brU.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CuQzWvg5.js → settings-form-section-Bb6yYt5f.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-C5FNbyej.js → settings-loading-skeleton-Q_Vh6HEl.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-a-A2yTGE.js → settings-page-CjOtQpbR.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-MuXpamWD.js → settings-page-layout-CtESNNdx.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BUdh8FKY.js → setup-status-panel-CGxHXgJB.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BfzzmTgg.js → share-preview-page-C65IsFmd.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-8a9qnLF8.js → shares-settings-Ct3fcbHr.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-ElA5kabh.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-CmHj-CKY.js → skills-page-FeieOEn3.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CyhRkWMi.js → system-settings-panel-CdUl2I0D.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-D37XLD_C.js → theme-store-H9T49Iar.js} +1 -1
- package/dist/gateway/static/root/assets/{time-picker-WEPp3HrB.js → time-picker-EkhqT3fS.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-Bi1uoxFR.js → typed-models-lib-5xRRUE9Y.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-DBh0dOC9.js → use-channel-catalog-UACJTyH0.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-BObEyiim.js → user-context-page-DHiRvd4i.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-Gvgodhec.js → voice-api-key-field-Bql0SPCp.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BHnjvGH1.js → work-discovery-page-BcmZux7y.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-CQ8ybkxx.js → work-item-detail-page-D94Q5zVD.js} +1 -1
- package/dist/gateway/static/root/assets/{work-page-D_U_En23.js → work-page-DdFBMDcB.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-B-Sk6gFn.js → workflow-run-setup-panel-Dow7ZztR.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DT0pzfkz.js → workflows-page-wOVSoduy.js} +1 -1
- package/dist/gateway/static/root/index.html +8 -8
- package/dist/package.js +1 -1
- package/dist/src/agent/image/generation/custom-openai-images-provider.d.ts +7 -0
- package/dist/src/agent/image/generation/custom-openai-images-provider.js +81 -0
- package/dist/src/agent/image/generation/{openai-compatible-image-provider.d.ts → openai-images-provider.d.ts} +10 -31
- package/dist/src/agent/image/generation/{openai-compatible-image-provider.js → openai-images-provider.js} +36 -23
- package/dist/src/agent/image/generation/provider-registry.d.ts +2 -0
- package/dist/src/agent/image/generation/provider-registry.js +50 -4
- package/dist/src/agent/image/generation/providers/openai.js +2 -2
- package/dist/src/agent/image/generation/runtime.js +5 -1
- package/dist/src/agent/image/generation/types.d.ts +11 -0
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/image-providers.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/image-providers.js +68 -0
- package/dist/src/cli/commands/doctor/flow.js +2 -0
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/models-json.d.ts +325 -0
- package/dist/src/config/models-json.js +139 -4
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/custom-image-providers.d.ts +89 -0
- package/dist/src/gateway/custom-image-providers.js +59 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/routes/models.js +182 -1
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +7 -1
- package/dist/src/gateway/service/config-coordinator.js +2 -0
- package/dist/src/gateway/service.js +2 -2
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/media-shared/http/index.d.ts +1 -1
- package/dist/src/media-shared/http/index.js +2 -2
- package/dist/src/media-shared/http/provider-http.d.ts +2 -0
- package/dist/src/media-shared/http/provider-http.js +43 -4
- package/dist/src/providers/model-reference-auditor.d.ts +1 -0
- package/dist/src/providers/model-reference-auditor.js +23 -13
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/agents-DZ69tC4K.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-LOQyfdsM.js +0 -2
- package/dist/gateway/static/root/assets/capability-presets-api-XL4h7dCK.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-KPJFkt1h.js +0 -2
- package/dist/gateway/static/root/assets/channels-status-swr-DZZq0upi.js +0 -1
- package/dist/gateway/static/root/assets/index-BXtJvaQl.css +0 -1
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-fhssr2-J.js +0 -1
- package/dist/gateway/static/root/assets/locale-store-C_ax27uc.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DR9Q2ZyF.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-da5gLCer.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./circle-alert-BEjgurr2.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-C96Zjb0V.js";import{l as c,n as l,r as u,s as d}from"./locale-store-C_ax27uc.js";import{i as f,o as p}from"./vendor-swr-BIWyz7Rc.js";import{Cc as m,Cs as h,Ds as g,Ec as _,Js as v,Kc as y,Ms as b,Ns as x,Nt as S,Zo as C,ai as w,bl as T,cs as E,dc as D,ei as O,fc as k,no as A,os as j,pc as M,rl as N,ro as P,tr as F,ts as I,vl as L,ws as R}from"./index-BhQMnKH1.js";import{n as ee,r as te,t as z}from"./settings-page-layout-MuXpamWD.js";import{n as ne}from"./settings-loading-skeleton-C5FNbyej.js";import{t as re}from"./settings-advanced-gate-DR9Q2ZyF.js";import{n as B,t as ie}from"./settings-form-section-CuQzWvg5.js";import{t as ae}from"./page-tabs-DU85jn98.js";import{a as oe,c as se,d as ce,n as le,o as ue,r as de,t as fe}from"./gateway-config-api-SVYgzqv7.js";var V=e(t(),1),H=n(),pe={critical:3,warn:2,info:1};function U(){return u(`/api/doctor?security=true`)}function W(e){return e.toSorted((e,t)=>pe[t.severity]-pe[e.severity]||e.checkId.localeCompare(t.checkId))}function G(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=W((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function K(){return G(await d(U()))}var q=r();function me(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=l(he),o;t[0]===a?o=t[1]:(o=s(a),t[0]=a,t[1]=o);let c=o.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[U(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1},t[5]=d):d=t[5];let{data:m,error:h,isLoading:g,isValidating:v,mutate:y}=f(u,J,d),b=m??null,S=h instanceof Error?h.message:h?String(h):null,C=g||v,w;t[6]===y?w=t[7]:(w=()=>{y(),p(U())},t[6]=y,t[7]=w);let T=w,E=!n||C,D;t[8]===C?D=t[9]:(D=C?(0,q.jsx)(N,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,q.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t[8]=C,t[9]=D);let O;t[10]===c.securityAuditRefresh?O=t[11]:(O=(0,q.jsx)(`span`,{className:`ml-1.5`,children:c.securityAuditRefresh}),t[10]=c.securityAuditRefresh,t[11]=O);let k;t[12]!==T||t[13]!==E||t[14]!==D||t[15]!==O?(k=(0,q.jsxs)(x,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:T,children:[D,O]}),t[12]=T,t[13]=E,t[14]=D,t[15]=O,t[16]=k):k=t[16];let A;t[17]!==c.securityAuditSubtitle||t[18]!==c.securityAuditTitle||t[19]!==k?(A=(0,q.jsx)(B,{icon:M,title:c.securityAuditTitle,subtitle:c.securityAuditSubtitle,trailing:k}),t[17]=c.securityAuditSubtitle,t[18]=c.securityAuditTitle,t[19]=k,t[20]=A):A=t[20];let j;t[21]===c.securityAuditSavedConfigHint?j=t[22]:(j=(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:c.securityAuditSavedConfigHint}),t[21]=c.securityAuditSavedConfigHint,t[22]=j);let F;t[23]!==S||t[24]!==c.securityAuditLoadError?(F=S?(0,q.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[c.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=c.securityAuditLoadError,t[25]=F):F=t[25];let I;t[26]!==b||t[27]!==S||t[28]!==C?(I=!S&&C&&!b?(0,q.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,q.jsx)(P,{className:`h-11 w-full rounded-lg`}),(0,q.jsx)(P,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=b,t[27]=S,t[28]=C,t[29]=I):I=t[29];let L;t[30]!==b||t[31]!==c?(L=b?(0,q.jsx)(ge,{g:c,audit:b}):null,t[30]=b,t[31]=c,t[32]=L):L=t[32];let R;return t[33]!==A||t[34]!==j||t[35]!==F||t[36]!==I||t[37]!==L?(R=(0,q.jsxs)(ie,{children:[A,j,F,I,L]}),t[33]=A,t[34]=j,t[35]=F,t[36]=I,t[37]=L,t[38]=R):R=t[38],R}function J(){return K()}function he(e){return e.language}function ge(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,a,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=ye(n,r.status,r.findings),d=`space-y-4`,l=o(`rounded-lg border px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,c=`flex items-start gap-2`,i=a.icon,s=o(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==s?(f=(0,q.jsx)(i,{className:s,"aria-hidden":!0}),t[10]=i,t[11]=s,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,q.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,q.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,q.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==c||t[21]!==f||t[22]!==h?(g=(0,q.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,q.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,q.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,q.jsx)(_e,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,q.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,q.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Y)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,q.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function Y(e){return(0,q.jsx)(`li`,{className:`font-mono`,children:e},e)}function _e(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,a,s,c;if(t[0]!==r.severity){let e=ve(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,s=`flex items-start gap-2`,i=e.icon,a=o(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=s,t[4]=c}else i=t[1],a=t[2],s=t[3],c=t[4];let l;t[5]!==i||t[6]!==a?(l=(0,q.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,q.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,q.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==s||t[26]!==l?(g=(0,q.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,q.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function ve(e){switch(e){case`critical`:return{icon:a,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:v,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:T,iconClass:`text-fg-muted`}}}function ye(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:a,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`border-red-200 bg-red-50 text-red-950 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:v,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:T,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`border-edge bg-surface-panel/60 text-fg`}:{icon:M,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`border-emerald-200 bg-emerald-50 text-emerald-950 dark:border-emerald-900/50 dark:bg-emerald-950/40 dark:text-emerald-100`}}function X(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}var be=[`network`,`access`,`updates`,`security`,`advanced`],xe={network:y,access:L,updates:_,security:k,advanced:D};function Se(e){return e&&be.includes(e)?e:`network`}function Z(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function Ce(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function we(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var Te={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Ee(){let e=l(e=>e.language),t=s(e),n=t.gatewaySettings,[r,u]=i(),d=O(e=>e.mode),f=d===`advanced`,p=Se(r.get(`tab`)),g=(0,V.useMemo)(()=>ce(be,d),[d]),_=(0,V.useCallback)(e=>{u(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[u]);se(p,_);let v=c(e=>e.token),y=c(e=>e.tokenExpired),b=c(e=>e.openTokenDialog),T=!!v,[D,k]=(0,V.useReducer)(we,{form:null,baseline:null,appliedBaseline:null}),M=D.form,P=D.baseline,L=D.appliedBaseline,[R,z]=(0,V.useReducer)(S,Te),{saving:B,error:ie,auditRefreshToken:ae,restarting:H,restartConfirmOpen:pe}=R,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:J,isLoading:he,mutate:ge}=A(T),Y=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(le(K.payload.config)),[K]);T?Y!==null&&(G.current||(G.current=!0,k({type:`init-applied`,value:Y})),!U.current&&W.current!==Y&&(W.current=Y,k({type:`sync`,value:Y}),z({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,k({type:`reset`}),U.current=!1);let _e=!!(T&&he&&K===void 0&&!J),ve=J instanceof Error?J.message:J?String(J):null,ye=(0,V.useMemo)(()=>!M||!P?!1:JSON.stringify(M)!==JSON.stringify(P),[M,P]),xe=(0,V.useMemo)(()=>!P||!L?!1:fe(L,P),[L,P]),Z=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),Ce=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Ee=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),$=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Fe=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,port:e})})},[]),Ie=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Le=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,maxSseConnections:e})})},[]),Re=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),ze=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Be=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Ve=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),He=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Ue=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),We=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ge=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),Ke=(0,V.useCallback)(async()=>{if(!M||B)return;let e=ue(M);if(e){z({type:`patch`,patch:{error:e}});return}z({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await de(M),U.current=!1,k({type:`saved`,value:M}),z({type:`patch`,patch:{saveOk:!0,auditRefreshToken:ae+1}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{z({type:`patch`,patch:{saving:!1}})}},[M,B,n.saveError]),qe=(0,V.useCallback)(()=>{P&&(U.current=!1,k({type:`discard`}),z({type:`patch`,patch:{error:null,saveOk:!1}}))},[P]),Je=h(n),Ye=(0,V.useCallback)(async()=>{if(!H){z({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await w();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):C({type:`error`,title:n.restartGatewayFailed,message:e.message??``})}catch(e){C({type:`error`,title:n.restartGatewayFailed,message:e instanceof Error?e.message:String(e)})}finally{z({type:`patch`,patch:{restarting:!1}})}}},[H,n.restartGatewayFailed]);return T?_e?(0,q.jsx)(te,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,q.jsx)(ne,{sections:3})}):M?(0,q.jsxs)(te,{gap:`gap-6`,children:[(0,q.jsx)(ee,{title:t.settingsSections.gateway,subtitle:n.subtitle,docsLink:I(e,`gateway`),docsLabel:n.docsLink,actions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(x,{type:`button`,variant:`secondary`,disabled:!ye||B,onClick:qe,children:n.discard}),(0,q.jsx)(x,{type:`button`,variant:`primary`,disabled:!ye||B,onClick:()=>void Ke(),children:B?n.saving:n.save})]})}),y?(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-900/50 dark:bg-red-950/40`,role:`alert`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(a,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,q.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,q.jsx)(`div`,{children:(0,q.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>b(),children:n.updateToken})})]}):null,ye?(0,q.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,ie?(0,q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ie}):null,xe?(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-950/40`,children:[(0,q.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,q.jsxs)(x,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:H,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[H?(0,q.jsx)(N,{className:`size-3.5 animate-spin`}):(0,q.jsx)(m,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,q.jsx)(F,{open:pe,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Ye(),onCancel:()=>z({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,q.jsx)(De,{g:n,activeTab:p,visibleTabs:g,onChange:_}),(0,q.jsxs)(Q,{g:n,id:`network`,activeTab:p,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,q.jsxs)(j,{id:`gateway-bind-mode`,className:X(),value:M.bind,onChange:e=>$(e.target.value),children:[(0,q.jsx)(E,{value:`loopback`,children:n.bindLoopback}),f?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E,{value:`lan`,children:n.bindLan}),(0,q.jsx)(E,{value:`auto`,children:n.bindAuto}),(0,q.jsx)(E,{value:`custom`,children:n.bindCustom}),(0,q.jsx)(E,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,q.jsx)(`input`,{id:`gateway-custom-bind-host`,className:o(X(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>Pe(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,q.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:o(X(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);Fe(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,q.jsx)(re,{children:(0,q.jsx)(je,{g:n,origins:M.corsOrigins,onChange:Ee})})]}),(0,q.jsxs)(Q,{g:n,id:`access`,activeTab:p,children:[M.auth.mode===`none`?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,q.jsxs)(j,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>Z({mode:e.target.value}),className:X(),children:[(0,q.jsx)(E,{value:`token`,children:n.authModeToken}),(0,q.jsx)(E,{value:`password`,children:n.authModePassword}),f?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,q.jsx)(E,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,q.jsx)(re,{children:M.auth.mode===`trusted-proxy`?(0,q.jsx)(ke,{g:n,form:M,onTrustedProxyChange:He,onTrustedProxiesChange:Ve,onAllowRealIpFallbackChange:We}):null}),M.auth.mode===`token`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Ne,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:M.auth.token,labels:Je,reveal:()=>oe(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Z({token:e})}),(0,q.jsx)(x,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>b(),children:n.changeToken})]}):null,M.auth.mode===`password`?(0,q.jsx)(Ne,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:M.auth.password,labels:Je,reveal:()=>oe(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Z({password:e})}):null,(0,q.jsx)(re,{children:M.auth.mode===`none`?null:(0,q.jsx)(Me,{g:n,rateLimit:M.auth.rateLimit,onChange:Ie})})]}),(0,q.jsxs)(Q,{g:n,id:`updates`,activeTab:p,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,q.jsxs)(j,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>Ce(e.target.value),className:X(),children:[(0,q.jsx)(E,{value:`stable`,children:n.channelStable}),(0,q.jsx)(E,{value:`beta`,children:n.channelBeta}),(0,q.jsx)(E,{value:`dev`,children:n.channelDev})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoStableDelayHours,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoStableJitterHours,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,q.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,q.jsxs)(Q,{g:n,id:`security`,activeTab:p,children:[(0,q.jsx)(me,{enabled:T,refreshToken:ae}),(0,q.jsx)(Oe,{g:n,form:M,onSecurityStrictChange:Ue,onDangerouslyAllowHostHeaderOriginFallbackChange:Ge})]}),(0,q.jsx)(Q,{g:n,id:`advanced`,activeTab:p,children:(0,q.jsx)(Ae,{g:n,form:M,onMaxSseConnectionsChange:Le,onDeferModeChange:Re,onDeferIdsChange:ze,onSkipIdsChange:Be})})]}):(0,q.jsxs)(te,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ie??ve??n.loadError}),(0,q.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>void ge(),children:n.retry})]}):(0,q.jsxs)(te,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(ee,{title:t.settingsSections.gateway}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function De(e){let t=(0,H.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Z(n,e),icon:xe[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,q.jsx)(ae,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Q(e){let t=(0,H.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Z(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Ce(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,q.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,q.jsx)(z,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Oe(e){let t=(0,H.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,q.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,q.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,q.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,q.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function ke(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(X(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,q.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,q.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==c.requiredHeaders?(_=(0,q.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==c.allowUsers?(y=(0,q.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,q.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,q.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,q.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,q.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,q.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function Ae(e){let t=(0,H.c)(58),{g:n,form:r,onMaxSseConnectionsChange:i,onDeferModeChange:a,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.maxSseConnections?l=t[1]:(l=(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-max-sse`,children:n.maxSseConnections}),t[0]=n.maxSseConnections,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(X(),`max-w-xs font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]===i?d=t[4]:(d=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i(Math.max(1,Math.floor(t)))},t[3]=i,t[4]=d);let f;t[5]!==r.maxSseConnections||t[6]!==d?(f=(0,q.jsx)(`input`,{id:`gateway-max-sse`,type:`number`,min:1,className:u,value:r.maxSseConnections,onChange:d}),t[5]=r.maxSseConnections,t[6]=d,t[7]=f):f=t[7];let p;t[8]===n.maxSseConnectionsHint?p=t[9]:(p=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.maxSseConnectionsHint}),t[8]=n.maxSseConnectionsHint,t[9]=p);let m;t[10]!==l||t[11]!==f||t[12]!==p?(m=(0,q.jsxs)(`div`,{children:[l,f,p]}),t[10]=l,t[11]=f,t[12]=p,t[13]=m):m=t[13];let h;t[14]===n.channelConnectDeferMode?h=t[15]:(h=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[14]=n.channelConnectDeferMode,t[15]=h);let g=r.channelConnectDeferMode,_;t[16]===a?_=t[17]:(_=e=>a(e.target.value),t[16]=a,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=X(),t[18]=v):v=t[18];let y;t[19]===n.channelConnectDeferModeAuto?y=t[20]:(y=(0,q.jsx)(E,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[19]=n.channelConnectDeferModeAuto,t[20]=y);let b;t[21]===n.channelConnectDeferModeOff?b=t[22]:(b=(0,q.jsx)(E,{value:`off`,children:n.channelConnectDeferModeOff}),t[21]=n.channelConnectDeferModeOff,t[22]=b);let x;t[23]===n.channelConnectDeferModeExplicit?x=t[24]:(x=(0,q.jsx)(E,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[23]=n.channelConnectDeferModeExplicit,t[24]=x);let S;t[25]!==r.channelConnectDeferMode||t[26]!==y||t[27]!==b||t[28]!==x||t[29]!==_?(S=(0,q.jsxs)(j,{id:`gateway-channel-defer-mode`,value:g,onChange:_,className:v,children:[y,b,x]}),t[25]=r.channelConnectDeferMode,t[26]=y,t[27]=b,t[28]=x,t[29]=_,t[30]=S):S=t[30];let C;t[31]===n.channelConnectDeferModeHint?C=t[32]:(C=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[31]=n.channelConnectDeferModeHint,t[32]=C);let w;t[33]!==S||t[34]!==C||t[35]!==h?(w=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[h,S,C]}),t[33]=S,t[34]=C,t[35]=h,t[36]=w):w=t[36];let T;t[37]!==r.channelConnectDeferIds||t[38]!==r.channelConnectDeferMode||t[39]!==n.channelConnectDeferIds||t[40]!==n.channelConnectDeferIdsHint||t[41]!==n.channelIdListEmpty||t[42]!==n.channelIdListPlaceholder||t[43]!==s?(T=r.channelConnectDeferMode===`explicit`?(0,q.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:s}):null,t[37]=r.channelConnectDeferIds,t[38]=r.channelConnectDeferMode,t[39]=n.channelConnectDeferIds,t[40]=n.channelConnectDeferIdsHint,t[41]=n.channelIdListEmpty,t[42]=n.channelIdListPlaceholder,t[43]=s,t[44]=T):T=t[44];let D;t[45]!==r.channelConnectDeferMode||t[46]!==r.channelConnectDeferSkipIds||t[47]!==n.channelConnectDeferSkipIds||t[48]!==n.channelConnectDeferSkipIdsHint||t[49]!==n.channelIdListEmpty||t[50]!==n.channelIdListPlaceholder||t[51]!==c?(D=r.channelConnectDeferMode===`off`?null:(0,q.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:c}),t[45]=r.channelConnectDeferMode,t[46]=r.channelConnectDeferSkipIds,t[47]=n.channelConnectDeferSkipIds,t[48]=n.channelConnectDeferSkipIdsHint,t[49]=n.channelIdListEmpty,t[50]=n.channelIdListPlaceholder,t[51]=c,t[52]=D):D=t[52];let O;return t[53]!==w||t[54]!==T||t[55]!==D||t[56]!==m?(O=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[m,w,T,D]}),t[53]=w,t[54]=T,t[55]=D,t[56]=m,t[57]=O):O=t[57],O}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==l||t[10]!==s?(h=s.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,q.jsx)(`button`,{type:`button`,className:o(`text-fg-muted hover:text-fg`,g.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=s,t[11]=h):h=t[11];let _;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=o(X(),`font-mono text-xs`),t[12]=_):_=t[12];let v=s.length>=c,y;t[13]===f?y=t[14]:(y=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=y);let b;t[15]!==a||t[16]!==v||t[17]!==y?(b=(0,q.jsx)(`input`,{className:_,placeholder:a,disabled:v,onKeyDown:y}),t[15]=a,t[16]=v,t[17]=y,t[18]=b):b=t[18];let x;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==b?(x=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[p,m,h,b,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=b,t[24]=x):x=t[24],x}function je(e){let t=(0,H.c)(13),{g:n,origins:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=r.includes(`*`),t[0]=r,t[1]=a);let o=a,s;t[2]!==n.corsOriginsWildcardWarning||t[3]!==o?(s=o?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[2]=n.corsOriginsWildcardWarning,t[3]=o,t[4]=s):s=t[4];let c;return t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==i||t[10]!==r||t[11]!==s?(c=(0,q.jsx)($,{title:n.corsOrigins,hint:n.corsOriginsHint,emptyText:n.corsOriginsEmpty,placeholder:n.corsOriginsPlaceholder,values:r,maxItems:128,onChange:i,children:s}),t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=i,t[10]=r,t[11]=s,t[12]=c):c=t[12],c}function Me(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,q.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=X(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,q.jsx)(`input`,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,q.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=X(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,q.jsx)(`input`,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,q.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=X(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,q.jsx)(`input`,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,q.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,q.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function Ne(e){let t=(0,H.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,q.jsx)(R,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{Ee as GatewaySettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./circle-alert-BEjgurr2.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-B1EG4gdu.js";import{l as c,n as l,r as u,s as d}from"./locale-store-tnRLWdx2.js";import{i as f,o as p}from"./vendor-swr-BIWyz7Rc.js";import{Cc as m,Cs as h,Ds as g,Ec as _,Js as v,Kc as y,Ms as b,Ns as x,Nt as S,Zo as C,ai as w,bl as T,cs as E,dc as D,ei as O,fc as k,no as A,os as j,pc as M,rl as N,ro as P,tr as F,ts as I,vl as L,ws as R}from"./index-B24B26og.js";import{n as ee,r as te,t as z}from"./settings-page-layout-CtESNNdx.js";import{n as ne}from"./settings-loading-skeleton-Q_Vh6HEl.js";import{t as re}from"./settings-advanced-gate-eVlH9brU.js";import{n as B,t as ie}from"./settings-form-section-Bb6yYt5f.js";import{t as ae}from"./page-tabs-P2BEd1D8.js";import{a as oe,c as se,d as ce,n as le,o as ue,r as de,t as fe}from"./gateway-config-api-D-NVkfts.js";var V=e(t(),1),H=n(),pe={critical:3,warn:2,info:1};function U(){return u(`/api/doctor?security=true`)}function W(e){return e.toSorted((e,t)=>pe[t.severity]-pe[e.severity]||e.checkId.localeCompare(t.checkId))}function G(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=W((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function K(){return G(await d(U()))}var q=r();function me(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=l(he),o;t[0]===a?o=t[1]:(o=s(a),t[0]=a,t[1]=o);let c=o.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[U(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1},t[5]=d):d=t[5];let{data:m,error:h,isLoading:g,isValidating:v,mutate:y}=f(u,J,d),b=m??null,S=h instanceof Error?h.message:h?String(h):null,C=g||v,w;t[6]===y?w=t[7]:(w=()=>{y(),p(U())},t[6]=y,t[7]=w);let T=w,E=!n||C,D;t[8]===C?D=t[9]:(D=C?(0,q.jsx)(N,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,q.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t[8]=C,t[9]=D);let O;t[10]===c.securityAuditRefresh?O=t[11]:(O=(0,q.jsx)(`span`,{className:`ml-1.5`,children:c.securityAuditRefresh}),t[10]=c.securityAuditRefresh,t[11]=O);let k;t[12]!==T||t[13]!==E||t[14]!==D||t[15]!==O?(k=(0,q.jsxs)(x,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:T,children:[D,O]}),t[12]=T,t[13]=E,t[14]=D,t[15]=O,t[16]=k):k=t[16];let A;t[17]!==c.securityAuditSubtitle||t[18]!==c.securityAuditTitle||t[19]!==k?(A=(0,q.jsx)(B,{icon:M,title:c.securityAuditTitle,subtitle:c.securityAuditSubtitle,trailing:k}),t[17]=c.securityAuditSubtitle,t[18]=c.securityAuditTitle,t[19]=k,t[20]=A):A=t[20];let j;t[21]===c.securityAuditSavedConfigHint?j=t[22]:(j=(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:c.securityAuditSavedConfigHint}),t[21]=c.securityAuditSavedConfigHint,t[22]=j);let F;t[23]!==S||t[24]!==c.securityAuditLoadError?(F=S?(0,q.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[c.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=c.securityAuditLoadError,t[25]=F):F=t[25];let I;t[26]!==b||t[27]!==S||t[28]!==C?(I=!S&&C&&!b?(0,q.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,q.jsx)(P,{className:`h-11 w-full rounded-lg`}),(0,q.jsx)(P,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=b,t[27]=S,t[28]=C,t[29]=I):I=t[29];let L;t[30]!==b||t[31]!==c?(L=b?(0,q.jsx)(ge,{g:c,audit:b}):null,t[30]=b,t[31]=c,t[32]=L):L=t[32];let R;return t[33]!==A||t[34]!==j||t[35]!==F||t[36]!==I||t[37]!==L?(R=(0,q.jsxs)(ie,{children:[A,j,F,I,L]}),t[33]=A,t[34]=j,t[35]=F,t[36]=I,t[37]=L,t[38]=R):R=t[38],R}function J(){return K()}function he(e){return e.language}function ge(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,a,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=ye(n,r.status,r.findings),d=`space-y-4`,l=o(`rounded-lg border px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,c=`flex items-start gap-2`,i=a.icon,s=o(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==s?(f=(0,q.jsx)(i,{className:s,"aria-hidden":!0}),t[10]=i,t[11]=s,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,q.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,q.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,q.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==c||t[21]!==f||t[22]!==h?(g=(0,q.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,q.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,q.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,q.jsx)(_e,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,q.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,q.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Y)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,q.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function Y(e){return(0,q.jsx)(`li`,{className:`font-mono`,children:e},e)}function _e(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,a,s,c;if(t[0]!==r.severity){let e=ve(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,s=`flex items-start gap-2`,i=e.icon,a=o(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=s,t[4]=c}else i=t[1],a=t[2],s=t[3],c=t[4];let l;t[5]!==i||t[6]!==a?(l=(0,q.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,q.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,q.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==s||t[26]!==l?(g=(0,q.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,q.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function ve(e){switch(e){case`critical`:return{icon:a,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:v,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:T,iconClass:`text-fg-muted`}}}function ye(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:a,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`border-red-200 bg-red-50 text-red-950 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:v,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:T,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`border-edge bg-surface-panel/60 text-fg`}:{icon:M,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`border-emerald-200 bg-emerald-50 text-emerald-950 dark:border-emerald-900/50 dark:bg-emerald-950/40 dark:text-emerald-100`}}function X(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}var be=[`network`,`access`,`updates`,`security`,`advanced`],xe={network:y,access:L,updates:_,security:k,advanced:D};function Se(e){return e&&be.includes(e)?e:`network`}function Z(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function Ce(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function we(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var Te={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Ee(){let e=l(e=>e.language),t=s(e),n=t.gatewaySettings,[r,u]=i(),d=O(e=>e.mode),f=d===`advanced`,p=Se(r.get(`tab`)),g=(0,V.useMemo)(()=>ce(be,d),[d]),_=(0,V.useCallback)(e=>{u(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[u]);se(p,_);let v=c(e=>e.token),y=c(e=>e.tokenExpired),b=c(e=>e.openTokenDialog),T=!!v,[D,k]=(0,V.useReducer)(we,{form:null,baseline:null,appliedBaseline:null}),M=D.form,P=D.baseline,L=D.appliedBaseline,[R,z]=(0,V.useReducer)(S,Te),{saving:B,error:ie,auditRefreshToken:ae,restarting:H,restartConfirmOpen:pe}=R,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:J,isLoading:he,mutate:ge}=A(T),Y=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(le(K.payload.config)),[K]);T?Y!==null&&(G.current||(G.current=!0,k({type:`init-applied`,value:Y})),!U.current&&W.current!==Y&&(W.current=Y,k({type:`sync`,value:Y}),z({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,k({type:`reset`}),U.current=!1);let _e=!!(T&&he&&K===void 0&&!J),ve=J instanceof Error?J.message:J?String(J):null,ye=(0,V.useMemo)(()=>!M||!P?!1:JSON.stringify(M)!==JSON.stringify(P),[M,P]),xe=(0,V.useMemo)(()=>!P||!L?!1:fe(L,P),[L,P]),Z=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),Ce=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Ee=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),$=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Fe=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,port:e})})},[]),Ie=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Le=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,maxSseConnections:e})})},[]),Re=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),ze=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Be=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Ve=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),He=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Ue=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),We=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ge=(0,V.useCallback)(e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),Ke=(0,V.useCallback)(async()=>{if(!M||B)return;let e=ue(M);if(e){z({type:`patch`,patch:{error:e}});return}z({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await de(M),U.current=!1,k({type:`saved`,value:M}),z({type:`patch`,patch:{saveOk:!0,auditRefreshToken:ae+1}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{z({type:`patch`,patch:{saving:!1}})}},[M,B,n.saveError]),qe=(0,V.useCallback)(()=>{P&&(U.current=!1,k({type:`discard`}),z({type:`patch`,patch:{error:null,saveOk:!1}}))},[P]),Je=h(n),Ye=(0,V.useCallback)(async()=>{if(!H){z({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await w();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):C({type:`error`,title:n.restartGatewayFailed,message:e.message??``})}catch(e){C({type:`error`,title:n.restartGatewayFailed,message:e instanceof Error?e.message:String(e)})}finally{z({type:`patch`,patch:{restarting:!1}})}}},[H,n.restartGatewayFailed]);return T?_e?(0,q.jsx)(te,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,q.jsx)(ne,{sections:3})}):M?(0,q.jsxs)(te,{gap:`gap-6`,children:[(0,q.jsx)(ee,{title:t.settingsSections.gateway,subtitle:n.subtitle,docsLink:I(e,`gateway`),docsLabel:n.docsLink,actions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(x,{type:`button`,variant:`secondary`,disabled:!ye||B,onClick:qe,children:n.discard}),(0,q.jsx)(x,{type:`button`,variant:`primary`,disabled:!ye||B,onClick:()=>void Ke(),children:B?n.saving:n.save})]})}),y?(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-900/50 dark:bg-red-950/40`,role:`alert`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(a,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,q.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,q.jsx)(`div`,{children:(0,q.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>b(),children:n.updateToken})})]}):null,ye?(0,q.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,ie?(0,q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ie}):null,xe?(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-950/40`,children:[(0,q.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,q.jsxs)(x,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:H,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[H?(0,q.jsx)(N,{className:`size-3.5 animate-spin`}):(0,q.jsx)(m,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,q.jsx)(F,{open:pe,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Ye(),onCancel:()=>z({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,q.jsx)(De,{g:n,activeTab:p,visibleTabs:g,onChange:_}),(0,q.jsxs)(Q,{g:n,id:`network`,activeTab:p,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,q.jsxs)(j,{id:`gateway-bind-mode`,className:X(),value:M.bind,onChange:e=>$(e.target.value),children:[(0,q.jsx)(E,{value:`loopback`,children:n.bindLoopback}),f?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E,{value:`lan`,children:n.bindLan}),(0,q.jsx)(E,{value:`auto`,children:n.bindAuto}),(0,q.jsx)(E,{value:`custom`,children:n.bindCustom}),(0,q.jsx)(E,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,q.jsx)(`input`,{id:`gateway-custom-bind-host`,className:o(X(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>Pe(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,q.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:o(X(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);Fe(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,q.jsx)(re,{children:(0,q.jsx)(je,{g:n,origins:M.corsOrigins,onChange:Ee})})]}),(0,q.jsxs)(Q,{g:n,id:`access`,activeTab:p,children:[M.auth.mode===`none`?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,q.jsxs)(j,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>Z({mode:e.target.value}),className:X(),children:[(0,q.jsx)(E,{value:`token`,children:n.authModeToken}),(0,q.jsx)(E,{value:`password`,children:n.authModePassword}),f?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(E,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,q.jsx)(E,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,q.jsx)(re,{children:M.auth.mode===`trusted-proxy`?(0,q.jsx)(ke,{g:n,form:M,onTrustedProxyChange:He,onTrustedProxiesChange:Ve,onAllowRealIpFallbackChange:We}):null}),M.auth.mode===`token`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Ne,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:M.auth.token,labels:Je,reveal:()=>oe(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Z({token:e})}),(0,q.jsx)(x,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>b(),children:n.changeToken})]}):null,M.auth.mode===`password`?(0,q.jsx)(Ne,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:M.auth.password,labels:Je,reveal:()=>oe(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Z({password:e})}):null,(0,q.jsx)(re,{children:M.auth.mode===`none`?null:(0,q.jsx)(Me,{g:n,rateLimit:M.auth.rateLimit,onChange:Ie})})]}),(0,q.jsxs)(Q,{g:n,id:`updates`,activeTab:p,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,q.jsxs)(j,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>Ce(e.target.value),className:X(),children:[(0,q.jsx)(E,{value:`stable`,children:n.channelStable}),(0,q.jsx)(E,{value:`beta`,children:n.channelBeta}),(0,q.jsx)(E,{value:`dev`,children:n.channelDev})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoStableDelayHours,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoStableJitterHours,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,q.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,q.jsxs)(Q,{g:n,id:`security`,activeTab:p,children:[(0,q.jsx)(me,{enabled:T,refreshToken:ae}),(0,q.jsx)(Oe,{g:n,form:M,onSecurityStrictChange:Ue,onDangerouslyAllowHostHeaderOriginFallbackChange:Ge})]}),(0,q.jsx)(Q,{g:n,id:`advanced`,activeTab:p,children:(0,q.jsx)(Ae,{g:n,form:M,onMaxSseConnectionsChange:Le,onDeferModeChange:Re,onDeferIdsChange:ze,onSkipIdsChange:Be})})]}):(0,q.jsxs)(te,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ie??ve??n.loadError}),(0,q.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>void ge(),children:n.retry})]}):(0,q.jsxs)(te,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(ee,{title:t.settingsSections.gateway}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function De(e){let t=(0,H.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Z(n,e),icon:xe[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,q.jsx)(ae,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Q(e){let t=(0,H.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Z(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Ce(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,q.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,q.jsx)(z,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Oe(e){let t=(0,H.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,q.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,q.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,q.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,q.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function ke(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(X(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,q.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,q.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==c.requiredHeaders?(_=(0,q.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==c.allowUsers?(y=(0,q.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,q.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,q.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,q.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,q.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,q.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function Ae(e){let t=(0,H.c)(58),{g:n,form:r,onMaxSseConnectionsChange:i,onDeferModeChange:a,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.maxSseConnections?l=t[1]:(l=(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-max-sse`,children:n.maxSseConnections}),t[0]=n.maxSseConnections,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(X(),`max-w-xs font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]===i?d=t[4]:(d=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i(Math.max(1,Math.floor(t)))},t[3]=i,t[4]=d);let f;t[5]!==r.maxSseConnections||t[6]!==d?(f=(0,q.jsx)(`input`,{id:`gateway-max-sse`,type:`number`,min:1,className:u,value:r.maxSseConnections,onChange:d}),t[5]=r.maxSseConnections,t[6]=d,t[7]=f):f=t[7];let p;t[8]===n.maxSseConnectionsHint?p=t[9]:(p=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.maxSseConnectionsHint}),t[8]=n.maxSseConnectionsHint,t[9]=p);let m;t[10]!==l||t[11]!==f||t[12]!==p?(m=(0,q.jsxs)(`div`,{children:[l,f,p]}),t[10]=l,t[11]=f,t[12]=p,t[13]=m):m=t[13];let h;t[14]===n.channelConnectDeferMode?h=t[15]:(h=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[14]=n.channelConnectDeferMode,t[15]=h);let g=r.channelConnectDeferMode,_;t[16]===a?_=t[17]:(_=e=>a(e.target.value),t[16]=a,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=X(),t[18]=v):v=t[18];let y;t[19]===n.channelConnectDeferModeAuto?y=t[20]:(y=(0,q.jsx)(E,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[19]=n.channelConnectDeferModeAuto,t[20]=y);let b;t[21]===n.channelConnectDeferModeOff?b=t[22]:(b=(0,q.jsx)(E,{value:`off`,children:n.channelConnectDeferModeOff}),t[21]=n.channelConnectDeferModeOff,t[22]=b);let x;t[23]===n.channelConnectDeferModeExplicit?x=t[24]:(x=(0,q.jsx)(E,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[23]=n.channelConnectDeferModeExplicit,t[24]=x);let S;t[25]!==r.channelConnectDeferMode||t[26]!==y||t[27]!==b||t[28]!==x||t[29]!==_?(S=(0,q.jsxs)(j,{id:`gateway-channel-defer-mode`,value:g,onChange:_,className:v,children:[y,b,x]}),t[25]=r.channelConnectDeferMode,t[26]=y,t[27]=b,t[28]=x,t[29]=_,t[30]=S):S=t[30];let C;t[31]===n.channelConnectDeferModeHint?C=t[32]:(C=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[31]=n.channelConnectDeferModeHint,t[32]=C);let w;t[33]!==S||t[34]!==C||t[35]!==h?(w=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[h,S,C]}),t[33]=S,t[34]=C,t[35]=h,t[36]=w):w=t[36];let T;t[37]!==r.channelConnectDeferIds||t[38]!==r.channelConnectDeferMode||t[39]!==n.channelConnectDeferIds||t[40]!==n.channelConnectDeferIdsHint||t[41]!==n.channelIdListEmpty||t[42]!==n.channelIdListPlaceholder||t[43]!==s?(T=r.channelConnectDeferMode===`explicit`?(0,q.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:s}):null,t[37]=r.channelConnectDeferIds,t[38]=r.channelConnectDeferMode,t[39]=n.channelConnectDeferIds,t[40]=n.channelConnectDeferIdsHint,t[41]=n.channelIdListEmpty,t[42]=n.channelIdListPlaceholder,t[43]=s,t[44]=T):T=t[44];let D;t[45]!==r.channelConnectDeferMode||t[46]!==r.channelConnectDeferSkipIds||t[47]!==n.channelConnectDeferSkipIds||t[48]!==n.channelConnectDeferSkipIdsHint||t[49]!==n.channelIdListEmpty||t[50]!==n.channelIdListPlaceholder||t[51]!==c?(D=r.channelConnectDeferMode===`off`?null:(0,q.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:c}),t[45]=r.channelConnectDeferMode,t[46]=r.channelConnectDeferSkipIds,t[47]=n.channelConnectDeferSkipIds,t[48]=n.channelConnectDeferSkipIdsHint,t[49]=n.channelIdListEmpty,t[50]=n.channelIdListPlaceholder,t[51]=c,t[52]=D):D=t[52];let O;return t[53]!==w||t[54]!==T||t[55]!==D||t[56]!==m?(O=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[m,w,T,D]}),t[53]=w,t[54]=T,t[55]=D,t[56]=m,t[57]=O):O=t[57],O}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==l||t[10]!==s?(h=s.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,q.jsx)(`button`,{type:`button`,className:o(`text-fg-muted hover:text-fg`,g.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=s,t[11]=h):h=t[11];let _;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=o(X(),`font-mono text-xs`),t[12]=_):_=t[12];let v=s.length>=c,y;t[13]===f?y=t[14]:(y=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=y);let b;t[15]!==a||t[16]!==v||t[17]!==y?(b=(0,q.jsx)(`input`,{className:_,placeholder:a,disabled:v,onKeyDown:y}),t[15]=a,t[16]=v,t[17]=y,t[18]=b):b=t[18];let x;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==b?(x=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[p,m,h,b,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=b,t[24]=x):x=t[24],x}function je(e){let t=(0,H.c)(13),{g:n,origins:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=r.includes(`*`),t[0]=r,t[1]=a);let o=a,s;t[2]!==n.corsOriginsWildcardWarning||t[3]!==o?(s=o?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[2]=n.corsOriginsWildcardWarning,t[3]=o,t[4]=s):s=t[4];let c;return t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==i||t[10]!==r||t[11]!==s?(c=(0,q.jsx)($,{title:n.corsOrigins,hint:n.corsOriginsHint,emptyText:n.corsOriginsEmpty,placeholder:n.corsOriginsPlaceholder,values:r,maxItems:128,onChange:i,children:s}),t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=i,t[10]=r,t[11]=s,t[12]=c):c=t[12],c}function Me(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,q.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=X(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,q.jsx)(`input`,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,q.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=X(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,q.jsx)(`input`,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,q.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=X(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,q.jsx)(`input`,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,q.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,q.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function Ne(e){let t=(0,H.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,q.jsx)(R,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{Ee as GatewaySettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./locale-store-
|
|
1
|
+
import{o as e}from"./locale-store-tnRLWdx2.js";var t=6e4,n=500,r=5e3;function i(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`STARTUP_UNAVAILABLE`&&t.retryable===!0&&typeof t.retryAfterMs==`number`}function a(e){return new Promise(t=>setTimeout(t,e))}function o(e){let t=typeof e.retryAfterMs==`number`?e.retryAfterMs:n;return Math.min(Math.max(t,100),r)}async function s(n,r,s){let c=Date.now(),l=s?.timeoutMs??t;for(;;){let t=await e(n,r);if(t.status!==503)return t;let s=await t.clone().json().catch(()=>null);if(!i(s)||Date.now()-c>=l)return t;await a(o(s))}}export{s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{t as i}from"./messages-C96Zjb0V.js";import{n as a}from"./locale-store-C_ax27uc.js";import{Go as o,Hc as s,Ir as c,Is as l,Jo as u,Ko as d,Lr as f,Lt as p,Nc as m,Ns as h,Uo as g,Yo as _,Ys as v,cs as y,gc as ee,kt as te,lc as b,os as x,qo as S,ss as C,yu as w}from"./index-BhQMnKH1.js";var T=e(t(),1);function E(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function D(e){let t=new Set,n=[];for(let r of e){let e=r.trim(),i=e.toLowerCase();!e||t.has(i)||(t.add(i),n.push(e))}return n}var O=n();function k(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function A(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function j(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),A(t)}function M(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),A(e)}function N(e){if(e===`today`)return j(0);if(e===`tomorrow`)return j(1);if(e===`friday`)return M();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),A(e)}return``}function P({open:e,t,chat:n,busy:A,options:j,onClose:M,onCreate:P,onDraftContract:F}){let I=i(a(e=>e.language)).agentsSettings,[L,R]=(0,T.useState)(()=>E()),[z,B]=(0,T.useState)(!1),[V,H]=(0,T.useState)(!1),[U,W]=(0,T.useState)(null),[G,K]=(0,T.useState)(!1),q=te({chat:n});(0,T.useEffect)(()=>{e||(R(E()),B(!1),H(!1),W(null),K(!1),q.clearAttachments())},[q.clearAttachments,e]),(0,T.useEffect)(()=>{!e||!j.defaultAgentId||R(e=>e.agentId?e:{...e,agentId:j.defaultAgentId})},[e,j.defaultAgentId]);let J=e=>R(t=>({...t,...e})),Y=j.agents.length?j.agents:[{id:j.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],X=Y.find(e=>e.id===L.agentId)??Y.find(e=>e.id===j.defaultAgentId)??Y[0],Z=X?c(X,I):``,Q=L.agentId||X?.id||`main`,$=[...X?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),ne=j.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),re=e=>{J({deadlineMode:e,deadline:N(e)})},ie=(e,t)=>{R(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},ae=e=>{R(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},oe=(e,t)=>{R(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},se=e=>{R(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},ce=async()=>{W(null),K(!0);try{J(F?await F({...L,attachments:q.wireAttachmentsPayload()}):{objective:L.objective||L.title,scopeBoundary:L.scopeBoundary,evidencePlan:D(L.evidencePlan).length?L.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:L.checklist}),B(!0)}catch(e){W(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{K(!1)}},le=async()=>{if(W(null),!L.title.trim()){W(t.createDialog.titleRequired);return}try{await P({...L,attachments:q.wireAttachmentsPayload(),checklist:D(L.checklist)}),M()}catch(e){W(e instanceof Error?e.message:t.errors.create)}};return(0,O.jsx)(g,{open:e,onOpenChange:e=>!e&&M(),children:(0,O.jsxs)(u,{children:[(0,O.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,O.jsxs)(o,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -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,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(_,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,O.jsx)(d,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,O.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:M,children:(0,O.jsx)(l,{className:`size-5`,"aria-hidden":!0})})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,O.jsxs)(`div`,{className:`grid gap-4`,children:[(0,O.jsx)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/50 p-3`,children:(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.createDialog.simpleStartTitle}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.simpleStartHint})]}),(0,O.jsxs)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 rounded-lg text-xs`,onClick:()=>void ce(),disabled:G||!L.title.trim()&&!L.description.trim(),children:[(0,O.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),G?t.createDialog.drafting:t.createDialog.aiDraft]})]})}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,O.jsx)(`input`,{value:L.title,onChange:e=>J({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,O.jsxs)(h,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>q.fileInputRef.current?.click(),children:[(0,O.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,O.jsx)(`textarea`,{value:L.description,onChange:e=>J({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,O.jsx)(`input`,{ref:q.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,q.processFiles(t)}}),(0,O.jsx)(p,{attachments:q.attachments,topPadded:!1,onRemove:q.removeAttachment})]}),(0,O.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>B(e=>!e),children:[(0,O.jsxs)(`span`,{className:`min-w-0`,children:[(0,O.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t.createDialog.completionPlan}),(0,O.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.createDialog.completionPlanHint})]}),(0,O.jsx)(w,{className:r(`size-4 shrink-0 text-fg-muted transition-transform`,z&&`rotate-180`),"aria-hidden":!0})]}),z?(0,O.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[(0,O.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:j.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,O.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[L.checklist.map((e,n)=>(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{value:e,onChange:e=>ie(n,e.target.value),placeholder:k(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,O.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>ae(n),children:(0,O.jsx)(v,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,O.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>J({checklist:[...L.checklist,``]}),children:[(0,O.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,O.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,O.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,O.jsx)(`textarea`,{value:L.objective,onChange:e=>J({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,O.jsx)(`textarea`,{value:L.scopeBoundary,onChange:e=>J({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),L.evidencePlan.map((e,n)=>(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{value:e,onChange:e=>oe(n,e.target.value),placeholder:k(t.createDialog.evidencePlanPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,O.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>se(n),children:(0,O.jsx)(v,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,O.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>J({evidencePlan:[...L.evidencePlan,``]}),children:[(0,O.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]})]}):null]}),(0,O.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>H(e=>!e),children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,O.jsx)(ee,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,O.jsx)(w,{className:r(`size-4 text-fg-muted transition-transform`,V&&`rotate-180`),"aria-hidden":!0})]}),V?(0,O.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,O.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,O.jsx)(x,{value:Q,onChange:e=>J({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:Y.map(e=>(0,O.jsx)(y,{value:e.id,children:f(e,I)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),Z?(0,O.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:Z}):X?.model?.primary?(0,O.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:k(t.createDialog.agentPrimaryModel,{model:X.model.primary})}):null]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,O.jsxs)(x,{value:L.priority,onChange:e=>J({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,O.jsx)(y,{value:`normal`,children:t.priorities.normal}),(0,O.jsx)(y,{value:`high`,children:t.priorities.high}),(0,O.jsx)(y,{value:`low`,children:t.priorities.low})]})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,O.jsxs)(x,{value:L.deadlineMode,onChange:e=>re(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,O.jsx)(y,{value:`none`,children:t.createDialog.deadlineNone}),(0,O.jsx)(y,{value:`today`,children:t.createDialog.deadlineToday}),(0,O.jsx)(y,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,O.jsx)(y,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,O.jsx)(y,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),L.deadlineMode===`none`?null:(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,O.jsx)(`input`,{type:`datetime-local`,value:L.deadline,onChange:e=>J({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,O.jsx)(`input`,{type:`number`,min:1,max:500,value:L.maxTurns,onChange:e=>J({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,O.jsxs)(x,{value:L.judgeModelRef,onChange:e=>J({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,O.jsx)(y,{value:``,children:t.createDialog.judgeModelPlaceholder}),$.length?(0,O.jsx)(C,{label:t.createDialog.agentModelRoles,children:$.map(e=>(0,O.jsxs)(y,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,O.jsx)(C,{label:t.createDialog.configuredModels,children:ne.map(e=>(0,O.jsxs)(y,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),U?(0,O.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:U}):null]})}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,O.jsx)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:M,children:t.createDialog.cancel}),(0,O.jsxs)(h,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:A||!L.title.trim(),onClick:()=>void le(),children:[(0,O.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{D as n,P as t};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{t as i}from"./messages-B1EG4gdu.js";import{n as a}from"./locale-store-tnRLWdx2.js";import{Go as o,Hc as s,Ir as c,Is as l,Jo as u,Ko as d,Lr as f,Lt as p,Nc as m,Ns as h,Uo as g,Yo as _,Ys as v,cs as y,gc as ee,kt as te,lc as b,os as x,qo as S,ss as C,yu as w}from"./index-B24B26og.js";var T=e(t(),1);function E(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function D(e){let t=new Set,n=[];for(let r of e){let e=r.trim(),i=e.toLowerCase();!e||t.has(i)||(t.add(i),n.push(e))}return n}var O=n();function k(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function A(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function j(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),A(t)}function M(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),A(e)}function N(e){if(e===`today`)return j(0);if(e===`tomorrow`)return j(1);if(e===`friday`)return M();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),A(e)}return``}function P({open:e,t,chat:n,busy:A,options:j,onClose:M,onCreate:P,onDraftContract:F}){let I=i(a(e=>e.language)).agentsSettings,[L,R]=(0,T.useState)(()=>E()),[z,B]=(0,T.useState)(!1),[V,H]=(0,T.useState)(!1),[U,W]=(0,T.useState)(null),[G,K]=(0,T.useState)(!1),q=te({chat:n});(0,T.useEffect)(()=>{e||(R(E()),B(!1),H(!1),W(null),K(!1),q.clearAttachments())},[q.clearAttachments,e]),(0,T.useEffect)(()=>{!e||!j.defaultAgentId||R(e=>e.agentId?e:{...e,agentId:j.defaultAgentId})},[e,j.defaultAgentId]);let J=e=>R(t=>({...t,...e})),Y=j.agents.length?j.agents:[{id:j.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],X=Y.find(e=>e.id===L.agentId)??Y.find(e=>e.id===j.defaultAgentId)??Y[0],Z=X?c(X,I):``,Q=L.agentId||X?.id||`main`,$=[...X?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),ne=j.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),re=e=>{J({deadlineMode:e,deadline:N(e)})},ie=(e,t)=>{R(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},ae=e=>{R(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},oe=(e,t)=>{R(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},se=e=>{R(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},ce=async()=>{W(null),K(!0);try{J(F?await F({...L,attachments:q.wireAttachmentsPayload()}):{objective:L.objective||L.title,scopeBoundary:L.scopeBoundary,evidencePlan:D(L.evidencePlan).length?L.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:L.checklist}),B(!0)}catch(e){W(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{K(!1)}},le=async()=>{if(W(null),!L.title.trim()){W(t.createDialog.titleRequired);return}try{await P({...L,attachments:q.wireAttachmentsPayload(),checklist:D(L.checklist)}),M()}catch(e){W(e instanceof Error?e.message:t.errors.create)}};return(0,O.jsx)(g,{open:e,onOpenChange:e=>!e&&M(),children:(0,O.jsxs)(u,{children:[(0,O.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,O.jsxs)(o,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -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,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(_,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,O.jsx)(d,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,O.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:M,children:(0,O.jsx)(l,{className:`size-5`,"aria-hidden":!0})})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,O.jsxs)(`div`,{className:`grid gap-4`,children:[(0,O.jsx)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/50 p-3`,children:(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.createDialog.simpleStartTitle}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.simpleStartHint})]}),(0,O.jsxs)(h,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 rounded-lg text-xs`,onClick:()=>void ce(),disabled:G||!L.title.trim()&&!L.description.trim(),children:[(0,O.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),G?t.createDialog.drafting:t.createDialog.aiDraft]})]})}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,O.jsx)(`input`,{value:L.title,onChange:e=>J({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,O.jsxs)(h,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>q.fileInputRef.current?.click(),children:[(0,O.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,O.jsx)(`textarea`,{value:L.description,onChange:e=>J({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,O.jsx)(`input`,{ref:q.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,q.processFiles(t)}}),(0,O.jsx)(p,{attachments:q.attachments,topPadded:!1,onRemove:q.removeAttachment})]}),(0,O.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>B(e=>!e),children:[(0,O.jsxs)(`span`,{className:`min-w-0`,children:[(0,O.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t.createDialog.completionPlan}),(0,O.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.createDialog.completionPlanHint})]}),(0,O.jsx)(w,{className:r(`size-4 shrink-0 text-fg-muted transition-transform`,z&&`rotate-180`),"aria-hidden":!0})]}),z?(0,O.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[(0,O.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:j.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,O.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[L.checklist.map((e,n)=>(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{value:e,onChange:e=>ie(n,e.target.value),placeholder:k(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,O.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>ae(n),children:(0,O.jsx)(v,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,O.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>J({checklist:[...L.checklist,``]}),children:[(0,O.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,O.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,O.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,O.jsx)(`textarea`,{value:L.objective,onChange:e=>J({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,O.jsx)(`textarea`,{value:L.scopeBoundary,onChange:e=>J({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),L.evidencePlan.map((e,n)=>(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{value:e,onChange:e=>oe(n,e.target.value),placeholder:k(t.createDialog.evidencePlanPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,O.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>se(n),children:(0,O.jsx)(v,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,O.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>J({evidencePlan:[...L.evidencePlan,``]}),children:[(0,O.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]})]}):null]}),(0,O.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>H(e=>!e),children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,O.jsx)(ee,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,O.jsx)(w,{className:r(`size-4 text-fg-muted transition-transform`,V&&`rotate-180`),"aria-hidden":!0})]}),V?(0,O.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,O.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,O.jsx)(x,{value:Q,onChange:e=>J({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:Y.map(e=>(0,O.jsx)(y,{value:e.id,children:f(e,I)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),Z?(0,O.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:Z}):X?.model?.primary?(0,O.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:k(t.createDialog.agentPrimaryModel,{model:X.model.primary})}):null]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,O.jsxs)(x,{value:L.priority,onChange:e=>J({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,O.jsx)(y,{value:`normal`,children:t.priorities.normal}),(0,O.jsx)(y,{value:`high`,children:t.priorities.high}),(0,O.jsx)(y,{value:`low`,children:t.priorities.low})]})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,O.jsxs)(x,{value:L.deadlineMode,onChange:e=>re(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,O.jsx)(y,{value:`none`,children:t.createDialog.deadlineNone}),(0,O.jsx)(y,{value:`today`,children:t.createDialog.deadlineToday}),(0,O.jsx)(y,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,O.jsx)(y,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,O.jsx)(y,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),L.deadlineMode===`none`?null:(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,O.jsx)(`input`,{type:`datetime-local`,value:L.deadline,onChange:e=>J({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,O.jsx)(`input`,{type:`number`,min:1,max:500,value:L.maxTurns,onChange:e=>J({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,O.jsxs)(x,{value:L.judgeModelRef,onChange:e=>J({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,O.jsx)(y,{value:``,children:t.createDialog.judgeModelPlaceholder}),$.length?(0,O.jsx)(C,{label:t.createDialog.agentModelRoles,children:$.map(e=>(0,O.jsxs)(y,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,O.jsx)(C,{label:t.createDialog.configuredModels,children:ne.map(e=>(0,O.jsxs)(y,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),U?(0,O.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:U}):null]})}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,O.jsx)(h,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:M,children:t.createDialog.cancel}),(0,O.jsxs)(h,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:A||!L.title.trim(),onClick:()=>void le(),children:[(0,O.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{D as n,P as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
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,l as a,t as o,u as s}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-
|
|
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,l as a,t as o,u as s}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-B1EG4gdu.js";import{n as u,r as d,s as f}from"./locale-store-tnRLWdx2.js";import{$s as p,A as m,Bl as h,Bu as g,C as _,Ec as v,Eu as y,F as b,Fu as x,Js as ee,Kl as S,Ml as C,Nc as w,Nl as T,Ns as E,Qs as D,R as O,Ru as k,To as A,Vl as j,Ys as M,_ as N,_t as P,_u as te,bc as F,cs as I,cu as L,hu as ne,k as R,lu as z,mu as re,nu as ie,os as ae,pu as oe,ro as B,ul as se,vt as V,y as ce}from"./index-B24B26og.js";import{t as le}from"./automation-suggestion-card-ByYBiiMR.js";var ue=n(),H=e(t(),1),U=r();function de(e){return e.split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(Boolean)}function fe(){let e=(0,ue.c)(7),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(B,{className:`h-5 w-20 rounded-full`}),(0,U.jsx)(B,{className:`h-4 w-28`}),(0,U.jsx)(B,{className:`h-4 w-24`})]}),n=(0,U.jsx)(B,{className:`mt-4 h-4 w-full max-w-3xl`}),r=(0,U.jsx)(B,{className:`mt-2 h-4 w-2/3 max-w-2xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[t,n,r,(0,U.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-3`,children:[(0,U.jsx)(B,{className:`h-16 rounded-md`}),(0,U.jsx)(B,{className:`h-16 rounded-md`}),(0,U.jsx)(B,{className:`h-16 rounded-md`})]})]}),e[3]=i):i=e[3];let a;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,U.jsx)(B,{className:`h-4 w-32`}),e[4]=a):a=e[4];let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[a,(0,U.jsx)(`div`,{className:`mt-4 grid gap-3`,children:Array.from({length:5}).map(W)})]}),e[5]=o):o=e[5];let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,U.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[i,(0,U.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[o,(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsx)(B,{className:`h-4 w-28`}),(0,U.jsx)(B,{className:`mt-4 h-24 rounded-md`}),(0,U.jsx)(B,{className:`mt-3 h-24 rounded-md`})]})]})]}),e[6]=s):s=e[6],s}function W(e,t){return(0,U.jsx)(B,{className:`h-14 rounded-md`},t)}var G=`min-w-0 rounded-md border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,pe=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function me(e){return e===`command`||e===`test`?D:e===`diff`?ie:e===`file`||e===`artifact`?h:e===`link`?S:F}function he(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function ge(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function K(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function _e(e){let t=(0,ue.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=me(n.kind),t[0]=n.kind,t[1]=a);let o=a,s,c,l,u,d,f,p,m,h;if(t[2]!==o||t[3]!==n||t[4]!==r||t[5]!==i){let e=he(n),a=ge(e,`command`),g=K(e,`exitCode`),_=ge(e,`path`)||n.uri,v=K(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,U.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[15]=o,t[16]=y);let b;t[17]===n.title?b=t[18]:(b=(0,U.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,U.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,ee;t[19]!==b||t[20]!==x?(ee=(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[19]=b,t[20]=x,t[21]=ee):ee=t[21];let S;t[22]!==y||t[23]!==ee?(S=(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[y,ee]}),t[22]=y,t[23]=ee,t[24]=S):S=t[24];let C;t[25]!==n.kind||t[26]!==i?(C=Oe(n.kind,i),t[25]=n.kind,t[26]=i,t[27]=C):C=t[27];let w;t[28]===C?w=t[29]:(w=(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:C}),t[28]=C,t[29]=w),t[30]!==S||t[31]!==w?(p=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[S,w]}),t[30]=S,t[31]=w,t[32]=p):p=t[32],m=a?(0,U.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,U.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,U.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg-muted`,children:(0,U.jsx)(`code`,{children:n.summary})}):(0,U.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-xs text-fg-muted`,children:n.summary}):null,t[33]=n.kind,t[34]=n.summary,t[35]=h):h=t[35],c=`mt-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`;let T;t[36]!==n.createdAt||t[37]!==r||t[38]!==i?(T=xe(n.createdAt,r,i),t[36]=n.createdAt,t[37]=r,t[38]=i,t[39]=T):T=t[39],t[40]===T?l=t[41]:(l=(0,U.jsx)(`time`,{children:T}),t[40]=T,t[41]=l),u=g==null?null:(0,U.jsx)(`span`,{children:q(i.exitCode,{code:g})}),d=v==null?null:(0,U.jsx)(`span`,{children:q(i.outputBytes,{bytes:v})}),t[2]=o,t[3]=n,t[4]=r,t[5]=i,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h}else s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14];let g;t[42]!==s||t[43]!==i?(g=s?(0,U.jsx)(`span`,{children:i.fuzzyMatch}):null,t[42]=s,t[43]=i,t[44]=g):g=t[44];let _;t[45]!==g||t[46]!==c||t[47]!==l||t[48]!==u||t[49]!==d?(_=(0,U.jsxs)(`div`,{className:c,children:[l,u,d,g]}),t[45]=g,t[46]=c,t[47]=l,t[48]=u,t[49]=d,t[50]=_):_=t[50];let v;return t[51]!==_||t[52]!==f||t[53]!==p||t[54]!==m||t[55]!==h?(v=(0,U.jsxs)(`li`,{className:f,children:[p,m,h,_]}),t[51]=_,t[52]=f,t[53]=p,t[54]=m,t[55]=h,t[56]=v):v=t[56],v}function ve(e){return e===`active`?`border-accent/40 bg-accent-soft text-accent-fg`:e===`done`?`border-edge bg-surface-muted text-fg-muted`:e===`blocked`||e===`needs_input`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge bg-surface-panel text-fg-muted`}function ye(e){return e===`succeeded`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-destructive/40 bg-destructive/10 text-destructive`:e===`cancelled`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-accent/40 bg-accent-soft text-accent-fg`}function be(e){return e===`workflow_run`?C:e===`goal_run`?y:e===`queue`?oe:e===`evidence`?h:g}function q(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function J(e){return e===`zh`?`zh-CN`:`en-US`}function xe(e,t,n){return e?V(e,J(t)):n.notSet}function Se(e,t,n){return e?P(e,J(t)):n.noDeadline}function Ce(e,t){return e===`blocked`||e===`needs_input`?t.primaryActions.resolveBlocker:e===`paused`?t.primaryActions.resume:e===`done`?t.primaryActions.completed:e===`archived`?t.primaryActions.archived:t.primaryActions.continue}function we(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function Te(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function Ee(e,t){return e?t.statuses[e]??e:``}function De(e,t){return t.priorities[e]??e}function Oe(e,t){return t.evidenceKinds[e]??e}function ke(e){return!e||e.currentValue==null?!1:e.direction===`increase`?e.currentValue>=e.targetValue:e.currentValue<=e.targetValue}function Ae(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function je(e,t,n){let r=e.evidenceRequirements.some(e=>e.status!==`approved`),i=!!(e.contract?.outcomeMetric&&!ke(e.contract.outcomeMetric));if(e.status===`done`&&(r||i||t?.verdict===`continue`))return{title:n.progressPanel.executionFinishedTitle,body:n.progressPanel.executionFinishedFallback,tone:`attention`,needsReview:!0};if(e.status===`blocked`)return{title:n.progressPanel.blockedTitle,body:e.blockedReason||n.progressPanel.blockedFallback,tone:`attention`,needsReview:!1};if(e.status===`needs_input`){let t=e.blockedReason?.startsWith(`Completion review required`);return{title:t?n.progressPanel.executionFinishedTitle:n.progressPanel.needsInputTitle,body:t?n.progressPanel.executionFinishedFallback:e.blockedReason||e.nextAction||n.progressPanel.needsInputFallback,tone:`attention`,needsReview:!!t}}return e.status===`paused`?{title:n.progressPanel.pausedTitle,body:e.blockedReason||n.progressPanel.pausedFallback,tone:`normal`,needsReview:!1}:e.status===`done`?{title:n.progressPanel.doneTitle,body:n.progressPanel.doneFallback,tone:`done`,needsReview:!1}:e.status===`archived`?{title:n.progressPanel.archivedTitle,body:n.progressPanel.archivedFallback,tone:`normal`,needsReview:!1}:{title:n.progressPanel.activeTitle,body:e.nextAction||n.noNextAction,tone:`normal`,needsReview:!1}}function Me(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function Ne(e){let t=(0,ue.c)(210),{goal:n,latestRun:r,done:i,total:a,evidence:o,language:s,t:l,busy:u,primaryActionDisabled:d,onContinue:f,onOpenChat:m,onPause:h,onConfigureOutcome:g,onReviewEvidence:_}=e,v;t[0]!==n||t[1]!==r||t[2]!==l?(v=je(n,r,l),t[0]=n,t[1]=r,t[2]=l,t[3]=v):v=t[3];let y=v,b,x,C,w,D,O,k,A,j,M,N,P,F,I;if(t[4]!==i||t[5]!==o||t[6]!==n.contract?.outcomeMetric||t[7]!==n.deadlineAt||t[8]!==n.evidenceRequirements||t[9]!==n.priority||t[10]!==n.status||t[11]!==s||t[12]!==r||t[13]!==_||t[14]!==y.body||t[15]!==y.needsReview||t[16]!==y.title||t[17]!==y.tone||t[18]!==l||t[19]!==a){let e=n.evidenceRequirements.filter(Ie).length,u=n.evidenceRequirements.length,d,f,p,m,h;if(t[34]!==i||t[35]!==n.contract?.outcomeMetric||t[36]!==n.deadlineAt||t[37]!==n.evidenceRequirements||t[38]!==n.priority||t[39]!==n.status||t[40]!==s||t[41]!==r||t[42]!==y.body||t[43]!==y.needsReview||t[44]!==y.title||t[45]!==y.tone||t[46]!==l||t[47]!==a){x=n.evidenceRequirements.filter(Fe).slice(0,2);let e;t[58]!==i||t[59]!==a?(e=Me(i,a),t[58]=i,t[59]=a,t[60]=e):e=t[60],d=e,b=n.contract?.outcomeMetric,C=ke(b);let o=y.tone===`attention`?ee:y.tone===`done`?ne:oe;O=`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,w=`grid gap-5`,f=`min-w-0`;let u;t[61]!==n.status||t[62]!==y.needsReview?(u=c(`rounded-full border px-2 py-0.5 text-xs`,ve(y.needsReview?`needs_input`:n.status)),t[61]=n.status,t[62]=y.needsReview,t[63]=u):u=t[63];let g;t[64]!==n.status||t[65]!==y.needsReview||t[66]!==l?(g=y.needsReview?l.progressPanel.reviewPendingLabel:Ee(n.status,l),t[64]=n.status,t[65]=y.needsReview,t[66]=l,t[67]=g):g=t[67];let _;t[68]!==u||t[69]!==g?(_=(0,U.jsx)(`span`,{className:u,children:g}),t[68]=u,t[69]=g,t[70]=_):_=t[70];let v;t[71]!==n.priority||t[72]!==l?(v=q(l.prioritySummary,{priority:De(n.priority,l)}),t[71]=n.priority,t[72]=l,t[73]=v):v=t[73];let S;t[74]===v?S=t[75]:(S=(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:v}),t[74]=v,t[75]=S);let T;t[76]!==n.deadlineAt||t[77]!==s||t[78]!==l?(T=n.deadlineAt?Se(n.deadlineAt,s,l):l.noDeadline,t[76]=n.deadlineAt,t[77]=s,t[78]=l,t[79]=T):T=t[79];let E;t[80]===T?E=t[81]:(E=(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:T}),t[80]=T,t[81]=E),t[82]!==_||t[83]!==S||t[84]!==E?(p=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[_,S,E]}),t[82]=_,t[83]=S,t[84]=E,t[85]=p):p=t[85];let D=y.tone===`attention`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:y.tone===`done`?`bg-success-soft text-success`:`bg-accent-soft text-accent-fg`,k;t[86]===D?k=t[87]:(k=c(`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg`,D),t[86]=D,t[87]=k);let A;t[88]===o?A=t[89]:(A=(0,U.jsx)(o,{className:`size-5`,"aria-hidden":!0}),t[88]=o,t[89]=A);let j;t[90]!==k||t[91]!==A?(j=(0,U.jsx)(`div`,{className:k,children:A}),t[90]=k,t[91]=A,t[92]=j):j=t[92];let M;t[93]===y.title?M=t[94]:(M=(0,U.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:y.title}),t[93]=y.title,t[94]=M);let N;t[95]===y.body?N=t[96]:(N=(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:y.body}),t[95]=y.body,t[96]=N);let P;t[97]!==s||t[98]!==r||t[99]!==l?(P=r?.reason?(0,U.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-xs text-fg-subtle`,children:q(l.progressPanel.lastCheck,{time:xe(r.finishedAt??r.startedAt,s,l),reason:r.reason})}):null,t[97]=s,t[98]=r,t[99]=l,t[100]=P):P=t[100];let te;t[101]!==M||t[102]!==N||t[103]!==P?(te=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[M,N,P]}),t[101]=M,t[102]=N,t[103]=P,t[104]=te):te=t[104],t[105]!==j||t[106]!==te?(m=(0,U.jsxs)(`div`,{className:`mt-3 flex items-start gap-3`,children:[j,te]}),t[105]=j,t[106]=te,t[107]=m):m=t[107],h=x.length?(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-amber-800 dark:text-amber-200`,children:l.progressPanel.evidenceNeeded}),(0,U.jsx)(`ul`,{className:`mt-1 grid gap-1 text-xs text-amber-800 dark:text-amber-200`,children:x.map(Pe)})]}):null,t[34]=i,t[35]=n.contract?.outcomeMetric,t[36]=n.deadlineAt,t[37]=n.evidenceRequirements,t[38]=n.priority,t[39]=n.status,t[40]=s,t[41]=r,t[42]=y.body,t[43]=y.needsReview,t[44]=y.title,t[45]=y.tone,t[46]=l,t[47]=a,t[48]=d,t[49]=b,t[50]=x,t[51]=C,t[52]=w,t[53]=O,t[54]=f,t[55]=p,t[56]=m,t[57]=h}else d=t[48],b=t[49],x=t[50],C=t[51],w=t[52],O=t[53],f=t[54],p=t[55],m=t[56],h=t[57];t[108]!==f||t[109]!==p||t[110]!==m||t[111]!==h?(D=(0,U.jsxs)(`div`,{className:f,children:[p,m,h]}),t[108]=f,t[109]=p,t[110]=m,t[111]=h,t[112]=D):D=t[112],F=`grid gap-3 md:grid-cols-3`;let g;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,U.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t[113]=g):g=t[113];let v;t[114]===l.progressPanel.execution?v=t[115]:(v=(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,l.progressPanel.execution]}),t[114]=l.progressPanel.execution,t[115]=v);let S;t[116]!==i||t[117]!==l.checklistProgress||t[118]!==l.notSet||t[119]!==a?(S=a?q(l.checklistProgress,{done:i,total:a}):l.notSet,t[116]=i,t[117]=l.checklistProgress,t[118]=l.notSet,t[119]=a,t[120]=S):S=t[120];let E;t[121]===S?E=t[122]:(E=(0,U.jsx)(`p`,{className:`mt-2 text-lg font-semibold tabular-nums text-fg`,children:S}),t[121]=S,t[122]=E);let L=`${d}%`,R;t[123]===L?R=t[124]:(R=(0,U.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,U.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:L}})}),t[123]=L,t[124]=R),t[125]!==v||t[126]!==E||t[127]!==R?(I=(0,U.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[v,E,R]}),t[125]=v,t[126]=E,t[127]=R,t[128]=I):I=t[128],j=`button`,M=`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3 text-left transition-colors hover:bg-surface-hover`,N=_;let z;t[129]===l.progressPanel.evidence?z=t[130]:(z=(0,U.jsx)(`span`,{children:l.progressPanel.evidence}),t[129]=l.progressPanel.evidence,t[130]=z);let re;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,U.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[131]=re):re=t[131],t[132]===z?P=t[133]:(P=(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs font-medium text-fg-muted`,children:[z,re]}),t[132]=z,t[133]=P),k=`mt-2 text-lg font-semibold tabular-nums text-fg`,A=u?q(l.evidenceRequirementProgress,{approved:e,total:u}):q(l.progressPanel.evidenceCount,{count:o.length}),t[4]=i,t[5]=o,t[6]=n.contract?.outcomeMetric,t[7]=n.deadlineAt,t[8]=n.evidenceRequirements,t[9]=n.priority,t[10]=n.status,t[11]=s,t[12]=r,t[13]=_,t[14]=y.body,t[15]=y.needsReview,t[16]=y.title,t[17]=y.tone,t[18]=l,t[19]=a,t[20]=b,t[21]=x,t[22]=C,t[23]=w,t[24]=D,t[25]=O,t[26]=k,t[27]=A,t[28]=j,t[29]=M,t[30]=N,t[31]=P,t[32]=F,t[33]=I}else b=t[20],x=t[21],C=t[22],w=t[23],D=t[24],O=t[25],k=t[26],A=t[27],j=t[28],M=t[29],N=t[30],P=t[31],F=t[32],I=t[33];let L;t[134]!==k||t[135]!==A?(L=(0,U.jsx)(`p`,{className:k,children:A}),t[134]=k,t[135]=A,t[136]=L):L=t[136];let R=x.length?l.progressPanel.reviewNeeded:l.progressPanel.reviewComplete,z;t[137]===R?z=t[138]:(z=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:R}),t[137]=R,t[138]=z);let ie;t[139]!==L||t[140]!==z||t[141]!==j||t[142]!==M||t[143]!==N||t[144]!==P?(ie=(0,U.jsxs)(`button`,{type:j,className:M,onClick:N,children:[P,L,z]}),t[139]=L,t[140]=z,t[141]=j,t[142]=M,t[143]=N,t[144]=P,t[145]=ie):ie=t[145];let ae=b&&C?`border-success/30 bg-success-soft/40`:`border-edge-subtle bg-surface-panel/70`,B;t[146]===ae?B=t[147]:(B=c(`rounded-lg border p-3 text-left transition-colors hover:bg-surface-hover`,ae),t[146]=ae,t[147]=B);let se;t[148]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,U.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[148]=se):se=t[148];let V;t[149]===l.progressPanel.outcome?V=t[150]:(V=(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[se,l.progressPanel.outcome]}),t[149]=l.progressPanel.outcome,t[150]=V);let ce;t[151]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,U.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[151]=ce):ce=t[151];let le;t[152]===V?le=t[153]:(le=(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs font-medium text-fg-muted`,children:[V,ce]}),t[152]=V,t[153]=le);let H;t[154]!==b||t[155]!==l.progressPanel.currentMissing||t[156]!==l.progressPanel.outcomeNotSet||t[157]!==l.progressPanel.outcomeSummary?(H=b?q(l.progressPanel.outcomeSummary,{baseline:b.baselineValue,current:b.currentValue??l.progressPanel.currentMissing,target:b.targetValue,unit:b.unit?` ${b.unit}`:``}):l.progressPanel.outcomeNotSet,t[154]=b,t[155]=l.progressPanel.currentMissing,t[156]=l.progressPanel.outcomeNotSet,t[157]=l.progressPanel.outcomeSummary,t[158]=H):H=t[158];let de;t[159]===H?de=t[160]:(de=(0,U.jsx)(`p`,{className:`mt-2 truncate text-lg font-semibold tabular-nums text-fg`,children:H}),t[159]=H,t[160]=de);let fe=b?b.name:l.progressPanel.outcomeNotSetHint,W;t[161]===fe?W=t[162]:(W=(0,U.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:fe}),t[161]=fe,t[162]=W);let G;t[163]!==g||t[164]!==B||t[165]!==le||t[166]!==de||t[167]!==W?(G=(0,U.jsxs)(`button`,{type:`button`,className:B,onClick:g,children:[le,de,W]}),t[163]=g,t[164]=B,t[165]=le,t[166]=de,t[167]=W,t[168]=G):G=t[168];let pe;t[169]!==ie||t[170]!==G||t[171]!==F||t[172]!==I?(pe=(0,U.jsxs)(`div`,{className:F,children:[I,ie,G]}),t[169]=ie,t[170]=G,t[171]=F,t[172]=I,t[173]=pe):pe=t[173];let me;t[174]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,U.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[174]=me):me=t[174];let he;t[175]!==n.nextAction||t[176]!==n.status||t[177]!==y.needsReview||t[178]!==l?(he=y.needsReview&&n.nextAction?l.progressPanel.continueExecution:Ce(n.status,l),t[175]=n.nextAction,t[176]=n.status,t[177]=y.needsReview,t[178]=l,t[179]=he):he=t[179];let ge;t[180]!==f||t[181]!==d||t[182]!==he?(ge=(0,U.jsxs)(E,{type:`button`,variant:`primary`,className:`h-9 flex-1 rounded-lg`,disabled:d,onClick:f,children:[me,he]}),t[180]=f,t[181]=d,t[182]=he,t[183]=ge):ge=t[183];let K;t[184]!==x.length||t[185]!==_||t[186]!==l.progressPanel.reviewEvidenceAction?(K=x.length?(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:_,children:l.progressPanel.reviewEvidenceAction}):null,t[184]=x.length,t[185]=_,t[186]=l.progressPanel.reviewEvidenceAction,t[187]=K):K=t[187];let _e;t[188]!==n.activeSessionKey||t[189]!==m||t[190]!==l.chat?(_e=n.activeSessionKey?(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-2.5`,"aria-label":l.chat,onClick:m,children:(0,U.jsx)(S,{className:`size-4`,"aria-hidden":!0})}):null,t[188]=n.activeSessionKey,t[189]=m,t[190]=l.chat,t[191]=_e):_e=t[191];let ye=u!=null||n.status!==`active`,be;t[192]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,U.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t[192]=be):be=t[192];let J;t[193]!==h||t[194]!==l.pause||t[195]!==ye?(J=(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg px-2.5`,"aria-label":l.pause,disabled:ye,onClick:h,children:be}),t[193]=h,t[194]=l.pause,t[195]=ye,t[196]=J):J=t[196];let we;t[197]!==ge||t[198]!==K||t[199]!==_e||t[200]!==J?(we=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-4`,children:[ge,K,_e,J]}),t[197]=ge,t[198]=K,t[199]=_e,t[200]=J,t[201]=we):we=t[201];let Te;t[202]!==w||t[203]!==D||t[204]!==pe||t[205]!==we?(Te=(0,U.jsxs)(`div`,{className:w,children:[D,pe,we]}),t[202]=w,t[203]=D,t[204]=pe,t[205]=we,t[206]=Te):Te=t[206];let Oe;return t[207]!==O||t[208]!==Te?(Oe=(0,U.jsx)(`section`,{className:O,children:Te}),t[207]=O,t[208]=Te,t[209]=Oe):Oe=t[209],Oe}function Pe(e){return(0,U.jsxs)(`li`,{className:`break-words`,children:[`- `,e.text]},e.id)}function Fe(e){return e.status!==`approved`}function Ie(e){return e.status===`approved`}function Le(e){let t=e?.trim();return!t||!t.startsWith(`/projects/`)||t.startsWith(`//`)||t.includes(`://`)?`/goals`:t}async function Re(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}`))).goal}async function ze(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Be(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function Ve(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function He(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function Ue(){let{goalId:e=``}=s(),t=a(),n=u(e=>e.language),r=l(n).goalDetailPage,h=l(n).automations.suggestions,y=A(e=>e.setPageHeader),ee=A(e=>e.clearPageHeader),[T,D]=i(),[P,F]=(0,H.useState)(null),[re,ie]=(0,H.useState)([]),[V,ue]=(0,H.useState)([]),[W,me]=(0,H.useState)([]),[K,ve]=(0,H.useState)([]),[J,Ce]=(0,H.useState)([]),[De,Me]=(0,H.useState)([]),[Pe,Fe]=(0,H.useState)(``),[Ie,Ue]=(0,H.useState)(`message`),[We,Ge]=(0,H.useState)(``),[Ke,qe]=(0,H.useState)(``),[Je,Ye]=(0,H.useState)(``),[Xe,Ze]=(0,H.useState)(``),[Qe,$e]=(0,H.useState)(``),[et,tt]=(0,H.useState)(``),[nt,rt]=(0,H.useState)(`normal`),[it,at]=(0,H.useState)(``),[ot,st]=(0,H.useState)(`10`),[ct,lt]=(0,H.useState)(``),[ut,dt]=(0,H.useState)(``),[ft,pt]=(0,H.useState)(``),[mt,ht]=(0,H.useState)(``),[gt,_t]=(0,H.useState)(``),[vt,yt]=(0,H.useState)(``),[bt,xt]=(0,H.useState)(``),[St,Ct]=(0,H.useState)(``),[wt,Tt]=(0,H.useState)(``),[Et,Dt]=(0,H.useState)(``),[Ot,kt]=(0,H.useState)(``),[At,jt]=(0,H.useState)(``),[Mt,Nt]=(0,H.useState)(``),[Pt,Ft]=(0,H.useState)(``),[It,Lt]=(0,H.useState)(``),[Rt,zt]=(0,H.useState)(!0),[Y,X]=(0,H.useState)(null),[Bt,Z]=(0,H.useState)(null),Vt=(0,H.useMemo)(()=>Le(T.get(`returnTo`)),[T]),Ht=(0,H.useCallback)(async()=>{if(e){zt(!0),Z(null);try{let[t,n,r]=await Promise.all([Re(e),ze(e),Be(e)]);F(t),ie(n);let[i,a]=await Promise.all([R(e,50),Ve(e)]);me(i),Me(a),ve(await He(e)),Ce(r)}catch(e){Z(e instanceof Error?e.message:r.errors.load)}finally{zt(!1)}}},[e,r.errors.load]);(0,H.useEffect)(()=>{Ht()},[Ht]),(0,H.useEffect)(()=>{let e=!1;return m().then(t=>{e||(ue(t),Ft(e=>e||t[0]?.id||``))}).catch(t=>{e||Z(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,H.useEffect)(()=>{if(!P)return;$e(P.title),tt(P.description??``),rt(P.priority),at(P.deadlineAt?new Date(P.deadlineAt).toISOString().slice(0,10):``),st(String(P.maxTurns)),lt(P.judgeModelRef??``),dt(P.nextAction??``),pt(P.blockedReason??``),ht(P.contract?.objective??P.title),_t(P.contract?.scopeBoundary??``),yt(P.checklist.map(e=>e.text).join(`
|
|
3
3
|
`)),xt(P.contract?.evidencePlan.join(`
|
|
4
4
|
`)??``);let e=P.contract?.outcomeMetric;Ct(e?.name??``),Tt(e?String(e.baselineValue):``),Dt(e?String(e.targetValue):``),kt(e?.currentValue==null?``:String(e.currentValue)),jt(e?.unit??``),Nt(e?.sourceUrl??``),Ze(e=>P.evidenceRequirements.some(t=>t.id===e)?e:P.evidenceRequirements[0]?.id??``),Lt(e=>e||P.nextAction||P.title)},[P?.id,P?.updatedAt]);let Ut=async()=>{if(P){X(`continue`);try{P.status===`done`&&await f(d(`/api/goals/${encodeURIComponent(P.id)}/reopen`),{method:`POST`,body:JSON.stringify({})});let e=await f(d(`/api/goals/${encodeURIComponent(P.id)}/continue`),{method:`POST`,body:JSON.stringify({})});if(e.sessionKey){t(`/chat/${encodeURIComponent(e.sessionKey)}`);return}await Ht()}catch(e){Z(e instanceof Error?e.message:r.errors.continue)}finally{X(null)}}},Wt=async e=>{if(e.preventDefault(),!P)return;let t=Qe.trim();if(t){X(`details:save`),Z(null);try{let e=Number.parseInt(ot,10);F((await f(d(`/api/goals/${encodeURIComponent(P.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:et.trim()||void 0,priority:nt,deadlineAt:it?new Date(`${it}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:P.maxTurns,judgeModelRef:ct.trim()||void 0,nextAction:ut.trim()||void 0,blockedReason:ft.trim()||void 0})})).goal),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Gt=async e=>{if(e.preventDefault(),!P)return;let t=mt.trim();if(t){X(`contract:save`),Z(null);try{F((await f(d(`/api/goals/${encodeURIComponent(P.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:t,scopeBoundary:gt.trim()||void 0,criteria:de(vt),evidencePlan:de(bt)})})).goal),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Kt=async e=>{if(e.preventDefault(),!P)return;let t=Ae(wt),n=Ae(Et),i=Ae(Ot);if(!(!St.trim()||t==null||n==null)){X(`outcome:save`),Z(null);try{F((await f(d(`/api/goals/${encodeURIComponent(P.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:P.contract?.objective??P.title,scopeBoundary:P.contract?.scopeBoundary,criteria:P.checklist.map(e=>e.text),evidencePlan:P.contract?.evidencePlan??[],outcomeMetric:{name:St.trim(),baselineValue:t,targetValue:n,currentValue:i,unit:At.trim()||void 0,sourceUrl:Mt.trim()||void 0,measuredAt:i==null?void 0:Date.now()}})})).goal),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},qt=async()=>{if(P){X(`outcome:clear`),Z(null);try{F((await f(d(`/api/goals/${encodeURIComponent(P.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:P.contract?.objective??P.title,scopeBoundary:P.contract?.scopeBoundary,criteria:P.checklist.map(e=>e.text),evidencePlan:P.contract?.evidencePlan??[],outcomeMetric:null})})).goal),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Jt=async e=>{if(P){X(e);try{await f(d(`/api/goals/${encodeURIComponent(P.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await Ht()}catch(e){Z(e instanceof Error?e.message:r.errors.action)}finally{X(null)}}},Yt=async()=>{if(!(!P||!Pt)){X(`workflow:run`),Z(null);try{let e=await O({goalId:P.id,definitionId:Pt,goal:It.trim()||P.nextAction||P.title});await Ht(),t(`/chat/${encodeURIComponent(e.sessionKey)}`)}catch(e){Z(e instanceof Error?e.message:r.errors.startWorkflow)}finally{X(null)}}},Q=async e=>{try{Me(await Ve(e))}catch{}},Xt=async e=>{try{let[t,n,r]=await Promise.all([R(e,50),Ve(e),He(e)]);me(t),Me(n),ve(r)}catch{}},Zt=async e=>{if(P){X(`workflow:${e.id}:cancel`),Z(null);try{await _(e.id,{ownerAgentId:P.agentId}),await Xt(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{X(null)}}},Qt=async e=>{if(P){X(`workflow:${e.id}:retry`),Z(null);try{let n=await b(e.id,{ownerAgentId:P.agentId});await Xt(P.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){Z(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{X(null)}}},$t=async e=>{if(e.preventDefault(),!P)return;let t=Pe.trim();if(t){X(`checklist:add`),Z(null);try{F((await f(d(`/api/goals/${encodeURIComponent(P.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Fe(``),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addChecklist)}finally{X(null)}}},en=async(e,t)=>{if(P){X(`checklist:${e}:${t}`),Z(null);try{F((await f(d(`/api/goals/${encodeURIComponent(P.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.updateChecklist)}finally{X(null)}}},tn=async e=>{if(P){X(`checklist:${e}:delete`),Z(null);try{F((await f(d(`/api/goals/${encodeURIComponent(P.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{X(null)}}},nn=async e=>{if(e.preventDefault(),!P)return;let t=We.trim();if(t){X(`evidence:add`),Z(null);try{let e=await f(d(`/api/goals/${encodeURIComponent(P.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:Ie,title:t,summary:Ke.trim()||void 0,uri:Je.trim()||void 0,requirementId:Xe||void 0})});Ce(t=>[e.evidence,...t]),F(await Re(P.id)),Ge(``),qe(``),Ye(``),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},rn=async e=>{if(P){X(`requirement:${e}:review`),Z(null);try{await f(d(`/api/goals/${encodeURIComponent(P.id)}/evidence-requirements/${encodeURIComponent(e)}/review`),{method:`POST`,body:JSON.stringify({modelRef:P.judgeModelRef})}),F(await Re(P.id)),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},an=async e=>{if(P){X(`requirement:${e}:approve`),Z(null);try{await f(d(`/api/goals/${encodeURIComponent(P.id)}/evidence-requirements/${encodeURIComponent(e)}/approve`),{method:`POST`,body:JSON.stringify({})}),F(await Re(P.id)),await Q(P.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},on=async e=>{if(!P||!e.summary)return;Z(null);let t=l(n).automations,r=await f(d(`/api/goals/${encodeURIComponent(P.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:`message`,title:ce(t.feedback.insightEvidenceTitle,{name:e.automationName}),summary:e.summary,data:{source:`automation`,automationRunId:e.id,automationId:e.automationId,automationName:e.automationName,sessionKey:e.sessionKey,workflowRunId:e.workflowRunId}})});Ce(e=>[r.evidence,...e]),await Q(P.id)},sn=P?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,cn=P?.checklist.length??0,ln=(0,H.useMemo)(()=>{let e=new Set;for(let t of J){let n=ge(he(t),`automationRunId`);n&&e.add(n)}return e},[J]),un=(0,H.useMemo)(()=>{let e=new Set;return J.filter(t=>{if(t.title.trim().toLowerCase().startsWith(`missing evidence:`))return!1;let n=`${t.kind}\u0000${t.title.trim()}\u0000${t.summary?.trim()??``}`;return e.has(n)?!1:(e.add(n),!0)})},[J]),dn=W.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),$=re[0],fn=Te(T.get(`timeline`))?T.get(`timeline`):`all`,pn=fn===`all`?De:De.filter(e=>e.kind===fn),mn=W.filter(e=>e.status===`queued`||e.status===`running`),hn=P?je(P,$,r):null,gn=P?.status===`done`&&!hn?.needsReview,_n=Y!=null||P?.status===`archived`||gn,vn=(0,H.useMemo)(()=>P?(0,U.jsxs)(U.Fragment,{children:[P.activeSessionKey?(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.chat,onClick:()=>t(`/chat/${encodeURIComponent(P.activeSessionKey)}`),children:[(0,U.jsx)(S,{className:`size-4`,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:Y!=null||P.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&&Jt(`archive`)},children:[(0,U.jsx)(k,{className:`size-4`,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[Y,P,t,r]);(0,H.useLayoutEffect)(()=>(y({startExtra:(0,U.jsx)(o,{to:Vt,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":r.back,children:(0,U.jsx)(x,{className:`size-4`,"aria-hidden":!0})}),main:(0,U.jsxs)(`div`,{className:`min-w-0`,children:[Rt?(0,U.jsx)(B,{className:`h-5 w-48 max-w-full`}):(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:P?.title??r.notFound}),P?(0,U.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[hn?.title??Ee(P.status,r),` · `,q(r.agent,{agentId:P.agentId})]}):null]}),end:vn}),()=>ee()),[Vt,ee,P,vn,Rt,y,hn?.title,r]);let yn=e=>{let t=new URLSearchParams(T);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),D(t,{replace:!0})};return(0,U.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:(0,U.jsxs)(`div`,{className:`flex w-full flex-1 flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[Bt?(0,U.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:Bt}):null,!Rt&&!P?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,Rt?(0,U.jsx)(fe,{}):P?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ne,{goal:P,latestRun:$,done:sn,total:cn,evidence:J,language:n,t:r,busy:Y,primaryActionDisabled:_n,onContinue:()=>void Ut(),onOpenChat:()=>P.activeSessionKey&&t(`/chat/${encodeURIComponent(P.activeSessionKey)}`),onPause:()=>void Jt(`pause`),onConfigureOutcome:()=>document.getElementById(`goal-outcome-metric`)?.scrollIntoView({behavior:`smooth`,block:`center`}),onReviewEvidence:()=>document.getElementById(`goal-verification`)?.scrollIntoView({behavior:`smooth`,block:`start`})}),(0,U.jsxs)(`section`,{id:`goal-outcome-metric`,className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(p,{className:`size-4 text-accent`,"aria-hidden":!0}),r.outcomeMetric.title]}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.outcomeMetric.hint})]}),P.contract?.outcomeMetric?(0,U.jsx)(`span`,{className:c(`rounded-full border px-2 py-0.5 text-xs font-medium`,ke(P.contract.outcomeMetric)?`border-success/30 bg-success-soft text-success`:`border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:ke(P.contract.outcomeMetric)?r.outcomeMetric.achieved:r.outcomeMetric.notAchieved}):null]}),(0,U.jsxs)(`form`,{className:`mt-4 grid gap-3`,onSubmit:Kt,children:[(0,U.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(12rem,1.4fr)_repeat(3,minmax(7rem,0.7fr))]`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.name,(0,U.jsx)(`input`,{value:St,onChange:e=>Ct(e.target.value),className:G,placeholder:r.outcomeMetric.namePlaceholder})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.baseline,(0,U.jsx)(`input`,{value:wt,onChange:e=>Tt(e.target.value),className:G,type:`number`,step:`any`,inputMode:`decimal`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.current,(0,U.jsx)(`input`,{value:Ot,onChange:e=>kt(e.target.value),className:G,type:`number`,step:`any`,inputMode:`decimal`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.target,(0,U.jsx)(`input`,{value:Et,onChange:e=>Dt(e.target.value),className:G,type:`number`,step:`any`,inputMode:`decimal`})]})]}),(0,U.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[10rem_minmax(0,1fr)_auto] md:items-end`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.unit,(0,U.jsx)(`input`,{value:At,onChange:e=>jt(e.target.value),className:G,placeholder:r.outcomeMetric.unitPlaceholder})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.source,(0,U.jsx)(`input`,{value:Mt,onChange:e=>Nt(e.target.value),className:G,placeholder:r.outcomeMetric.sourcePlaceholder})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P.contract?.outcomeMetric?(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`h-9`,disabled:Y!=null,onClick:()=>void qt(),children:r.outcomeMetric.clear}):null,(0,U.jsx)(E,{type:`submit`,variant:`secondary`,className:`h-9`,disabled:Y!=null||!St.trim()||Ae(wt)==null||Ae(Et)==null,children:r.outcomeMetric.save})]})]})]})]}),(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalBrief}),P.description?(0,U.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:P.description}):null,P.contract?(0,U.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface-muted/40 p-3`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.goalContract}),(0,U.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:P.contract.objective}),P.contract.scopeBoundary?(0,U.jsxs)(`div`,{className:`mt-3`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.scopeBoundary}),(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:P.contract.scopeBoundary})]}):null,P.contract.evidencePlan.length?(0,U.jsxs)(`div`,{className:`mt-3`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.completionEvidence}),(0,U.jsx)(`ul`,{className:`mt-1 grid gap-1 text-sm text-fg-muted`,children:P.contract.evidencePlan.map(e=>(0,U.jsxs)(`li`,{children:[`• `,e]},e))})]}):null,(0,U.jsxs)(`details`,{className:`mt-3 rounded-md bg-surface-base/70 px-3 py-2`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editContract}),(0,U.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Gt,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.contractObjective,(0,U.jsx)(`textarea`,{value:mt,onChange:e=>ht(e.target.value),name:`contractObjective`,autoComplete:`off`,className:c(G,`resize-y`),rows:2,placeholder:r.contractObjectivePlaceholder})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.scopeBoundary,(0,U.jsx)(`textarea`,{value:gt,onChange:e=>_t(e.target.value),name:`contractScopeBoundary`,autoComplete:`off`,className:c(G,`resize-y`),rows:2,placeholder:r.scopeBoundaryPlaceholder})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.acceptanceCriteria,(0,U.jsx)(`textarea`,{value:vt,onChange:e=>yt(e.target.value),name:`contractCriteria`,autoComplete:`off`,className:c(G,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.completionEvidence,(0,U.jsx)(`textarea`,{value:bt,onChange:e=>xt(e.target.value),name:`contractEvidencePlan`,autoComplete:`off`,className:c(G,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,U.jsx)(E,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:Y!=null||!mt.trim(),children:r.saveContract})]})]})]}):null]}),(0,U.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,U.jsxs)(`section`,{id:`goal-verification`,className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,U.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[sn,`/`,cn]})]}),$?(0,U.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{children:q(r.latestJudgement,{status:Ee($.verdict??$.status,r)})}),(0,U.jsx)(`time`,{children:xe($.finishedAt??$.startedAt,n,r)})]}),$.reason?(0,U.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:$.reason}):null,$.nextAction?(0,U.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:q(r.latestNext,{next:$.nextAction})}):null]}):null,(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,U.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[sn,`/`,cn]})]}),(0,U.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:$t,children:[(0,U.jsx)(`input`,{value:Pe,onChange:e=>Fe(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:c(G,`flex-1`)}),(0,U.jsxs)(E,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:Y!=null||!Pe.trim(),children:[(0,U.jsx)(w,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),P.checklist.length?(0,U.jsx)(`ul`,{className:`space-y-2 text-sm`,children:P.checklist.map(e=>(0,U.jsx)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,U.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:we(e.status)}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:Y!=null||e.status===`pending`,onClick:()=>void en(e.id,`pending`),children:(0,U.jsx)(L,{className:`size-4`,"aria-hidden":!0})}),(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:Y!=null||e.status===`completed`,onClick:()=>void en(e.id,`completed`),children:(0,U.jsx)(ne,{className:`size-4`,"aria-hidden":!0})}),(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:Y!=null||e.status===`impossible`,onClick:()=>void en(e.id,`impossible`),children:(0,U.jsx)(z,{className:`size-4`,"aria-hidden":!0})}),(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-destructive hover:text-destructive`,title:r.deleteChecklistItem,"aria-label":r.deleteChecklistItem,disabled:Y!=null,onClick:()=>void tn(e.id),children:(0,U.jsx)(M,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,U.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,U.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(j,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),P.evidenceRequirements.length?(0,U.jsxs)(`div`,{className:`mb-4 grid gap-2 rounded-md border border-edge-subtle bg-surface-muted/40 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.evidenceRequirements}),(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:q(r.evidenceRequirementProgress,{approved:P.evidenceRequirements.filter(e=>e.status===`approved`).length,total:P.evidenceRequirements.length})})]}),P.evidenceRequirements.map(e=>(0,U.jsx)(`div`,{className:`rounded-md bg-surface-base px-2.5 py-2`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`break-words text-sm text-fg`,children:e.text}),(0,U.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[q(r.linkedEvidenceCount,{count:e.evidenceIds.length}),` · `,r.evidenceRequirementStatuses[e.status]]}),e.reviewReason?(0,U.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:e.reviewReason}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:[(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,disabled:Y!=null||e.evidenceIds.length===0,onClick:()=>void rn(e.id),children:r.reviewEvidence}),(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`h-7 text-xs`,disabled:Y!=null||e.evidenceIds.length===0||e.status===`approved`,onClick:()=>void an(e.id),children:r.approveEvidence})]})]})},e.id))]}):null,(0,U.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:nn,children:[(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,U.jsx)(ae,{value:Ie,onChange:e=>Ue(e.target.value),className:G,name:`evidenceKind`,children:pe.map(e=>(0,U.jsx)(I,{value:e,children:Oe(e,r)},e))})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,U.jsx)(`input`,{value:We,onChange:e=>Ge(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:G})]})]}),P.evidenceRequirements.length?(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.provesRequirement,(0,U.jsx)(ae,{value:Xe,onChange:e=>Ze(e.target.value),name:`evidenceRequirement`,className:G,children:P.evidenceRequirements.map(e=>(0,U.jsx)(I,{value:e.id,children:e.text},e.id))})]}):null,(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,U.jsx)(`input`,{value:Je,onChange:e=>Ye(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:G})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,U.jsx)(`textarea`,{value:Ke,onChange:e=>qe(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:c(G,`resize-y`)})]}),(0,U.jsxs)(E,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:Y!=null||!We.trim(),children:[(0,U.jsx)(w,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),un.length?(0,U.jsx)(`ul`,{className:`space-y-2 text-sm`,children:un.slice(0,6).map(e=>(0,U.jsx)(_e,{item:e,language:n,t:r},e.id))}):(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(g,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void Ht(),children:[(0,U.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),re.length?(0,U.jsx)(`ol`,{className:`mt-4 grid gap-2`,children:re.slice(0,6).map((e,t)=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`details`,{open:t===0&&e.verdict!==`done`,className:`group rounded-lg border border-edge-subtle bg-surface-muted/40 px-3 py-2`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 marker:hidden`,children:[(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:q(r.executionProgress.runTitle,{number:re.length-t})}),(0,U.jsx)(`time`,{className:`mt-0.5 block text-xs text-fg-muted`,children:xe(e.finishedAt??e.startedAt,n,r)})]}),(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-fg-muted`,children:[Ee(e.verdict??e.status,r),(0,U.jsx)(te,{className:`size-4 transition-transform group-open:rotate-90`,"aria-hidden":!0})]})]}),(0,U.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[e.reason?(0,U.jsx)(`p`,{className:`text-sm text-fg`,children:e.reason}):null,e.assistantPreview?(0,U.jsx)(`p`,{className:`mt-2 line-clamp-5 whitespace-pre-wrap text-xs text-fg-muted`,children:e.assistantPreview}):null,e.nextAction?(0,U.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-base px-3 py-2`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.nextAction}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:e.nextAction})]}):null]})]})},e.id))}):(0,U.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.executionProgress.noRuns}),(0,U.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:q(r.executionProgress.systemActivity,{count:De.length})}),(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,U.jsx)(`button`,{type:`button`,className:c(`rounded-md border px-2.5 py-1 text-xs font-medium`,fn===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>yn(e),children:r.timelineFilters[e]},e))}),pn.length?(0,U.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:pn.map(e=>(0,U.jsx)(`li`,{className:`rounded-md bg-surface-muted/50 px-2.5 py-2`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,U.jsx)(be(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,U.jsx)(`span`,{children:Ee(e.status,r)}):null]}),(0,U.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,U.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,U.jsx)(`time`,{children:xe(e.createdAt,n,r)}),e.link?.type===`chat`?(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,U.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,U.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]})]}),(0,U.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,U.jsxs)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/30 p-4`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:r.actionRail.nextTitle}),(0,U.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm font-medium text-fg`,children:gn?r.progressPanel.doneFallback:P.nextAction||r.noNextAction}),(0,U.jsxs)(E,{type:`button`,variant:`primary`,className:`mt-3 h-9 w-full gap-2`,disabled:Y!=null||P.status===`archived`,onClick:()=>{if(gn){window.confirm(r.archiveConfirm)&&Jt(`archive`);return}Ut()},children:[gn?(0,U.jsx)(k,{className:`size-4`,"aria-hidden":!0}):(0,U.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),gn?r.archive:r.actionRail.continueAction]})]}),P.evidenceRequirements.some(e=>e.status!==`approved`)||P.contract?.outcomeMetric&&!ke(P.contract.outcomeMetric)||$?.verdict===`continue`?(0,U.jsxs)(`section`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-4`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:r.actionRail.needsYou}),(0,U.jsxs)(`ul`,{className:`mt-3 grid gap-2 text-sm text-amber-900 dark:text-amber-100`,children:[P.contract?.outcomeMetric&&!ke(P.contract.outcomeMetric)?(0,U.jsxs)(`li`,{children:[`• `,r.outcomeMetric.notAchieved]}):null,P.evidenceRequirements.some(e=>e.status!==`approved`)?(0,U.jsxs)(`li`,{children:[`• `,q(r.actionRail.reviewEvidenceCount,{count:P.evidenceRequirements.filter(e=>e.status!==`approved`).length})]}):null,$?.verdict===`continue`?(0,U.jsxs)(`li`,{children:[`• `,r.actionRail.latestCheckContinue]}):null]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[P.contract?.outcomeMetric&&!ke(P.contract.outcomeMetric)?(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`h-8`,onClick:()=>document.getElementById(`goal-outcome-metric`)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:r.actionRail.setOutcome}):null,P.evidenceRequirements.some(e=>e.status!==`approved`)?(0,U.jsx)(E,{type:`button`,variant:`secondary`,className:`h-8`,onClick:()=>document.getElementById(`goal-verification`)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:r.actionRail.reviewEvidence}):null]})]}):null,(0,U.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:r.actionRail.automation}),(0,U.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[(0,U.jsx)(N,{eventType:`goal.status_changed`,source:`goals`,payloadKey:`goalId`,payloadValue:P.id,onSaveInsight:on,isInsightSaved:e=>ln.has(e.id)}),(0,U.jsx)(N,{eventType:`goal.created`,source:`goals`,payloadKey:`goalId`,payloadValue:P.id,onSaveInsight:on,isInsightSaved:e=>ln.has(e.id)}),P.status===`blocked`||P.blockedReason?(0,U.jsx)(le,{title:h.goalBlockedTitle,description:h.goalBlockedDescription,prompt:q(h.goalBlockedPrompt,{title:P.title}),coverage:{eventType:`goal.status_changed`,source:`goals`,eventPayload:{goalId:P.id,status:`blocked`}}}):null]})]}),(0,U.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:r.goalSettings}),(0,U.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,U.jsx)(`dd`,{className:`text-right text-fg`,children:Se(P.deadlineAt,n,r)})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,U.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:P.judgeModelRef||r.default})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,U.jsx)(`dd`,{className:`text-right text-fg`,children:Se(P.createdAt,n,r)})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,U.jsx)(`dd`,{className:`text-right text-fg`,children:xe(P.updatedAt,n,r)})]})]}),(0,U.jsxs)(`details`,{className:`mt-4 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,U.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Wt,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,U.jsx)(`input`,{value:Qe,onChange:e=>$e(e.target.value),name:`goalTitle`,autoComplete:`off`,className:G,placeholder:`${r.title}…`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,U.jsx)(`textarea`,{value:et,onChange:e=>tt(e.target.value),name:`goalDescription`,autoComplete:`off`,className:c(G,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,U.jsxs)(ae,{value:nt,onChange:e=>rt(e.target.value),name:`goalPriority`,className:G,children:[(0,U.jsx)(I,{value:`low`,children:r.priorities.low}),(0,U.jsx)(I,{value:`normal`,children:r.priorities.normal}),(0,U.jsx)(I,{value:`high`,children:r.priorities.high})]})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,U.jsx)(`input`,{value:it,onChange:e=>at(e.target.value),name:`goalDeadline`,className:G,type:`date`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,U.jsx)(`input`,{value:ot,onChange:e=>st(e.target.value),name:`goalMaxTurns`,className:G,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,U.jsx)(`input`,{value:ct,onChange:e=>lt(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:G,placeholder:`${r.judgeModel}…`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,U.jsx)(`textarea`,{value:ut,onChange:e=>dt(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:c(G,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,U.jsx)(`textarea`,{value:ft,onChange:e=>pt(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:c(G,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,U.jsx)(E,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:Y!=null||!Qe.trim(),children:r.saveDetails})]})]})]}),(0,U.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 text-sm font-semibold text-fg marker:hidden`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(C,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),mn.length?(0,U.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:q(r.activeCount,{count:mn.length})}):null]}),(0,U.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:r.workflowHint}),K.length?(0,U.jsx)(`div`,{className:`mt-3 grid gap-2`,children:K.slice(0,2).map(e=>(0,U.jsxs)(`button`,{type:`button`,className:c(`min-w-0 rounded-md bg-surface-muted/40 px-2.5 py-2 text-left hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Pt===e.definitionId&&`bg-accent-soft/60 ring-1 ring-accent/30`),onClick:()=>{Ft(e.definitionId),Lt(P.nextAction||P.title)},children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,U.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,U.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,U.jsxs)(ae,{value:Pt,onChange:e=>Ft(e.target.value),className:G,name:`workflowDefinition`,disabled:V.length===0,children:[V.length===0?(0,U.jsx)(I,{value:``,children:r.noWorkflows}):null,V.map(e=>(0,U.jsx)(I,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,U.jsx)(`input`,{value:It,onChange:e=>Lt(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:G,placeholder:`${r.workflowGoal}…`})]}),(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:Y!=null||!Pt||P.status===`done`||P.status===`archived`,onClick:()=>void Yt(),children:[(0,U.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),W.length?(0,U.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,U.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>yn(`workflow_run`),children:r.viewTimeline})]}),(0,U.jsx)(`ul`,{className:`grid gap-2`,children:W.slice(0,3).map(e=>{let i=e.metadata?.sessionKey,a=e.status===`queued`||e.status===`running`,o=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,U.jsxs)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,U.jsx)(`span`,{className:c(`shrink-0 rounded-full border px-2 py-0.5`,ye(e.status)),children:Ee(e.status,r)})]}),(0,U.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,U.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:xe(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[i?(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(i)}`),children:[(0,U.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,a?(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:Y!=null,onClick:()=>void Zt(e),children:[(0,U.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,o?(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:Y!=null,onClick:()=>void Qt(e),children:[(0,U.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,dn.length?(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,U.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:q(r.failedCount,{count:dn.length})})]}),(0,U.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:dn.slice(0,3).map(e=>(0,U.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,U.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,Ee(e.status,r)]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,U.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,U.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:Y!=null,onClick:()=>void Qt(e),children:[(0,U.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{Ue as GoalDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-tnRLWdx2.js";import{to as n}from"./index-B24B26og.js";var r={maxTurns:20,judgeModelRef:``,checklistMode:!0,checklistDecomposePolicy:`empty_only`,maxConsecutiveParseFailures:3,judgeTimeoutSec:60,checklistHistoryChars:24e3,notifications:{enabled:!1,includeLinkedSessions:!0,channels:[`telegram`,`weixin`],events:[`done`,`blocked`,`needs_input`,`queue_failed`,`queue_retry`],targets:[]}};function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){let t=i(e)?e:{},n=i(t.goals)?t.goals:{},a=i(n.notifications)?n.notifications:{};return{maxTurns:typeof n.maxTurns==`number`&&Number.isFinite(n.maxTurns)?Math.max(1,Math.min(500,Math.floor(n.maxTurns))):r.maxTurns,judgeModelRef:typeof n.judgeModelRef==`string`?n.judgeModelRef:``,checklistMode:n.checklistMode!==!1,checklistDecomposePolicy:n.checklistDecomposePolicy===`supplement_existing`?`supplement_existing`:r.checklistDecomposePolicy,maxConsecutiveParseFailures:typeof n.maxConsecutiveParseFailures==`number`&&Number.isFinite(n.maxConsecutiveParseFailures)?Math.max(1,Math.min(20,Math.floor(n.maxConsecutiveParseFailures))):r.maxConsecutiveParseFailures,judgeTimeoutSec:typeof n.judgeTimeoutMs==`number`&&Number.isFinite(n.judgeTimeoutMs)?Math.max(5,Math.min(120,Math.round(n.judgeTimeoutMs/1e3))):r.judgeTimeoutSec,checklistHistoryChars:typeof n.checklistHistoryChars==`number`&&Number.isFinite(n.checklistHistoryChars)?Math.max(0,Math.min(1e5,Math.floor(n.checklistHistoryChars))):r.checklistHistoryChars,notifications:{enabled:a.enabled===!0,includeLinkedSessions:a.includeLinkedSessions!==!1,channels:Array.isArray(a.channels)?a.channels.filter(e=>typeof e==`string`&&e.trim().length>0):r.notifications.channels,events:Array.isArray(a.events)?a.events.filter(e=>typeof e==`string`&&e.trim().length>0):r.notifications.events,targets:Array.isArray(a.targets)?a.targets.filter(i).map(e=>({channel:typeof e.channel==`string`?e.channel:``,chatId:typeof e.chatId==`string`?e.chatId:``,accountId:typeof e.accountId==`string`?e.accountId:void 0,threadId:typeof e.threadId==`string`||typeof e.threadId==`number`?e.threadId:void 0,silent:e.silent===!0,events:Array.isArray(e.events)?e.events.filter(e=>typeof e==`string`&&e.trim().length>0):void 0})).filter(e=>e.channel.trim()&&e.chatId.trim()):[]}}}async function o(r){let i=r.notifications.targets.map(e=>({...e,chatId:e.chatId.trim(),channel:e.channel.trim(),accountId:e.accountId?.trim()||void 0})).filter(e=>e.channel&&e.chatId&&e.chatId!==`__custom__`);await t(e(`/api/config`),{method:`PATCH`,body:JSON.stringify({goals:{maxTurns:r.maxTurns,...r.judgeModelRef.trim()?{judgeModelRef:r.judgeModelRef.trim()}:{judgeModelRef:null},checklistMode:r.checklistMode,checklistDecomposePolicy:r.checklistDecomposePolicy,maxConsecutiveParseFailures:r.maxConsecutiveParseFailures,judgeTimeoutMs:r.judgeTimeoutSec*1e3,checklistHistoryChars:r.checklistHistoryChars,notifications:{enabled:r.notifications.enabled,includeLinkedSessions:r.notifications.includeLinkedSessions,channels:r.notifications.channels,events:r.notifications.events,targets:i}}})}),n()}export{o as n,a as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-B1EG4gdu.js";import{n as l,r as u,s as d}from"./locale-store-tnRLWdx2.js";import{Ds as f,Go as p,Is as m,Jo as h,Kl as g,Ko as _,Nc as v,Ns as y,Ru as b,Tl as x,To as S,Uo as C,Wr as w,Yo as T,Zn as E,aa as D,au as O,cs as k,eo as A,hu as j,mu as M,os as N,pu as P,qo as F,ro as I,ul as L,vt as R,wc as z,xl as B,yc as V,yt as H,zu as U}from"./index-B24B26og.js";import{t as ee}from"./page-tabs-P2BEd1D8.js";import{t as te}from"./goals-config-api-BkVBh7ct.js";import{n as ne,t as re}from"./goal-create-dialog-51j_DxgV.js";var W=e(t(),1),ie=n(),G=[`active`,`paused`,`blocked`,`needs_input`,`done`,`archived`],ae=[`attention`,`running`,`ready`,`later`];function oe(e){let t=e.checklist.length;return{done:e.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length,total:t}}function se(e){return e.nextRunAt??e.finishedAt??e.startedAt??e.enqueuedAt}function ce(e){let t=new Map;for(let n of e){let e=t.get(n.goalId);(!e||se(n)>se(e))&&t.set(n.goalId,n)}return t}function K(e){return e===`running`||e===`queued`||e===`retry_waiting`}function le(e,t){return e.status===`done`||e.status===`archived`?null:e.status===`blocked`||e.status===`needs_input`||t?.status===`failed`?`attention`:t&&K(t.status)?`running`:e.status===`active`?`ready`:e.status===`paused`?`later`:null}function ue(e){return e===`high`?3:e===`normal`?2:1}function de(e,t,n){let r=n.get(e.id),i=n.get(t.id),a=r&&K(r.status)?1:0,o=i&&K(i.status)?1:0;if(a!==o)return o-a;let s=ue(t.priority)-ue(e.priority);if(s!==0)return s;let c=e.deadlineAt??1/0,l=t.deadlineAt??1/0;return c===l?t.updatedAt-e.updatedAt:c-l}function fe(e,t){let n=t.trim().toLowerCase();return n?[e.title,e.description,e.nextAction,e.blockedReason,e.latestRun?.reason,e.agentId,...e.checklist.map(e=>e.text)].filter(Boolean).join(`
|
|
2
2
|
`).toLowerCase().includes(n):!0}function pe(e,t){let n={attention:0,running:0,ready:0,later:0,history:0};for(let r of e){if(r.status===`done`||r.status===`archived`){n.history+=1;continue}let e=le(r,t.get(r.id));e&&(n[e]+=1)}return n}var q=r();function J(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function me(e,t){return R(e,t)}function he(e,t){let n=Math.round((e-Date.now())/1e3),r=Math.abs(n);return r<60?H(n,`second`,t):r<3600?H(Math.round(n/60),`minute`,t):r<86400?H(Math.round(n/3600),`hour`,t):r<2592e3?H(Math.round(n/86400),`day`,t):me(e,t)}function ge(e,t){return t.statuses[e]??e}function Y(e,t,n){return e.status===`blocked`?{label:n.workbench.status.blocked,tone:`attention`}:e.status===`needs_input`?{label:n.workbench.status.needsInput,tone:`attention`}:t?.status===`failed`?{label:n.workbench.status.executionFailed,tone:`attention`}:t?.status===`running`?{label:n.workbench.status.running,tone:`running`}:t?.status===`queued`?{label:n.workbench.status.queued,tone:`running`}:t?.status===`retry_waiting`?{label:n.workbench.status.retryWaiting,tone:`running`}:e.status===`active`?{label:n.workbench.status.ready,tone:`ready`}:e.status===`paused`?{label:n.workbench.status.paused,tone:`neutral`}:e.status===`done`?{label:n.workbench.status.done,tone:`done`}:{label:n.workbench.status.archived,tone:`neutral`}}function X(e){return e===`attention`?`bg-warning-soft text-amber-800 dark:text-amber-200`:e===`running`?`bg-accent-soft text-accent-fg`:e===`ready`?`bg-surface-active text-fg`:e===`done`?`bg-success-soft text-emerald-800 dark:text-emerald-200`:`bg-surface-hover text-fg-muted`}function _e(e,t){return e.status===`done`?`review`:e.status===`archived`?`unarchive`:e.status===`blocked`||e.status===`needs_input`?`details`:t?.status===`running`||t?.status===`queued`||t?.status===`retry_waiting`?`execution`:`continue`}function Z(e,t){return e===`details`?t.workbench.actions.handle:e===`review`?t.workbench.actions.review:e===`execution`?t.workbench.actions.viewExecution:e===`continue`?t.workbench.actions.continueExecution:t.actions[e]}function Q(e){return e===`details`?o:e===`review`?L:e===`execution`?O:e===`pause`?M:e===`archive`?b:e===`unarchive`?U:e===`reopen`?z:e===`complete`?j:P}function ve(e,t,n){return e.status===`needs_input`?e.blockedReason||e.nextAction||n.workbench.row.inputNeeded:e.status===`blocked`?e.blockedReason||n.workbench.row.reviewBlocker:t?.status===`failed`?t.error||n.workbench.row.executionFailed:t&&K(t.status)?e.nextAction||t.userTurn?.text||n.workbench.row.executionInProgress:e.status===`paused`?e.blockedReason&&e.blockedReason!==`user-paused`?e.blockedReason:n.workbench.row.pausedByUser:e.status===`done`?n.workbench.row.completedReview:e.status===`archived`?n.workbench.row.archived:e.nextAction||n.noNextAction}function ye(e,t,n){if(!e||K(e.status))return null;let r=he(se(e),t);return e.status===`succeeded`?J(n.workbench.row.lastSucceeded,{time:r}):e.status===`failed`?J(n.workbench.row.lastFailed,{time:r}):J(n.workbench.row.lastFinished,{time:r})}function $(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function be(e){return e===`archive`?`unarchive`:e===`unarchive`?`archive`:e===`complete`?`reopen`:`complete`}async function xe(){return(await d(u(`/api/goals?${new URLSearchParams({status:G.join(`,`),limit:`500`}).toString()}`))).goals}async function Se(){return(await d(u(`/api/goals/queue`))).queue??[]}async function Ce(e){return(await d(u(`/api/goals`),{method:`POST`,body:JSON.stringify({...e,source:`api`})})).goal}async function we(e,t){let n=await d(u(`/api/goals/contract/draft`),{method:`POST`,body:JSON.stringify({title:e.title,context:e.description,criteria:e.checklist,judgeModelRef:e.judgeModelRef||void 0,uiLocale:t})});return{objective:n.contract.objective??e.objective,scopeBoundary:n.contract.scopeBoundary??e.scopeBoundary,evidencePlan:n.contract.evidencePlan??e.evidencePlan,checklist:n.contract.criteria??e.checklist}}async function Te(e,t){await d(u(`/api/goals/${encodeURIComponent(e)}/${t}`),{method:`POST`,body:JSON.stringify({})})}async function Ee(e){return(await d(u(`/api/goals/${encodeURIComponent(e)}/continue`),{method:`POST`,body:JSON.stringify({})})).sessionKey}function De(e){let t=(0,ie.c)(51),{goal:n,queueItem:r,intent:i,t:o,busy:c,onAction:l}=e,u;t[0]===i?u=t[1]:(u=Q(i),t[0]=i,t[1]=u);let d=u,f=c===`${n.id}:${i}`,p=i===`continue`?`primary`:`secondary`;if(i===`details`||i===`review`){let e=`/goals/${encodeURIComponent(n.id)}`,r;t[2]===d?r=t[3]:(r=(0,q.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[2]=d,t[3]=r);let s;t[4]!==i||t[5]!==o?(s=Z(i,o),t[4]=i,t[5]=o,t[6]=s):s=t[6];let c;t[7]!==e||t[8]!==r||t[9]!==s?(c=(0,q.jsxs)(a,{to:e,children:[r,s]}),t[7]=e,t[8]=r,t[9]=s,t[10]=c):c=t[10];let l;return t[11]!==c||t[12]!==p?(l=(0,q.jsx)(y,{asChild:!0,type:`button`,variant:p,className:`h-11 rounded-lg px-3.5`,children:c}),t[11]=c,t[12]=p,t[13]=l):l=t[13],l}if(i===`execution`){if(r?.sessionKey){let e=`/chat/${encodeURIComponent(r.sessionKey)}`,n;t[14]===d?n=t[15]:(n=(0,q.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[14]=d,t[15]=n);let s;t[16]!==i||t[17]!==o?(s=Z(i,o),t[16]=i,t[17]=o,t[18]=s):s=t[18];let c;return t[19]!==e||t[20]!==n||t[21]!==s?(c=(0,q.jsx)(y,{asChild:!0,type:`button`,variant:`secondary`,className:`h-11 rounded-lg px-3.5`,children:(0,q.jsxs)(a,{to:e,children:[n,s]})}),t[19]=e,t[20]=n,t[21]=s,t[22]=c):c=t[22],c}let e=`/goals/${encodeURIComponent(n.id)}`,s;t[23]===d?s=t[24]:(s=(0,q.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[23]=d,t[24]=s);let c;t[25]!==i||t[26]!==o?(c=Z(i,o),t[25]=i,t[26]=o,t[27]=c):c=t[27];let l;return t[28]!==e||t[29]!==s||t[30]!==c?(l=(0,q.jsx)(y,{asChild:!0,type:`button`,variant:`secondary`,className:`h-11 rounded-lg px-3.5`,children:(0,q.jsxs)(a,{to:e,children:[s,c]})}),t[28]=e,t[29]=s,t[30]=c,t[31]=l):l=t[31],l}let m;t[32]!==n.id||t[33]!==i||t[34]!==l?(m=()=>l(n.id,i),t[32]=n.id,t[33]=i,t[34]=l,t[35]=m):m=t[35];let h=f&&`animate-pulse`,g;t[36]===h?g=t[37]:(g=s(`size-4`,h),t[36]=h,t[37]=g);let _;t[38]!==d||t[39]!==g?(_=(0,q.jsx)(d,{className:g,"aria-hidden":!0}),t[38]=d,t[39]=g,t[40]=_):_=t[40];let v;t[41]!==i||t[42]!==f||t[43]!==o?(v=f?o.workbench.actions.working:Z(i,o),t[41]=i,t[42]=f,t[43]=o,t[44]=v):v=t[44];let b;return t[45]!==f||t[46]!==m||t[47]!==_||t[48]!==v||t[49]!==p?(b=(0,q.jsxs)(y,{type:`button`,variant:p,className:`h-11 rounded-lg px-3.5`,disabled:f,onClick:m,children:[_,v]}),t[45]=f,t[46]=m,t[47]=_,t[48]=v,t[49]=p,t[50]=b):b=t[50],b}function Oe(e){let t=(0,ie.c)(126),{goal:n,queueItem:r,t:i,language:a,busy:o,actionError:c,onOpen:l,onAction:u}=e,d,p,m,h,_,v,b,x,S,C,w,T,E,D,O;if(t[0]!==n||t[1]!==a||t[2]!==l||t[3]!==r||t[4]!==i){let e=Y(n,r,i),o;t[20]!==n||t[21]!==r?(o=_e(n,r),t[20]=n,t[21]=r,t[22]=o):o=t[22],d=o;let c=oe(n),u;t[23]!==n.latestRun?.finishedAt||t[24]!==n.updatedAt||t[25]!==r?(u=r&&K(r.status)?se(r):n.latestRun?.finishedAt??n.updatedAt,t[23]=n.latestRun?.finishedAt,t[24]=n.updatedAt,t[25]=r,t[26]=u):u=t[26];let g=u,y;t[27]!==a||t[28]!==r||t[29]!==i?(y=ye(r,a,i),t[27]=a,t[28]=r,t[29]=i,t[30]=y):y=t[30],p=y,b=`group border-b border-edge-subtle py-4 last:border-b-0 sm:py-5`,v=`flex flex-col gap-4 lg:flex-row lg:items-center`,w=`button`,t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=s(`min-w-0 flex-1 rounded-lg text-left`,f.focusRingPanel),t[31]=T):T=t[31],E=`${i.openDetails}: ${n.title}`,t[32]!==n||t[33]!==l?(D=()=>l(n),t[32]=n,t[33]=l,t[34]=D):D=t[34];let k=s(`rounded-full px-2.5 py-1 text-xs font-semibold`,X(e.tone)),A;t[35]!==e||t[36]!==k?(A=(0,q.jsx)(`span`,{className:k,children:e.label}),t[35]=e,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==n.priority||t[39]!==i.workbench?(j=n.priority===`high`?(0,q.jsx)(`span`,{className:`text-xs font-semibold text-fg`,children:i.workbench.row.highPriority}):null,t[38]=n.priority,t[39]=i.workbench,t[40]=j):j=t[40];let M;t[41]===n.agentId?M=t[42]:(M=(0,q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.agentId}),t[41]=n.agentId,t[42]=M),t[43]!==A||t[44]!==j||t[45]!==M?(O=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[A,j,M]}),t[43]=A,t[44]=j,t[45]=M,t[46]=O):O=t[46],t[47]===n.title?h=t[48]:(h=(0,q.jsx)(`h3`,{className:`mt-2.5 text-base font-semibold leading-6 text-fg`,children:n.title}),t[47]=n.title,t[48]=h);let N=e.tone===`attention`?`text-amber-800 dark:text-amber-200`:`text-fg-muted`,P;t[49]===N?P=t[50]:(P=s(`mt-1 max-w-[70ch] text-sm leading-6`,N),t[49]=N,t[50]=P);let F;t[51]!==n||t[52]!==r||t[53]!==i?(F=ve(n,r,i),t[51]=n,t[52]=r,t[53]=i,t[54]=F):F=t[54],t[55]!==P||t[56]!==F?(_=(0,q.jsx)(`p`,{className:P,children:F}),t[55]=P,t[56]=F,t[57]=_):_=t[57],m=`mt-2.5 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-fg-subtle`;let I;t[58]!==a||t[59]!==g?(I=me(g,a),t[58]=a,t[59]=g,t[60]=I):I=t[60];let L;t[61]!==a||t[62]!==g?(L=he(g,a),t[61]=a,t[62]=g,t[63]=L):L=t[63],t[64]!==I||t[65]!==L?(x=(0,q.jsx)(`span`,{title:I,children:L}),t[64]=I,t[65]=L,t[66]=x):x=t[66];let R;t[67]!==n.maxTurns||t[68]!==n.turnsUsed||t[69]!==i.turns?(R=J(i.turns,{used:n.turnsUsed,max:n.maxTurns}),t[67]=n.maxTurns,t[68]=n.turnsUsed,t[69]=i.turns,t[70]=R):R=t[70],t[71]===R?S=t[72]:(S=(0,q.jsx)(`span`,{children:R}),t[71]=R,t[72]=S),C=c.total?(0,q.jsx)(`span`,{children:J(i.checklistProgress,{done:c.done,total:c.total})}):null,t[0]=n,t[1]=a,t[2]=l,t[3]=r,t[4]=i,t[5]=d,t[6]=p,t[7]=m,t[8]=h,t[9]=_,t[10]=v,t[11]=b,t[12]=x,t[13]=S,t[14]=C,t[15]=w,t[16]=T,t[17]=E,t[18]=D,t[19]=O}else d=t[5],p=t[6],m=t[7],h=t[8],_=t[9],v=t[10],b=t[11],x=t[12],S=t[13],C=t[14],w=t[15],T=t[16],E=t[17],D=t[18],O=t[19];let k;t[73]!==n.deadlineAt||t[74]!==a||t[75]!==i.deadlineSummary?(k=n.deadlineAt?(0,q.jsx)(`span`,{children:J(i.deadlineSummary,{deadline:me(n.deadlineAt,a)})}):null,t[73]=n.deadlineAt,t[74]=a,t[75]=i.deadlineSummary,t[76]=k):k=t[76];let A;t[77]===p?A=t[78]:(A=p?(0,q.jsx)(`span`,{children:p}):null,t[77]=p,t[78]=A);let j;t[79]!==r||t[80]!==i.attempt?(j=r&&K(r.status)?(0,q.jsx)(`span`,{children:J(i.attempt,{attempts:r.attempts,max:r.maxRetries+1})}):null,t[79]=r,t[80]=i.attempt,t[81]=j):j=t[81];let M;t[82]!==m||t[83]!==k||t[84]!==A||t[85]!==j||t[86]!==x||t[87]!==S||t[88]!==C?(M=(0,q.jsxs)(`div`,{className:m,children:[x,S,C,k,A,j]}),t[82]=m,t[83]=k,t[84]=A,t[85]=j,t[86]=x,t[87]=S,t[88]=C,t[89]=M):M=t[89];let N;t[90]!==h||t[91]!==_||t[92]!==M||t[93]!==w||t[94]!==T||t[95]!==E||t[96]!==D||t[97]!==O?(N=(0,q.jsxs)(`button`,{type:w,className:T,"aria-label":E,onClick:D,children:[O,h,_,M]}),t[90]=h,t[91]=_,t[92]=M,t[93]=w,t[94]=T,t[95]=E,t[96]=D,t[97]=O,t[98]=N):N=t[98];let P;t[99]!==o||t[100]!==n||t[101]!==d||t[102]!==u||t[103]!==r||t[104]!==i?(P=(0,q.jsx)(De,{goal:n,queueItem:r,intent:d,t:i,busy:o,onAction:u}),t[99]=o,t[100]=n,t[101]=d,t[102]=u,t[103]=r,t[104]=i,t[105]=P):P=t[105];let F;t[106]!==n||t[107]!==l?(F=()=>l(n),t[106]=n,t[107]=l,t[108]=F):F=t[108];let I;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,q.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[109]=I):I=t[109];let L;t[110]!==i.openDetails||t[111]!==F?(L=(0,q.jsx)(y,{type:`button`,variant:`ghost`,className:`size-11 shrink-0 rounded-lg p-0`,"aria-label":i.openDetails,onClick:F,children:I}),t[110]=i.openDetails,t[111]=F,t[112]=L):L=t[112];let R;t[113]!==P||t[114]!==L?(R=(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 lg:justify-end`,children:[P,L]}),t[113]=P,t[114]=L,t[115]=R):R=t[115];let z;t[116]!==v||t[117]!==N||t[118]!==R?(z=(0,q.jsxs)(`div`,{className:v,children:[N,R]}),t[116]=v,t[117]=N,t[118]=R,t[119]=z):z=t[119];let B;t[120]===c?B=t[121]:(B=c?(0,q.jsx)(`p`,{className:`mt-3 rounded-lg bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:c}):null,t[120]=c,t[121]=B);let V;return t[122]!==b||t[123]!==z||t[124]!==B?(V=(0,q.jsxs)(`article`,{className:b,children:[z,B]}),t[122]=b,t[123]=z,t[124]=B,t[125]=V):V=t[125],V}function ke(){let e=(0,ie.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,q.jsx)(`div`,{"aria-hidden":`true`,children:Array.from({length:3}).map(Ae)}),e[0]=t):t=e[0],t}function Ae(e,t){return(0,q.jsx)(`div`,{className:`border-b border-edge-subtle py-5 last:border-b-0`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(I,{className:`h-6 w-24 rounded-full`}),(0,q.jsx)(I,{className:`h-4 w-16`})]}),(0,q.jsx)(I,{className:`mt-3 h-5 w-2/3`}),(0,q.jsx)(I,{className:`mt-2 h-4 w-full max-w-2xl`}),(0,q.jsx)(I,{className:`mt-3 h-3 w-72 max-w-full`})]}),(0,q.jsx)(I,{className:`h-11 w-32 rounded-lg`})]})},t)}function je(e){let t=(0,ie.c)(36),{title:n,description:r,goals:i,queueByGoal:a,t:o,language:s,busy:c,actionError:l,onOpen:u,onAction:d}=e,f=`goal-section-${n}`,p=`goal-section-${n}`,m;t[0]!==p||t[1]!==n?(m=(0,q.jsx)(`h2`,{id:p,className:`text-base font-semibold text-fg`,children:n}),t[0]=p,t[1]=n,t[2]=m):m=t[2];let h;t[3]===r?h=t[4]:(h=(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r}),t[3]=r,t[4]=h);let g;t[5]!==m||t[6]!==h?(g=(0,q.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[5]=m,t[6]=h,t[7]=g):g=t[7];let _;t[8]===i.length?_=t[9]:(_=(0,q.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2.5 py-1 text-xs font-semibold tabular-nums text-fg-muted`,children:i.length}),t[8]=i.length,t[9]=_);let v;t[10]!==g||t[11]!==_?(v=(0,q.jsxs)(`header`,{className:`flex items-start justify-between gap-4 pb-1`,children:[g,_]}),t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;if(t[13]!==l||t[14]!==c||t[15]!==i||t[16]!==s||t[17]!==d||t[18]!==u||t[19]!==a||t[20]!==o){let e;t[22]!==l||t[23]!==c||t[24]!==s||t[25]!==d||t[26]!==u||t[27]!==a||t[28]!==o?(e=e=>(0,q.jsx)(Oe,{goal:e,queueItem:a.get(e.id),t:o,language:s,busy:c,actionError:l?.goalId===e.id?l.message:void 0,onOpen:u,onAction:d},e.id),t[22]=l,t[23]=c,t[24]=s,t[25]=d,t[26]=u,t[27]=a,t[28]=o,t[29]=e):e=t[29],y=i.map(e),t[13]=l,t[14]=c,t[15]=i,t[16]=s,t[17]=d,t[18]=u,t[19]=a,t[20]=o,t[21]=y}else y=t[21];let b;t[30]===y?b=t[31]:(b=(0,q.jsx)(`div`,{className:`mt-2`,children:y}),t[30]=y,t[31]=b);let x;return t[32]!==f||t[33]!==v||t[34]!==b?(x=(0,q.jsxs)(`section`,{"aria-labelledby":f,children:[v,b]}),t[32]=f,t[33]=v,t[34]=b,t[35]=x):x=t[35],x}function Me(e){let t=(0,ie.c)(140),{goal:n,queueItem:r,t:i,language:o,busy:c,onClose:l,onAction:u}=e;if(!n)return null;let d,f,v,x,S,w,E,D,O,k,A,j,N,P,I,R,z;if(t[0]!==n||t[1]!==l||t[2]!==r||t[3]!==i){let e=oe(n);S=Y(n,r,i);let a;t[21]!==n||t[22]!==r?(a=_e(n,r),t[21]=n,t[22]=r,t[23]=a):a=t[23],x=a,v=C,D=!0,t[24]===l?O=t[25]:(O=e=>!e&&l(),t[24]=l,t[25]=O),f=h,t[26]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,q.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[26]=E):E=t[26],d=p,R=`fixed left-1/2 top-1/2 z-66 flex h-[min(90vh,48rem)] w-[min(100%-2rem,56rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`;let o;t[27]===n.title?o=t[28]:(o=(0,q.jsx)(T,{className:`text-base font-semibold leading-6 text-fg`,children:n.title}),t[27]=n.title,t[28]=o);let c;t[29]!==n||t[30]!==r||t[31]!==i?(c=ve(n,r,i),t[29]=n,t[30]=r,t[31]=i,t[32]=c):c=t[32];let u;t[33]===c?u=t[34]:(u=(0,q.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:c}),t[33]=c,t[34]=u);let g;t[35]!==o||t[36]!==u?(g=(0,q.jsxs)(`div`,{className:`min-w-0`,children:[o,u]}),t[35]=o,t[36]=u,t[37]=g):g=t[37];let b;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,q.jsx)(m,{className:`size-5`,"aria-hidden":!0}),t[38]=b):b=t[38];let M;t[39]!==l||t[40]!==i.closeDetails?(M=(0,q.jsx)(y,{type:`button`,variant:`ghost`,className:`size-11 shrink-0 rounded-lg p-0`,"aria-label":i.closeDetails,onClick:l,children:b}),t[39]=l,t[40]=i.closeDetails,t[41]=M):M=t[41],t[42]!==g||t[43]!==M?(z=(0,q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[g,M]}),t[42]=g,t[43]=M,t[44]=z):z=t[44],I=`min-h-0 flex-1 overflow-y-auto p-5`,P=`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,A=`flex flex-wrap items-center gap-2`;let L=s(`rounded-full px-2.5 py-1 text-xs font-semibold`,X(S.tone));t[45]!==S.label||t[46]!==L?(j=(0,q.jsx)(`span`,{className:L,children:S.label}),t[45]=S.label,t[46]=L,t[47]=j):j=t[47],t[48]===n.agentId?N=t[49]:(N=(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n.agentId}),t[48]=n.agentId,t[49]=N),w=`text-xs text-fg-muted`,k=J(i.checklistProgress,{done:e.done,total:e.total}),t[0]=n,t[1]=l,t[2]=r,t[3]=i,t[4]=d,t[5]=f,t[6]=v,t[7]=x,t[8]=S,t[9]=w,t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=A,t[15]=j,t[16]=N,t[17]=P,t[18]=I,t[19]=R,t[20]=z}else d=t[4],f=t[5],v=t[6],x=t[7],S=t[8],w=t[9],E=t[10],D=t[11],O=t[12],k=t[13],A=t[14],j=t[15],N=t[16],P=t[17],I=t[18],R=t[19],z=t[20];let B;t[50]!==w||t[51]!==k?(B=(0,q.jsx)(`span`,{className:w,children:k}),t[50]=w,t[51]=k,t[52]=B):B=t[52];let V;t[53]!==B||t[54]!==A||t[55]!==j||t[56]!==N?(V=(0,q.jsxs)(`div`,{className:A,children:[j,N,B]}),t[53]=B,t[54]=A,t[55]=j,t[56]=N,t[57]=V):V=t[57];let H;t[58]!==c||t[59]!==n||t[60]!==x||t[61]!==u||t[62]!==r||t[63]!==i?(H=(0,q.jsx)(De,{goal:n,queueItem:r,intent:x,t:i,busy:c,onAction:u}),t[58]=c,t[59]=n,t[60]=x,t[61]=u,t[62]=r,t[63]=i,t[64]=H):H=t[64];let U;t[65]!==V||t[66]!==H||t[67]!==P?(U=(0,q.jsxs)(`div`,{className:P,children:[V,H]}),t[65]=V,t[66]=H,t[67]=P,t[68]=U):U=t[68];let ee;t[69]===n.description?ee=t[70]:(ee=n.description?(0,q.jsx)(`p`,{className:`mt-6 max-w-[70ch] whitespace-pre-wrap break-words text-sm leading-6 text-fg-muted`,children:n.description}):null,t[69]=n.description,t[70]=ee);let te=n.blockedReason?i.currentBlocker:i.nextAction,ne;t[71]===te?ne=t[72]:(ne=(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:te}),t[71]=te,t[72]=ne);let re=S.tone===`attention`?`text-amber-800 dark:text-amber-200`:`text-fg-muted`,W;t[73]===re?W=t[74]:(W=s(`mt-2 text-sm leading-6`,re),t[73]=re,t[74]=W);let G;t[75]!==n||t[76]!==r||t[77]!==i?(G=ve(n,r,i),t[75]=n,t[76]=r,t[77]=i,t[78]=G):G=t[78];let ae;t[79]!==W||t[80]!==G?(ae=(0,q.jsx)(`p`,{className:W,children:G}),t[79]=W,t[80]=G,t[81]=ae):ae=t[81];let ce;t[82]!==ne||t[83]!==ae?(ce=(0,q.jsxs)(`section`,{className:`mt-7 border-t border-edge-subtle pt-5`,children:[ne,ae]}),t[82]=ne,t[83]=ae,t[84]=ce):ce=t[84];let K;t[85]!==o||t[86]!==r||t[87]!==i?(K=r?(0,q.jsxs)(`section`,{className:`mt-6 border-t border-edge-subtle pt-5`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.workbench.row.latestExecution}),(0,q.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:ge(r.status,i)})]}),(0,q.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[J(i.attempt,{attempts:r.attempts,max:r.maxRetries+1}),` · `,me(se(r),o)]}),r.error?(0,q.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:r.error}):null]}):null,t[85]=o,t[86]=r,t[87]=i,t[88]=K):K=t[88];let le;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,q.jsx)(L,{className:`size-4 text-accent`,"aria-hidden":!0}),t[89]=le):le=t[89];let ue;t[90]===i.checklist?ue=t[91]:(ue=(0,q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[le,i.checklist]}),t[90]=i.checklist,t[91]=ue);let de;t[92]!==n.checklist||t[93]!==i.noChecklist?(de=n.checklist.length?(0,q.jsx)(`ul`,{className:`mt-3 grid gap-2 text-sm leading-6 text-fg-muted`,children:n.checklist.map(Ne)}):(0,q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:i.noChecklist}),t[92]=n.checklist,t[93]=i.noChecklist,t[94]=de):de=t[94];let fe;t[95]!==ue||t[96]!==de?(fe=(0,q.jsxs)(`section`,{className:`mt-6 border-t border-edge-subtle pt-5`,children:[ue,de]}),t[95]=ue,t[96]=de,t[97]=fe):fe=t[97];let pe;t[98]!==U||t[99]!==ee||t[100]!==ce||t[101]!==K||t[102]!==fe||t[103]!==I?(pe=(0,q.jsxs)(`div`,{className:I,children:[U,ee,ce,K,fe]}),t[98]=U,t[99]=ee,t[100]=ce,t[101]=K,t[102]=fe,t[103]=I,t[104]=pe):pe=t[104];let he;t[105]!==n.id||t[106]!==n.status||t[107]!==u||t[108]!==i.actions?(he=n.status===`active`?(0,q.jsxs)(y,{type:`button`,variant:`ghost`,className:`h-11 rounded-lg`,onClick:()=>u(n.id,`pause`),children:[(0,q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),i.actions.pause]}):null,t[105]=n.id,t[106]=n.status,t[107]=u,t[108]=i.actions,t[109]=he):he=t[109];let Z;t[110]!==n.id||t[111]!==n.status||t[112]!==u||t[113]!==i.actions?(Z=n.status===`archived`?null:(0,q.jsxs)(y,{type:`button`,variant:`ghost`,className:`h-11 rounded-lg`,onClick:()=>u(n.id,`archive`),children:[(0,q.jsx)(b,{className:`size-4`,"aria-hidden":!0}),i.actions.archive]}),t[110]=n.id,t[111]=n.status,t[112]=u,t[113]=i.actions,t[114]=Z):Z=t[114];let Q;t[115]!==he||t[116]!==Z?(Q=(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[he,Z]}),t[115]=he,t[116]=Z,t[117]=Q):Q=t[117];let ye=`/goals/${encodeURIComponent(n.id)}`,$;t[118]===Symbol.for(`react.memo_cache_sentinel`)?($=(0,q.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[118]=$):$=t[118];let be;t[119]!==i.fullDetails||t[120]!==ye?(be=(0,q.jsx)(y,{asChild:!0,type:`button`,variant:`secondary`,className:`h-11 rounded-lg`,children:(0,q.jsxs)(a,{to:ye,children:[$,i.fullDetails]})}),t[119]=i.fullDetails,t[120]=ye,t[121]=be):be=t[121];let xe;t[122]!==Q||t[123]!==be?(xe=(0,q.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-5 py-3`,children:[Q,be]}),t[122]=Q,t[123]=be,t[124]=xe):xe=t[124];let Se;t[125]!==d||t[126]!==pe||t[127]!==xe||t[128]!==R||t[129]!==z?(Se=(0,q.jsxs)(d,{className:R,children:[z,pe,xe]}),t[125]=d,t[126]=pe,t[127]=xe,t[128]=R,t[129]=z,t[130]=Se):Se=t[130];let Ce;t[131]!==f||t[132]!==E||t[133]!==Se?(Ce=(0,q.jsxs)(f,{children:[E,Se]}),t[131]=f,t[132]=E,t[133]=Se,t[134]=Ce):Ce=t[134];let we;return t[135]!==v||t[136]!==D||t[137]!==O||t[138]!==Ce?(we=(0,q.jsx)(v,{open:D,onOpenChange:O,children:Ce}),t[135]=v,t[136]=D,t[137]=O,t[138]=Ce,t[139]=we):we=t[139],we}function Ne(e){return(0,q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,q.jsx)(`span`,{className:`w-5 shrink-0 text-center`,children:$(e.status)}),(0,q.jsx)(`span`,{className:`break-words`,children:e.text})]},e.id)}function Pe(){let e=i(),t=l(e=>e.language),n=c(t).goalsPage,r=S(e=>e.setPageHeader),a=S(e=>e.clearPageHeader),[o,s]=(0,W.useState)([]),[u,d]=(0,W.useState)([]),[f,p]=(0,W.useState)(``),[h,g]=(0,W.useState)(`workbench`),[_,b]=(0,W.useState)(``),[C,T]=(0,W.useState)(``),[O,M]=(0,W.useState)(``),[P,F]=(0,W.useState)(!0),[I,R]=(0,W.useState)(null),[z,H]=(0,W.useState)(null),[U,ie]=(0,W.useState)(null),[G,oe]=(0,W.useState)(null),[se,K]=(0,W.useState)(!1),[ue,me]=(0,W.useState)(null),[he,ge]=(0,W.useState)({defaultAgentId:``,agents:[],models:[],checklistDecomposePolicy:`empty_only`}),Y=(0,W.useCallback)(async()=>{F(!0),R(null);try{let[e,t]=await Promise.all([xe(),Se()]);s(e),d(t)}catch(e){R(e instanceof Error?e.message:n.errors.load)}finally{F(!1)}},[n.errors.load]);(0,W.useEffect)(()=>{Y()},[Y]),(0,W.useEffect)(()=>{let e=!1;async function t(){let[t,n,r]=await Promise.allSettled([w(),E(),A()]);e||ge(e=>{let i=t.status===`fulfilled`?t.value.defaultId:e.defaultAgentId,a=t.status===`fulfilled`?t.value.agents:e.agents;return{defaultAgentId:i,agents:a.length?a:[{id:i||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],models:n.status===`fulfilled`?n.value:e.models,checklistDecomposePolicy:r.status===`fulfilled`?te(r.value.payload?.config).checklistDecomposePolicy:e.checklistDecomposePolicy}})}return t(),()=>{e=!0}},[]),(0,W.useEffect)(()=>{let e=()=>{Y()};return window.addEventListener(`goal-queue-updated`,e),window.addEventListener(`goal-status-updated`,e),()=>{window.removeEventListener(`goal-queue-updated`,e),window.removeEventListener(`goal-status-updated`,e)}},[Y]),(0,W.useEffect)(()=>{if(!G)return;let e=window.setTimeout(()=>oe(null),8e3);return()=>window.clearTimeout(e)},[G]);let X=(0,W.useMemo)(()=>ce(u),[u]),Z=(0,W.useMemo)(()=>o.filter(e=>fe(e,f)),[o,f]),Q=(0,W.useMemo)(()=>pe(o,X),[o,X]),ve=(0,W.useMemo)(()=>o.find(e=>e.id===ue)??null,[o,ue]),ye=(0,W.useMemo)(()=>[...new Set(o.map(e=>e.agentId))].sort(),[o]),$=(0,W.useMemo)(()=>{let e=new Map(ae.map(e=>[e,[]]));for(let t of Z){let n=le(t,X.get(t.id));n&&e.get(n)?.push(t)}for(let t of ae)e.get(t)?.sort((e,t)=>de(e,t,X));return e},[X,Z]),Ae=(0,W.useMemo)(()=>Z.filter(e=>e.status!==`done`&&e.status!==`archived`).filter(e=>!_||e.agentId===_).filter(e=>!C||e.status===C).filter(e=>!O||e.priority===O).sort((e,t)=>de(e,t,X)),[_,O,X,Z,C]),Ne=(0,W.useMemo)(()=>Z.filter(e=>e.status===`done`||e.status===`archived`).sort((e,t)=>t.updatedAt-e.updatedAt),[Z]),Pe=$.get(`attention`)?.[0]??$.get(`running`)?.[0]??$.get(`ready`)?.[0]??null,Fe=Q.attention>0?{title:Q.attention===1?n.workbench.hero.attentionOne:J(n.workbench.hero.attentionMany,{count:Q.attention}),description:n.workbench.hero.attentionDescription}:Q.running>0?{title:Q.running===1?n.workbench.hero.runningOne:J(n.workbench.hero.runningMany,{count:Q.running}),description:n.workbench.hero.runningDescription}:Q.ready>0?{title:Q.ready===1?n.workbench.hero.readyOne:J(n.workbench.hero.readyMany,{count:Q.ready}),description:n.workbench.hero.readyDescription}:{title:n.workbench.hero.calm,description:Q.later>0?J(n.workbench.hero.calmDescriptionWithPaused,{paused:Q.later}):n.workbench.hero.calmDescription},Ie=(0,W.useCallback)(async(t,r,i)=>{let a=o.find(e=>e.id===t);ie(`${t}:${r}`),H(null);try{if(r===`continue`){let n=await Ee(t);if(n){e(`/chat/${encodeURIComponent(n)}`);return}}else await Te(t,r),!i?.skipUndo&&a&&(r===`archive`||r===`unarchive`||r===`complete`||r===`reopen`)&&oe({goalId:t,action:r,title:a.title});await Y()}catch(e){H({goalId:t,message:e instanceof Error?e.message:n.errors.action})}finally{ie(null)}},[o,e,Y,n.errors.action]),Le=(0,W.useCallback)(async e=>{let t=Number.parseInt(e.maxTurns,10),r=e.deadline?new Date(e.deadline).getTime():void 0;ie(`create`),R(null);try{let n=await Ce({title:e.title.trim(),contextMessage:{text:e.description.trim(),attachments:e.attachments.length?e.attachments:void 0},priority:e.priority,deadlineAt:Number.isFinite(r)?r:void 0,maxTurns:Number.isFinite(t)?t:void 0,agentId:e.agentId.trim()||void 0,judgeModelRef:e.judgeModelRef.trim()||void 0,contract:{objective:e.objective.trim()||e.title.trim(),scopeBoundary:e.scopeBoundary.trim()||void 0,evidencePlan:ne(e.evidencePlan),criteria:ne(e.checklist)}});await Y(),me(n.id)}catch(e){throw R(e instanceof Error?e.message:n.errors.create),e}finally{ie(null)}},[Y,n.errors.create]),Re=(0,W.useMemo)(()=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`relative min-w-0`,children:[(0,q.jsx)(V,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,q.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),"aria-label":n.searchPlaceholder,autoComplete:`off`,placeholder:n.searchPlaceholder,className:`h-10 w-36 rounded-lg border border-edge bg-surface-muted py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent sm:w-56 lg:w-72`})]}),(0,q.jsx)(D,{className:`size-10 shrink-0 p-0`,loading:P,label:n.refresh,onClick:Y}),(0,q.jsxs)(y,{type:`button`,variant:`primary`,className:`h-10 rounded-lg`,disabled:U===`create`,onClick:()=>K(!0),children:[(0,q.jsx)(v,{className:`size-4`,"aria-hidden":!0}),n.create]})]}),[U,P,f,Y,n.create,n.refresh,n.searchPlaceholder]);(0,W.useLayoutEffect)(()=>(r({startExtra:null,main:(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.workbench.pageDescription})]}),end:Re}),()=>a()),[a,Re,r,n.title,n.workbench.pageDescription]);let ze=[{id:`workbench`,label:n.workbench.tabs.workbench,icon:B,count:Q.attention+Q.running+Q.ready},{id:`all`,label:n.workbench.tabs.all,icon:L,count:o.length-Q.history},{id:`history`,label:n.workbench.tabs.history,icon:x,count:Q.history}],Be=n.workbench.sections;return(0,q.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,q.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,q.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base px-4 py-5 sm:px-6 sm:py-6`,"aria-labelledby":`goals-now-title`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 max-w-2xl`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:n.workbench.hero.eyebrow}),(0,q.jsx)(`h2`,{id:`goals-now-title`,className:`mt-1.5 text-xl font-semibold tracking-tight text-fg sm:text-2xl`,children:Fe.title}),(0,q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Fe.description})]}),Pe?(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 border-t border-edge-subtle pt-4 lg:max-w-md lg:border-l lg:border-t-0 lg:pl-6 lg:pt-0`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.workbench.hero.nextFocus}),(0,q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm font-semibold leading-5 text-fg`,children:Pe.title})]}),(0,q.jsx)(De,{goal:Pe,queueItem:X.get(Pe.id),intent:_e(Pe,X.get(Pe.id)),t:n,busy:U,onAction:(e,t)=>void Ie(e,t)})]}):null]})}),(0,q.jsx)(`div`,{className:`mt-5 border-b border-edge-subtle`,children:(0,q.jsx)(ee,{items:ze,activeTab:h,onChange:g,ariaLabel:n.workbench.tabs.label,tabIdPrefix:`goals-tab`,panelIdPrefix:`goals-panel`,className:`pb-2`,selectedClassName:`bg-surface-active text-fg`})}),I?(0,q.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 rounded-lg bg-danger-soft px-4 py-3 text-sm text-danger sm:flex-row sm:items-center sm:justify-between`,role:`alert`,children:[(0,q.jsx)(`span`,{children:I}),(0,q.jsx)(y,{type:`button`,variant:`secondary`,className:`h-10 rounded-lg`,onClick:()=>void Y(),children:n.workbench.actions.retryLoad})]}):null,(0,q.jsxs)(`section`,{id:`goals-panel-${h}`,role:`tabpanel`,"aria-labelledby":`goals-tab-${h}`,className:`min-h-0 flex-1 overflow-y-auto pb-12 pt-5`,children:[P&&o.length===0?(0,q.jsx)(ke,{}):null,!P&&h===`workbench`?(0,q.jsxs)(`div`,{className:`grid gap-9`,children:[[`attention`,`running`,`ready`].map(e=>{let r=$.get(e)??[];return r.length===0?null:(0,q.jsx)(je,{...Be[e],goals:r,queueByGoal:X,t:n,language:t,busy:U,actionError:z,onOpen:e=>me(e.id),onAction:(e,t)=>void Ie(e,t)},e)}),($.get(`attention`)?.length??0)+($.get(`running`)?.length??0)+($.get(`ready`)?.length??0)===0?(0,q.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-5 py-8 text-center`,children:[(0,q.jsx)(j,{className:`mx-auto size-6 text-success`,"aria-hidden":!0}),(0,q.jsx)(`h2`,{className:`mt-3 text-base font-semibold text-fg`,children:n.workbench.empty.healthyTitle}),(0,q.jsx)(`p`,{className:`mx-auto mt-2 max-w-xl text-sm leading-6 text-fg-muted`,children:Q.later>0?J(n.workbench.empty.healthyDescriptionWithPaused,{paused:Q.later}):n.workbench.empty.healthyDescription})]}):null,($.get(`later`)?.length??0)>0?(0,q.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-5`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-lg px-1 text-sm font-semibold text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,q.jsx)(`span`,{children:Be.later.title}),(0,q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs tabular-nums text-fg-muted`,children:$.get(`later`)?.length})]}),(0,q.jsx)(`p`,{className:`mt-1 px-1 text-sm text-fg-muted`,children:Be.later.description}),(0,q.jsx)(`div`,{className:`mt-2`,children:($.get(`later`)??[]).map(e=>(0,q.jsx)(Oe,{goal:e,queueItem:X.get(e.id),t:n,language:t,busy:U,actionError:z?.goalId===e.id?z.message:void 0,onOpen:e=>me(e.id),onAction:(e,t)=>void Ie(e,t)},e.id))})]}):null]}):null,!P&&h===`all`?(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-b border-edge-subtle pb-4`,children:[(0,q.jsxs)(N,{value:_,onChange:e=>b(e.target.value),className:`w-full sm:w-44`,"aria-label":n.workbench.filters.agent,children:[(0,q.jsx)(k,{value:``,children:n.workbench.filters.allAgents}),ye.map(e=>(0,q.jsx)(k,{value:e,children:e},e))]}),(0,q.jsxs)(N,{value:C,onChange:e=>T(e.target.value),className:`w-full sm:w-44`,"aria-label":n.workbench.filters.status,children:[(0,q.jsx)(k,{value:``,children:n.workbench.filters.allStatuses}),[`active`,`paused`,`blocked`,`needs_input`].map(e=>(0,q.jsx)(k,{value:e,children:n.statuses[e]},e))]}),(0,q.jsxs)(N,{value:O,onChange:e=>M(e.target.value),className:`w-full sm:w-44`,"aria-label":n.workbench.filters.priority,children:[(0,q.jsx)(k,{value:``,children:n.workbench.filters.allPriorities}),[`high`,`normal`,`low`].map(e=>(0,q.jsx)(k,{value:e,children:n.priorities[e]},e))]}),_||C||O?(0,q.jsx)(y,{type:`button`,variant:`ghost`,className:`h-10 rounded-lg`,onClick:()=>{b(``),T(``),M(``)},children:n.workbench.filters.clear}):null]}),Ae.length?Ae.map(e=>(0,q.jsx)(Oe,{goal:e,queueItem:X.get(e.id),t:n,language:t,busy:U,actionError:z?.goalId===e.id?z.message:void 0,onOpen:e=>me(e.id),onAction:(e,t)=>void Ie(e,t)},e.id)):(0,q.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.workbench.empty.noOpenTitle}),(0,q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:n.workbench.empty.noOpenDescription})]})]}):null,!P&&h===`history`?(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`header`,{className:`border-b border-edge-subtle pb-4`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workbench.history.title}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.workbench.history.description})]}),Ne.length?Ne.map(e=>(0,q.jsx)(Oe,{goal:e,queueItem:X.get(e.id),t:n,language:t,busy:U,actionError:z?.goalId===e.id?z.message:void 0,onOpen:e=>me(e.id),onAction:(e,t)=>void Ie(e,t)},e.id)):(0,q.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.workbench.empty.noHistoryTitle}),(0,q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:n.workbench.empty.noHistoryDescription})]})]}):null]})]}),G?(0,q.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 flex max-w-[calc(100%-2rem)] items-center gap-3 rounded-xl border border-edge bg-surface-panel px-4 py-3 shadow-popover`,role:`status`,"aria-live":`polite`,children:[(0,q.jsx)(`p`,{className:`min-w-0 text-sm text-fg`,children:J(n.workbench.undo.message,{title:G.title})}),(0,q.jsx)(y,{type:`button`,variant:`ghost`,className:`h-10 shrink-0 rounded-lg text-accent-fg`,onClick:()=>{let e=G;oe(null),Ie(e.goalId,be(e.action),{skipUndo:!0})},children:n.workbench.undo.action}),(0,q.jsx)(y,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 rounded-lg p-0`,"aria-label":n.workbench.undo.dismiss,onClick:()=>oe(null),children:(0,q.jsx)(m,{className:`size-4`,"aria-hidden":!0})})]}):null,(0,q.jsx)(re,{open:se,t:n,chat:c(t).chat,busy:U===`create`,options:he,onClose:()=>K(!1),onCreate:Le,onDraftContract:e=>we(e,t)}),(0,q.jsx)(Me,{goal:ve,queueItem:ve?X.get(ve.id):void 0,t:n,language:t,busy:U,onClose:()=>me(null),onAction:(e,t)=>void Ie(e,t)})]})}export{Pe as GoalsPage};
|