@xopcai/xopc 0.0.112 → 0.0.113
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/icons/icon-128.png +0 -0
- package/dist/browser-ext/icons/icon-16.png +0 -0
- package/dist/browser-ext/icons/icon-32.png +0 -0
- package/dist/browser-ext/icons/icon-48.png +0 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/delivery-to.d.ts +3 -3
- package/dist/extensions/weixin/src/delivery-to.js.map +1 -1
- package/dist/gateway/static/root/apple-touch-icon.png +0 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-EhRp-ZMa.js → agent-avatar-dicebear-CBlklyNr.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-browser-settings-page-H4foVCiS.js → agent-browser-settings-page-rGbKc2Hh.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-tabbed-page-DDNw2oNU.js → agent-defaults-tabbed-page-CtwVbjOA.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-E_X2kzS1.js → agents-CCBmGcwc.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BIy7KEsM.js → app-management-settings-panel-28E_WfMe.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DGQG8NwA.js → appearance-settings-Do1z0XgJ.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BZLvInLr.js → apps-page-xwCsJS15.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-uuQPupqx.js → archive-plugin-BAFlsov_.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DBkv0cAv.js → attachment-load-V3qGPC3x.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-DxxN_VAR.js → binary-plugins-DT8NvA6W.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CwnUlRmO.js → block-editor-CdLMEcHd.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-BHvUKlzw.js → channels-settings-C044DcYk.js} +1 -1
- package/dist/gateway/static/root/assets/{config-api-BD-NcD5d.js → config-api-Bf5mjpu7.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-settings-VBzXcEXL.js → connectors-settings-8VEWUOTj.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-api-C5DoipZA.js → cron-api--pAB_rps.js} +1 -1
- package/dist/gateway/static/root/assets/cron-page-DqmNGNOy.js +3 -0
- package/dist/gateway/static/root/assets/{dreaming-settings-DSVhXTPq.js → dreaming-settings-6UZE1FSK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BDHA9o_e.js → extension-debug-page-BGhE7msg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DmDLVSPE.js → extension-page-CvpI45WG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-1124aHw_.js → extension-settings-page-DAmR5FUe.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-DOe56Wmy.js → fetch-NZmjSXLl.js} +1 -1
- package/dist/gateway/static/root/assets/{format-interval-label-tsMSvBSR.js → format-interval-label-qhth3BMV.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CsD4FC9D.js → gateway-config-api-CaXBt-9R.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-HQ8FBhY2.js → gateway-settings-DphpbLBc.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-C1zg7pH3.js → gateway-startup-retry-Be1omjh3.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-BG3Onph0.js → goal-detail-page-bv0VRDaf.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-1Ywnt4Cb.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-B5nI6lgz.js → goals-settings-ceEBjnfc.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-CIv42nJD.js → heartbeat-config-api-BzO6G4fD.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DFcVuJ3M.js → heartbeat-settings-DCST9-du.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BTmbp2AU.js → index-Cxm6xsps.js} +59 -58
- package/dist/gateway/static/root/assets/{index-5A_ZaABy.css → index-b_R4tKqt.css} +1 -1
- package/dist/gateway/static/root/assets/{interval-presets-DGP3S7OB.js → interval-presets-DJmshV8n.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-fETaDYQP.js → keyboard-shortcuts-settings-9AUUlQ5Q.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-B1-b27lK.js → logs-page-B_wrxhee.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CgeBJMOD.js → markdown-split-CYYELqAr.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C30GzlV2.js → media-plugins-BEcMR2M8.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CkT-lcgP.js +3 -0
- package/dist/gateway/static/root/assets/{models-hub-panel-DPcTS1-u.js → models-hub-panel-D0JDSbNu.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-page-xeGb4owe.js → note-detail-page-DpFV-EO6.js} +2 -2
- package/dist/gateway/static/root/assets/{note-image-lightbox-t1g0qZYh.js → note-image-lightbox-DNAoPcmm.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-C_TdnKBe.js → notes-page-CdkjTch8.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DeWp9x5g.js → preview-open-alternatives-BPLz0AIv.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BtkPmJIN.js → remote-access-hub-DSYVAi96.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-BOaAOJI3.js → save-bar-controls-CrWwWRVK.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BLWLKqgw.js → schedule-field-CF2sadvN.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-plqRFYT8.js → schema-form-Di5cKjYE.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-DOUjxzJm.js → sessions-page-CenkcVjF.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-D9sva86V.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BP5zRrDI.js → settings-collapsible-section-Chh282jW.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Bv8MZplG.js → settings-form-section-Dq-83cQd.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DmDfE1ww.js → settings-page-DL35U0x0.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BEFwNcIZ.js → setup-status-panel-Ctwbp9Er.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-4OX1YCgp.js → share-preview-page-0FXYnSUA.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CbKmJZot.js → shares-settings-DIM3JNsr.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DAlNaNzL.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CLrHVzAt.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CGy4f_s2.js → system-settings-panel-W1pTcojB.js} +1 -1
- package/dist/gateway/static/root/assets/use-agent-defaults-form-BVRvkK7m.js +1 -0
- package/dist/gateway/static/root/assets/{use-channel-catalog-CjGHnDvN.js → use-channel-catalog-CgJibfMM.js} +1 -1
- package/dist/gateway/static/root/assets/{use-settings-tab-guard-BMMFa0oA.js → use-settings-tab-guard-Bw_qkRQE.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DnRbhMNq.js → voice-api-key-field-vYAO71Gn.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-player-store-D5vzWwls.js → voice-player-store-C7lziaAx.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-page.utils-tjGpRVnw.js → workflow-page.utils-sgHjOXOm.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DqqHKGj2.js → workflows-page-DYyOTmFx.js} +1 -1
- package/dist/gateway/static/root/favicon-16x16.png +0 -0
- package/dist/gateway/static/root/favicon-32x32.png +0 -0
- package/dist/gateway/static/root/favicon-icon.svg +1 -0
- package/dist/gateway/static/root/favicon.ico +0 -0
- package/dist/gateway/static/root/favicon.png +0 -0
- package/dist/gateway/static/root/favicon.svg +24 -17
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/gateway/static/root/logo-dark.svg +23 -15
- package/dist/gateway/static/root/logo.svg +23 -16
- package/dist/package.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +9 -4
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/ai-assist/text-assist.d.ts +3 -0
- package/dist/src/ai-assist/text-assist.js +25 -7
- package/dist/src/ai-assist/text-assist.js.map +1 -1
- package/dist/src/channels/plugins/types.adapters.d.ts +2 -2
- package/dist/src/cron/executor.js.map +1 -1
- package/dist/src/cron/types.d.ts +2 -2
- package/dist/src/session/store-reader.d.ts +5 -0
- package/dist/src/session/store-reader.js +1 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/cron-page-BLTpdm34.js +0 -3
- package/dist/gateway/static/root/assets/goals-page-DgeKn8zL.js +0 -2
- package/dist/gateway/static/root/assets/messages-BUUfPaZ9.js +0 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-qK_bnTrw.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-YdtnUHtK.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DwW1IzQ0.js +0 -2
- package/dist/gateway/static/root/assets/use-agent-defaults-form-BMuMvzl_.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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-BUUfPaZ9.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-DOe56Wmy.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Di as p,Dr as m,Es as h,Oi as g,Ss as _,Ti as v,b as y,ki as b,qa as x}from"./index-BTmbp2AU.js";import{a as S,c as C,d as w,i as T,l as E,s as D,t as O,u as k}from"./voice-api-key-field-DnRbhMNq.js";import{t as A}from"./schema-form-plqRFYT8.js";var j=n(),M=e(t(),1),N=r(),P=()=>c(w);function F(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function I(e){let t=(0,j.c)(40),{extensionId:n}=e,r=o(L),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let c=i,l=c.imageModelsSettings,u=s(ee),d;t[2]===u?d=t[3]:(d=u?P():null,t[2]=u,t[3]=d);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[4]=p):p=t[4];let{data:m,isLoading:h}=f(d,k,p),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),v=_.filter(e),t[7]=_,t[8]=n,t[9]=v}else v=t[9];let y=v,b=C(y),S;t[12]===l?S=t[13]:(S=F(l),t[12]=l,t[13]=S);let w=S,T;t[14]!==c.providersSettings.getApiKey||t[15]!==c.providersSettings.getApiKeyCn||t[16]!==c.providersSettings.getApiKeyIntl?(T={getApiKey:c.providersSettings.getApiKey,getApiKeyIntl:c.providersSettings.getApiKeyIntl,getApiKeyCn:c.providersSettings.getApiKeyCn},t[14]=c.providersSettings.getApiKey,t[15]=c.providersSettings.getApiKeyCn,t[16]=c.providersSettings.getApiKeyIntl,t[17]=T):T=t[17];let D=T;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,N.jsx)(x,{className:`size-4 animate-spin`}),`…`]}),t[18]=e):e=t[18],e}if(y.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let O;t[21]!==b||t[22]!==l.credentialsSaveError?(O=()=>void b.saveCredentials(l.credentialsSaveError),t[21]=b,t[22]=l.credentialsSaveError,t[23]=O):O=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[24]=A):A=t[24];let M;return t[25]!==D||t[26]!==b.credBaseline||t[27]!==b.credDirty||t[28]!==b.credDraft||t[29]!==b.credError||t[30]!==b.credNoopFlash||t[31]!==b.credSavedFlash||t[32]!==b.credSaving||t[33]!==b.onDiscardCredentials||t[34]!==b.updateCredRow||t[35]!==r||t[36]!==w||t[37]!==y||t[38]!==O?(M=(0,N.jsx)(E,{summaries:y,credDraft:b.credDraft,credBaseline:b.credBaseline,credDirty:b.credDirty,credSaving:b.credSaving,credError:b.credError,credSavedFlash:b.credSavedFlash,credNoopFlash:b.credNoopFlash,updateCredRow:b.updateCredRow,onDiscardCredentials:b.onDiscardCredentials,onSaveCredentials:O,extensionIds:A,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:D,messages:w}),t[25]=D,t[26]=b.credBaseline,t[27]=b.credDirty,t[28]=b.credDraft,t[29]=b.credError,t[30]=b.credNoopFlash,t[31]=b.credSavedFlash,t[32]=b.credSaving,t[33]=b.onDiscardCredentials,t[34]=b.updateCredRow,t[35]=r,t[36]=w,t[37]=y,t[38]=O,t[39]=M):M=t[39],M}function ee(e){return!!e.token}function L(e){return e.language}function R(e){let t=(0,j.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,N.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var z=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function B(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function V(){return i(p,v)}function H(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function U(e,t){if(!e||!t)return{apiKey:``,model:z[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:z[0].id}}function W({providerId:e,voiceSettings:t,mutateVoice:n}){let r=a(o(e=>e.language)),s=r.voiceSettings,l=r.extensionSttMedia,u={maskedHelp:s.apiKeyMaskedHelp,copy:s.apiKeyCopy,copied:s.apiKeyCopied,show:s.apiKeyShow,hide:s.apiKeyHide,notInConfigFile:s.apiKeyNotInConfigFile,loadFailed:s.apiKeyRevealFailed},{data:p}=f(c(`/api/voice/stt-providers`),S,{revalidateOnFocus:!1}),m=(0,M.useMemo)(()=>p?.providers.some(t=>t.id===e&&t.configured)??!1,[e,p]),h=(0,M.useMemo)(()=>U(t,e),[e,t]),g=(0,M.useRef)(!1),[_,y]=(0,M.useState)(null),[x,C]=(0,M.useState)(!1),[w,T]=(0,M.useState)(null),[E,k]=(0,M.useState)(!1),A=_??h,j=h,P=A.apiKey!==j.apiKey||A.model!==j.model,F=(0,M.useCallback)(async()=>{C(!0),T(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:A.apiKey,model:A.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:A.apiKey,model:A.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:A.apiKey,model:A.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await D(r),await n(r,!1),g.current=!1,y(null),k(!0),d({type:`success`,title:s.saved})}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}},[A.apiKey,A.model,n,e,t]),I=e===`groq`?z:[{id:A.model,name:A.model}];return(0,N.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.credentialsTitle}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l.credentialsHint.replace(`{providerId}`,e)})]}),(0,N.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,m?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:m?l.configured:l.notConfigured})]}),(0,N.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,N.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,v),children:[(0,N.jsx)(R,{children:s.stt.apiKey}),(0,N.jsx)(O,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:A.apiKey,onChange:e=>{g.current=!0,y(t=>({...t??h,apiKey:e})),T(null)},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,N.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[s.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,N.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,v),children:[(0,N.jsx)(R,{children:s.stt.model}),e===`groq`?(0,N.jsx)(`select`,{className:V(),value:A.model,onChange:e=>{g.current=!0,y(t=>({...t??h,model:e.target.value})),T(null)},children:I.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))}):(0,N.jsx)(`input`,{className:H(),value:A.model,onChange:e=>{g.current=!0,y(t=>({...t??h,model:e.target.value})),T(null)}})]})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[w?(0,N.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:w}):null,(0,N.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!P||x,onClick:()=>{g.current=!1,y(null),T(null)},children:s.discard}),(0,N.jsx)(b,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!P||x,onClick:()=>void F(),children:x?s.saving:s.save})]})]})}function G(e){let t=(0,j.c)(13),{extensionId:n}=e,r=o(q),i=s(K),a;t[0]===n?a=t[1]:(a=()=>l(c(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:u,isLoading:d}=f(i&&n?`ext-stt-detail-${n}`:null,a),p;t[2]===u?p=t[3]:(p=B(u),t[2]=u,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=f(i?`voice-settings-ext-stt`:null,T,h);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,N.jsx)(x,{className:`size-4 animate-spin`}),`…`]}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,N.jsx)(W,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function K(e){return!!e.token}function q(e){return e.language}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){let t={};if(e.type!==`object`||!J(e.properties))return t;for(let[n,r]of Object.entries(e.properties))J(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function X(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function Z({extensionId:e}){let t=a(o(e=>e.language)).agentSettings,n=s(e=>!!e.token),{data:r,error:i}=f(n&&e?`ext-detail-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}`))),{data:p,mutate:m,error:h}=f(n&&e?`ext-cfg-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}/config`))),g=r?.manifest?.configSchema,_=(0,M.useMemo)(()=>g&&g.type===`object`?Y(g):{},[g]),v=(0,M.useMemo)(()=>({..._,...p??{}}),[_,p]),[y,x]=(0,M.useReducer)(X,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[S,C]=(0,M.useState)(!1),w=(0,M.useRef)(!1),T=(0,M.useRef)(v);!w.current&&T.current!==v&&(T.current=v,x({type:`sync`,value:v}));let E=(0,M.useCallback)(e=>{w.current=!0,x({type:`change`,value:e})},[]),D=(0,M.useCallback)(()=>{w.current=!1,x({type:`discard`,value:v})},[v]),O=(0,M.useCallback)(()=>{!g||g.type!==`object`||(w.current=!0,x({type:`reset-defaults`,value:{...Y(g)}}))},[g]),k=(0,M.useCallback)(async()=>{if(e){x({type:`save-start`});try{let n=await u(c(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(y.localValues)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await m(y.localValues,!1),w.current=!1,x({type:`save-success`,value:y.localValues}),C(!0),d({type:`success`,title:t.saved})}catch(e){x({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[y.localValues,e,m]);if(!n)return null;if(i||h){let e=i??h;return(0,N.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!g||g.type!==`object`?null:(0,N.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[y.saveError?(0,N.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:y.saveError}):null,(0,N.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!y.isDirty,onClick:D,children:t.discard}),(0,N.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:O,children:`Reset to defaults`}),(0,N.jsx)(b,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!y.isDirty||y.saving,onClick:()=>void k(),children:y.saving?t.saving:t.save})]})]}),(0,N.jsx)(A,{schema:g,values:y.localValues,onChange:E,disabled:y.saving})]})}function Q(){let e=(0,j.c)(47),t=o(te),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.extensionImageGen,s=r.extensionSttMedia,{extensionId:c,panelId:l}=h(),u=m();if(!c){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let d,f,p;if(e[3]!==c||e[4]!==u||e[5]!==l){p=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===c?t=e[10]:(t=e=>e.id===c,e[9]=c,e[10]=t),d=u.find(t),!d){let t=`Extension "${c}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,N.jsx)($,{message:t}),e[11]=t,e[12]=n),p=n;break bb0}let n=d.ui?.contributions?.settingsPanels;f=l?n?.find(e=>e.id===l||e.id===`${c}.${l}`):n?.[0]}e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=f,e[8]=p}else d=e[6],f=e[7],p=e[8];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let g=f,v=!!(g&&d.ui),b=!!d.hasConfigSchema,x=d.kind===`image-generation`,S=d.kind===`media-provider`;if(!b&&!v&&!(x||S)){let t=`Extension "${c}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,N.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=g?.title??`${d.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,N.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==i?(T=x?(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,N.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:i.banner}),(0,N.jsx)(_,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:i.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=i,e[20]=T):T=e[20];let E;e[21]!==c||e[22]!==x?(E=x?(0,N.jsx)(I,{extensionId:c}):null,e[21]=c,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==s?(D=S?(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,N.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:s.banner}),(0,N.jsx)(_,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:s.openVoice})]}):null,e[24]=S,e[25]=s,e[26]=D):D=e[26];let O;e[27]!==c||e[28]!==S?(O=S?(0,N.jsx)(G,{extensionId:c}):null,e[27]=c,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==c||e[31]!==b?(k=b?(0,N.jsx)(Z,{extensionId:c}):null,e[30]=c,e[31]=b,e[32]=k):k=e[32];let A;e[33]!==d.name||e[34]!==d.ui||e[35]!==c||e[36]!==v||e[37]!==g?(A=v&&g&&d.ui?(0,N.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,N.jsx)(y,{extensionId:c,extensionName:d.name,entrypoint:g.entrypoint,permissions:d.ui?.permissions,title:g.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=d.name,e[34]=d.ui,e[35]=c,e[36]=v,e[37]=g,e[38]=A):A=e[38];let M;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==A?(M=(0,N.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[w,T,E,D,O,k,A]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=A,e[46]=M):M=e[46],M}function te(e){return e.language}function $(e){let t=(0,j.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,N.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{Q as ExtensionSettingsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-NZmjSXLl.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Di as p,Dr as m,Es as h,Oi as g,Ss as _,Ti as v,b as y,ki as b,qa as x}from"./index-Cxm6xsps.js";import{a as S,c as C,d as w,i as T,l as E,s as D,t as O,u as k}from"./voice-api-key-field-vYAO71Gn.js";import{t as A}from"./schema-form-Di5cKjYE.js";var j=n(),M=e(t(),1),N=r(),P=()=>c(w);function F(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function I(e){let t=(0,j.c)(40),{extensionId:n}=e,r=o(L),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let c=i,l=c.imageModelsSettings,u=s(ee),d;t[2]===u?d=t[3]:(d=u?P():null,t[2]=u,t[3]=d);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[4]=p):p=t[4];let{data:m,isLoading:h}=f(d,k,p),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),v=_.filter(e),t[7]=_,t[8]=n,t[9]=v}else v=t[9];let y=v,b=C(y),S;t[12]===l?S=t[13]:(S=F(l),t[12]=l,t[13]=S);let w=S,T;t[14]!==c.providersSettings.getApiKey||t[15]!==c.providersSettings.getApiKeyCn||t[16]!==c.providersSettings.getApiKeyIntl?(T={getApiKey:c.providersSettings.getApiKey,getApiKeyIntl:c.providersSettings.getApiKeyIntl,getApiKeyCn:c.providersSettings.getApiKeyCn},t[14]=c.providersSettings.getApiKey,t[15]=c.providersSettings.getApiKeyCn,t[16]=c.providersSettings.getApiKeyIntl,t[17]=T):T=t[17];let D=T;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,N.jsx)(x,{className:`size-4 animate-spin`}),`…`]}),t[18]=e):e=t[18],e}if(y.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let O;t[21]!==b||t[22]!==l.credentialsSaveError?(O=()=>void b.saveCredentials(l.credentialsSaveError),t[21]=b,t[22]=l.credentialsSaveError,t[23]=O):O=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[24]=A):A=t[24];let M;return t[25]!==D||t[26]!==b.credBaseline||t[27]!==b.credDirty||t[28]!==b.credDraft||t[29]!==b.credError||t[30]!==b.credNoopFlash||t[31]!==b.credSavedFlash||t[32]!==b.credSaving||t[33]!==b.onDiscardCredentials||t[34]!==b.updateCredRow||t[35]!==r||t[36]!==w||t[37]!==y||t[38]!==O?(M=(0,N.jsx)(E,{summaries:y,credDraft:b.credDraft,credBaseline:b.credBaseline,credDirty:b.credDirty,credSaving:b.credSaving,credError:b.credError,credSavedFlash:b.credSavedFlash,credNoopFlash:b.credNoopFlash,updateCredRow:b.updateCredRow,onDiscardCredentials:b.onDiscardCredentials,onSaveCredentials:O,extensionIds:A,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:D,messages:w}),t[25]=D,t[26]=b.credBaseline,t[27]=b.credDirty,t[28]=b.credDraft,t[29]=b.credError,t[30]=b.credNoopFlash,t[31]=b.credSavedFlash,t[32]=b.credSaving,t[33]=b.onDiscardCredentials,t[34]=b.updateCredRow,t[35]=r,t[36]=w,t[37]=y,t[38]=O,t[39]=M):M=t[39],M}function ee(e){return!!e.token}function L(e){return e.language}function R(e){let t=(0,j.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,N.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var z=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function B(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function V(){return i(p,v)}function H(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function U(e,t){if(!e||!t)return{apiKey:``,model:z[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:z[0].id}}function W({providerId:e,voiceSettings:t,mutateVoice:n}){let r=a(o(e=>e.language)),s=r.voiceSettings,l=r.extensionSttMedia,u={maskedHelp:s.apiKeyMaskedHelp,copy:s.apiKeyCopy,copied:s.apiKeyCopied,show:s.apiKeyShow,hide:s.apiKeyHide,notInConfigFile:s.apiKeyNotInConfigFile,loadFailed:s.apiKeyRevealFailed},{data:p}=f(c(`/api/voice/stt-providers`),S,{revalidateOnFocus:!1}),m=(0,M.useMemo)(()=>p?.providers.some(t=>t.id===e&&t.configured)??!1,[e,p]),h=(0,M.useMemo)(()=>U(t,e),[e,t]),g=(0,M.useRef)(!1),[_,y]=(0,M.useState)(null),[x,C]=(0,M.useState)(!1),[w,T]=(0,M.useState)(null),[E,k]=(0,M.useState)(!1),A=_??h,j=h,P=A.apiKey!==j.apiKey||A.model!==j.model,F=(0,M.useCallback)(async()=>{C(!0),T(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:A.apiKey,model:A.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:A.apiKey,model:A.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:A.apiKey,model:A.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await D(r),await n(r,!1),g.current=!1,y(null),k(!0),d({type:`success`,title:s.saved})}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}},[A.apiKey,A.model,n,e,t]),I=e===`groq`?z:[{id:A.model,name:A.model}];return(0,N.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.credentialsTitle}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l.credentialsHint.replace(`{providerId}`,e)})]}),(0,N.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,m?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:m?l.configured:l.notConfigured})]}),(0,N.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,N.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,v),children:[(0,N.jsx)(R,{children:s.stt.apiKey}),(0,N.jsx)(O,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:A.apiKey,onChange:e=>{g.current=!0,y(t=>({...t??h,apiKey:e})),T(null)},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,N.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[s.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,N.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,v),children:[(0,N.jsx)(R,{children:s.stt.model}),e===`groq`?(0,N.jsx)(`select`,{className:V(),value:A.model,onChange:e=>{g.current=!0,y(t=>({...t??h,model:e.target.value})),T(null)},children:I.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))}):(0,N.jsx)(`input`,{className:H(),value:A.model,onChange:e=>{g.current=!0,y(t=>({...t??h,model:e.target.value})),T(null)}})]})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[w?(0,N.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:w}):null,(0,N.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!P||x,onClick:()=>{g.current=!1,y(null),T(null)},children:s.discard}),(0,N.jsx)(b,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!P||x,onClick:()=>void F(),children:x?s.saving:s.save})]})]})}function G(e){let t=(0,j.c)(13),{extensionId:n}=e,r=o(q),i=s(K),a;t[0]===n?a=t[1]:(a=()=>l(c(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:u,isLoading:d}=f(i&&n?`ext-stt-detail-${n}`:null,a),p;t[2]===u?p=t[3]:(p=B(u),t[2]=u,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=f(i?`voice-settings-ext-stt`:null,T,h);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,N.jsx)(x,{className:`size-4 animate-spin`}),`…`]}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,N.jsx)(W,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function K(e){return!!e.token}function q(e){return e.language}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){let t={};if(e.type!==`object`||!J(e.properties))return t;for(let[n,r]of Object.entries(e.properties))J(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function X(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function Z({extensionId:e}){let t=a(o(e=>e.language)).agentSettings,n=s(e=>!!e.token),{data:r,error:i}=f(n&&e?`ext-detail-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}`))),{data:p,mutate:m,error:h}=f(n&&e?`ext-cfg-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}/config`))),g=r?.manifest?.configSchema,_=(0,M.useMemo)(()=>g&&g.type===`object`?Y(g):{},[g]),v=(0,M.useMemo)(()=>({..._,...p??{}}),[_,p]),[y,x]=(0,M.useReducer)(X,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[S,C]=(0,M.useState)(!1),w=(0,M.useRef)(!1),T=(0,M.useRef)(v);!w.current&&T.current!==v&&(T.current=v,x({type:`sync`,value:v}));let E=(0,M.useCallback)(e=>{w.current=!0,x({type:`change`,value:e})},[]),D=(0,M.useCallback)(()=>{w.current=!1,x({type:`discard`,value:v})},[v]),O=(0,M.useCallback)(()=>{!g||g.type!==`object`||(w.current=!0,x({type:`reset-defaults`,value:{...Y(g)}}))},[g]),k=(0,M.useCallback)(async()=>{if(e){x({type:`save-start`});try{let n=await u(c(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(y.localValues)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await m(y.localValues,!1),w.current=!1,x({type:`save-success`,value:y.localValues}),C(!0),d({type:`success`,title:t.saved})}catch(e){x({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[y.localValues,e,m]);if(!n)return null;if(i||h){let e=i??h;return(0,N.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!g||g.type!==`object`?null:(0,N.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[y.saveError?(0,N.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:y.saveError}):null,(0,N.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!y.isDirty,onClick:D,children:t.discard}),(0,N.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:O,children:`Reset to defaults`}),(0,N.jsx)(b,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!y.isDirty||y.saving,onClick:()=>void k(),children:y.saving?t.saving:t.save})]})]}),(0,N.jsx)(A,{schema:g,values:y.localValues,onChange:E,disabled:y.saving})]})}function Q(){let e=(0,j.c)(47),t=o(te),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.extensionImageGen,s=r.extensionSttMedia,{extensionId:c,panelId:l}=h(),u=m();if(!c){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let d,f,p;if(e[3]!==c||e[4]!==u||e[5]!==l){p=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===c?t=e[10]:(t=e=>e.id===c,e[9]=c,e[10]=t),d=u.find(t),!d){let t=`Extension "${c}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,N.jsx)($,{message:t}),e[11]=t,e[12]=n),p=n;break bb0}let n=d.ui?.contributions?.settingsPanels;f=l?n?.find(e=>e.id===l||e.id===`${c}.${l}`):n?.[0]}e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=f,e[8]=p}else d=e[6],f=e[7],p=e[8];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let g=f,v=!!(g&&d.ui),b=!!d.hasConfigSchema,x=d.kind===`image-generation`,S=d.kind===`media-provider`;if(!b&&!v&&!(x||S)){let t=`Extension "${c}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,N.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=g?.title??`${d.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,N.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==i?(T=x?(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,N.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:i.banner}),(0,N.jsx)(_,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:i.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=i,e[20]=T):T=e[20];let E;e[21]!==c||e[22]!==x?(E=x?(0,N.jsx)(I,{extensionId:c}):null,e[21]=c,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==s?(D=S?(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,N.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:s.banner}),(0,N.jsx)(_,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:s.openVoice})]}):null,e[24]=S,e[25]=s,e[26]=D):D=e[26];let O;e[27]!==c||e[28]!==S?(O=S?(0,N.jsx)(G,{extensionId:c}):null,e[27]=c,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==c||e[31]!==b?(k=b?(0,N.jsx)(Z,{extensionId:c}):null,e[30]=c,e[31]=b,e[32]=k):k=e[32];let A;e[33]!==d.name||e[34]!==d.ui||e[35]!==c||e[36]!==v||e[37]!==g?(A=v&&g&&d.ui?(0,N.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,N.jsx)(y,{extensionId:c,extensionName:d.name,entrypoint:g.entrypoint,permissions:d.ui?.permissions,title:g.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=d.name,e[34]=d.ui,e[35]=c,e[36]=v,e[37]=g,e[38]=A):A=e[38];let M;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==A?(M=(0,N.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[w,T,E,D,O,k,A]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=A,e[46]=M):M=e[46],M}function te(e){return e.language}function $(e){let t=(0,j.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,N.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{Q as ExtensionSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./messages-
|
|
1
|
+
import{t as e}from"./messages-CkT-lcgP.js";import{a as t,i as n,n as r,s as i,t as a}from"./locale-store-DjbfSsfA.js";var o=i((e,n)=>({baseUrl:typeof window<`u`?window.location.origin:``,token:void 0,tokenDialogOpen:!1,tokenExpired:!1,setGatewayToken:n=>{t(n),e({token:n,tokenDialogOpen:!1,tokenExpired:!1}),window.dispatchEvent(new CustomEvent(`token-saved`,{detail:{token:n}}))},clearGatewayToken:()=>{r(),e({token:void 0})},openTokenDialog:()=>e({tokenDialogOpen:!0}),closeTokenDialog:()=>e({tokenDialogOpen:!1}),onUnauthorized:()=>{n().clearGatewayToken(),e({tokenDialogOpen:!1,tokenExpired:!0}),window.dispatchEvent(new CustomEvent(`token-expired`))}}));function s(){let e=new URLSearchParams(window.location.search).get(`token`);if(e){o.getState().setGatewayToken(e);let t=window.location.pathname+window.location.hash,n=window.history.state,r=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:n;window.history.replaceState(r,``,t);return}let t=n();o.setState({token:t||void 0,tokenDialogOpen:!1})}function c(){return window.location.origin}function l(e){let t=e.startsWith(`/`)?e:`/${e}`;return`${c()}${t}`}function u(e){let t=e.baseUrl.trim().replace(/\/+$/,``),n=new URL(`xopc://gateway/mobile-connect`);return n.searchParams.set(`baseUrl`,t),e.lanUrl?.trim()&&n.searchParams.set(`lanUrl`,e.lanUrl.trim().replace(/\/+$/,``)),n.searchParams.set(`ps`,e.pairingSecret),n.toString()}function d(e){try{let t=new URL(e.trim());if(t.protocol!==`http:`&&t.protocol!==`https:`)return!1;let n=t.hostname.toLowerCase();return!!(n===`localhost`||n===`127.0.0.1`||n===`[::1]`||n===`::1`||/^127\.\d+\.\d+\.\d+$/.test(n))}catch{return!1}}function f(){return a.getState().language}function p(e,t,n){let r=e.trim().toLowerCase();return!!(!r||r===`http ${t}`||n&&r===n.trim().toLowerCase()||t===500&&r===`internal server error`)}function m(t,n,r){let i=r?.trim()??``;if(i&&!p(i,t,n))return i;let a=e(f()).api;return t>=500?t===502?a.errorBadGateway:t===503?a.errorServiceUnavailable:t===504?a.errorGatewayTimeout:t===500?a.errorInternal:a.errorServer.replace(`{{status}}`,String(t)):t===404?a.errorNotFound:t===403?a.errorForbidden:a.errorRequest.replace(`{{status}}`,String(t))}var h=null,g=null;function _(){h||=new Promise(e=>{g=e})}function v(){h&&(g?.(),h=null,g=null)}typeof window<`u`&&window.addEventListener(`token-saved`,v);async function y(e,t){h&&await h;let n=o.getState().token,r=new Headers(t?.headers),i=t?.body,a=typeof FormData<`u`&&i instanceof FormData;!r.has(`Content-Type`)&&!a&&r.set(`Content-Type`,`application/json`),n&&r.set(`Authorization`,`Bearer ${n}`);let s=await fetch(e,{...t,headers:r});return s.status===401&&(_(),o.getState().onUnauthorized()),s}async function b(e,t){let n=await y(e,t);if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message,r=m(n.status,n.statusText,t);throw Error(r)}return n.json()}export{u as a,o as c,l as i,b as n,d as o,m as r,s,y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./interval-presets-
|
|
1
|
+
import{t as e}from"./interval-presets-DJmshV8n.js";function t(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var n={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},r={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function i(e,t){return e.startsWith(`zh`)?r[t]:n[t]}function a(n,r,a){let o=Math.max(1e3,Math.round(n));if(a&&e.has(o)){let e=t(o,a);if(e)return e}let s=Math.max(1,Math.round(o/1e3));if(s<120)return i(r,`second`).format(s);let c=Math.round(s/60);if(c<120)return i(r,`minute`).format(c);let l=Math.round(c/60);return i(r,`hour`).format(l)}export{a as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./fetch-
|
|
1
|
+
import{i as e,n as t}from"./fetch-NZmjSXLl.js";import{yi as n,yr as r}from"./index-Cxm6xsps.js";var i=18790,a={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(e){return n(e)}async function c(n){let r=await t(e(`/api/gateway/reveal-auth-secret/${encodeURIComponent(n)}`),{method:`POST`,body:`{}`});if(!r.ok||!r.payload)throw Error(r.error?.message??`Reveal failed`);return r.payload}async function l(){let n=await t(e(`/api/agents/browser/reveal-cloud-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!n.ok||!n.payload)throw Error(n.error?.message??`Reveal failed`);return n.payload}function u(e){return s(e)?``:e.trim()}function d(e){return[...e].map(e=>e.trim()).sort()}function f(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:u(e.auth.token),password:u(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:d(e.auth.trustedProxy.requiredHeaders),allowUsers:d(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},corsOrigins:d(e.corsOrigins),trustedProxies:d(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function p(e,t){return f(e)!==f(t)}function m(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function h(e){let t=o(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):a.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):a.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):a.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function g(e){let t=o(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:v(t.requiredHeaders,32),allowUsers:v(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function _(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function v(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function y(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function b(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function x(e){let t=b(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function S(e){let t=o(e)?e:{},n=o(t.gateway)?t.gateway:{},r=o(n.auth)?n.auth:{},a=o(n.security)?n.security:{},s=o(t.update)?t.update:{},c=o(s.auto)?s.auto:{},l=s.channel,u=l===`beta`||l===`dev`||l===`stable`?l:`stable`,d=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:y(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):i,auth:{mode:m(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:h(r.rateLimit),trustedProxy:g(r.trustedProxy)},corsOrigins:d,trustedProxies:v(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:a.strict===!0,maxSseConnections:typeof n.maxSseConnections==`number`&&Number.isFinite(n.maxSseConnections)?Math.max(1,Math.floor(n.maxSseConnections)):100,channelConnectDeferMode:_(n.channelConnectDeferMode),channelConnectDeferIds:v(n.channelConnectDeferIds),channelConnectDeferSkipIds:v(n.channelConnectDeferSkipIds),updateChannel:u,updateCheckOnStart:s.checkOnStart!==!1,updateAutoEnabled:c.enabled===!0,updateAutoStableDelayHours:typeof c.stableDelayHours==`number`&&Number.isFinite(c.stableDelayHours)?Math.max(0,Math.floor(c.stableDelayHours)):6,updateAutoStableJitterHours:typeof c.stableJitterHours==`number`&&Number.isFinite(c.stableJitterHours)?Math.max(0,Math.floor(c.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof c.betaCheckIntervalHours==`number`&&Number.isFinite(c.betaCheckIntervalHours)?Math.max(.25,c.betaCheckIntervalHours):1}}function C(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!s(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!s(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function w(n){let i=x(n);if(i)throw Error(i);await t(e(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:n.bind,...n.bind===`custom`?{customBindHost:n.customBindHost.trim()}:{},port:n.port,auth:C(n),corsOrigins:n.corsOrigins,trustedProxies:n.trustedProxies,allowRealIpFallback:n.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback,security:{strict:n.securityStrict},maxSseConnections:n.maxSseConnections,channelConnectDeferMode:n.channelConnectDeferMode,channelConnectDeferIds:n.channelConnectDeferIds,channelConnectDeferSkipIds:n.channelConnectDeferSkipIds},update:{channel:n.updateChannel,checkOnStart:n.updateCheckOnStart,auto:{enabled:n.updateAutoEnabled,stableDelayHours:n.updateAutoStableDelayHours,stableJitterHours:n.updateAutoStableJitterHours,betaCheckIntervalHours:n.updateAutoBetaCheckIntervalHours}}})}),r()}export{c as a,l as i,S as n,x as o,w as r,p as t};
|
|
@@ -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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-BUUfPaZ9.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-DOe56Wmy.js";import{r as u}from"./toast-z0toXu32.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{$o as p,B as m,Ds as h,La as g,Oi as _,Vi as v,Xt as y,aa as b,ba as x,br as S,co as C,gi as w,hi as T,ki as E,ko as D,li as O,oa as k,p as A,qa as j,sa as M,tn as N,uo as P,va as F,xi as I}from"./index-BTmbp2AU.js";import{t as L}from"./settings-advanced-gate-qK_bnTrw.js";import{n as ee,t as R}from"./settings-form-section-Bv8MZplG.js";import{r as te,s as ne}from"./use-settings-tab-guard-BMMFa0oA.js";import{a as re,n as ie,o as ae,r as oe,t as se}from"./gateway-config-api-CsD4FC9D.js";var z=e(t(),1),B=n(),V={critical:3,warn:2,info:1};function H(){return c(`/api/doctor?security=true`)}function U(e){return e.toSorted((e,t)=>V[t.severity]-V[e.severity]||e.checkId.localeCompare(t.checkId))}function ce(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=U((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 W(){return ce(await l(H()))}var G=r();function le(e){let t=(0,B.c)(40),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,s=o(q),c;t[0]===s?c=t[1]:(c=a(s),t[0]=s,t[1]=c);let l=c.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[H(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:h,isLoading:g,isValidating:_,mutate:v}=d(u,K,p),y=m??null,b=h instanceof Error?h.message:h?String(h):null,S=g||_,C;t[6]===v?C=t[7]:(C=()=>{v(),f(H())},t[6]=v,t[7]=C);let w=C,T=!n||S,D;t[8]===S?D=t[9]:(D=S?(0,G.jsx)(j,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,G.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),t[8]=S,t[9]=D);let O;t[10]===l.securityAuditRefresh?O=t[11]:(O=(0,G.jsx)(`span`,{className:`ml-1.5`,children:l.securityAuditRefresh}),t[10]=l.securityAuditRefresh,t[11]=O);let k;t[12]!==w||t[13]!==T||t[14]!==D||t[15]!==O?(k=(0,G.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:T,onClick:w,children:[D,O]}),t[12]=w,t[13]=T,t[14]=D,t[15]=O,t[16]=k):k=t[16];let A;t[17]!==l.securityAuditSubtitle||t[18]!==l.securityAuditTitle||t[19]!==k?(A=(0,G.jsx)(ee,{icon:M,title:l.securityAuditTitle,subtitle:l.securityAuditSubtitle,trailing:k}),t[17]=l.securityAuditSubtitle,t[18]=l.securityAuditTitle,t[19]=k,t[20]=A):A=t[20];let N;t[21]===l.securityAuditSavedConfigHint?N=t[22]:(N=(0,G.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:l.securityAuditSavedConfigHint}),t[21]=l.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==b||t[24]!==l.securityAuditLoadError?(P=b?(0,G.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[l.securityAuditLoadError,`: `,b]}):null,t[23]=b,t[24]=l.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==y||t[27]!==b||t[28]!==l.securityAuditLoading||t[29]!==S?(F=!b&&S&&!y?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(j,{className:`size-4 animate-spin`,"aria-hidden":!0}),l.securityAuditLoading]}):null,t[26]=y,t[27]=b,t[28]=l.securityAuditLoading,t[29]=S,t[30]=F):F=t[30];let I;t[31]!==y||t[32]!==l?(I=y?(0,G.jsx)(J,{g:l,audit:y}):null,t[31]=y,t[32]=l,t[33]=I):I=t[33];let L;return t[34]!==A||t[35]!==N||t[36]!==P||t[37]!==F||t[38]!==I?(L=(0,G.jsxs)(R,{children:[A,N,P,F,I]}),t[34]=A,t[35]=N,t[36]=P,t[37]=F,t[38]=I,t[39]=L):L=t[39],L}function K(){return W()}function q(e){return e.language}function J(e){let t=(0,B.c)(40),{g:n,audit:r}=e,a,o,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(o=X(n,r.status,r.findings),d=`space-y-4`,l=i(`rounded-lg border px-3 py-2.5 text-sm`,o.bannerClass),u=`status`,c=`flex items-start gap-2`,a=o.icon,s=i(`mt-0.5 size-4 shrink-0`,o.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==a||t[11]!==s?(f=(0,G.jsx)(a,{className:s,"aria-hidden":!0}),t[10]=a,t[11]=s,t[12]=f):f=t[12];let p;t[13]===o.title?p=t[14]:(p=(0,G.jsx)(`p`,{className:`font-medium`,children:o.title}),t[13]=o.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,G.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,G.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,G.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,G.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,G.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,G.jsx)(ue,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,G.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,G.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-3`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,G.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,G.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,G.jsx)(`li`,{className:`font-mono`,children:e},e)}function ue(e){let t=(0,B.c)(31),{g:n,finding:r}=e,a,o,s,c;if(t[0]!==r.severity){let e=de(r.severity);c=`rounded-lg border border-edge bg-surface-panel/50 px-3 py-2.5`,s=`flex items-start gap-2`,a=e.icon,o=i(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=a,t[2]=o,t[3]=s,t[4]=c}else a=t[1],o=t[2],s=t[3],c=t[4];let l;t[5]!==a||t[6]!==o?(l=(0,G.jsx)(a,{className:o,"aria-hidden":!0}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,G.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,G.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,G.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,G.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,G.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,G.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,G.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,G.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,G.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function de(e){switch(e){case`critical`:return{icon:p,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:v,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:P,iconClass:`text-fg-muted`}}}function X(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:p,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:P,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 Z(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}var fe=[`network`,`access`,`updates`,`security`,`advanced`],pe={network:g,access:C,updates:x,security:k,advanced:b};function me(e){return e&&fe.includes(e)?e:`network`}function he(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function ge(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function _e(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 ve={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function ye(){let e=o(e=>e.language),t=a(e),n=t.gatewaySettings,[r,c]=h(),l=y(e=>e.mode),d=l===`advanced`,f=me(r.get(`tab`)),g=(0,z.useMemo)(()=>ne(fe,l),[l]),_=(0,z.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]);te(f,_);let v=s(e=>e.token),b=s(e=>e.tokenExpired),x=s(e=>e.openTokenDialog),C=!!v,[w,k]=(0,z.useReducer)(_e,{form:null,baseline:null,appliedBaseline:null}),M=w.form,P=w.baseline,I=w.appliedBaseline,[ee,R]=(0,z.useReducer)(m,ve),{saving:B,error:V,auditRefreshToken:H,restarting:U,restartConfirmOpen:ce}=ee,W=(0,z.useRef)(!1),K=(0,z.useRef)(null),q=(0,z.useRef)(!1),{data:J,error:Y,isLoading:ue,mutate:de}=S(C),X=(0,z.useMemo)(()=>J?.payload?.config===void 0?null:structuredClone(ie(J.payload.config)),[J]);C?X!==null&&(q.current||(q.current=!0,k({type:`init-applied`,value:X})),!W.current&&K.current!==X&&(K.current=X,k({type:`sync`,value:X}),R({type:`patch`,patch:{saveOk:!1}}))):(K.current!==null||q.current)&&(K.current=null,q.current=!1,k({type:`reset`}),W.current=!1);let pe=!!(C&&ue&&J===void 0&&!Y),he=Y instanceof Error?Y.message:Y?String(Y):null,ge=(0,z.useMemo)(()=>!M||!P?!1:JSON.stringify(M)!==JSON.stringify(P),[M,P]),ye=(0,z.useMemo)(()=>!P||!I?!1:se(I,P),[I,P]),$=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),De=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Oe=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),ke=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Ae=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),je=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,port:e})})},[]),Me=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Ne=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,maxSseConnections:e})})},[]),Pe=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Fe=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Ie=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Le=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Re=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),ze=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Be=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ve=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),He=(0,z.useCallback)(async()=>{if(!M||B)return;let e=ae(M);if(e){R({type:`patch`,patch:{error:e}});return}R({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await oe(M),W.current=!1,k({type:`saved`,value:M}),R({type:`patch`,patch:{saveOk:!0,auditRefreshToken:H+1}}),u({type:`success`,title:n.saved})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{R({type:`patch`,patch:{saving:!1}})}},[M,B,n.saveError]),Ue=(0,z.useCallback)(()=>{P&&(W.current=!1,k({type:`discard`}),R({type:`patch`,patch:{error:null,saveOk:!1}}))},[P]),We=T(n),Ge=(0,z.useCallback)(async()=>{if(!U){R({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await N();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):u({type:`error`,title:n.restartGatewayFailed,message:e.message??``})}catch(e){u({type:`error`,title:n.restartGatewayFailed,message:e instanceof Error?e.message:String(e)})}finally{R({type:`patch`,patch:{restarting:!1}})}}},[U,n.restartGatewayFailed]);return C?pe?(0,G.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(j,{className:`size-4 animate-spin`}),n.loading]})}):M?(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.gateway}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,G.jsxs)(`a`,{href:O(e,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,G.jsx)(D,{className:`size-3.5`})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,G.jsx)(E,{type:`button`,variant:`secondary`,disabled:!ge||B,onClick:Ue,children:n.discard}),(0,G.jsx)(E,{type:`button`,variant:`primary`,disabled:!ge||B,onClick:()=>void He(),children:B?n.saving:n.save})]})]}),b?(0,G.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,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,G.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,G.jsx)(`div`,{children:(0,G.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>x(),children:n.updateToken})})]}):null,ge?(0,G.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,V?(0,G.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:V}):null,ye?(0,G.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,G.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,G.jsxs)(E,{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:U,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[U?(0,G.jsx)(j,{className:`size-3.5 animate-spin`}):(0,G.jsx)(F,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,G.jsx)(A,{open:ce,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Ge(),onCancel:()=>R({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,G.jsx)(be,{g:n,activeTab:f,visibleTabs:g,onChange:_}),(0,G.jsxs)(Q,{g:n,id:`network`,activeTab:f,children:[(0,G.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,G.jsxs)(`select`,{id:`gateway-bind-mode`,className:Z(),value:M.bind,onChange:e=>ke(e.target.value),children:[(0,G.jsx)(`option`,{value:`loopback`,children:n.bindLoopback}),d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`option`,{value:`lan`,children:n.bindLan}),(0,G.jsx)(`option`,{value:`auto`,children:n.bindAuto}),(0,G.jsx)(`option`,{value:`custom`,children:n.bindCustom}),(0,G.jsx)(`option`,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,G.jsx)(`input`,{id:`gateway-custom-bind-host`,className:i(Z(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>Ae(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,G.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:i(Z(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);je(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,G.jsx)(L,{children:(0,G.jsx)(we,{g:n,origins:M.corsOrigins,onChange:Oe})})]}),(0,G.jsxs)(Q,{g:n,id:`access`,activeTab:f,children:[M.auth.mode===`none`?(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,G.jsxs)(`select`,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>$({mode:e.target.value}),className:Z(),children:[(0,G.jsx)(`option`,{value:`token`,children:n.authModeToken}),(0,G.jsx)(`option`,{value:`password`,children:n.authModePassword}),d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`option`,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,G.jsx)(`option`,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,G.jsx)(L,{children:M.auth.mode===`trusted-proxy`?(0,G.jsx)(Se,{g:n,form:M,onTrustedProxyChange:Re,onTrustedProxiesChange:Le,onAllowRealIpFallbackChange:Be}):null}),M.auth.mode===`token`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ee,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:M.auth.token,labels:We,reveal:()=>re(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>$({token:e})}),(0,G.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>x(),children:n.changeToken})]}):null,M.auth.mode===`password`?(0,G.jsx)(Ee,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:M.auth.password,labels:We,reveal:()=>re(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>$({password:e})}):null,(0,G.jsx)(L,{children:M.auth.mode===`none`?null:(0,G.jsx)(Te,{g:n,rateLimit:M.auth.rateLimit,onChange:Me})})]}),(0,G.jsxs)(Q,{g:n,id:`updates`,activeTab:f,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,G.jsxs)(`select`,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>De(e.target.value),className:Z(),children:[(0,G.jsx)(`option`,{value:`stable`,children:n.channelStable}),(0,G.jsx)(`option`,{value:`beta`,children:n.channelBeta}),(0,G.jsx)(`option`,{value:`dev`,children:n.channelDev})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,G.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,G.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableDelayHours,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,G.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableJitterHours,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,G.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,G.jsxs)(Q,{g:n,id:`security`,activeTab:f,children:[(0,G.jsx)(le,{enabled:C,refreshToken:H}),(0,G.jsx)(xe,{g:n,form:M,onSecurityStrictChange:ze,onDangerouslyAllowHostHeaderOriginFallbackChange:Ve})]}),(0,G.jsx)(Q,{g:n,id:`advanced`,activeTab:f,children:(0,G.jsx)(Ce,{g:n,form:M,onMaxSseConnectionsChange:Ne,onDeferModeChange:Pe,onDeferIdsChange:Fe,onSkipIdsChange:Ie})})]}):(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V??he??n.loadError}),(0,G.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>void de(),children:n.retry})]}):(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.gateway}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function be(e){let t=(0,B.c)(17),{g:n,activeTab:r,visibleTabs:a,onChange:o}=e,s=n.tabsAriaLabel,c;t[0]!==r||t[1]!==o||t[2]!==a?(c=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=a.indexOf(r);t<0||o(a[(t+(e.key===`ArrowRight`?1:-1)+a.length)%a.length])},t[0]=r,t[1]=o,t[2]=a,t[3]=c):c=t[3];let l;if(t[4]!==r||t[5]!==n||t[6]!==o||t[7]!==a){let e;t[9]!==r||t[10]!==n||t[11]!==o?(e=e=>{let t=pe[e],a=e===r;return(0,G.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`gateway-settings-panel-${e}`,id:`gateway-settings-tab-${e}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,I.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>o(e),children:[(0,G.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:he(n,e)})]},e)},t[9]=r,t[10]=n,t[11]=o,t[12]=e):e=t[12],l=a.map(e),t[4]=r,t[5]=n,t[6]=o,t[7]=a,t[8]=l}else l=t[8];let u;return t[13]!==n.tabsAriaLabel||t[14]!==c||t[15]!==l?(u=(0,G.jsx)(`nav`,{"aria-label":s,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:c,children:l}),t[13]=n.tabsAriaLabel,t[14]=c,t[15]=l,t[16]=u):u=t[16],u}function Q(e){let t=(0,B.c)(20),{g:n,id:r,activeTab:i,children:a}=e;if(i!==r)return null;let o=`gateway-settings-panel-${r}`,s=`gateway-settings-tab-${r}`,c;t[0]!==n||t[1]!==r?(c=he(n,r),t[0]=n,t[1]=r,t[2]=c):c=t[2];let l;t[3]===c?l=t[4]:(l=(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==n||t[6]!==r?(u=ge(n,r),t[5]=n,t[6]=r,t[7]=u):u=t[7];let d;t[8]===u?d=t[9]:(d=(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}),t[8]=u,t[9]=d);let f;t[10]!==l||t[11]!==d?(f=(0,G.jsxs)(`div`,{className:`mb-5`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;t[13]===a?p=t[14]:(p=(0,G.jsx)(`div`,{className:`space-y-4`,children:a}),t[13]=a,t[14]=p);let m;return t[15]!==o||t[16]!==s||t[17]!==f||t[18]!==p?(m=(0,G.jsxs)(`section`,{id:o,role:`tabpanel`,"aria-labelledby":s,className:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,children:[f,p]}),t[15]=o,t[16]=s,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function xe(e){let t=(0,B.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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 Se(e){let t=(0,B.c)(80),{g:n,form:r,onTrustedProxyChange:a,onTrustedProxiesChange:o,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,G.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,G.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=i(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===a?f=t[6]:(f=e=>a({userHeader:e.target.value}),t[5]=a,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,G.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,G.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,G.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]===a?g=t[18]:(g=e=>a({requiredHeaders:e}),t[17]=a,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,G.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]===a?v=t[27]:(v=e=>a({allowUsers:e}),t[26]=a,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,G.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]===a?b=t[36]:(b=e=>a({allowLoopback:e.target.checked}),t[35]=a,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,G.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,G.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,G.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,G.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,G.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]!==o?(E=(0,G.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:o}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=o,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,G.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,G.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,G.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,G.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,G.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,G.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 Ce(e){let t=(0,B.c)(58),{g:n,form:r,onMaxSseConnectionsChange:a,onDeferModeChange:o,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.maxSseConnections?l=t[1]:(l=(0,G.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=i(Z(),`max-w-xs font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]===a?d=t[4]:(d=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(Math.max(1,Math.floor(t)))},t[3]=a,t[4]=d);let f;t[5]!==r.maxSseConnections||t[6]!==d?(f=(0,G.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,G.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,G.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,G.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]===o?_=t[17]:(_=e=>o(e.target.value),t[16]=o,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=Z(),t[18]=v):v=t[18];let y;t[19]===n.channelConnectDeferModeAuto?y=t[20]:(y=(0,G.jsx)(`option`,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[19]=n.channelConnectDeferModeAuto,t[20]=y);let b;t[21]===n.channelConnectDeferModeOff?b=t[22]:(b=(0,G.jsx)(`option`,{value:`off`,children:n.channelConnectDeferModeOff}),t[21]=n.channelConnectDeferModeOff,t[22]=b);let x;t[23]===n.channelConnectDeferModeExplicit?x=t[24]:(x=(0,G.jsx)(`option`,{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,G.jsxs)(`select`,{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,G.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,G.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,G.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 E;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?(E=r.channelConnectDeferMode===`off`?null:(0,G.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]=E):E=t[52];let D;return t[53]!==w||t[54]!==T||t[55]!==E||t[56]!==m?(D=(0,G.jsxs)(`div`,{className:`space-y-4`,children:[m,w,T,E]}),t[53]=w,t[54]=T,t[55]=E,t[56]=m,t[57]=D):D=t[57],D}function $(e){let t=(0,B.c)(25),{title:n,hint:r,emptyText:a,placeholder:o,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,G.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,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==a||t[9]!==l||t[10]!==s?(h=s.length===0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a}):(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,G.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,G.jsx)(`button`,{type:`button`,className:i(`text-fg-muted hover:text-fg`,I.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=a,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let _=s.length>=c,v;t[13]===f?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=v);let y;t[15]!==o||t[16]!==_||t[17]!==v?(y=(0,G.jsx)(`input`,{className:g,placeholder:o,disabled:_,onKeyDown:v}),t[15]=o,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(b=(0,G.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[p,m,h,y,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=b):b=t[24],b}function we(e){let t=(0,B.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,G.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,G.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 Te(e){let t=(0,B.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Z(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,G.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,G.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,G.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Z(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,G.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,G.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,G.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Z(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,G.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,G.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,G.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,G.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 Ee(e){let t=(0,B.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,G.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,G.jsx)(w,{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,G.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,G.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{ye 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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-NZmjSXLl.js";import{r as u}from"./toast-z0toXu32.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{$o as p,B as m,Ds as h,La as g,Oi as _,Vi as v,Xt as y,aa as b,ba as x,br as S,co as C,gi as w,hi as T,ki as E,ko as D,li as O,oa as k,p as A,qa as j,sa as M,tn as N,uo as P,va as F,xi as I}from"./index-Cxm6xsps.js";import{t as L}from"./settings-advanced-gate-D9sva86V.js";import{n as ee,t as R}from"./settings-form-section-Dq-83cQd.js";import{r as te,s as ne}from"./use-settings-tab-guard-Bw_qkRQE.js";import{a as re,n as ie,o as ae,r as oe,t as se}from"./gateway-config-api-CaXBt-9R.js";var z=e(t(),1),B=n(),V={critical:3,warn:2,info:1};function H(){return c(`/api/doctor?security=true`)}function U(e){return e.toSorted((e,t)=>V[t.severity]-V[e.severity]||e.checkId.localeCompare(t.checkId))}function ce(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=U((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 W(){return ce(await l(H()))}var G=r();function le(e){let t=(0,B.c)(40),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,s=o(q),c;t[0]===s?c=t[1]:(c=a(s),t[0]=s,t[1]=c);let l=c.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[H(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:h,isLoading:g,isValidating:_,mutate:v}=d(u,K,p),y=m??null,b=h instanceof Error?h.message:h?String(h):null,S=g||_,C;t[6]===v?C=t[7]:(C=()=>{v(),f(H())},t[6]=v,t[7]=C);let w=C,T=!n||S,D;t[8]===S?D=t[9]:(D=S?(0,G.jsx)(j,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,G.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),t[8]=S,t[9]=D);let O;t[10]===l.securityAuditRefresh?O=t[11]:(O=(0,G.jsx)(`span`,{className:`ml-1.5`,children:l.securityAuditRefresh}),t[10]=l.securityAuditRefresh,t[11]=O);let k;t[12]!==w||t[13]!==T||t[14]!==D||t[15]!==O?(k=(0,G.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:T,onClick:w,children:[D,O]}),t[12]=w,t[13]=T,t[14]=D,t[15]=O,t[16]=k):k=t[16];let A;t[17]!==l.securityAuditSubtitle||t[18]!==l.securityAuditTitle||t[19]!==k?(A=(0,G.jsx)(ee,{icon:M,title:l.securityAuditTitle,subtitle:l.securityAuditSubtitle,trailing:k}),t[17]=l.securityAuditSubtitle,t[18]=l.securityAuditTitle,t[19]=k,t[20]=A):A=t[20];let N;t[21]===l.securityAuditSavedConfigHint?N=t[22]:(N=(0,G.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:l.securityAuditSavedConfigHint}),t[21]=l.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==b||t[24]!==l.securityAuditLoadError?(P=b?(0,G.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[l.securityAuditLoadError,`: `,b]}):null,t[23]=b,t[24]=l.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==y||t[27]!==b||t[28]!==l.securityAuditLoading||t[29]!==S?(F=!b&&S&&!y?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(j,{className:`size-4 animate-spin`,"aria-hidden":!0}),l.securityAuditLoading]}):null,t[26]=y,t[27]=b,t[28]=l.securityAuditLoading,t[29]=S,t[30]=F):F=t[30];let I;t[31]!==y||t[32]!==l?(I=y?(0,G.jsx)(J,{g:l,audit:y}):null,t[31]=y,t[32]=l,t[33]=I):I=t[33];let L;return t[34]!==A||t[35]!==N||t[36]!==P||t[37]!==F||t[38]!==I?(L=(0,G.jsxs)(R,{children:[A,N,P,F,I]}),t[34]=A,t[35]=N,t[36]=P,t[37]=F,t[38]=I,t[39]=L):L=t[39],L}function K(){return W()}function q(e){return e.language}function J(e){let t=(0,B.c)(40),{g:n,audit:r}=e,a,o,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(o=X(n,r.status,r.findings),d=`space-y-4`,l=i(`rounded-lg border px-3 py-2.5 text-sm`,o.bannerClass),u=`status`,c=`flex items-start gap-2`,a=o.icon,s=i(`mt-0.5 size-4 shrink-0`,o.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==a||t[11]!==s?(f=(0,G.jsx)(a,{className:s,"aria-hidden":!0}),t[10]=a,t[11]=s,t[12]=f):f=t[12];let p;t[13]===o.title?p=t[14]:(p=(0,G.jsx)(`p`,{className:`font-medium`,children:o.title}),t[13]=o.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,G.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,G.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,G.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,G.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,G.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,G.jsx)(ue,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,G.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,G.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-3`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,G.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,G.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,G.jsx)(`li`,{className:`font-mono`,children:e},e)}function ue(e){let t=(0,B.c)(31),{g:n,finding:r}=e,a,o,s,c;if(t[0]!==r.severity){let e=de(r.severity);c=`rounded-lg border border-edge bg-surface-panel/50 px-3 py-2.5`,s=`flex items-start gap-2`,a=e.icon,o=i(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=a,t[2]=o,t[3]=s,t[4]=c}else a=t[1],o=t[2],s=t[3],c=t[4];let l;t[5]!==a||t[6]!==o?(l=(0,G.jsx)(a,{className:o,"aria-hidden":!0}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,G.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,G.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,G.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,G.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,G.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,G.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,G.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,G.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,G.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function de(e){switch(e){case`critical`:return{icon:p,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:v,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:P,iconClass:`text-fg-muted`}}}function X(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:p,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:P,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 Z(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}var fe=[`network`,`access`,`updates`,`security`,`advanced`],pe={network:g,access:C,updates:x,security:k,advanced:b};function me(e){return e&&fe.includes(e)?e:`network`}function he(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function ge(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function _e(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 ve={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function ye(){let e=o(e=>e.language),t=a(e),n=t.gatewaySettings,[r,c]=h(),l=y(e=>e.mode),d=l===`advanced`,f=me(r.get(`tab`)),g=(0,z.useMemo)(()=>ne(fe,l),[l]),_=(0,z.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]);te(f,_);let v=s(e=>e.token),b=s(e=>e.tokenExpired),x=s(e=>e.openTokenDialog),C=!!v,[w,k]=(0,z.useReducer)(_e,{form:null,baseline:null,appliedBaseline:null}),M=w.form,P=w.baseline,I=w.appliedBaseline,[ee,R]=(0,z.useReducer)(m,ve),{saving:B,error:V,auditRefreshToken:H,restarting:U,restartConfirmOpen:ce}=ee,W=(0,z.useRef)(!1),K=(0,z.useRef)(null),q=(0,z.useRef)(!1),{data:J,error:Y,isLoading:ue,mutate:de}=S(C),X=(0,z.useMemo)(()=>J?.payload?.config===void 0?null:structuredClone(ie(J.payload.config)),[J]);C?X!==null&&(q.current||(q.current=!0,k({type:`init-applied`,value:X})),!W.current&&K.current!==X&&(K.current=X,k({type:`sync`,value:X}),R({type:`patch`,patch:{saveOk:!1}}))):(K.current!==null||q.current)&&(K.current=null,q.current=!1,k({type:`reset`}),W.current=!1);let pe=!!(C&&ue&&J===void 0&&!Y),he=Y instanceof Error?Y.message:Y?String(Y):null,ge=(0,z.useMemo)(()=>!M||!P?!1:JSON.stringify(M)!==JSON.stringify(P),[M,P]),ye=(0,z.useMemo)(()=>!P||!I?!1:se(I,P),[I,P]),$=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),De=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Oe=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),ke=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Ae=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),je=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,port:e})})},[]),Me=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Ne=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,maxSseConnections:e})})},[]),Pe=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Fe=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Ie=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Le=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Re=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),ze=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Be=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ve=(0,z.useCallback)(e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),He=(0,z.useCallback)(async()=>{if(!M||B)return;let e=ae(M);if(e){R({type:`patch`,patch:{error:e}});return}R({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await oe(M),W.current=!1,k({type:`saved`,value:M}),R({type:`patch`,patch:{saveOk:!0,auditRefreshToken:H+1}}),u({type:`success`,title:n.saved})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{R({type:`patch`,patch:{saving:!1}})}},[M,B,n.saveError]),Ue=(0,z.useCallback)(()=>{P&&(W.current=!1,k({type:`discard`}),R({type:`patch`,patch:{error:null,saveOk:!1}}))},[P]),We=T(n),Ge=(0,z.useCallback)(async()=>{if(!U){R({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await N();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):u({type:`error`,title:n.restartGatewayFailed,message:e.message??``})}catch(e){u({type:`error`,title:n.restartGatewayFailed,message:e instanceof Error?e.message:String(e)})}finally{R({type:`patch`,patch:{restarting:!1}})}}},[U,n.restartGatewayFailed]);return C?pe?(0,G.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(j,{className:`size-4 animate-spin`}),n.loading]})}):M?(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.gateway}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,G.jsxs)(`a`,{href:O(e,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,G.jsx)(D,{className:`size-3.5`})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,G.jsx)(E,{type:`button`,variant:`secondary`,disabled:!ge||B,onClick:Ue,children:n.discard}),(0,G.jsx)(E,{type:`button`,variant:`primary`,disabled:!ge||B,onClick:()=>void He(),children:B?n.saving:n.save})]})]}),b?(0,G.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,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,G.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,G.jsx)(`div`,{children:(0,G.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>x(),children:n.updateToken})})]}):null,ge?(0,G.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,V?(0,G.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:V}):null,ye?(0,G.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,G.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,G.jsxs)(E,{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:U,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[U?(0,G.jsx)(j,{className:`size-3.5 animate-spin`}):(0,G.jsx)(F,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,G.jsx)(A,{open:ce,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Ge(),onCancel:()=>R({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,G.jsx)(be,{g:n,activeTab:f,visibleTabs:g,onChange:_}),(0,G.jsxs)(Q,{g:n,id:`network`,activeTab:f,children:[(0,G.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,G.jsxs)(`select`,{id:`gateway-bind-mode`,className:Z(),value:M.bind,onChange:e=>ke(e.target.value),children:[(0,G.jsx)(`option`,{value:`loopback`,children:n.bindLoopback}),d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`option`,{value:`lan`,children:n.bindLan}),(0,G.jsx)(`option`,{value:`auto`,children:n.bindAuto}),(0,G.jsx)(`option`,{value:`custom`,children:n.bindCustom}),(0,G.jsx)(`option`,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,G.jsx)(`input`,{id:`gateway-custom-bind-host`,className:i(Z(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>Ae(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,G.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:i(Z(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);je(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,G.jsx)(L,{children:(0,G.jsx)(we,{g:n,origins:M.corsOrigins,onChange:Oe})})]}),(0,G.jsxs)(Q,{g:n,id:`access`,activeTab:f,children:[M.auth.mode===`none`?(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,G.jsxs)(`select`,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>$({mode:e.target.value}),className:Z(),children:[(0,G.jsx)(`option`,{value:`token`,children:n.authModeToken}),(0,G.jsx)(`option`,{value:`password`,children:n.authModePassword}),d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`option`,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,G.jsx)(`option`,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,G.jsx)(L,{children:M.auth.mode===`trusted-proxy`?(0,G.jsx)(Se,{g:n,form:M,onTrustedProxyChange:Re,onTrustedProxiesChange:Le,onAllowRealIpFallbackChange:Be}):null}),M.auth.mode===`token`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ee,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:M.auth.token,labels:We,reveal:()=>re(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>$({token:e})}),(0,G.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>x(),children:n.changeToken})]}):null,M.auth.mode===`password`?(0,G.jsx)(Ee,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:M.auth.password,labels:We,reveal:()=>re(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>$({password:e})}):null,(0,G.jsx)(L,{children:M.auth.mode===`none`?null:(0,G.jsx)(Te,{g:n,rateLimit:M.auth.rateLimit,onChange:Me})})]}),(0,G.jsxs)(Q,{g:n,id:`updates`,activeTab:f,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,G.jsxs)(`select`,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>De(e.target.value),className:Z(),children:[(0,G.jsx)(`option`,{value:`stable`,children:n.channelStable}),(0,G.jsx)(`option`,{value:`beta`,children:n.channelBeta}),(0,G.jsx)(`option`,{value:`dev`,children:n.channelDev})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,G.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,G.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableDelayHours,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,G.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableJitterHours,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,G.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{W.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,G.jsxs)(Q,{g:n,id:`security`,activeTab:f,children:[(0,G.jsx)(le,{enabled:C,refreshToken:H}),(0,G.jsx)(xe,{g:n,form:M,onSecurityStrictChange:ze,onDangerouslyAllowHostHeaderOriginFallbackChange:Ve})]}),(0,G.jsx)(Q,{g:n,id:`advanced`,activeTab:f,children:(0,G.jsx)(Ce,{g:n,form:M,onMaxSseConnectionsChange:Ne,onDeferModeChange:Pe,onDeferIdsChange:Fe,onSkipIdsChange:Ie})})]}):(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V??he??n.loadError}),(0,G.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>void de(),children:n.retry})]}):(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.gateway}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function be(e){let t=(0,B.c)(17),{g:n,activeTab:r,visibleTabs:a,onChange:o}=e,s=n.tabsAriaLabel,c;t[0]!==r||t[1]!==o||t[2]!==a?(c=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=a.indexOf(r);t<0||o(a[(t+(e.key===`ArrowRight`?1:-1)+a.length)%a.length])},t[0]=r,t[1]=o,t[2]=a,t[3]=c):c=t[3];let l;if(t[4]!==r||t[5]!==n||t[6]!==o||t[7]!==a){let e;t[9]!==r||t[10]!==n||t[11]!==o?(e=e=>{let t=pe[e],a=e===r;return(0,G.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`gateway-settings-panel-${e}`,id:`gateway-settings-tab-${e}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,I.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>o(e),children:[(0,G.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:he(n,e)})]},e)},t[9]=r,t[10]=n,t[11]=o,t[12]=e):e=t[12],l=a.map(e),t[4]=r,t[5]=n,t[6]=o,t[7]=a,t[8]=l}else l=t[8];let u;return t[13]!==n.tabsAriaLabel||t[14]!==c||t[15]!==l?(u=(0,G.jsx)(`nav`,{"aria-label":s,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:c,children:l}),t[13]=n.tabsAriaLabel,t[14]=c,t[15]=l,t[16]=u):u=t[16],u}function Q(e){let t=(0,B.c)(20),{g:n,id:r,activeTab:i,children:a}=e;if(i!==r)return null;let o=`gateway-settings-panel-${r}`,s=`gateway-settings-tab-${r}`,c;t[0]!==n||t[1]!==r?(c=he(n,r),t[0]=n,t[1]=r,t[2]=c):c=t[2];let l;t[3]===c?l=t[4]:(l=(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==n||t[6]!==r?(u=ge(n,r),t[5]=n,t[6]=r,t[7]=u):u=t[7];let d;t[8]===u?d=t[9]:(d=(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}),t[8]=u,t[9]=d);let f;t[10]!==l||t[11]!==d?(f=(0,G.jsxs)(`div`,{className:`mb-5`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;t[13]===a?p=t[14]:(p=(0,G.jsx)(`div`,{className:`space-y-4`,children:a}),t[13]=a,t[14]=p);let m;return t[15]!==o||t[16]!==s||t[17]!==f||t[18]!==p?(m=(0,G.jsxs)(`section`,{id:o,role:`tabpanel`,"aria-labelledby":s,className:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,children:[f,p]}),t[15]=o,t[16]=s,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function xe(e){let t=(0,B.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.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 Se(e){let t=(0,B.c)(80),{g:n,form:r,onTrustedProxyChange:a,onTrustedProxiesChange:o,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,G.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,G.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=i(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===a?f=t[6]:(f=e=>a({userHeader:e.target.value}),t[5]=a,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,G.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,G.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,G.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]===a?g=t[18]:(g=e=>a({requiredHeaders:e}),t[17]=a,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,G.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]===a?v=t[27]:(v=e=>a({allowUsers:e}),t[26]=a,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,G.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]===a?b=t[36]:(b=e=>a({allowLoopback:e.target.checked}),t[35]=a,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,G.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,G.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,G.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,G.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,G.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]!==o?(E=(0,G.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:o}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=o,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,G.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,G.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,G.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,G.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,G.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,G.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 Ce(e){let t=(0,B.c)(58),{g:n,form:r,onMaxSseConnectionsChange:a,onDeferModeChange:o,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.maxSseConnections?l=t[1]:(l=(0,G.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=i(Z(),`max-w-xs font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]===a?d=t[4]:(d=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(Math.max(1,Math.floor(t)))},t[3]=a,t[4]=d);let f;t[5]!==r.maxSseConnections||t[6]!==d?(f=(0,G.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,G.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,G.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,G.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]===o?_=t[17]:(_=e=>o(e.target.value),t[16]=o,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=Z(),t[18]=v):v=t[18];let y;t[19]===n.channelConnectDeferModeAuto?y=t[20]:(y=(0,G.jsx)(`option`,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[19]=n.channelConnectDeferModeAuto,t[20]=y);let b;t[21]===n.channelConnectDeferModeOff?b=t[22]:(b=(0,G.jsx)(`option`,{value:`off`,children:n.channelConnectDeferModeOff}),t[21]=n.channelConnectDeferModeOff,t[22]=b);let x;t[23]===n.channelConnectDeferModeExplicit?x=t[24]:(x=(0,G.jsx)(`option`,{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,G.jsxs)(`select`,{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,G.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,G.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,G.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 E;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?(E=r.channelConnectDeferMode===`off`?null:(0,G.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]=E):E=t[52];let D;return t[53]!==w||t[54]!==T||t[55]!==E||t[56]!==m?(D=(0,G.jsxs)(`div`,{className:`space-y-4`,children:[m,w,T,E]}),t[53]=w,t[54]=T,t[55]=E,t[56]=m,t[57]=D):D=t[57],D}function $(e){let t=(0,B.c)(25),{title:n,hint:r,emptyText:a,placeholder:o,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,G.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,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==a||t[9]!==l||t[10]!==s?(h=s.length===0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a}):(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,G.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,G.jsx)(`button`,{type:`button`,className:i(`text-fg-muted hover:text-fg`,I.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=a,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let _=s.length>=c,v;t[13]===f?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=v);let y;t[15]!==o||t[16]!==_||t[17]!==v?(y=(0,G.jsx)(`input`,{className:g,placeholder:o,disabled:_,onKeyDown:v}),t[15]=o,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(b=(0,G.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[p,m,h,y,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=b):b=t[24],b}function we(e){let t=(0,B.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,G.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,G.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 Te(e){let t=(0,B.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,G.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,G.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,G.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,G.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,G.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,G.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,G.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,G.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Z(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,G.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,G.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,G.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Z(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,G.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,G.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,G.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Z(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,G.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,G.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,G.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,G.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 Ee(e){let t=(0,B.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,G.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,G.jsx)(w,{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,G.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,G.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{ye as GatewaySettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./fetch-
|
|
1
|
+
import{t as e}from"./fetch-NZmjSXLl.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,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-BUUfPaZ9.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{i as s,n as c}from"./fetch-DOe56Wmy.js";import{$a as l,Ds as u,Ea as d,Eo as f,Es as p,Go as m,Hi as h,Ki as g,M as _,O as v,P as y,Ro as b,S as x,Ss as S,To as C,Ts as w,Wo as T,Xo as E,Yo as ee,Zo as te,ba as ne,bo as re,gs as ie,ii as ae,k as oe,ki as D,ko as O,ls as se,ma as k,vs as ce,xs as le}from"./index-BTmbp2AU.js";var A=n(),j=e(t(),1),M=r(),N=`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`,ue=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function de(e){return e===`command`||e===`test`?g:e===`diff`?b:e===`file`||e===`artifact`?C:e===`link`?O:k}function fe(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function P(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function pe(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function me(e){let t=(0,A.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=de(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=fe(n),a=P(e,`command`),g=pe(e,`exitCode`),_=P(e,`path`)||n.uri,v=pe(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,M.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,M.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,M.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,S;t[19]!==b||t[20]!==x?(S=(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==S?(C=(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[y,S]}),t[22]=y,t[23]=S,t[24]=C):C=t[24];let w;t[25]!==n.kind||t[26]!==i?(w=Ce(n.kind,i),t[25]=n.kind,t[26]=i,t[27]=w):w=t[27];let T;t[28]===w?T=t[29]:(T=(0,M.jsx)(`span`,{className:`rounded-full border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:w}),t[28]=w,t[29]=T),t[30]!==C||t[31]!==T?(p=(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[C,T]}),t[30]=C,t[31]=T,t[32]=p):p=t[32],m=a?(0,M.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,M.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,M.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,M.jsx)(`code`,{children:n.summary})}):(0,M.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 E;t[36]!==n.createdAt||t[37]!==r||t[38]!==i?(E=L(n.createdAt,r,i),t[36]=n.createdAt,t[37]=r,t[38]=i,t[39]=E):E=t[39],t[40]===E?l=t[41]:(l=(0,M.jsx)(`time`,{children:E}),t[40]=E,t[41]=l),u=g==null?null:(0,M.jsx)(`span`,{children:F(i.exitCode,{code:g})}),d=v==null?null:(0,M.jsx)(`span`,{children:F(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,M.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,M.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,M.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 he(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 ge(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 _e(e){return e===`workflow_run`?re:e===`goal_run`?se:e===`queue`?ee:e===`evidence`?C:le}function F(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function I(e){return e===`zh`?`zh-CN`:`en-US`}function L(e,t,n){return e?new Intl.DateTimeFormat(I(t),{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):n.notSet}function ve(e,t,n){return e?new Intl.DateTimeFormat(I(t),{dateStyle:`medium`}).format(new Date(e)):n.noDeadline}function ye(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 be(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function xe(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function R(e,t){return e?t.statuses[e]??e:``}function Se(e,t){return t.priorities[e]??e}function Ce(e,t){return t.evidenceKinds[e]??e}async function we(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}`))).goal}async function Te(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Ee(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function De(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function Oe(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function z(){let{goalId:e=``}=p(),t=w(),n=o(e=>e.language),r=a(n).goalDetailPage,g=ae(e=>e.setPageHeader),b=ae(e=>e.clearPageHeader),[C,se]=u(),[k,A]=(0,j.useState)(null),[de,fe]=(0,j.useState)([]),[P,pe]=(0,j.useState)([]),[I,z]=(0,j.useState)([]),[ke,Ae]=(0,j.useState)([]),[je,Me]=(0,j.useState)([]),[Ne,B]=(0,j.useState)([]),[V,Pe]=(0,j.useState)(``),[Fe,Ie]=(0,j.useState)(`message`),[H,Le]=(0,j.useState)(``),[Re,ze]=(0,j.useState)(``),[Be,Ve]=(0,j.useState)(``),[He,Ue]=(0,j.useState)(``),[We,Ge]=(0,j.useState)(``),[Ke,qe]=(0,j.useState)(`normal`),[Je,Ye]=(0,j.useState)(``),[Xe,Ze]=(0,j.useState)(`10`),[Qe,$e]=(0,j.useState)(``),[et,tt]=(0,j.useState)(``),[nt,rt]=(0,j.useState)(``),[U,it]=(0,j.useState)(``),[at,ot]=(0,j.useState)(``),[W,st]=(0,j.useState)(!0),[G,K]=(0,j.useState)(null),[ct,q]=(0,j.useState)(null),J=(0,j.useCallback)(async()=>{if(e){st(!0),q(null);try{let[t,n,r]=await Promise.all([we(e),Te(e),Ee(e)]);A(t),fe(n);let[i,a]=await Promise.all([v(e,50),De(e)]);z(i),B(a),Ae(await Oe(e)),Me(r)}catch(e){q(e instanceof Error?e.message:r.errors.load)}finally{st(!1)}}},[e,r.errors.load]);(0,j.useEffect)(()=>{J()},[J]),(0,j.useEffect)(()=>{let e=!1;return oe().then(t=>{e||(pe(t),it(e=>e||t[0]?.id||``))}).catch(t=>{e||q(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,j.useEffect)(()=>{k&&(Ue(k.title),Ge(k.description??``),qe(k.priority),Ye(k.deadlineAt?new Date(k.deadlineAt).toISOString().slice(0,10):``),Ze(String(k.maxTurns)),$e(k.judgeModelRef??``),tt(k.nextAction??``),rt(k.blockedReason??``),ot(e=>e||k.nextAction||k.title))},[k?.id,k?.updatedAt]);let lt=async()=>{if(k){K(`continue`);try{let e=await c(s(`/api/goals/${encodeURIComponent(k.id)}/continue`),{method:`POST`,body:JSON.stringify({})});if(e.sessionKey){t(`/chat/${encodeURIComponent(e.sessionKey)}`);return}await J()}catch(e){q(e instanceof Error?e.message:r.errors.continue)}finally{K(null)}}},ut=async e=>{if(e.preventDefault(),!k)return;let t=He.trim();if(t){K(`details:save`),q(null);try{let e=Number.parseInt(Xe,10);A((await c(s(`/api/goals/${encodeURIComponent(k.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:We.trim()||void 0,priority:Ke,deadlineAt:Je?new Date(`${Je}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:k.maxTurns,judgeModelRef:Qe.trim()||void 0,nextAction:et.trim()||void 0,blockedReason:nt.trim()||void 0})})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.save)}finally{K(null)}}},dt=async e=>{if(k){K(e);try{await c(s(`/api/goals/${encodeURIComponent(k.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await J()}catch(e){q(e instanceof Error?e.message:r.errors.action)}finally{K(null)}}},ft=async()=>{if(!(!k||!U)){K(`workflow:run`),q(null);try{let e=await y({goalId:k.id,definitionId:U,goal:at.trim()||k.nextAction||k.title});await J(),t(`/chat/${encodeURIComponent(e.sessionKey)}`)}catch(e){q(e instanceof Error?e.message:r.errors.startWorkflow)}finally{K(null)}}},Y=async e=>{try{B(await De(e))}catch{}},pt=async e=>{try{let[t,n,r]=await Promise.all([v(e,50),De(e),Oe(e)]);z(t),B(n),Ae(r)}catch{}},mt=async e=>{if(k){K(`workflow:${e.id}:cancel`),q(null);try{await x(e.id,{ownerAgentId:k.agentId}),await pt(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{K(null)}}},ht=async e=>{if(k){K(`workflow:${e.id}:retry`),q(null);try{let n=await _(e.id,{ownerAgentId:k.agentId});await pt(k.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){q(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{K(null)}}},gt=async e=>{if(e.preventDefault(),!k)return;let t=V.trim();if(t){K(`checklist:add`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Pe(``),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.addChecklist)}finally{K(null)}}},_t=async(e,t)=>{if(k){K(`checklist:${e}:${t}`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.updateChecklist)}finally{K(null)}}},vt=async e=>{if(k){K(`checklist:${e}:delete`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{K(null)}}},yt=async e=>{if(e.preventDefault(),!k)return;let t=H.trim();if(t){K(`evidence:add`),q(null);try{let e=await c(s(`/api/goals/${encodeURIComponent(k.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:Fe,title:t,summary:Re.trim()||void 0,uri:Be.trim()||void 0})});Me(t=>[e.evidence,...t]),Le(``),ze(``),Ve(``),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.addEvidence)}finally{K(null)}}},X=k?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,Z=k?.checklist.length??0,bt=I.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),Q=de[0],$=xe(C.get(`timeline`))?C.get(`timeline`):`all`,xt=$===`all`?Ne:Ne.filter(e=>e.kind===$),St=I.filter(e=>e.status===`queued`||e.status===`running`),Ct=G!=null||k?.status===`done`||k?.status===`archived`,wt=(0,j.useMemo)(()=>k?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(D,{type:`button`,variant:`primary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":ye(k.status,r),disabled:Ct,onClick:()=>void lt(),children:[(0,M.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:ye(k.status,r)})]}),k.activeSessionKey?(0,M.jsxs)(D,{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(k.activeSessionKey)}`),children:[(0,M.jsx)(O,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.pause,disabled:G!=null||k.status!==`active`,onClick:()=>void dt(`pause`),children:[(0,M.jsx)(E,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.pause})]}),(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:G!=null||k.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&&dt(`archive`)},children:[(0,M.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[G,k,t,Ct,r]);(0,j.useLayoutEffect)(()=>(g({startExtra:(0,M.jsx)(S,{to:`/goals`,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,M.jsx)(ie,{className:`size-4`,"aria-hidden":!0})}),main:(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:k?.title??(W?r.loading:r.notFound)}),k?(0,M.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[R(k.status,r),` · `,F(r.agent,{agentId:k.agentId}),` · `,F(r.turns,{used:k.turnsUsed,max:k.maxTurns}),Z?` · ${F(r.checklistProgress,{done:X,total:Z})}`:``]}):null]}),end:wt}),()=>b()),[b,X,k,wt,W,g,r,Z]);let Tt=e=>{let t=new URLSearchParams(C);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),se(t,{replace:!0})};return(0,M.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-base`,children:(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-1 flex-col gap-4 px-4 py-5 sm:px-6`,children:[W?(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading}):null,ct?(0,M.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:ct}):null,!W&&!k?(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,k?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:i(`rounded-full border px-2 py-0.5 text-xs`,he(k.status)),children:R(k.status,r)}),(0,M.jsx)(`span`,{className:`text-xs text-fg-muted`,children:F(r.prioritySummary,{priority:Se(k.priority,r)})}),(0,M.jsx)(`span`,{className:`text-xs text-fg-muted`,children:k.deadlineAt?ve(k.deadlineAt,n,r):r.noDeadline})]}),k.description?(0,M.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:k.description}):null,(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:k.blockedReason?r.currentBlocker:r.nextAction}),(0,M.jsx)(`p`,{className:i(`mt-1 break-words text-sm`,k.blockedReason?`text-amber-700 dark:text-amber-300`:`text-fg`),children:k.blockedReason||k.nextAction||r.noNextAction})]})]}),(0,M.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,M.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(l,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,M.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[X,`/`,Z]})]}),Q?(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{children:F(r.latestJudgement,{status:R(Q.verdict??Q.status,r)})}),(0,M.jsx)(`time`,{children:L(Q.finishedAt??Q.startedAt,n,r)})]}),Q.reason?(0,M.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:Q.reason}):null,Q.nextAction?(0,M.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:F(r.latestNext,{next:Q.nextAction})}):null]}):null,(0,M.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(l,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,M.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[X,`/`,Z]})]}),(0,M.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:gt,children:[(0,M.jsx)(`input`,{value:V,onChange:e=>Pe(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:i(N,`flex-1`)}),(0,M.jsxs)(D,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:G!=null||!V.trim(),children:[(0,M.jsx)(d,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),k.checklist.length?(0,M.jsx)(`ul`,{className:`space-y-2 text-sm`,children:k.checklist.map(e=>(0,M.jsx)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2`,children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:be(e.status)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:G!=null||e.status===`pending`,onClick:()=>void _t(e.id,`pending`),children:(0,M.jsx)(T,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:G!=null||e.status===`completed`,onClick:()=>void _t(e.id,`completed`),children:(0,M.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:G!=null||e.status===`impossible`,onClick:()=>void _t(e.id,`impossible`),children:(0,M.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-destructive hover:text-destructive`,title:r.deleteChecklistItem,"aria-label":r.deleteChecklistItem,disabled:G!=null,onClick:()=>void vt(e.id),children:(0,M.jsx)(h,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,M.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,M.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(f,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),(0,M.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:yt,children:[(0,M.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,M.jsx)(`select`,{value:Fe,onChange:e=>Ie(e.target.value),className:N,name:`evidenceKind`,children:ue.map(e=>(0,M.jsx)(`option`,{value:e,children:Ce(e,r)},e))})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,M.jsx)(`input`,{value:H,onChange:e=>Le(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:N})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,M.jsx)(`input`,{value:Be,onChange:e=>Ve(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:N})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,M.jsx)(`textarea`,{value:Re,onChange:e=>ze(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:i(N,`resize-y`)})]}),(0,M.jsxs)(D,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:G!=null||!H.trim(),children:[(0,M.jsx)(d,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),je.length?(0,M.jsx)(`ul`,{className:`space-y-2 text-sm`,children:je.slice(0,6).map(e=>(0,M.jsx)(me,{item:e,language:n,t:r},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void J(),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),(0,M.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,M.jsx)(`button`,{type:`button`,className:i(`rounded-md border px-2.5 py-1 text-xs font-medium`,$===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:()=>Tt(e),children:r.timelineFilters[e]},e))}),xt.length?(0,M.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:xt.map(e=>(0,M.jsx)(`li`,{className:`rounded-md border border-edge/60 bg-surface-muted/50 px-2.5 py-2`,children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,M.jsx)(_e(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,M.jsx)(`span`,{children:R(e.status,r)}):null]}),(0,M.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,M.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,M.jsx)(`time`,{children:L(e.createdAt,n,r)}),e.link?.type===`chat`?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,M.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]}),(0,M.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalSettings}),(0,M.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:ve(k.deadlineAt,n,r)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,M.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:k.judgeModelRef||r.default})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:ve(k.createdAt,n,r)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:L(k.updatedAt,n,r)})]})]}),(0,M.jsxs)(`details`,{className:`mt-4 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,M.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:ut,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,M.jsx)(`input`,{value:He,onChange:e=>Ue(e.target.value),name:`goalTitle`,autoComplete:`off`,className:N,placeholder:`${r.title}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,M.jsx)(`textarea`,{value:We,onChange:e=>Ge(e.target.value),name:`goalDescription`,autoComplete:`off`,className:i(N,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,M.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,M.jsxs)(`select`,{value:Ke,onChange:e=>qe(e.target.value),name:`goalPriority`,className:N,children:[(0,M.jsx)(`option`,{value:`low`,children:r.priorities.low}),(0,M.jsx)(`option`,{value:`normal`,children:r.priorities.normal}),(0,M.jsx)(`option`,{value:`high`,children:r.priorities.high})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,M.jsx)(`input`,{value:Je,onChange:e=>Ye(e.target.value),name:`goalDeadline`,className:N,type:`date`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,M.jsx)(`input`,{value:Xe,onChange:e=>Ze(e.target.value),name:`goalMaxTurns`,className:N,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,M.jsx)(`input`,{value:Qe,onChange:e=>$e(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:N,placeholder:`${r.judgeModel}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,M.jsx)(`textarea`,{value:et,onChange:e=>tt(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:i(N,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,M.jsx)(`textarea`,{value:nt,onChange:e=>rt(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:i(N,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,M.jsx)(D,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:G!=null||!He.trim(),children:r.saveDetails})]})]})]}),(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.workflowHint})]}),St.length?(0,M.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:F(r.activeCount,{count:St.length})}):null]}),ke.length?(0,M.jsx)(`div`,{className:`mt-3 grid gap-2`,children:ke.slice(0,2).map(e=>(0,M.jsxs)(`button`,{type:`button`,className:i(`min-w-0 rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2 text-left hover:border-accent/60 hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,U===e.definitionId&&`border-accent/70 bg-accent-soft/60`),onClick:()=>{it(e.definitionId),ot(k.nextAction||k.title)},children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,M.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,M.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,M.jsxs)(`select`,{value:U,onChange:e=>it(e.target.value),className:N,name:`workflowDefinition`,disabled:P.length===0,children:[P.length===0?(0,M.jsx)(`option`,{value:``,children:r.noWorkflows}):null,P.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,M.jsx)(`input`,{value:at,onChange:e=>ot(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:N,placeholder:`${r.workflowGoal}…`})]}),(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:G!=null||!U||k.status===`done`||k.status===`archived`,onClick:()=>void ft(),children:[(0,M.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),I.length?(0,M.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,M.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,M.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:()=>Tt(`workflow_run`),children:r.viewTimeline})]}),(0,M.jsx)(`ul`,{className:`grid gap-2`,children:I.slice(0,3).map(e=>{let a=e.metadata?.sessionKey,o=e.status===`queued`||e.status===`running`,s=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,M.jsxs)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,M.jsx)(`span`,{className:i(`shrink-0 rounded-full border px-2 py-0.5`,ge(e.status)),children:R(e.status,r)})]}),(0,M.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,M.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:L(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[a?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(a)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,o?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:G!=null,onClick:()=>void mt(e),children:[(0,M.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,s?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:G!=null,onClick:()=>void ht(e),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,bt.length?(0,M.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,M.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:F(r.failedCount,{count:bt.length})})]}),(0,M.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:bt.slice(0,3).map(e=>(0,M.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,R(e.status,r)]})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:G!=null,onClick:()=>void ht(e),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{z as GoalDetailPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{i as s,n as c}from"./fetch-NZmjSXLl.js";import{$a as l,Ds as u,Ea as d,Eo as f,Es as p,Go as m,Hi as h,Ki as g,M as _,O as v,P as y,Ro as b,S as x,Ss as S,To as C,Ts as w,Wo as T,Xo as E,Yo as ee,Zo as te,ba as ne,bo as re,gs as ie,ii as ae,k as oe,ki as D,ko as O,ls as se,ma as k,vs as ce,xs as le}from"./index-Cxm6xsps.js";var A=n(),j=e(t(),1),M=r(),N=`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`,ue=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function de(e){return e===`command`||e===`test`?g:e===`diff`?b:e===`file`||e===`artifact`?C:e===`link`?O:k}function fe(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function P(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function pe(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function me(e){let t=(0,A.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=de(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=fe(n),a=P(e,`command`),g=pe(e,`exitCode`),_=P(e,`path`)||n.uri,v=pe(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,M.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,M.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,M.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,S;t[19]!==b||t[20]!==x?(S=(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==S?(C=(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[y,S]}),t[22]=y,t[23]=S,t[24]=C):C=t[24];let w;t[25]!==n.kind||t[26]!==i?(w=Ce(n.kind,i),t[25]=n.kind,t[26]=i,t[27]=w):w=t[27];let T;t[28]===w?T=t[29]:(T=(0,M.jsx)(`span`,{className:`rounded-full border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:w}),t[28]=w,t[29]=T),t[30]!==C||t[31]!==T?(p=(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[C,T]}),t[30]=C,t[31]=T,t[32]=p):p=t[32],m=a?(0,M.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,M.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,M.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,M.jsx)(`code`,{children:n.summary})}):(0,M.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 E;t[36]!==n.createdAt||t[37]!==r||t[38]!==i?(E=L(n.createdAt,r,i),t[36]=n.createdAt,t[37]=r,t[38]=i,t[39]=E):E=t[39],t[40]===E?l=t[41]:(l=(0,M.jsx)(`time`,{children:E}),t[40]=E,t[41]=l),u=g==null?null:(0,M.jsx)(`span`,{children:F(i.exitCode,{code:g})}),d=v==null?null:(0,M.jsx)(`span`,{children:F(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,M.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,M.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,M.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 he(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 ge(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 _e(e){return e===`workflow_run`?re:e===`goal_run`?se:e===`queue`?ee:e===`evidence`?C:le}function F(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function I(e){return e===`zh`?`zh-CN`:`en-US`}function L(e,t,n){return e?new Intl.DateTimeFormat(I(t),{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):n.notSet}function ve(e,t,n){return e?new Intl.DateTimeFormat(I(t),{dateStyle:`medium`}).format(new Date(e)):n.noDeadline}function ye(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 be(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function xe(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function R(e,t){return e?t.statuses[e]??e:``}function Se(e,t){return t.priorities[e]??e}function Ce(e,t){return t.evidenceKinds[e]??e}async function we(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}`))).goal}async function Te(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Ee(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function De(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function Oe(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function z(){let{goalId:e=``}=p(),t=w(),n=o(e=>e.language),r=a(n).goalDetailPage,g=ae(e=>e.setPageHeader),b=ae(e=>e.clearPageHeader),[C,se]=u(),[k,A]=(0,j.useState)(null),[de,fe]=(0,j.useState)([]),[P,pe]=(0,j.useState)([]),[I,z]=(0,j.useState)([]),[ke,Ae]=(0,j.useState)([]),[je,Me]=(0,j.useState)([]),[Ne,B]=(0,j.useState)([]),[V,Pe]=(0,j.useState)(``),[Fe,Ie]=(0,j.useState)(`message`),[H,Le]=(0,j.useState)(``),[Re,ze]=(0,j.useState)(``),[Be,Ve]=(0,j.useState)(``),[He,Ue]=(0,j.useState)(``),[We,Ge]=(0,j.useState)(``),[Ke,qe]=(0,j.useState)(`normal`),[Je,Ye]=(0,j.useState)(``),[Xe,Ze]=(0,j.useState)(`10`),[Qe,$e]=(0,j.useState)(``),[et,tt]=(0,j.useState)(``),[nt,rt]=(0,j.useState)(``),[U,it]=(0,j.useState)(``),[at,ot]=(0,j.useState)(``),[W,st]=(0,j.useState)(!0),[G,K]=(0,j.useState)(null),[ct,q]=(0,j.useState)(null),J=(0,j.useCallback)(async()=>{if(e){st(!0),q(null);try{let[t,n,r]=await Promise.all([we(e),Te(e),Ee(e)]);A(t),fe(n);let[i,a]=await Promise.all([v(e,50),De(e)]);z(i),B(a),Ae(await Oe(e)),Me(r)}catch(e){q(e instanceof Error?e.message:r.errors.load)}finally{st(!1)}}},[e,r.errors.load]);(0,j.useEffect)(()=>{J()},[J]),(0,j.useEffect)(()=>{let e=!1;return oe().then(t=>{e||(pe(t),it(e=>e||t[0]?.id||``))}).catch(t=>{e||q(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,j.useEffect)(()=>{k&&(Ue(k.title),Ge(k.description??``),qe(k.priority),Ye(k.deadlineAt?new Date(k.deadlineAt).toISOString().slice(0,10):``),Ze(String(k.maxTurns)),$e(k.judgeModelRef??``),tt(k.nextAction??``),rt(k.blockedReason??``),ot(e=>e||k.nextAction||k.title))},[k?.id,k?.updatedAt]);let lt=async()=>{if(k){K(`continue`);try{let e=await c(s(`/api/goals/${encodeURIComponent(k.id)}/continue`),{method:`POST`,body:JSON.stringify({})});if(e.sessionKey){t(`/chat/${encodeURIComponent(e.sessionKey)}`);return}await J()}catch(e){q(e instanceof Error?e.message:r.errors.continue)}finally{K(null)}}},ut=async e=>{if(e.preventDefault(),!k)return;let t=He.trim();if(t){K(`details:save`),q(null);try{let e=Number.parseInt(Xe,10);A((await c(s(`/api/goals/${encodeURIComponent(k.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:We.trim()||void 0,priority:Ke,deadlineAt:Je?new Date(`${Je}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:k.maxTurns,judgeModelRef:Qe.trim()||void 0,nextAction:et.trim()||void 0,blockedReason:nt.trim()||void 0})})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.save)}finally{K(null)}}},dt=async e=>{if(k){K(e);try{await c(s(`/api/goals/${encodeURIComponent(k.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await J()}catch(e){q(e instanceof Error?e.message:r.errors.action)}finally{K(null)}}},ft=async()=>{if(!(!k||!U)){K(`workflow:run`),q(null);try{let e=await y({goalId:k.id,definitionId:U,goal:at.trim()||k.nextAction||k.title});await J(),t(`/chat/${encodeURIComponent(e.sessionKey)}`)}catch(e){q(e instanceof Error?e.message:r.errors.startWorkflow)}finally{K(null)}}},Y=async e=>{try{B(await De(e))}catch{}},pt=async e=>{try{let[t,n,r]=await Promise.all([v(e,50),De(e),Oe(e)]);z(t),B(n),Ae(r)}catch{}},mt=async e=>{if(k){K(`workflow:${e.id}:cancel`),q(null);try{await x(e.id,{ownerAgentId:k.agentId}),await pt(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{K(null)}}},ht=async e=>{if(k){K(`workflow:${e.id}:retry`),q(null);try{let n=await _(e.id,{ownerAgentId:k.agentId});await pt(k.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){q(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{K(null)}}},gt=async e=>{if(e.preventDefault(),!k)return;let t=V.trim();if(t){K(`checklist:add`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Pe(``),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.addChecklist)}finally{K(null)}}},_t=async(e,t)=>{if(k){K(`checklist:${e}:${t}`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.updateChecklist)}finally{K(null)}}},vt=async e=>{if(k){K(`checklist:${e}:delete`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{K(null)}}},yt=async e=>{if(e.preventDefault(),!k)return;let t=H.trim();if(t){K(`evidence:add`),q(null);try{let e=await c(s(`/api/goals/${encodeURIComponent(k.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:Fe,title:t,summary:Re.trim()||void 0,uri:Be.trim()||void 0})});Me(t=>[e.evidence,...t]),Le(``),ze(``),Ve(``),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.addEvidence)}finally{K(null)}}},X=k?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,Z=k?.checklist.length??0,bt=I.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),Q=de[0],$=xe(C.get(`timeline`))?C.get(`timeline`):`all`,xt=$===`all`?Ne:Ne.filter(e=>e.kind===$),St=I.filter(e=>e.status===`queued`||e.status===`running`),Ct=G!=null||k?.status===`done`||k?.status===`archived`,wt=(0,j.useMemo)(()=>k?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(D,{type:`button`,variant:`primary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":ye(k.status,r),disabled:Ct,onClick:()=>void lt(),children:[(0,M.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:ye(k.status,r)})]}),k.activeSessionKey?(0,M.jsxs)(D,{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(k.activeSessionKey)}`),children:[(0,M.jsx)(O,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.pause,disabled:G!=null||k.status!==`active`,onClick:()=>void dt(`pause`),children:[(0,M.jsx)(E,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.pause})]}),(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:G!=null||k.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&&dt(`archive`)},children:[(0,M.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[G,k,t,Ct,r]);(0,j.useLayoutEffect)(()=>(g({startExtra:(0,M.jsx)(S,{to:`/goals`,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,M.jsx)(ie,{className:`size-4`,"aria-hidden":!0})}),main:(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:k?.title??(W?r.loading:r.notFound)}),k?(0,M.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[R(k.status,r),` · `,F(r.agent,{agentId:k.agentId}),` · `,F(r.turns,{used:k.turnsUsed,max:k.maxTurns}),Z?` · ${F(r.checklistProgress,{done:X,total:Z})}`:``]}):null]}),end:wt}),()=>b()),[b,X,k,wt,W,g,r,Z]);let Tt=e=>{let t=new URLSearchParams(C);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),se(t,{replace:!0})};return(0,M.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-base`,children:(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-1 flex-col gap-4 px-4 py-5 sm:px-6`,children:[W?(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading}):null,ct?(0,M.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:ct}):null,!W&&!k?(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,k?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:i(`rounded-full border px-2 py-0.5 text-xs`,he(k.status)),children:R(k.status,r)}),(0,M.jsx)(`span`,{className:`text-xs text-fg-muted`,children:F(r.prioritySummary,{priority:Se(k.priority,r)})}),(0,M.jsx)(`span`,{className:`text-xs text-fg-muted`,children:k.deadlineAt?ve(k.deadlineAt,n,r):r.noDeadline})]}),k.description?(0,M.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:k.description}):null,(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:k.blockedReason?r.currentBlocker:r.nextAction}),(0,M.jsx)(`p`,{className:i(`mt-1 break-words text-sm`,k.blockedReason?`text-amber-700 dark:text-amber-300`:`text-fg`),children:k.blockedReason||k.nextAction||r.noNextAction})]})]}),(0,M.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,M.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(l,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,M.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[X,`/`,Z]})]}),Q?(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{children:F(r.latestJudgement,{status:R(Q.verdict??Q.status,r)})}),(0,M.jsx)(`time`,{children:L(Q.finishedAt??Q.startedAt,n,r)})]}),Q.reason?(0,M.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:Q.reason}):null,Q.nextAction?(0,M.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:F(r.latestNext,{next:Q.nextAction})}):null]}):null,(0,M.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(l,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,M.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[X,`/`,Z]})]}),(0,M.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:gt,children:[(0,M.jsx)(`input`,{value:V,onChange:e=>Pe(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:i(N,`flex-1`)}),(0,M.jsxs)(D,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:G!=null||!V.trim(),children:[(0,M.jsx)(d,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),k.checklist.length?(0,M.jsx)(`ul`,{className:`space-y-2 text-sm`,children:k.checklist.map(e=>(0,M.jsx)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2`,children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:be(e.status)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:G!=null||e.status===`pending`,onClick:()=>void _t(e.id,`pending`),children:(0,M.jsx)(T,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:G!=null||e.status===`completed`,onClick:()=>void _t(e.id,`completed`),children:(0,M.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:G!=null||e.status===`impossible`,onClick:()=>void _t(e.id,`impossible`),children:(0,M.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-destructive hover:text-destructive`,title:r.deleteChecklistItem,"aria-label":r.deleteChecklistItem,disabled:G!=null,onClick:()=>void vt(e.id),children:(0,M.jsx)(h,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,M.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,M.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(f,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),(0,M.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:yt,children:[(0,M.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,M.jsx)(`select`,{value:Fe,onChange:e=>Ie(e.target.value),className:N,name:`evidenceKind`,children:ue.map(e=>(0,M.jsx)(`option`,{value:e,children:Ce(e,r)},e))})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,M.jsx)(`input`,{value:H,onChange:e=>Le(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:N})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,M.jsx)(`input`,{value:Be,onChange:e=>Ve(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:N})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,M.jsx)(`textarea`,{value:Re,onChange:e=>ze(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:i(N,`resize-y`)})]}),(0,M.jsxs)(D,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:G!=null||!H.trim(),children:[(0,M.jsx)(d,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),je.length?(0,M.jsx)(`ul`,{className:`space-y-2 text-sm`,children:je.slice(0,6).map(e=>(0,M.jsx)(me,{item:e,language:n,t:r},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void J(),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),(0,M.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,M.jsx)(`button`,{type:`button`,className:i(`rounded-md border px-2.5 py-1 text-xs font-medium`,$===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:()=>Tt(e),children:r.timelineFilters[e]},e))}),xt.length?(0,M.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:xt.map(e=>(0,M.jsx)(`li`,{className:`rounded-md border border-edge/60 bg-surface-muted/50 px-2.5 py-2`,children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,M.jsx)(_e(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,M.jsx)(`span`,{children:R(e.status,r)}):null]}),(0,M.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,M.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,M.jsx)(`time`,{children:L(e.createdAt,n,r)}),e.link?.type===`chat`?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,M.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]}),(0,M.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalSettings}),(0,M.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:ve(k.deadlineAt,n,r)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,M.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:k.judgeModelRef||r.default})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:ve(k.createdAt,n,r)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:L(k.updatedAt,n,r)})]})]}),(0,M.jsxs)(`details`,{className:`mt-4 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,M.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:ut,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,M.jsx)(`input`,{value:He,onChange:e=>Ue(e.target.value),name:`goalTitle`,autoComplete:`off`,className:N,placeholder:`${r.title}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,M.jsx)(`textarea`,{value:We,onChange:e=>Ge(e.target.value),name:`goalDescription`,autoComplete:`off`,className:i(N,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,M.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,M.jsxs)(`select`,{value:Ke,onChange:e=>qe(e.target.value),name:`goalPriority`,className:N,children:[(0,M.jsx)(`option`,{value:`low`,children:r.priorities.low}),(0,M.jsx)(`option`,{value:`normal`,children:r.priorities.normal}),(0,M.jsx)(`option`,{value:`high`,children:r.priorities.high})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,M.jsx)(`input`,{value:Je,onChange:e=>Ye(e.target.value),name:`goalDeadline`,className:N,type:`date`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,M.jsx)(`input`,{value:Xe,onChange:e=>Ze(e.target.value),name:`goalMaxTurns`,className:N,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,M.jsx)(`input`,{value:Qe,onChange:e=>$e(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:N,placeholder:`${r.judgeModel}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,M.jsx)(`textarea`,{value:et,onChange:e=>tt(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:i(N,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,M.jsx)(`textarea`,{value:nt,onChange:e=>rt(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:i(N,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,M.jsx)(D,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:G!=null||!He.trim(),children:r.saveDetails})]})]})]}),(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.workflowHint})]}),St.length?(0,M.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:F(r.activeCount,{count:St.length})}):null]}),ke.length?(0,M.jsx)(`div`,{className:`mt-3 grid gap-2`,children:ke.slice(0,2).map(e=>(0,M.jsxs)(`button`,{type:`button`,className:i(`min-w-0 rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2 text-left hover:border-accent/60 hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,U===e.definitionId&&`border-accent/70 bg-accent-soft/60`),onClick:()=>{it(e.definitionId),ot(k.nextAction||k.title)},children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,M.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,M.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,M.jsxs)(`select`,{value:U,onChange:e=>it(e.target.value),className:N,name:`workflowDefinition`,disabled:P.length===0,children:[P.length===0?(0,M.jsx)(`option`,{value:``,children:r.noWorkflows}):null,P.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,M.jsx)(`input`,{value:at,onChange:e=>ot(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:N,placeholder:`${r.workflowGoal}…`})]}),(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:G!=null||!U||k.status===`done`||k.status===`archived`,onClick:()=>void ft(),children:[(0,M.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),I.length?(0,M.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,M.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,M.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:()=>Tt(`workflow_run`),children:r.viewTimeline})]}),(0,M.jsx)(`ul`,{className:`grid gap-2`,children:I.slice(0,3).map(e=>{let a=e.metadata?.sessionKey,o=e.status===`queued`||e.status===`running`,s=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,M.jsxs)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,M.jsx)(`span`,{className:i(`shrink-0 rounded-full border px-2 py-0.5`,ge(e.status)),children:R(e.status,r)})]}),(0,M.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,M.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:L(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[a?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(a)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,o?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:G!=null,onClick:()=>void mt(e),children:[(0,M.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,s?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:G!=null,onClick:()=>void ht(e),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,bt.length?(0,M.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,M.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:F(r.failedCount,{count:bt.length})})]}),(0,M.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:bt.slice(0,3).map(e=>(0,M.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,R(e.status,r)]})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:G!=null,onClick:()=>void ht(e),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{z as GoalDetailPage};
|