@xopcai/xopc 0.0.119 → 0.0.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CU8J6zou.js → agent-avatar-dicebear-APTlX9Sq.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CFW_FS_V.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B9vfYoEr.js → app-management-settings-panel-DTKc5HHT.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-ClOzIO24.js → appearance-settings-BTciFrE9.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DU0dz9Zo.js → apps-page-DT52OrbM.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BkVIgZzA.js → archive-plugin-CiHaUMII.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CaCMWh1D.js → attachment-load-t4gSrNjL.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-DhGDpKP3.js → automation-suggestion-card-CtysjSoQ.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CTedroVo.js → automations-page-B2YvT3ES.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-B4TO_bsn.js → binary-plugins-BAbSldW5.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DJRWwWNI.js → block-editor-BNr_82xl.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-FCDwOOBK.js → browser-settings-page-BQEXPhDU.js} +3 -3
- package/dist/gateway/static/root/assets/{capability-presets-api-Befi89CL.js → capability-presets-api-tzD702Gg.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-_G8eb2vJ.js → capability-presets-settings-panel-AGhTueAc.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-BNSuJb5f.js → channel-recipient-api-DL_KzwGE.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-C3d5JBJX.js → channels-settings-DRTutLlN.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-yaUNvt5u.js → connectors-page-DneJVuge.js} +2 -2
- package/dist/gateway/static/root/assets/dreaming-settings-BEwWA1yf.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DYh402XV.js → extension-debug-page-Dl2kO0Sf.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Cr_TizrN.js → extension-page-DmbLPsx_.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BU1KoKRj.js → extension-settings-page-BS2rx40e.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-Y7AEX4H3.js → fetch-B3ME5Eri.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-RbMmAOpX.js → gateway-config-api-DI9_BBTo.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-C79wkXef.js → gateway-settings-DAFI_T0W.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DiD_Tx4N.js → gateway-startup-retry-CSZQTz6K.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DLuz4jC9.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-DqxVi0p5.js → goals-config-api-Bhzqrp2w.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-CS0R-Af2.js → goals-page-DTAfv9Ft.js} +2 -2
- package/dist/gateway/static/root/assets/{goals-settings-CSuzZ8Ae.js → goals-settings-CWN2iirQ.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DXPaYJm3.js → heartbeat-settings-CkkkHvOi.js} +1 -1
- package/dist/gateway/static/root/assets/index-CnjzMw5i.js +191 -0
- package/dist/gateway/static/root/assets/index-E1QinYKp.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Dvg53qnd.js → keyboard-shortcuts-settings-kMp08SlX.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DjbfSsfA.js → locale-store-Ba72bFmP.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DLXPcksQ.js → logs-page-CDXDlS_W.js} +2 -2
- package/dist/gateway/static/root/assets/{markdown-split-CpHxbtWJ.js → markdown-split-Bc0w40vz.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-SFPQRSxq.js → media-plugins-DJ_HvgIy.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CISb1HLv.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BTwxMIgZ.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-BBfOeB0m.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-BUYURRgn.js → note-image-lightbox-4zntqpZq.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BsIBSFyZ.js → notes-page-VocWOjoK.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BHz9iWYA.js → preview-open-alternatives-BbA7sRd_.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CXwjuD_Q.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-CefkOlRg.js → save-bar-controls-Dividh61.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CmTRoOcE.js → schedule-field-pRheF2CO.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-FMKv1vGu.js → schema-form-D6PiPxfr.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CpcVySQK.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BVy_TawT.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BouO6JTi.js → settings-collapsible-section-BMCOfuE_.js} +1 -1
- package/dist/gateway/static/root/assets/settings-form-section-DBkGwpIN.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-CZpNyCWn.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-BJ4Gsef5.js → settings-page-layout-NxoW5Y57.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-MVHLLu_a.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BDy2btRN.js → share-preview-page-B0suFCfj.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-B18OBmH5.js → shares-settings-C6DBbQGo.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-6hJmhwSn.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Bm2ebkwl.js → skills-page-Im1MA0Iw.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CRngrlnZ.js → system-settings-panel-CrmEnyX4.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-CD2wtgZV.js → theme-store-Bt6vAkSB.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-BltBc0b-.js → typed-models-lib-BAsGn25g.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CjN-51e6.js → use-channel-catalog-C7vcAoGb.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-DJ1dKwZy.js → user-profile-settings-panel-QAQWGelF.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-B5M5-YvK.js → utils-Dl9efgnV.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-CeEevm7z.js → voice-api-key-field-D-6XueTv.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-player-store-B7ykUlHM.js → voice-player-store-CMC5NOJp.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C4PzUQjB.js → workflow-run-setup-panel-DVPllR4k.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-BL84_-Ky.js → workflows-page-B94WISTW.js} +2 -2
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/context/workspace-templates/AGENTS.md +3 -2
- package/dist/src/agent/memory/builtin-memory-store.d.ts +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
- package/dist/src/agent/memory/builtin-provider.d.ts +2 -2
- package/dist/src/agent/memory/builtin-provider.js +2 -2
- package/dist/src/agent/memory/builtin-provider.js.map +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.d.ts +0 -7
- package/dist/src/agent/memory/dreaming/light-sweep.js +16 -277
- package/dist/src/agent/memory/dreaming/light-sweep.js.map +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js.map +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.d.ts +3 -3
- package/dist/src/agent/memory/dreaming/short-term-store.js +5 -5
- package/dist/src/agent/memory/dreaming/short-term-store.js.map +1 -1
- package/dist/src/agent/memory/dreaming/utils.d.ts +2 -2
- package/dist/src/agent/memory/dreaming/utils.js +2 -2
- package/dist/src/agent/memory/dreaming/utils.js.map +1 -1
- package/dist/src/agent/memory/index.d.ts +0 -2
- package/dist/src/agent/memory/index.js +1 -2
- package/dist/src/agent/prompt/sections/memory-skills.js +11 -10
- package/dist/src/agent/prompt/sections/memory-skills.js.map +1 -1
- package/dist/src/agent/prompt/sections/tooling.js +2 -2
- package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
- package/dist/src/agent/reply/startup-context.js +6 -105
- package/dist/src/agent/reply/startup-context.js.map +1 -1
- package/dist/src/agent/service.d.ts +0 -3
- package/dist/src/agent/service.js +0 -41
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/tools/memory-tool.js +2 -2
- package/dist/src/agent/tools/memory-tool.js.map +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/templates.js +3 -2
- package/dist/src/cli/templates.js.map +1 -1
- package/dist/src/config/schema.d.ts +2 -2
- package/dist/src/config/schema.js +2 -2
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +4 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/storage/sqlite/row-mappers.js +3 -1
- package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -2
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-B0hkpLhP.js +0 -2
- package/dist/gateway/static/root/assets/dreaming-settings-DNrdg1Ve.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-9paXuHdo.js +0 -1
- package/dist/gateway/static/root/assets/index-BoKafJIZ.js +0 -191
- package/dist/gateway/static/root/assets/index-CArhCcYn.css +0 -1
- package/dist/gateway/static/root/assets/messages-CrDHEbss.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-BDF2iyRk.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-CSb_hwig.js +0 -2
- package/dist/gateway/static/root/assets/remote-access-hub-CwzSovcS.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-PHmX-NmA.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BRAeKJN4.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-D-4lBl6X.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-KKrbFjy8.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CrUjHPQo.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C28-2uKQ.js +0 -1
- package/dist/src/agent/memory/memory-flush.d.ts +0 -27
- package/dist/src/agent/memory/memory-flush.js +0 -124
- package/dist/src/agent/memory/memory-flush.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-CrDHEbss.js";import{t as a}from"./locale-store-DjbfSsfA.js";import{Bi as o,Ia as s,Xn as c,Ya as l,Yn as u,ct as d,ta as f,ts as p}from"./index-BoKafJIZ.js";import{r as m,t as h}from"./settings-form-section-D-4lBl6X.js";import{n as g,t as _}from"./settings-page-layout-BJ4Gsef5.js";var v=e(t(),1),y=n();async function b(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function x(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function S(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function C(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function w(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var T=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function E(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||T.has(e)?t===`unknown`:!1}function D(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:T.has(e)?t===`denied`:!0}var O=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function k(e){return e===`linux`?O:O.filter(t=>!t.platforms||t.platforms.includes(e))}function A(e,t){let n=i(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function j(e,t,n){let r=i(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var M={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function N(){let e=a(e=>e.language),t=i(e).systemSettings,[n,T]=(0,v.useReducer)(d,M),{behavior:O,perms:N,loadError:P,permFeedback:F,permBusy:I,refreshing:L}=n,R=typeof window<`u`?window.electronAPI?.system:void 0,z=(0,v.useCallback)(async e=>{if(R){T({type:`patch`,patch:{loadError:null}});try{T({type:`patch`,patch:{behavior:await R.getBehavior(),perms:await R.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){T({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[R,t.refreshDone]),B=(0,v.useCallback)(async()=>{if(!(L||I)){T({type:`patch`,patch:{refreshing:!0}});try{await z({showRefreshFeedback:!0})}finally{T({type:`patch`,patch:{refreshing:!1}})}}},[z,I,L]);if((0,v.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!F||!e.has(F))return;let n=window.setTimeout(()=>{T({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[F,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,v.useEffect)(()=>{o()&&R&&z()},[R,z]),!o()||!R)return(0,y.jsxs)(_,{gap:`gap-3`,children:[(0,y.jsx)(g,{title:t.title}),(0,y.jsxs)(`div`,{className:m(),children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.desktopOnlyTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.desktopOnlyBody})]})]});let V=async e=>{try{let{behavior:t}=await R.setBehavior(e);T({type:`patch`,patch:{behavior:t}}),(e.notifyEnabled!==void 0||e.notifySoundEnabled!==void 0)&&u()}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},H=async e=>{if(!e){await V({notifyEnabled:!1});return}T({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await c(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){T({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){T({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e==="default"){T({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await V({notifyEnabled:!0}),T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}},U=async e=>{T({type:`patch`,patch:{permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{(await R.openPrivacy(e)).ok?T({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):T({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},W=async()=>{T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestMicrophone(),n=await b();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:x(e,n,t.permFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}},G=async()=>{if(R.requestAccessibility){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestAccessibility();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:S(e,t.accessibilityFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},K=async()=>{if(R.requestNotifications){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestNotifications();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:C(e,t.notificationsFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(R.requestScreen){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestScreen();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:w(e,t.screenFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},J=O?O.platform===`win32`?t.permissionsHintWin:O.platform===`linux`?t.permissionsHintLinux:O.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,y.jsxs)(_,{gap:`gap-6`,children:[(0,y.jsx)(g,{title:t.title}),P?(0,y.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:P}):null,F?(0,y.jsx)(`p`,{className:r(`text-sm`,F===t.refreshDone||F===t.openSettingsDone||F===t.permFeedback.granted||F===t.permFeedback.alreadyGranted||F===t.accessibilityFeedback.granted||F===t.accessibilityFeedback.alreadyGranted||F===t.notificationsFeedback.granted||F===t.notificationsFeedback.alreadyGranted||F===t.screenFeedback.granted||F===t.screenFeedback.alreadyGranted||F===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:F}):null,(0,y.jsxs)(h,{children:[(0,y.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,y.jsx)(s,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.openAtLogin}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.openAtLogin,onChange:e=>{V({openAtLogin:e.target.checked})}})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.keepAwake}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.keepAwakePreferred,onChange:e=>{V({keepAwakePreferred:e.target.checked})}})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifyDesktop}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O||I,checked:!!O?.notifyEnabled,onChange:e=>{H(e.target.checked)}})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifySound}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.notifySoundEnabled,onChange:e=>{V({notifySoundEnabled:e.target.checked})}})]})]})]}),O&&N?(0,y.jsxs)(`section`,{className:m(),children:[(0,y.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.permissionsTitle}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:J}),O.platform===`darwin`&&!O.packaged?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,y.jsxs)(`button`,{type:`button`,disabled:L||I,"aria-busy":L,className:r(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,f.press),onClick:()=>void B(),children:[(0,y.jsx)(l,{className:r(`size-3.5`,L&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),L?t.refreshing:t.refresh]})]}),(0,y.jsx)(`ul`,{className:`space-y-3`,children:k(O.platform).map(({key:n,pane:i})=>{let a=A(e,N[n]),o=t.perm[n],s=N[n]===`unknown`?j(e,n,O.platform):null;return o?(0,y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl border border-edge-subtle bg-surface-panel/60 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:o.title}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.desc}),(0,y.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),s?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:s}):null]}),(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[n===`notifications`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,f.press),onClick:()=>void K(),children:t.requestAccess}):null,n===`microphone`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,f.press),onClick:()=>void W(),children:t.requestAccess}):null,n===`accessibility`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,f.press),onClick:()=>void G(),children:t.requestAccess}):null,n===`screen`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,f.press),onClick:()=>void q(),children:t.requestAccess}):null,D(n,N[n],O.platform)?(0,y.jsxs)(`button`,{type:`button`,className:r(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,f.press),onClick:()=>void U(i),children:[t.openSettings,(0,y.jsx)(p,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}export{N as SystemSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-CISb1HLv.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Bi as o,Ia as s,Xn as c,Ya as l,Yn as u,ct as d,ta as f,ts as p}from"./index-CnjzMw5i.js";import{r as m,t as h}from"./settings-form-section-DBkGwpIN.js";import{n as g,t as _}from"./settings-page-layout-NxoW5Y57.js";var v=e(t(),1),y=n();async function b(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function x(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function S(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function C(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function w(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var T=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function E(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||T.has(e)?t===`unknown`:!1}function D(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:T.has(e)?t===`denied`:!0}var O=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function k(e){return e===`linux`?O:O.filter(t=>!t.platforms||t.platforms.includes(e))}function A(e,t){let n=i(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function j(e,t,n){let r=i(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var M={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function N(){let e=a(e=>e.language),t=i(e).systemSettings,[n,T]=(0,v.useReducer)(d,M),{behavior:O,perms:N,loadError:P,permFeedback:F,permBusy:I,refreshing:L}=n,R=typeof window<`u`?window.electronAPI?.system:void 0,z=(0,v.useCallback)(async e=>{if(R){T({type:`patch`,patch:{loadError:null}});try{T({type:`patch`,patch:{behavior:await R.getBehavior(),perms:await R.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){T({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[R,t.refreshDone]),B=(0,v.useCallback)(async()=>{if(!(L||I)){T({type:`patch`,patch:{refreshing:!0}});try{await z({showRefreshFeedback:!0})}finally{T({type:`patch`,patch:{refreshing:!1}})}}},[z,I,L]);if((0,v.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!F||!e.has(F))return;let n=window.setTimeout(()=>{T({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[F,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,v.useEffect)(()=>{o()&&R&&z()},[R,z]),!o()||!R)return(0,y.jsxs)(_,{gap:`gap-3`,children:[(0,y.jsx)(g,{title:t.title}),(0,y.jsxs)(`div`,{className:m(),children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.desktopOnlyTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.desktopOnlyBody})]})]});let V=async e=>{try{let{behavior:t}=await R.setBehavior(e);T({type:`patch`,patch:{behavior:t}}),(e.notifyEnabled!==void 0||e.notifySoundEnabled!==void 0)&&u()}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},H=async e=>{if(!e){await V({notifyEnabled:!1});return}T({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await c(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){T({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){T({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e==="default"){T({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await V({notifyEnabled:!0}),T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}},U=async e=>{T({type:`patch`,patch:{permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{(await R.openPrivacy(e)).ok?T({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):T({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},W=async()=>{T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestMicrophone(),n=await b();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:x(e,n,t.permFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}},G=async()=>{if(R.requestAccessibility){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestAccessibility();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:S(e,t.accessibilityFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},K=async()=>{if(R.requestNotifications){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestNotifications();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:C(e,t.notificationsFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(R.requestScreen){T({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),T({type:`patch`,patch:{loadError:null}});try{let e=await R.requestScreen();T({type:`patch`,patch:{perms:await R.getPermissions()}}),T({type:`patch`,patch:{permFeedback:w(e,t.screenFeedback)}})}catch(e){T({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{T({type:`patch`,patch:{permBusy:!1}})}}},J=O?O.platform===`win32`?t.permissionsHintWin:O.platform===`linux`?t.permissionsHintLinux:O.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,y.jsxs)(_,{gap:`gap-6`,children:[(0,y.jsx)(g,{title:t.title}),P?(0,y.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:P}):null,F?(0,y.jsx)(`p`,{className:r(`text-sm`,F===t.refreshDone||F===t.openSettingsDone||F===t.permFeedback.granted||F===t.permFeedback.alreadyGranted||F===t.accessibilityFeedback.granted||F===t.accessibilityFeedback.alreadyGranted||F===t.notificationsFeedback.granted||F===t.notificationsFeedback.alreadyGranted||F===t.screenFeedback.granted||F===t.screenFeedback.alreadyGranted||F===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:F}):null,(0,y.jsxs)(h,{children:[(0,y.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,y.jsx)(s,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.openAtLogin}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.openAtLogin,onChange:e=>{V({openAtLogin:e.target.checked})}})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.keepAwake}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.keepAwakePreferred,onChange:e=>{V({keepAwakePreferred:e.target.checked})}})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifyDesktop}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O||I,checked:!!O?.notifyEnabled,onChange:e=>{H(e.target.checked)}})]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.toggles.notifySound}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!O,checked:!!O?.notifySoundEnabled,onChange:e=>{V({notifySoundEnabled:e.target.checked})}})]})]})]}),O&&N?(0,y.jsxs)(`section`,{className:m(),children:[(0,y.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.permissionsTitle}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:J}),O.platform===`darwin`&&!O.packaged?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,y.jsxs)(`button`,{type:`button`,disabled:L||I,"aria-busy":L,className:r(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,f.press),onClick:()=>void B(),children:[(0,y.jsx)(l,{className:r(`size-3.5`,L&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),L?t.refreshing:t.refresh]})]}),(0,y.jsx)(`ul`,{className:`space-y-3`,children:k(O.platform).map(({key:n,pane:i})=>{let a=A(e,N[n]),o=t.perm[n],s=N[n]===`unknown`?j(e,n,O.platform):null;return o?(0,y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl border border-edge-subtle bg-surface-panel/60 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:o.title}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.desc}),(0,y.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),s?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:s}):null]}),(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[n===`notifications`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,f.press),onClick:()=>void K(),children:t.requestAccess}):null,n===`microphone`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,f.press),onClick:()=>void W(),children:t.requestAccess}):null,n===`accessibility`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,f.press),onClick:()=>void G(),children:t.requestAccess}):null,n===`screen`&&E(n,N[n],O.platform)?(0,y.jsx)(`button`,{type:`button`,disabled:I,className:r(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,f.press),onClick:()=>void q(),children:t.requestAccess}):null,D(n,N[n],O.platform)?(0,y.jsxs)(`button`,{type:`button`,className:r(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,f.press),onClick:()=>void U(i),children:[t.openSettings,(0,y.jsx)(p,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}export{N as SystemSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as e}from"./locale-store-Ba72bFmP.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#ffffff`,emerald:`#f0fdf4`,mono:`#ffffff`,clay:`#fffaf0`},dark:{default:`#0a0a0a`,emerald:`#000000`,mono:`#101010`,clay:`#0a1a1a`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e===`cal`?`mono`:e==="default"||e===`emerald`||e===`mono`||e===`clay`?e:n}function l(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function u(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}l(o(t),r,!1)}catch{l(o(`system`),`default`,!1)}}var d=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();l(r,a,r!==i),e({preference:n,resolved:r})},setColorScheme:n=>{let{resolved:r}=t();l(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function f(){let{preference:e,colorScheme:t}=d.getState(),n=o(e);l(n,t,!1),d.setState({resolved:n})}function p(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=d.getState();if(e!==`system`)return;let n=o(`system`),r=d.getState().resolved;l(n,t,n!==r),d.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{d as i,p as n,f as r,u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cn-BQ_8x0bT.js";import{aa as t,ia as n,oa as r}from"./index-
|
|
1
|
+
import{t as e}from"./cn-BQ_8x0bT.js";import{aa as t,ia as n,oa as r}from"./index-CnjzMw5i.js";function i(){return e(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,r,`dark:border-edge`)}function a(){return e(t,n)}var o=`h-auto shrink-0 px-2.5 py-1.5 text-xs font-medium`,s=/^[a-z][a-z0-9_-]{0,63}$/;function c(e){let t=e.trim(),n=t.indexOf(`/`);return n>0&&n<t.length-1}function l(e){let t=e&&typeof e==`object`&&!Array.isArray(e)&&`roles`in e?Object.entries(e.roles??{}).map(([e,t])=>({id:e,...t&&typeof t==`object`&&!Array.isArray(t)?t:{}})):e;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e,r=typeof t.id==`string`?t.id.trim():``,i=typeof t.model==`string`?t.model.trim():``;if(!r||!i)continue;let a=typeof t.description==`string`?t.description.trim():``,o=Array.isArray(t.fallbacks)?t.fallbacks.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean):[];n.push({id:r,model:i,fallbacks:o,description:a})}return n}function u(e,t){let n=new Set([t.toLowerCase()]),r=[];for(let t of e){let e=t.trim(),i=e.toLowerCase();!e||!c(e)||n.has(i)||(n.add(i),r.push(e))}return r}function d(e){let t=new Map;for(let n of e){let e=n.id.trim(),r=n.model.trim();if(!e||!s.test(e)||!r||!c(r))continue;let i=n.description.trim(),a=u(n.fallbacks??[],r);t.set(e,{model:r,...a.length>0?{fallbacks:a}:{},...i?{description:i}:{}})}return t.size===0?null:{roles:Object.fromEntries(t.entries())}}function f(e,t){let n=new Set;for(let r of e){let e=r.id.trim(),i=r.model.trim(),a=r.fallbacks??[];if(!(!e&&!i&&!r.description.trim()&&a.every(e=>!e.trim()))){if(!e||!s.test(e))return t.invalidId;if(n.has(e))return t.duplicateId;if(n.add(e),!i||!c(i)||a.some(e=>e.trim()&&!c(e)))return t.invalidModel}}return null}function p(e){return e.length===0?`—`:e.map(e=>`${e.id} -> ${e.model}${e.fallbacks?.length?` (+${e.fallbacks.length})`:``}`).join(`, `)}function m(e){return(e??[]).map(e=>({id:e.id,model:e.model,fallbacks:e.fallbacks??[],description:e.description?.trim()??``}))}export{f as a,a as c,m as i,p as n,o,l as r,i as s,d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./vendor-react-BOUWij0V.js";import{i as t,n}from"./fetch-
|
|
1
|
+
import{n as e}from"./vendor-react-BOUWij0V.js";import{i as t,n}from"./fetch-B3ME5Eri.js";import{i as r}from"./vendor-swr-BIWyz7Rc.js";var i=e();function a(e){return t(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function o(e){return(await n(a(e))).payload?.channels??[]}function s(e,t){let n=(0,i.c)(14),s;n[0]!==e||n[1]!==t?(s=e?a(t):null,n[0]=e,n[1]=t,n[2]=s):s=n[2];let c;n[3]===t?c=n[4]:(c=()=>o(t),n[3]=t,n[4]=c);let l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},n[5]=l):l=n[5];let{data:u,error:d,isLoading:f,isValidating:p,mutate:m}=r(s,c,l),h;n[6]===u?h=n[7]:(h=u??[],n[6]=u,n[7]=h);let g;return n[8]!==d||n[9]!==f||n[10]!==p||n[11]!==m||n[12]!==h?(g={entries:h,isLoading:f,isValidating:p,error:d,mutate:m},n[8]=d,n[9]=f,n[10]=p,n[11]=m,n[12]=h,n[13]=g):g=n[13],g}export{s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-CISb1HLv.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{En as o,Io as s,Ka as c,St as l,gt as u,sa as d,ta as f,vt as p,wt as m,xn as h,ys as g,yt as _}from"./index-CnjzMw5i.js";import{n as v,t as y}from"./settings-form-section-DBkGwpIN.js";import{n as b,t as x}from"./settings-page-layout-NxoW5Y57.js";import{t as S}from"./utils-Dl9efgnV.js";var C=e(t(),1),w=n(),T={callName:``,pronouns:``,timezone:``,notes:``};function E(e){if(e.timezone)return e;let t=_();return t?{...e,timezone:t}:e}function D(){let e=a(e=>e.language),t=i(e).userProfileSettings,n=S(),[D,O]=(0,C.useState)(T),[k,A]=(0,C.useState)(JSON.stringify(T)),[j,M]=(0,C.useState)(``),[N,P]=(0,C.useState)(!1),[F,I]=(0,C.useState)(!1),[L,R]=(0,C.useState)(!0),[z,B]=(0,C.useState)(!1),[V,H]=(0,C.useState)(!1),[U,W]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return R(!0),W(null),h().then(t=>{if(e)return;let n=E(l(t)),r=p.some(e=>e.value===n.timezone),i=!n.pronouns||u.some(e=>e.value===n.pronouns);O(n),A(JSON.stringify(n)),P(!!(n.timezone&&!r)),M(n.timezone&&!r?n.timezone:``),I(!!(n.pronouns&&!i))}).catch(n=>{e||W(n instanceof Error?n.message:t.loadError)}).finally(()=>{e||R(!1)}),()=>{e=!0}},[t.loadError]);let G=JSON.stringify(D)!==k,K=(0,C.useCallback)((t,n)=>e===`zh`?n:t,[e]),q=(0,C.useCallback)(e=>{O(t=>({...t,...e})),H(!1)},[]),J=(0,C.useMemo)(()=>N?`__custom__`:p.some(e=>e.value===D.timezone)?D.timezone:`__custom__`,[N,D.timezone]),Y=(0,C.useCallback)(e=>{if(e===`__custom__`){P(!0);return}P(!1),M(``),q({timezone:e})},[q]),X=(0,C.useCallback)(()=>{let e=_();if(!e)return;let t=p.some(t=>t.value===e);P(!t),M(t?``:e),q({timezone:e})},[q]);async function Z(){B(!0),W(null);try{await o(m(D)),A(JSON.stringify(D)),H(!0)}catch(e){W(e instanceof Error?e.message:t.saveError)}finally{B(!1)}}return(0,w.jsxs)(x,{gap:`gap-6`,children:[(0,w.jsx)(b,{title:t.title,subtitle:t.subtitle,actions:(0,w.jsxs)(d,{type:`button`,variant:`primary`,disabled:L||z||!G,onClick:()=>void Z(),children:[(0,w.jsx)(c,{className:`size-4`,"aria-hidden":!0}),z?t.saving:V?t.saved:t.save]})}),(0,w.jsxs)(y,{children:[(0,w.jsx)(v,{icon:g,title:t.sectionTitle,subtitle:t.sectionSubtitle}),L?(0,w.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):(0,w.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,w.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,w.jsx)(`span`,{className:`font-medium text-fg`,children:t.callName}),(0,w.jsx)(`input`,{className:n,value:D.callName,onChange:e=>q({callName:e.target.value}),placeholder:t.callNamePlaceholder,autoComplete:`off`})]}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,w.jsx)(`span`,{className:`font-medium text-fg`,children:t.pronouns}),(0,w.jsxs)(`select`,{className:n,value:u.some(e=>e.value===D.pronouns)?D.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){I(!0);return}I(!1),q({pronouns:e.target.value})},children:[(0,w.jsx)(`option`,{value:``,disabled:!0,children:t.pronounsPlaceholder}),u.map(e=>(0,w.jsx)(`option`,{value:e.value,children:K(e.labelEn,e.labelZh)},e.value)),(0,w.jsx)(`option`,{value:`__custom__`,children:t.custom})]}),F?(0,w.jsx)(`input`,{className:r(n,`mt-1 text-xs`),value:u.some(e=>e.value===D.pronouns)?``:D.pronouns,onChange:e=>q({pronouns:e.target.value}),placeholder:t.pronounsPlaceholder,autoComplete:`off`}):null]}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,w.jsx)(`span`,{className:`font-medium text-fg`,children:t.timezone}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,w.jsxs)(`select`,{className:r(n,`min-w-0 flex-1`),value:J,onChange:e=>Y(e.target.value),children:[p.map(e=>(0,w.jsx)(`option`,{value:e.value,children:K(e.labelEn,e.labelZh)},e.value)),(0,w.jsx)(`option`,{value:`__custom__`,children:t.timezoneCustom})]}),(0,w.jsx)(`button`,{type:`button`,className:r(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,f.press),onClick:X,children:t.timezoneDetect})]}),N?(0,w.jsx)(`input`,{className:r(n,`mt-1 font-mono text-xs`),value:j,onChange:e=>{M(e.target.value),q({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,w.jsx)(`span`,{className:`font-medium text-fg`,children:t.notes}),(0,w.jsx)(`textarea`,{className:r(n,`min-h-28 resize-y text-sm leading-relaxed`),value:D.notes,onChange:e=>q({notes:e.target.value}),placeholder:t.notesPlaceholder,rows:5,spellCheck:!0})]})]}),(0,w.jsxs)(`div`,{className:`mt-4 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,w.jsx)(s,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,w.jsx)(`span`,{children:t.note})]}),U?(0,w.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:U}):null]})]})}export{D as UserProfileSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cn-BQ_8x0bT.js";import{oa as t}from"./index-
|
|
1
|
+
import{t as e}from"./cn-BQ_8x0bT.js";import{oa as t}from"./index-CnjzMw5i.js";function n(){return e(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,t,`dark:border-edge`)}function r(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function i(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}export{i as n,r,n 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-BQ_8x0bT.js";import{c as a,i as o,n as s}from"./fetch-Y7AEX4H3.js";import{o as c}from"./vendor-swr-BIWyz7Rc.js";import{At as l,Dt as u,Et as d,Ka as f,Ks as p,So as m,Xi as h,ks as g,ni as _,oa as v,sa as y,ti as b,ts as x}from"./index-BoKafJIZ.js";var S=`/api/image/providers`;async function C(){return(await s(o(`/api/image/providers`)))?.payload?.providers??[]}var w=e(t(),1),ee=n();function T(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function te(e){return e?.apiKey?`••••••••••••`:``}function E(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:te(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function D(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function O(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(l(n)&&l(r)))return n||(r?null:void 0)}function k(e,t,n){let r={};for(let i of e){let e=t[i]??T(),a=n[i]??T();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=O(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=D(e,a,`region`);c!==void 0&&(o.region=c);let l=D(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=D(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function A(e){let t=await s(o(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function j(e){Object.keys(e).length!==0&&(await s(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await b())}var M=r();function ne(e){let t=(0,ee.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>A(n).then(N),t[0]=n,t[1]=c);let l=c,d=`img-cred-key-${n}`,f;t[2]!==a.apiKeyLabel||t[3]!==d?(f=(0,M.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:d,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=d,t[4]=f):f=t[4];let p;t[5]!==s||t[6]!==o?(p=o.length>0?(0,M.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,M.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u(e.kind,s),(0,M.jsx)(x,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=p):p=t[7];let m=`img-cred-key-${n}`,g;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==m||t[12]!==r?(g=(0,M.jsx)(h,{id:m,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=m,t[12]=r,t[13]=g):g=t[13];let _;return t[14]!==f||t[15]!==p||t[16]!==g?(_=(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[f,p,g]}),t[14]=f,t[15]=p,t[16]=g,t[17]=_):_=t[17],_}function N(e){return e.apiKey??null}function P(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,v)}function re(){return i(P(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var F=`__custom__`;function ie(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:F}function ae(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:F}function oe(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function se(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function ce(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function le(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function ue(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function I(e){let t=(0,ee.c)(76),{summaries:n,credDraft:r,credBaseline:a,credDirty:o,credSaving:s,credError:c,credSavedFlash:l,credNoopFlash:u,updateCredRow:h,onDiscardCredentials:_,onSaveCredentials:v,extensionIds:b,showExtensionLinks:S,showImageModelsLink:C,hideActions:te,language:E,apiKeyLinkLabels:D,messages:O}=e,k=te===void 0?!1:te,A;t[0]===n?A=t[1]:(A=n.some(he),t[0]=n,t[1]=A);let j=A,N;t[2]===n?N=t[3]:(N=n.some(me),t[2]=n,t[3]=N);let I=N,[ge,_e]=(0,w.useState)(pe),[ve,L]=(0,w.useState)(fe),R;if(t[4]!==a||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)le(r[e.id]??T(),a[e.id]??T())&&R.add(e.id);t[4]=a,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==ve||t[10]!==ge?(B=e=>ve.has(e)?!1:ge.has(e)?!0:z.has(e),t[8]=z,t[9]=ve,t[10]=ge,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),_e(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),_e(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===O.credentialsIntro?W=t[15]:(W=(0,M.jsx)(`p`,{children:O.credentialsIntro}),t[14]=O.credentialsIntro,t[15]=W);let G;t[16]!==j||t[17]!==O.regionHint?(G=j?(0,M.jsx)(`p`,{className:`text-fg-subtle`,children:O.regionHint}):null,t[16]=j,t[17]=O.regionHint,t[18]=G):G=t[18];let K;t[19]!==I||t[20]!==O.endpointPresetsHint?(K=I?(0,M.jsx)(`p`,{className:`text-fg-subtle`,children:O.endpointPresetsHint}):null,t[19]=I,t[20]=O.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==C||t[23]!==O.imageModelsLinkTitle||t[24]!==O.openImageModelsPage?(q=C?(0,M.jsx)(`p`,{children:(0,M.jsx)(p,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:O.imageModelsLinkTitle,children:O.openImageModelsPage})}):null,t[22]=C,t[23]=O.imageModelsLinkTitle,t[24]=O.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===c?Y=t[32]:(Y=c?(0,M.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:c}):null,t[31]=c,t[32]=Y);let X;t[33]!==o||t[34]!==u||t[35]!==l||t[36]!==s||t[37]!==k||t[38]!==_||t[39]!==v||t[40]!==O.credentialsNothingToSave||t[41]!==O.credentialsSaved||t[42]!==O.discardCredentials||t[43]!==O.saveCredentials||t[44]!==O.savingCredentials?(X=k?null:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[l?(0,M.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsSaved}):null,u?(0,M.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsNothingToSave}):null,(0,M.jsx)(y,{type:`button`,variant:`secondary`,onClick:_,disabled:!o||s,children:O.discardCredentials}),(0,M.jsx)(y,{type:`button`,variant:`primary`,onClick:v,disabled:!o||s,children:s?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(m,{className:`size-3.5 animate-spin`}),(0,M.jsx)(`span`,{className:`ml-1.5`,children:O.savingCredentials})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(f,{className:`size-3.5`}),(0,M.jsx)(`span`,{className:`ml-1.5`,children:O.saveCredentials})]})})]}),t[33]=o,t[34]=u,t[35]=l,t[36]=s,t[37]=k,t[38]=_,t[39]=v,t[40]=O.credentialsNothingToSave,t[41]=O.credentialsSaved,t[42]=O.discardCredentials,t[43]=O.saveCredentials,t[44]=O.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==D||t[47]!==a||t[48]!==r||t[49]!==b||t[50]!==V||t[51]!==E||t[52]!==S||t[53]!==n||t[54]!==O||t[55]!==U||t[56]!==h){let e;t[58]!==D||t[59]!==a||t[60]!==r||t[61]!==b||t[62]!==V||t[63]!==E||t[64]!==S||t[65]!==O||t[66]!==U||t[67]!==h?(e=e=>{let t=r[e.id]??T(),n=e.ui,o=S&&b.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,s=le(t,a[e.id]??T()),c=V(e.id),l=e.label??e.id,u=ue(O,e.models.length);return(0,M.jsxs)(`section`,{className:i(`overflow-hidden rounded-xl border bg-surface-panel shadow-sm transition-colors dark:shadow-none`,s?`border-accent/50`:`border-edge`),children:[(0,M.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":c,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:l}),(0,M.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),s?(0,M.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.unsavedChanges}):null,e.configured?(0,M.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.configured}):(0,M.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:O.missingKey})]}),(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,M.jsx)(`span`,{children:u}),e.defaultModel?(0,M.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,M.jsxs)(`span`,{className:`text-fg-muted`,children:[O.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,M.jsx)(g,{className:i(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,c?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`sr-only`,children:c?O.collapseProvider:O.expandProvider})]}),c?(0,M.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`border-t border-edge px-4 py-4`,children:[o?(0,M.jsxs)(p,{to:o,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:O.extensionSettingsLinkTitle,children:[(0,M.jsx)(x,{className:`size-3`}),O.openExtensionSettings]}):null,e.models.length>0?(0,M.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,M.jsxs)(`span`,{className:`text-fg-muted`,children:[O.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsx)(ne,{providerId:e.id,value:t.apiKey,onChange:t=>h(e.id,{apiKey:t}),apiKeyLinks:d(e.id,E),apiKeyLinkLabels:D,labels:{apiKeyLabel:O.apiKeyLabel,optionalPlaceholder:O.optionalPlaceholder,maskedHelp:O.apiKeyMaskedHelp,copy:O.apiKeyCopy,copied:O.apiKeyCopied,show:O.apiKeyShow,hide:O.apiKeyHide,notInConfigFile:O.apiKeyNotInConfigFile,loadFailed:O.apiKeyRevealFailed}}),n?.regions?.length?(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,M.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:O.regionLabel}),(0,M.jsxs)(`select`,{id:`img-cred-region-preset-${e.id}`,className:re(),value:ie(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){h(e.id,{region:``,imageBaseUrl:``});return}if(r===F){h(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&h(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,M.jsx)(`option`,{value:``,children:O.regionPresetDefault}),n.regions.map(e=>(0,M.jsx)(`option`,{value:e.value,children:oe(O,e.value,e.label)},e.value)),(0,M.jsx)(`option`,{value:F,children:O.regionPresetCustom})]}),ie(t,n.regions)===F?(0,M.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,M.jsx)(`input`,{type:`text`,className:P(),value:t.region,placeholder:`region`,onChange:t=>h(e.id,{region:t.target.value})}),(0,M.jsx)(`input`,{type:`url`,className:P(),value:t.imageBaseUrl,placeholder:O.imageBaseUrlLabel,onChange:t=>h(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,M.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:se(O,n.baseUrlPresetKind)}),ce(O,n.baseUrlPresetKind)?(0,M.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:ce(O,n.baseUrlPresetKind)}):null,(0,M.jsxs)(`select`,{id:`img-cred-base-preset-${e.id}`,className:re(),value:ae(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){h(e.id,{baseUrl:``});return}if(n===F){h(e.id,{baseUrl:``});return}h(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,M.jsx)(`option`,{value:``,children:O.baseUrlPresetDefault}),n.baseUrlPresets.map(de),(0,M.jsx)(`option`,{value:F,children:O.baseUrlPresetCustom})]}),ae(t,n.baseUrlPresets)===F?(0,M.jsx)(`input`,{type:`url`,className:i(P(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>h(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&ie(t,n.regions)!==F?(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,M.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:O.imageBaseUrlLabel}),(0,M.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:i(P(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:O.imageBaseUrlPresetHint}),(0,M.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:O.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=D,t[59]=a,t[60]=r,t[61]=b,t[62]=V,t[63]=E,t[64]=S,t[65]=O,t[66]=U,t[67]=h,t[68]=e):e=t[68],Z=n.map(e),t[46]=D,t[47]=a,t[48]=r,t[49]=b,t[50]=V,t[51]=E,t[52]=S,t[53]=n,t[54]=O,t[55]=U,t[56]=h,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,M.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function de(e){return(0,M.jsx)(`option`,{value:e.value,children:e.label},e.value)}function fe(){return new Set}function pe(){return new Set}function me(e){return(e.ui?.baseUrlPresets?.length??0)>0}function he(e){return(e.ui?.regions?.length??0)>0}function ge(e){let t=_(a(e=>!!e.token)),n=t.data,r=(0,w.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,w.useRef)(!1),[s,l]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(!1),[g,v]=(0,w.useState)(!1),y=(0,w.useMemo)(()=>E(n?.payload?.config,r),[n?.payload?.config,r]),b=s??y,x=y;return{gwSwr:t,credDraft:b,credBaseline:x,credDirty:(0,w.useMemo)(()=>JSON.stringify(b)!==JSON.stringify(x),[b,x]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,w.useCallback)((e,t)=>{i.current=!0,l(n=>{let r=n??y,i=r[e]??T();return{...r,[e]:{...i,...t}}})},[y]),onDiscardCredentials:(0,w.useCallback)(()=>{i.current=!1,l(null),p(null),h(!1),v(!1)},[]),saveCredentials:(0,w.useCallback)(async e=>{let n=k(r,b,x);if(Object.keys(n).length===0){v(!0),window.setTimeout(()=>v(!1),2200);return}d(!0),p(null),h(!1);try{await j(n),await t.mutate?.(),c(o(S)),i.current=!1,l(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,b,x,t])}}function _e(){return{enabled:!1,provider:`alibaba`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},fallback:{enabled:!0,order:[`alibaba`,`openai`]}}}function ve(){return{enabled:!1,provider:`edge`,trigger:`always`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`en-US-MichelleNeural`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`alibaba`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=_e();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!0,order:[`alibaba`,`openai`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=ve();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`always`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{};return{stt:B(t.stt),tts:H(t.tts)}}async function K(){return G((await s(o(`/api/config`))).payload?.config??{})}async function q(e){await s(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts)})}),b()}async function J(){let e=await s(o(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await s(o(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await s(o(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(e){let t=await s(o(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Q(e){let t=await s(o(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function $(e){let t=(0,ee.c)(15),{kind:n,providerId:r,fieldId:a,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Q({kind:n,provider:r}).then(ye),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=i(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let g;t[5]!==a||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(g=(0,M.jsx)(h,{id:a,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=g):g=t[11];let _;return t[12]!==m||t[13]!==g?(_=(0,M.jsx)(`div`,{className:m,children:g}),t[12]=m,t[13]=g,t[14]=_):_=t[14],_}function ye(e){return e.apiKey??null}export{X as a,Z as c,C as d,S as f,K as i,ge as l,J as n,G as o,Y as r,q as s,$ as t,I as u};
|
|
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-BQ_8x0bT.js";import{c as a,i as o,n as s}from"./fetch-B3ME5Eri.js";import{o as c}from"./vendor-swr-BIWyz7Rc.js";import{At as l,Dt as u,Et as d,Ka as f,So as p,Xi as m,ks as h,ni as g,oa as _,qs as v,sa as y,ti as b,ts as x}from"./index-CnjzMw5i.js";var S=`/api/image/providers`;async function C(){return(await s(o(`/api/image/providers`)))?.payload?.providers??[]}var w=e(t(),1),ee=n();function T(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function te(e){return e?.apiKey?`••••••••••••`:``}function E(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:te(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function D(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function O(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(l(n)&&l(r)))return n||(r?null:void 0)}function k(e,t,n){let r={};for(let i of e){let e=t[i]??T(),a=n[i]??T();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=O(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=D(e,a,`region`);c!==void 0&&(o.region=c);let l=D(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=D(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function A(e){let t=await s(o(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function j(e){Object.keys(e).length!==0&&(await s(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await b())}var M=r();function ne(e){let t=(0,ee.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>A(n).then(N),t[0]=n,t[1]=c);let l=c,d=`img-cred-key-${n}`,f;t[2]!==a.apiKeyLabel||t[3]!==d?(f=(0,M.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:d,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=d,t[4]=f):f=t[4];let p;t[5]!==s||t[6]!==o?(p=o.length>0?(0,M.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,M.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u(e.kind,s),(0,M.jsx)(x,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=p):p=t[7];let h=`img-cred-key-${n}`,g;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==h||t[12]!==r?(g=(0,M.jsx)(m,{id:h,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=h,t[12]=r,t[13]=g):g=t[13];let _;return t[14]!==f||t[15]!==p||t[16]!==g?(_=(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[f,p,g]}),t[14]=f,t[15]=p,t[16]=g,t[17]=_):_=t[17],_}function N(e){return e.apiKey??null}function P(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_)}function re(){return i(P(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var F=`__custom__`;function ie(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:F}function ae(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:F}function oe(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function se(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function ce(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function le(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function ue(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function I(e){let t=(0,ee.c)(76),{summaries:n,credDraft:r,credBaseline:a,credDirty:o,credSaving:s,credError:c,credSavedFlash:l,credNoopFlash:u,updateCredRow:m,onDiscardCredentials:g,onSaveCredentials:_,extensionIds:b,showExtensionLinks:S,showImageModelsLink:C,hideActions:te,language:E,apiKeyLinkLabels:D,messages:O}=e,k=te===void 0?!1:te,A;t[0]===n?A=t[1]:(A=n.some(he),t[0]=n,t[1]=A);let j=A,N;t[2]===n?N=t[3]:(N=n.some(me),t[2]=n,t[3]=N);let I=N,[ge,_e]=(0,w.useState)(pe),[ve,L]=(0,w.useState)(fe),R;if(t[4]!==a||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)le(r[e.id]??T(),a[e.id]??T())&&R.add(e.id);t[4]=a,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==ve||t[10]!==ge?(B=e=>ve.has(e)?!1:ge.has(e)?!0:z.has(e),t[8]=z,t[9]=ve,t[10]=ge,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),_e(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),_e(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===O.credentialsIntro?W=t[15]:(W=(0,M.jsx)(`p`,{children:O.credentialsIntro}),t[14]=O.credentialsIntro,t[15]=W);let G;t[16]!==j||t[17]!==O.regionHint?(G=j?(0,M.jsx)(`p`,{className:`text-fg-subtle`,children:O.regionHint}):null,t[16]=j,t[17]=O.regionHint,t[18]=G):G=t[18];let K;t[19]!==I||t[20]!==O.endpointPresetsHint?(K=I?(0,M.jsx)(`p`,{className:`text-fg-subtle`,children:O.endpointPresetsHint}):null,t[19]=I,t[20]=O.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==C||t[23]!==O.imageModelsLinkTitle||t[24]!==O.openImageModelsPage?(q=C?(0,M.jsx)(`p`,{children:(0,M.jsx)(v,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:O.imageModelsLinkTitle,children:O.openImageModelsPage})}):null,t[22]=C,t[23]=O.imageModelsLinkTitle,t[24]=O.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===c?Y=t[32]:(Y=c?(0,M.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:c}):null,t[31]=c,t[32]=Y);let X;t[33]!==o||t[34]!==u||t[35]!==l||t[36]!==s||t[37]!==k||t[38]!==g||t[39]!==_||t[40]!==O.credentialsNothingToSave||t[41]!==O.credentialsSaved||t[42]!==O.discardCredentials||t[43]!==O.saveCredentials||t[44]!==O.savingCredentials?(X=k?null:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[l?(0,M.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsSaved}):null,u?(0,M.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsNothingToSave}):null,(0,M.jsx)(y,{type:`button`,variant:`secondary`,onClick:g,disabled:!o||s,children:O.discardCredentials}),(0,M.jsx)(y,{type:`button`,variant:`primary`,onClick:_,disabled:!o||s,children:s?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(p,{className:`size-3.5 animate-spin`}),(0,M.jsx)(`span`,{className:`ml-1.5`,children:O.savingCredentials})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(f,{className:`size-3.5`}),(0,M.jsx)(`span`,{className:`ml-1.5`,children:O.saveCredentials})]})})]}),t[33]=o,t[34]=u,t[35]=l,t[36]=s,t[37]=k,t[38]=g,t[39]=_,t[40]=O.credentialsNothingToSave,t[41]=O.credentialsSaved,t[42]=O.discardCredentials,t[43]=O.saveCredentials,t[44]=O.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==D||t[47]!==a||t[48]!==r||t[49]!==b||t[50]!==V||t[51]!==E||t[52]!==S||t[53]!==n||t[54]!==O||t[55]!==U||t[56]!==m){let e;t[58]!==D||t[59]!==a||t[60]!==r||t[61]!==b||t[62]!==V||t[63]!==E||t[64]!==S||t[65]!==O||t[66]!==U||t[67]!==m?(e=e=>{let t=r[e.id]??T(),n=e.ui,o=S&&b.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,s=le(t,a[e.id]??T()),c=V(e.id),l=e.label??e.id,u=ue(O,e.models.length);return(0,M.jsxs)(`section`,{className:i(`overflow-hidden rounded-xl border bg-surface-panel shadow-sm transition-colors dark:shadow-none`,s?`border-accent/50`:`border-edge`),children:[(0,M.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":c,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:l}),(0,M.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),s?(0,M.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.unsavedChanges}):null,e.configured?(0,M.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.configured}):(0,M.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:O.missingKey})]}),(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,M.jsx)(`span`,{children:u}),e.defaultModel?(0,M.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,M.jsxs)(`span`,{className:`text-fg-muted`,children:[O.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,M.jsx)(h,{className:i(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,c?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`sr-only`,children:c?O.collapseProvider:O.expandProvider})]}),c?(0,M.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`border-t border-edge px-4 py-4`,children:[o?(0,M.jsxs)(v,{to:o,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:O.extensionSettingsLinkTitle,children:[(0,M.jsx)(x,{className:`size-3`}),O.openExtensionSettings]}):null,e.models.length>0?(0,M.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,M.jsxs)(`span`,{className:`text-fg-muted`,children:[O.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsx)(ne,{providerId:e.id,value:t.apiKey,onChange:t=>m(e.id,{apiKey:t}),apiKeyLinks:d(e.id,E),apiKeyLinkLabels:D,labels:{apiKeyLabel:O.apiKeyLabel,optionalPlaceholder:O.optionalPlaceholder,maskedHelp:O.apiKeyMaskedHelp,copy:O.apiKeyCopy,copied:O.apiKeyCopied,show:O.apiKeyShow,hide:O.apiKeyHide,notInConfigFile:O.apiKeyNotInConfigFile,loadFailed:O.apiKeyRevealFailed}}),n?.regions?.length?(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,M.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:O.regionLabel}),(0,M.jsxs)(`select`,{id:`img-cred-region-preset-${e.id}`,className:re(),value:ie(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){m(e.id,{region:``,imageBaseUrl:``});return}if(r===F){m(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&m(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,M.jsx)(`option`,{value:``,children:O.regionPresetDefault}),n.regions.map(e=>(0,M.jsx)(`option`,{value:e.value,children:oe(O,e.value,e.label)},e.value)),(0,M.jsx)(`option`,{value:F,children:O.regionPresetCustom})]}),ie(t,n.regions)===F?(0,M.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,M.jsx)(`input`,{type:`text`,className:P(),value:t.region,placeholder:`region`,onChange:t=>m(e.id,{region:t.target.value})}),(0,M.jsx)(`input`,{type:`url`,className:P(),value:t.imageBaseUrl,placeholder:O.imageBaseUrlLabel,onChange:t=>m(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,M.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:se(O,n.baseUrlPresetKind)}),ce(O,n.baseUrlPresetKind)?(0,M.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:ce(O,n.baseUrlPresetKind)}):null,(0,M.jsxs)(`select`,{id:`img-cred-base-preset-${e.id}`,className:re(),value:ae(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){m(e.id,{baseUrl:``});return}if(n===F){m(e.id,{baseUrl:``});return}m(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,M.jsx)(`option`,{value:``,children:O.baseUrlPresetDefault}),n.baseUrlPresets.map(de),(0,M.jsx)(`option`,{value:F,children:O.baseUrlPresetCustom})]}),ae(t,n.baseUrlPresets)===F?(0,M.jsx)(`input`,{type:`url`,className:i(P(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>m(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&ie(t,n.regions)!==F?(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,M.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:O.imageBaseUrlLabel}),(0,M.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:i(P(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:O.imageBaseUrlPresetHint}),(0,M.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:O.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=D,t[59]=a,t[60]=r,t[61]=b,t[62]=V,t[63]=E,t[64]=S,t[65]=O,t[66]=U,t[67]=m,t[68]=e):e=t[68],Z=n.map(e),t[46]=D,t[47]=a,t[48]=r,t[49]=b,t[50]=V,t[51]=E,t[52]=S,t[53]=n,t[54]=O,t[55]=U,t[56]=m,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,M.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function de(e){return(0,M.jsx)(`option`,{value:e.value,children:e.label},e.value)}function fe(){return new Set}function pe(){return new Set}function me(e){return(e.ui?.baseUrlPresets?.length??0)>0}function he(e){return(e.ui?.regions?.length??0)>0}function ge(e){let t=g(a(e=>!!e.token)),n=t.data,r=(0,w.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,w.useRef)(!1),[s,l]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(!1),[_,v]=(0,w.useState)(!1),y=(0,w.useMemo)(()=>E(n?.payload?.config,r),[n?.payload?.config,r]),b=s??y,x=y;return{gwSwr:t,credDraft:b,credBaseline:x,credDirty:(0,w.useMemo)(()=>JSON.stringify(b)!==JSON.stringify(x),[b,x]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:_,updateCredRow:(0,w.useCallback)((e,t)=>{i.current=!0,l(n=>{let r=n??y,i=r[e]??T();return{...r,[e]:{...i,...t}}})},[y]),onDiscardCredentials:(0,w.useCallback)(()=>{i.current=!1,l(null),p(null),h(!1),v(!1)},[]),saveCredentials:(0,w.useCallback)(async e=>{let n=k(r,b,x);if(Object.keys(n).length===0){v(!0),window.setTimeout(()=>v(!1),2200);return}d(!0),p(null),h(!1);try{await j(n),await t.mutate?.(),c(o(S)),i.current=!1,l(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,b,x,t])}}function _e(){return{enabled:!1,provider:`alibaba`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},fallback:{enabled:!0,order:[`alibaba`,`openai`]}}}function ve(){return{enabled:!1,provider:`edge`,trigger:`always`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`en-US-MichelleNeural`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`alibaba`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=_e();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!0,order:[`alibaba`,`openai`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=ve();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`always`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{};return{stt:B(t.stt),tts:H(t.tts)}}async function K(){return G((await s(o(`/api/config`))).payload?.config??{})}async function q(e){await s(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts)})}),b()}async function J(){let e=await s(o(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await s(o(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await s(o(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(e){let t=await s(o(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Q(e){let t=await s(o(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function $(e){let t=(0,ee.c)(15),{kind:n,providerId:r,fieldId:a,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Q({kind:n,provider:r}).then(ye),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,h;t[3]===u?h=t[4]:(h=i(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=h);let g;t[5]!==a||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(g=(0,M.jsx)(m,{id:a,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=g):g=t[11];let _;return t[12]!==h||t[13]!==g?(_=(0,M.jsx)(`div`,{className:h,children:g}),t[12]=h,t[13]=g,t[14]=_):_=t[14],_}function ye(e){return e.apiKey??null}export{X as a,Z as c,C as d,S as f,K as i,ge as l,J as n,G as o,Y as r,q as s,$ as t,I as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as e}from"./locale-store-Ba72bFmP.js";import{an as t,on as n}from"./index-CnjzMw5i.js";var r={noteId:null,attachmentId:null,playing:!1,currentTime:0,duration:0,loading:!1},i=null,a=null,o=null,s=null;function c(){return i||(i=new Audio,i.addEventListener(`timeupdate`,()=>{u.setState({currentTime:i.currentTime})}),i.addEventListener(`loadedmetadata`,()=>{let e=i.duration;Number.isFinite(e)&&u.setState({duration:e})}),i.addEventListener(`ended`,()=>{u.setState({playing:!1,currentTime:0}),i.currentTime=0}),i.addEventListener(`pause`,()=>{u.setState({playing:!1})}),i.addEventListener(`play`,()=>{u.setState({playing:!0})})),i}function l(){o&&s&&n(o,s),a=null,o=null,s=null}var u=e()((e,n)=>({...r,play:async(r,i,u)=>{let d=c(),f=n();if(f.noteId===r&&f.attachmentId===i&&a){d.play();return}d.pause(),l(),e({noteId:r,attachmentId:i,playing:!1,currentTime:0,duration:u??0,loading:!0});try{let n=await t(r,i);a=n,o=r,s=i,d.src=n,await d.play(),e({loading:!1})}catch{e({loading:!1,playing:!1}),l()}},pause:()=>{c().pause()},toggle:(e,t,r)=>{let i=n();i.noteId===e&&i.attachmentId===t&&i.playing?n().pause():n().play(e,t,r)},seek:t=>{let n=c();n.currentTime=t,e({currentTime:t})},reset:()=>{c().pause(),c().src=``,l(),e(r)}}));export{u as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
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-BQ_8x0bT.js";import{t as a}from"./messages-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CISb1HLv.js";import{i as o,t as s}from"./fetch-B3ME5Eri.js";import{F as c,Fa as l,Mi as u,Na as d,Ni as f,No as p,Oi as m,P as h,Pi as g,Ya as _,b as v,br as y,es as b,ja as x,ji as S,k as C,ki as w,ks as T,la as E,m as D,ma as O,sa as k,wa as A}from"./index-CnjzMw5i.js";var j=e(t(),1),M=n();function N(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function P(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function F(e,t={}){let n=N(e.split(`
|
|
2
2
|
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
|
|
3
3
|
`));if(!n)return null;if(n.type===`text_delta`&&typeof n.delta==`string`)return t.onDelta?.(n.delta),null;if(n.type===`thinking_delta`&&typeof n.delta==`string`)return t.onThinkingDelta?.(n.delta),null;if(n.type===`done`&&typeof n.text==`string`)return n.text;if(n.type===`error`)throw Error(P(n));return null}async function I(e,t={}){let n=await s(o(`/api/ai/text-assist`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(t||`AI suggestion failed (${n.status})`)}if(!n.body){let e=await n.json().catch(()=>null);if(e?.text)return e;throw Error(`AI suggestion stream is empty`)}let r=n.body.getReader(),i=new TextDecoder,a=``,c=``,l=``;for(;;){let{done:e,value:n}=await r.read();if(n){a+=i.decode(n,{stream:!e});let r=a.split(/\r?\n\r?\n/);a=r.pop()??``;for(let e of r){let n=F(e,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});n!==null&&(c=n)}}if(e)break}if(a.trim()){let e=F(a,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});e!==null&&(c=e)}let u=c.trim();if(!u)throw Error(`AI returned an empty suggestion`);return{text:u,thinking:l.trim()||void 0}}function ee(){let[e,t]=(0,j.useState)(``),[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(null);return{suggestion:e,thinking:n,loading:i,error:o,generate:(0,j.useCallback)(async e=>{a(!0),s(null),t(``),r(``);try{let n=await I(e,{onDelta:e=>{t(t=>t+e)},onThinkingDelta:e=>{r(t=>t+e)}});return t(n.text),r(n.thinking??``),n.text}catch(e){return s(e instanceof Error?e.message:`AI suggestion failed`),null}finally{a(!1)}},[]),reset:(0,j.useCallback)(()=>{t(``),r(``),s(null),a(!1)},[])}}var L=r(),te=5;function ne(e){return e.startsWith(`zh`)?{title:`AI 优化文案`,buttonTitle:`优化文案`,current:`当前内容`,suggestion:`AI 建议`,editedSuggestion:`审核并编辑建议`,thinking:`模型思考`,thinkingLoading:`思考中`,edit:`编辑`,preview:`预览`,loading:`正在生成建议...`,empty:`暂无内容`,generate:`生成建议`,regenerate:`重新生成`,applyCurrent:`应用当前内容`,replace:`替换`,append:`追加`,cancel:`取消`,close:`关闭`}:{title:`AI text assist`,buttonTitle:`Improve text`,current:`Current`,suggestion:`Suggestion`,editedSuggestion:`Review and edit suggestion`,thinking:`Model thinking`,thinkingLoading:`Thinking`,edit:`Edit`,preview:`Preview`,loading:`Generating suggestion...`,empty:`No content`,generate:`Generate suggestion`,regenerate:`Regenerate`,applyCurrent:`Apply current`,replace:`Replace`,append:`Append`,cancel:`Cancel`,close:`Close`}}function R(e){let t=(0,M.c)(232),{value:n,onApply:r,fieldId:a,fieldLabel:o,scenario:s,format:c,intent:l,locale:p,context:h,disabled:v,className:C,showLabel:D}=e,O=s===void 0?`generic.text`:s,A=c===void 0?`plain`:c,N=l===void 0?`improve`:l,P=D===void 0?!0:D,[F,I]=(0,j.useState)(!1),[R,z]=(0,j.useState)(n),[B,V]=(0,j.useState)(`preview`),[H,U]=(0,j.useState)(``),[W,G]=(0,j.useState)(`edit`),[K,ae]=(0,j.useState)(!0),oe=(0,j.useRef)(null),q=(0,j.useRef)(!0),{suggestion:J,thinking:Y,loading:X,error:Z,generate:se,reset:ce}=ee(),le;t[0]===p?le=t[1]:(le=ne(p),t[0]=p,t[1]=le);let Q=le,ue;t[2]!==X||t[3]!==Y?(ue=X&&Y.trim().length>0,t[2]=X,t[3]=Y,t[4]=ue):ue=t[4];let de=ue,fe,pe;t[5]!==F||t[6]!==n?(fe=()=>{F||z(n)},pe=[F,n],t[5]=F,t[6]=n,t[7]=fe,t[8]=pe):(fe=t[7],pe=t[8]),(0,j.useEffect)(fe,pe);let me,he;t[9]===J?(me=t[10],he=t[11]):(he=()=>{U(J)},me=[J],t[9]=J,t[10]=me,t[11]=he),(0,j.useEffect)(he,me);let ge,_e;t[12]===Y?(ge=t[13],_e=t[14]):(ge=()=>{Y.trim()&&ae(!0)},_e=[Y],t[12]=Y,t[13]=ge,t[14]=_e),(0,j.useEffect)(ge,_e);let ve;t[15]!==de||t[16]!==K?(ve=()=>{let e=oe.current;!e||!de||!K||q.current&&(e.scrollTop=e.scrollHeight)},t[15]=de,t[16]=K,t[17]=ve):ve=t[17];let ye;t[18]!==de||t[19]!==Y||t[20]!==K?(ye=[de,Y,K],t[18]=de,t[19]=Y,t[20]=K,t[21]=ye):ye=t[21],(0,j.useLayoutEffect)(ve,ye);let be;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>{let e=oe.current;e&&(q.current=e.scrollHeight-e.scrollTop-e.clientHeight<=te)},t[22]=be):be=t[22];let xe=be,Se;t[23]!==h||t[24]!==a||t[25]!==o||t[26]!==A||t[27]!==se||t[28]!==N||t[29]!==p||t[30]!==O?(Se=async e=>{G(`edit`),ae(!0),q.current=!0,await se({intent:N,scenario:O,input:e,locale:p,field:{id:a,label:o,format:A},context:h})},t[23]=h,t[24]=a,t[25]=o,t[26]=A,t[27]=se,t[28]=N,t[29]=p,t[30]=O,t[31]=Se):Se=t[31];let Ce=Se,we;t[32]!==ce||t[33]!==n?(we=()=>{z(n),V(`preview`),U(``),G(`edit`),ae(!0),ce(),I(!0)},t[32]=ce,t[33]=n,t[34]=we):we=t[34];let Te=we,Ee;t[35]!==R||t[36]!==Ce?(Ee=async()=>{await Ce(R)},t[35]=R,t[36]=Ce,t[37]=Ee):Ee=t[37];let De=Ee,Oe;t[38]!==ce||t[39]!==n?(Oe=()=>{I(!1),z(n),V(`preview`),U(``),G(`edit`),ae(!0),ce()},t[38]=ce,t[39]=n,t[40]=Oe):Oe=t[40];let $=Oe,ke;t[41]!==$||t[42]!==R||t[43]!==r?(ke=()=>{r(R),$()},t[41]=$,t[42]=R,t[43]=r,t[44]=ke):ke=t[44];let Ae=ke,je;t[45]!==$||t[46]!==H||t[47]!==r?(je=()=>{H.trim()&&(r(H),$())},t[45]=$,t[46]=H,t[47]=r,t[48]=je):je=t[48];let Me=je,Ne;t[49]!==$||t[50]!==R||t[51]!==H||t[52]!==r?(Ne=()=>{if(!H.trim())return;let e=R.trimEnd();r(e?`${e}\n\n${H}`:H),$()},t[49]=$,t[50]=R,t[51]=H,t[52]=r,t[53]=Ne):Ne=t[53];let Pe=Ne,Fe;t[54]!==H||t[55]!==Z||t[56]!==X?(Fe=!X&&!Z&&H.trim().length>0,t[54]=H,t[55]=Z,t[56]=X,t[57]=Fe):Fe=t[57];let Ie=Fe,Le=R!==n,Re;t[58]!==H||t[59]!==Z||t[60]!==Y?(Re=H.trim().length>0||Y.trim().length>0||!!Z,t[58]=H,t[59]=Z,t[60]=Y,t[61]=Re):Re=t[61];let ze=Re,Be=!P&&`size-7 p-0`,Ve;t[62]!==C||t[63]!==Be?(Ve=i(`h-7 gap-1 px-2 text-xs`,Be,C),t[62]=C,t[63]=Be,t[64]=Ve):Ve=t[64];let He=v||X,Ue;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,L.jsx)(d,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[65]=Ue):Ue=t[65];let We=P?Q.buttonTitle:null,Ge;t[66]!==Q.buttonTitle||t[67]!==Te||t[68]!==Ve||t[69]!==He||t[70]!==We?(Ge=(0,L.jsxs)(k,{type:`button`,variant:`ghost`,className:Ve,title:Q.buttonTitle,"aria-label":Q.buttonTitle,disabled:He,onClick:Te,children:[Ue,We]}),t[66]=Q.buttonTitle,t[67]=Te,t[68]=Ve,t[69]=He,t[70]=We,t[71]=Ge):Ge=t[71];let Ke;t[72]===$?Ke=t[73]:(Ke=e=>e?I(!0):$(),t[72]=$,t[73]=Ke);let qe;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,L.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[74]=qe):qe=t[74];let Je;t[75]===Q.title?Je=t[76]:(Je=(0,L.jsx)(g,{className:`text-base font-semibold text-fg`,children:Q.title}),t[75]=Q.title,t[76]=Je);let Ye;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,L.jsx)(E,{className:`size-5`,strokeWidth:1.75}),t[77]=Ye):Ye=t[77];let Xe;t[78]===Q.close?Xe=t[79]:(Xe=(0,L.jsx)(m,{asChild:!0,children:(0,L.jsx)(k,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":Q.close,children:Ye})}),t[78]=Q.close,t[79]=Xe);let Ze;t[80]!==Je||t[81]!==Xe?(Ze=(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[Je,Xe]}),t[80]=Je,t[81]=Xe,t[82]=Ze):Ze=t[82];let Qe;t[83]===Q.current?Qe=t[84]:(Qe=(0,L.jsx)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:Q.current}),t[83]=Q.current,t[84]=Qe);let $e=B===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,et;t[85]===$e?et=t[86]:(et=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,$e),t[85]=$e,t[86]=et);let tt,nt;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(tt=()=>V(`edit`),nt=(0,L.jsx)(x,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[87]=tt,t[88]=nt):(tt=t[87],nt=t[88]);let rt;t[89]!==Q.edit||t[90]!==et?(rt=(0,L.jsxs)(`button`,{type:`button`,className:et,onClick:tt,children:[nt,Q.edit]}),t[89]=Q.edit,t[90]=et,t[91]=rt):rt=t[91];let it=B===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,at;t[92]===it?at=t[93]:(at=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,it),t[92]=it,t[93]=at);let ot,st;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(ot=()=>V(`preview`),st=(0,L.jsx)(b,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[94]=ot,t[95]=st):(ot=t[94],st=t[95]);let ct;t[96]!==Q.preview||t[97]!==at?(ct=(0,L.jsxs)(`button`,{type:`button`,className:at,onClick:ot,children:[st,Q.preview]}),t[96]=Q.preview,t[97]=at,t[98]=ct):ct=t[98];let lt;t[99]!==rt||t[100]!==ct?(lt=(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[rt,ct]}),t[99]=rt,t[100]=ct,t[101]=lt):lt=t[101];let ut;t[102]!==Qe||t[103]!==lt?(ut=(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[Qe,lt]}),t[102]=Qe,t[103]=lt,t[104]=ut):ut=t[104];let dt;t[105]!==R||t[106]!==B||t[107]!==A||t[108]!==Q.current||t[109]!==Q.empty?(dt=B===`preview`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:A===`markdown`?(0,L.jsx)(y,{content:R||Q.empty,compact:!0,className:`text-sm`}):(0,L.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:R||Q.empty})}):(0,L.jsx)(`textarea`,{className:`min-h-0 flex-1 resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25`,value:R,onChange:e=>z(e.currentTarget.value),placeholder:Q.empty,"aria-label":Q.current}),t[105]=R,t[106]=B,t[107]=A,t[108]=Q.current,t[109]=Q.empty,t[110]=dt):dt=t[110];let ft;t[111]!==ut||t[112]!==dt?(ft=(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[ut,dt]}),t[111]=ut,t[112]=dt,t[113]=ft):ft=t[113];let pt;t[114]===Q.editedSuggestion?pt=t[115]:(pt=(0,L.jsx)(`span`,{children:Q.editedSuggestion}),t[114]=Q.editedSuggestion,t[115]=pt);let mt;t[116]!==Q.loading||t[117]!==X?(mt=X?(0,L.jsx)(`span`,{className:`ml-2 font-normal`,children:Q.loading}):null,t[116]=Q.loading,t[117]=X,t[118]=mt):mt=t[118];let ht;t[119]!==pt||t[120]!==mt?(ht=(0,L.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:[pt,mt]}),t[119]=pt,t[120]=mt,t[121]=ht):ht=t[121];let gt=W===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,_t;t[122]===gt?_t=t[123]:(_t=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,gt),t[122]=gt,t[123]=_t);let vt,yt;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>G(`edit`),yt=(0,L.jsx)(x,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[124]=vt,t[125]=yt):(vt=t[124],yt=t[125]);let bt;t[126]!==Q.edit||t[127]!==_t?(bt=(0,L.jsxs)(`button`,{type:`button`,className:_t,onClick:vt,children:[yt,Q.edit]}),t[126]=Q.edit,t[127]=_t,t[128]=bt):bt=t[128];let xt=W===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,St;t[129]===xt?St=t[130]:(St=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,xt),t[129]=xt,t[130]=St);let Ct,wt;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(Ct=()=>G(`preview`),wt=(0,L.jsx)(b,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[131]=Ct,t[132]=wt):(Ct=t[131],wt=t[132]);let Tt;t[133]!==Q.preview||t[134]!==St?(Tt=(0,L.jsxs)(`button`,{type:`button`,className:St,onClick:Ct,children:[wt,Q.preview]}),t[133]=Q.preview,t[134]=St,t[135]=Tt):Tt=t[135];let Et;t[136]!==bt||t[137]!==Tt?(Et=(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[bt,Tt]}),t[136]=bt,t[137]=Tt,t[138]=Et):Et=t[138];let Dt;t[139]!==ht||t[140]!==Et?(Dt=(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[ht,Et]}),t[139]=ht,t[140]=Et,t[141]=Dt):Dt=t[141];let Ot=de?`opacity-100`:`pointer-events-none opacity-0`,kt;t[142]===Ot?kt=t[143]:(kt=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Ot),t[142]=Ot,t[143]=kt);let At=!de,jt;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(jt=()=>ae(re),t[144]=jt):jt=t[144];let Mt;t[145]!==Q.thinkingLoading||t[146]!==X?(Mt=X?(0,L.jsxs)(`span`,{className:`ml-1 font-normal`,children:[`· `,Q.thinkingLoading]}):null,t[145]=Q.thinkingLoading,t[146]=X,t[147]=Mt):Mt=t[147];let Nt;t[148]!==Q.thinking||t[149]!==Mt?(Nt=(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Q.thinking,Mt]}),t[148]=Q.thinking,t[149]=Mt,t[150]=Nt):Nt=t[150];let Pt=K&&`rotate-180`,Ft;t[151]===Pt?Ft=t[152]:(Ft=i(`size-3.5 shrink-0 transition-transform`,Pt),t[151]=Pt,t[152]=Ft);let It;t[153]===Ft?It=t[154]:(It=(0,L.jsx)(T,{className:Ft,strokeWidth:1.75,"aria-hidden":!0}),t[153]=Ft,t[154]=It);let Lt;t[155]!==Nt||t[156]!==It?(Lt=(0,L.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center justify-between gap-2 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:text-fg`,onClick:jt,children:[Nt,It]}),t[155]=Nt,t[156]=It,t[157]=Lt):Lt=t[157];let Rt;t[158]!==Y||t[159]!==K?(Rt=K?(0,L.jsx)(`pre`,{ref:oe,className:`min-h-0 flex-1 overflow-auto border-t border-edge px-2.5 py-2 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,onScroll:xe,children:Y}):null,t[158]=Y,t[159]=K,t[160]=Rt):Rt=t[160];let zt;t[161]!==Lt||t[162]!==Rt?(zt=(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-lg border border-edge bg-surface-muted/70`,children:[Lt,Rt]}),t[161]=Lt,t[162]=Rt,t[163]=zt):zt=t[163];let Bt;t[164]!==kt||t[165]!==At||t[166]!==zt?(Bt=(0,L.jsx)(`div`,{className:kt,"aria-hidden":At,children:zt}),t[164]=kt,t[165]=At,t[166]=zt,t[167]=Bt):Bt=t[167];let Vt=de?`pointer-events-none opacity-0`:`opacity-100`,Ht;t[168]===Vt?Ht=t[169]:(Ht=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Vt),t[168]=Vt,t[169]=Ht);let Ut;t[170]!==H||t[171]!==Z||t[172]!==A||t[173]!==Q.empty||t[174]!==Q.loading||t[175]!==Q.suggestion||t[176]!==X||t[177]!==W?(Ut=Z?(0,L.jsx)(`pre`,{className:`h-full min-h-0 overflow-auto whitespace-pre-wrap rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg-muted`,children:Z}):W===`preview`?(0,L.jsx)(`div`,{className:`h-full min-h-0 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:X&&!H.trim()?(0,L.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Q.loading}):A===`markdown`?(0,L.jsx)(y,{content:H||Q.empty,compact:!0,className:`text-sm`}):(0,L.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:H||Q.empty})}):(0,L.jsx)(`textarea`,{className:`h-full min-h-0 w-full resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25 disabled:text-fg-muted`,value:H,onChange:e=>U(e.currentTarget.value),disabled:X,placeholder:X?Q.loading:Q.empty,"aria-label":Q.suggestion}),t[170]=H,t[171]=Z,t[172]=A,t[173]=Q.empty,t[174]=Q.loading,t[175]=Q.suggestion,t[176]=X,t[177]=W,t[178]=Ut):Ut=t[178];let Wt;t[179]!==Ht||t[180]!==Ut?(Wt=(0,L.jsx)(`div`,{className:Ht,children:Ut}),t[179]=Ht,t[180]=Ut,t[181]=Wt):Wt=t[181];let Gt;t[182]!==Bt||t[183]!==Wt?(Gt=(0,L.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[Bt,Wt]}),t[182]=Bt,t[183]=Wt,t[184]=Gt):Gt=t[184];let Kt;t[185]!==Dt||t[186]!==Gt?(Kt=(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[Dt,Gt]}),t[185]=Dt,t[186]=Gt,t[187]=Kt):Kt=t[187];let qt;t[188]!==ft||t[189]!==Kt?(qt=(0,L.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-hidden p-4 md:grid-cols-2`,children:[ft,Kt]}),t[188]=ft,t[189]=Kt,t[190]=qt):qt=t[190];let Jt;t[191]!==$||t[192]!==Q.cancel?(Jt=(0,L.jsx)(k,{type:`button`,variant:`secondary`,onClick:$,children:Q.cancel}),t[191]=$,t[192]=Q.cancel,t[193]=Jt):Jt=t[193];let Yt=!Le,Xt;t[194]!==Ae||t[195]!==Q.applyCurrent||t[196]!==Yt?(Xt=(0,L.jsx)(k,{type:`button`,variant:`secondary`,disabled:Yt,onClick:Ae,children:Q.applyCurrent}),t[194]=Ae,t[195]=Q.applyCurrent,t[196]=Yt,t[197]=Xt):Xt=t[197];let Zt;t[198]===De?Zt=t[199]:(Zt=()=>void De(),t[198]=De,t[199]=Zt);let Qt;t[200]===ze?Qt=t[201]:(Qt=ze?(0,L.jsx)(_,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,L.jsx)(d,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[200]=ze,t[201]=Qt);let $t=ze?Q.regenerate:Q.generate,en;t[202]!==X||t[203]!==Zt||t[204]!==Qt||t[205]!==$t?(en=(0,L.jsxs)(k,{type:`button`,variant:`secondary`,disabled:X,onClick:Zt,children:[Qt,$t]}),t[202]=X,t[203]=Zt,t[204]=Qt,t[205]=$t,t[206]=en):en=t[206];let tn=!Ie,nn;t[207]!==Pe||t[208]!==Q.append||t[209]!==tn?(nn=(0,L.jsx)(k,{type:`button`,variant:`secondary`,disabled:tn,onClick:Pe,children:Q.append}),t[207]=Pe,t[208]=Q.append,t[209]=tn,t[210]=nn):nn=t[210];let rn=!Ie,an;t[211]!==Me||t[212]!==Q.replace||t[213]!==rn?(an=(0,L.jsx)(k,{type:`button`,variant:`primary`,disabled:rn,onClick:Me,children:Q.replace}),t[211]=Me,t[212]=Q.replace,t[213]=rn,t[214]=an):an=t[214];let on;t[215]!==Jt||t[216]!==Xt||t[217]!==en||t[218]!==nn||t[219]!==an?(on=(0,L.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Jt,Xt,en,nn,an]}),t[215]=Jt,t[216]=Xt,t[217]=en,t[218]=nn,t[219]=an,t[220]=on):on=t[220];let sn;t[221]!==Ze||t[222]!==qt||t[223]!==on?(sn=(0,L.jsxs)(u,{children:[qe,(0,L.jsx)(`div`,{className:`fixed inset-0 z-[80] flex items-center justify-center p-4 pointer-events-none`,children:(0,L.jsxs)(w,{className:`xopc-dialog-content-pane pointer-events-auto flex h-[min(78vh,38rem)] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,onOpenAutoFocus:ie,children:[Ze,qt,on]})})]}),t[221]=Ze,t[222]=qt,t[223]=on,t[224]=sn):sn=t[224];let cn;t[225]!==F||t[226]!==Ke||t[227]!==sn?(cn=(0,L.jsx)(f,{open:F,onOpenChange:Ke,children:sn}),t[225]=F,t[226]=Ke,t[227]=sn,t[228]=cn):cn=t[228];let ln;return t[229]!==cn||t[230]!==Ge?(ln=(0,L.jsxs)(L.Fragment,{children:[Ge,cn]}),t[229]=cn,t[230]=Ge,t[231]=ln):ln=t[231],ln}function re(e){return!e}function ie(e){return e.preventDefault()}function z(e,t){return e[t]??t}function B(e){let t=(0,M.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,L.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,L.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,L.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function V(e){let t=(0,M.c)(34),{workflowName:n,language:r,argValues:o,onArgValuesChange:s,goal:c,onGoalChange:l,examplePrompts:u,showGoal:d,inputClassName:f,aiAssist:p}=e,m;t[0]===u?m=t[1]:(m=u===void 0?[]:u,t[0]=u,t[1]=m);let g=m,_=d===void 0?!0:d,v,y,b,x,S,w,T;if(t[2]!==p||t[3]!==o||t[4]!==g||t[5]!==c||t[6]!==f||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==_||t[11]!==n){b=a(r).workflows;let e=C[n]??[];y=e.length>0;let u=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,f),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{h(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],v=d,x=`flex flex-col gap-3`,S=e.map(e=>{let t=z(b.args,e.labelKey),a=z(b.args,e.placeholderKey),c=o[e.key]??``;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[t,e.required?` *`:``]}),e.multiline&&p?(0,L.jsx)(R,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:p.argScenario??`workflow.arg`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:p.disabled,showLabel:!1}):null]}),e.multiline?(0,L.jsx)(`textarea`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:i(u,`min-h-20 resize-y`)}):(0,L.jsx)(`input`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:u})]},e.key)}),w=y&&g.length>0?(0,L.jsx)(B,{examples:g,labels:b,onSelect:v}):null,T=_?(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:b.goalLabel}),p?(0,L.jsx)(R,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:b.goalLabel,scenario:p.goalScenario??`cron.workflowGoal`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o},disabled:p.disabled,showLabel:!1}):null]}),(0,L.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:b.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=p,t[3]=o,t[4]=g,t[5]=c,t[6]=f,t[7]=r,t[8]=s,t[9]=l,t[10]=_,t[11]=n,t[12]=v,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=w,t[18]=T}else v=t[12],y=t[13],b=t[14],x=t[15],S=t[16],w=t[17],T=t[18];let E;t[23]!==v||t[24]!==g||t[25]!==y||t[26]!==b?(E=!y&&g.length>0?(0,L.jsx)(B,{examples:g,labels:b,onSelect:v}):null,t[23]=v,t[24]=g,t[25]=y,t[26]=b,t[27]=E):E=t[27];let D;return t[28]!==x||t[29]!==S||t[30]!==w||t[31]!==T||t[32]!==E?(D=(0,L.jsxs)(`div`,{className:x,children:[S,w,T,E]}),t[28]=x,t[29]=S,t[30]=w,t[31]=T,t[32]=E,t[33]=D):D=t[33],D}var H=`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`;function U(e){return!!(e&&e.type===`object`&&e.properties&&!Array.isArray(e.properties))}function W({schema:e,value:t,onChange:n,labels:r,aiAssist:a,onValidChange:o}){let s=(0,j.useMemo)(()=>ae(e),[e]),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(()=>JSON.stringify(t,null,2)),[f,p]=(0,j.useState)(null);if(s.length===0)return null;let m=(e,r)=>{let i={...t,[e]:r};(r===``||r===void 0)&&delete i[e],n(i),c&&d(JSON.stringify(i,null,2))},h=e=>{d(e);try{let t=e.trim()?JSON.parse(e):{};if(!t||typeof t!=`object`||Array.isArray(t)){p(r.rawJsonInvalid),o?.(!1);return}p(null),n(t),o?.(!0,t)}catch{p(r.rawJsonInvalid),o?.(!1)}};return(0,L.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/35 p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.inputSchemaHeading}),(0,L.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>{let e=!c;l(e),e&&(d(JSON.stringify(t,null,2)),p(null),o?.(!0))},children:r.rawJson})]}),c?(0,L.jsxs)(`div`,{className:`mt-3`,children:[(0,L.jsx)(`textarea`,{value:u,onChange:e=>h(e.target.value),spellCheck:!1,className:i(H,`min-h-40 font-mono text-xs leading-5`)}),f?(0,L.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-300`,children:f}):null]}):(0,L.jsx)(`div`,{className:`mt-3 grid gap-3`,children:s.map(e=>(0,L.jsx)(G,{field:e,value:t[e.key],labels:r,aiAssist:a,allValues:t,onChange:t=>m(e.key,t)},e.key))})]})}function G(e){let t=(0,M.c)(30),{field:n,value:r,labels:a,aiAssist:o,allValues:s,onChange:c}=e,l=n.schema.title||n.key,u=typeof n.schema.description==`string`?n.schema.description:void 0,d=Array.isArray(n.schema.type)?n.schema.type[0]:n.schema.type,f;t[0]===n.schema.enum?f=t[1]:(f=Array.isArray(n.schema.enum)?n.schema.enum:[],t[0]=n.schema.enum,t[1]=f);let p=f,m=!!o&&!p.length&&(d===`string`||!d),h=String(l),g=n.required?` *`:``,_;t[2]!==h||t[3]!==g?(_=(0,L.jsxs)(`span`,{className:`text-xs font-medium text-fg`,children:[h,g]}),t[2]=h,t[3]=g,t[4]=_):_=t[4];let v;t[5]!==o||t[6]!==s||t[7]!==n.key||t[8]!==n.schema||t[9]!==c||t[10]!==m||t[11]!==l||t[12]!==r?(v=m&&o?(0,L.jsx)(R,{value:typeof r==`string`?r:r==null?``:String(r),onApply:c,fieldId:`workflow.schema.${n.key}`,fieldLabel:String(l),scenario:o.scenario??`workflow.arg`,locale:o.locale,context:{...o.context,fieldKey:n.key,fieldSchema:n.schema,inputValues:s},disabled:o.disabled,showLabel:!1}):null,t[5]=o,t[6]=s,t[7]=n.key,t[8]=n.schema,t[9]=c,t[10]=m,t[11]=l,t[12]=r,t[13]=v):v=t[13];let y;t[14]!==_||t[15]!==v?(y=(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===u?b=t[18]:(b=u?(0,L.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-subtle`,children:u}):null,t[17]=u,t[18]=b);let x;t[19]!==u||t[20]!==p||t[21]!==a||t[22]!==c||t[23]!==d||t[24]!==r?(x=p.length>0?(0,L.jsxs)(`select`,{value:r==null?``:String(r),onChange:e=>c(e.target.value),className:H,children:[(0,L.jsx)(`option`,{value:``}),p.map(K)]}):d===`boolean`?(0,L.jsxs)(`select`,{value:typeof r==`boolean`?String(r):``,onChange:e=>c(e.target.value===``?void 0:e.target.value===`true`),className:H,children:[(0,L.jsx)(`option`,{value:``}),(0,L.jsx)(`option`,{value:`true`,children:a.booleanTrue}),(0,L.jsx)(`option`,{value:`false`,children:a.booleanFalse})]}):d===`number`||d===`integer`?(0,L.jsx)(`input`,{type:`number`,value:typeof r==`number`||typeof r==`string`?String(r):``,onChange:e=>c(e.target.value===``?void 0:Number(e.target.value)),className:H}):(0,L.jsx)(`textarea`,{value:typeof r==`string`?r:r==null?``:String(r),onChange:e=>c(e.target.value),className:i(H,u&&u.length>80?`min-h-20 resize-y`:`min-h-10 resize-y`)}),t[19]=u,t[20]=p,t[21]=a,t[22]=c,t[23]=d,t[24]=r,t[25]=x):x=t[25];let S;return t[26]!==y||t[27]!==b||t[28]!==x?(S=(0,L.jsxs)(`div`,{className:`block`,children:[y,b,x]}),t[26]=y,t[27]=b,t[28]=x,t[29]=S):S=t[29],S}function K(e){return(0,L.jsx)(`option`,{value:String(e),children:String(e)},String(e))}function ae(e){let t=e.properties??{},n=new Set(e.required??[]);return Object.entries(t).map(([e,t])=>({key:e,schema:t,required:n.has(e)}))}function oe(e,t){return!U(e)||!e?!0:ae(e).every(e=>{if(!e.required)return!0;let n=t[e.key];return n==null?!1:typeof n==`string`?n.trim().length>0:!0})}function q(e){let t=(0,M.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,L.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,L.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,L.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function J(e,t){if(e)return U(e.inputSchema)?Object.keys(t.schemaInput).length>0?t.schemaInput:void 0:D(t.argValues)}function Y(e,t,n){let r=a(t).workflows;if(!e)return r.noInputSummary;let i=c(e,t);if(U(e.inputSchema)&&Object.keys(n.schemaInput).length>0)return Object.entries(n.schemaInput).map(([e,t])=>`${e}: ${String(t)}`).join(` · `);let o=Object.values(n.argValues).map(e=>e.trim()).filter(Boolean),s=n.goal.trim()||i.description;return s&&o.unshift(s),o.length>0?o.join(` · `):r.noInputSummary}function X(e,t,n=!0){return e?n?U(e.inputSchema)?oe(e.inputSchema,t.schemaInput)?{valid:!0}:{valid:!1,reason:`schema-required`}:{valid:(C[e.name]??[]).every(e=>!e.required||!!t.argValues[e.key]?.trim())}:{valid:!1,reason:`raw-json`}:{valid:!1}}function Z(e){let t=(0,M.c)(114),{definition:n,language:r,value:o,onChange:s,aiAssist:l,inputClassName:u,onValidityChange:d}=e,f;t[0]===r?f=t[1]:(f=a(r),t[0]=r,t[1]=f);let p=f.workflows,m;t[2]!==n||t[3]!==r?(m=c(n,r),t[2]=n,t[3]=r,t[4]=m):m=t[4];let h=m,[g,_]=(0,j.useState)(!0),v;t[5]===h.examplePrompts?v=t[6]:(v=h.examplePrompts??[],t[5]=h.examplePrompts,t[6]=v);let y=v,b;t[7]===n.inputSchema?b=t[8]:(b=U(n.inputSchema),t[7]=n.inputSchema,t[8]=b);let x=b,S,C,w,T,E,D,O,k,A,N;if(t[9]!==l||t[10]!==n||t[11]!==y||t[12]!==x||t[13]!==u||t[14]!==p||t[15]!==r||t[16]!==h.description||t[17]!==s||t[18]!==d||t[19]!==g||t[20]!==o){E=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,u),a;t[31]!==n||t[32]!==s||t[33]!==d||t[34]!==g?(a=(e,t)=>{let r=t===void 0?g:t;s(e),d?.(X(n,e,r))},t[31]=n,t[32]=s,t[33]=d,t[34]=g,t[35]=a):a=t[35];let c=a,f;t[36]!==c||t[37]!==o?(f=e=>c({...o,goal:e}),t[36]=c,t[37]=o,t[38]=f):f=t[38];let m=f,v;t[39]!==c||t[40]!==o?(v=e=>c({...o,schemaInput:e}),t[39]=c,t[40]=o,t[41]=v):v=t[41];let b=v,j;t[42]!==c||t[43]!==o?(j=e=>c({...o,argValues:e}),t[42]=c,t[43]=o,t[44]=j):j=t[44];let M=j,P;if(t[45]!==m||t[46]!==b||t[47]!==o.schemaInput?(P=e=>{if(e.field===`goal`){m(e.text);return}b({...o.schemaInput,[e.field]:e.text})},t[45]=m,t[46]=b,t[47]=o.schemaInput,t[48]=P):P=t[48],S=P,!x){let e;t[49]!==l||t[50]!==n.id||t[51]!==n.name||t[52]!==n.title||t[53]!==h.description?(e=l?{disabled:l.disabled,argScenario:l.inputScenario??`workflow.arg`,goalScenario:l.goalScenario??`workflow.goal`,context:{...l.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:h.description}}:void 0,t[49]=l,t[50]=n.id,t[51]=n.name,t[52]=n.title,t[53]=h.description,t[54]=e):e=t[54];let i;t[55]!==n.name||t[56]!==y||t[57]!==u||t[58]!==r||t[59]!==M||t[60]!==m||t[61]!==e||t[62]!==o.argValues||t[63]!==o.goal?(i=(0,L.jsx)(V,{workflowName:n.name,language:r,argValues:o.argValues,onArgValuesChange:M,goal:o.goal,onGoalChange:m,examplePrompts:y,inputClassName:u,aiAssist:e}),t[55]=n.name,t[56]=y,t[57]=u,t[58]=r,t[59]=M,t[60]=m,t[61]=e,t[62]=o.argValues,t[63]=o.goal,t[64]=i):i=t[64],E=i;break bb0}w=`flex flex-col gap-3`,t[65]!==l||t[66]!==n||t[67]!==p.booleanFalse||t[68]!==p.booleanTrue||t[69]!==p.inputSchemaHeading||t[70]!==p.rawJson||t[71]!==p.rawJsonInvalid||t[72]!==r||t[73]!==h.description||t[74]!==d||t[75]!==b||t[76]!==o?(T=n.inputSchema?(0,L.jsx)(W,{schema:n.inputSchema,value:o.schemaInput,onChange:b,onValidChange:(e,t)=>{_(e),d?.(X(n,t?{...o,schemaInput:t}:o,e))},aiAssist:l?{locale:r,disabled:l.disabled,scenario:l.inputScenario??`workflow.arg`,context:{...l.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:h.description}}:void 0,labels:{inputSchemaHeading:p.inputSchemaHeading,rawJson:p.rawJson,rawJsonInvalid:p.rawJsonInvalid,booleanTrue:p.booleanTrue,booleanFalse:p.booleanFalse}}):null,t[65]=l,t[66]=n,t[67]=p.booleanFalse,t[68]=p.booleanTrue,t[69]=p.inputSchemaHeading,t[70]=p.rawJson,t[71]=p.rawJsonInvalid,t[72]=r,t[73]=h.description,t[74]=d,t[75]=b,t[76]=o,t[77]=T):T=t[77],N=`flex flex-col gap-1`;let F;t[78]===p.goalLabel?F=t[79]:(F=(0,L.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:p.goalLabel}),t[78]=p.goalLabel,t[79]=F);let I;t[80]!==l||t[81]!==n.id||t[82]!==n.name||t[83]!==n.title||t[84]!==p.goalLabel||t[85]!==r||t[86]!==h.description||t[87]!==m||t[88]!==o.goal||t[89]!==o.schemaInput?(I=l?(0,L.jsx)(R,{value:o.goal,onApply:m,fieldId:`workflow.goal`,fieldLabel:p.goalLabel,scenario:l.goalScenario??`workflow.goal`,locale:r,context:{...l.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:h.description,workflowInput:o.schemaInput},disabled:l.disabled,showLabel:!1}):null,t[80]=l,t[81]=n.id,t[82]=n.name,t[83]=n.title,t[84]=p.goalLabel,t[85]=r,t[86]=h.description,t[87]=m,t[88]=o.goal,t[89]=o.schemaInput,t[90]=I):I=t[90],t[91]!==F||t[92]!==I?(C=(0,L.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[F,I]}),t[91]=F,t[92]=I,t[93]=C):C=t[93],D=o.goal,t[94]===m?O=t[95]:(O=e=>m(e.target.value),t[94]=m,t[95]=O),k=p.goalPlaceholder,A=i(e,`min-h-20 resize-y`)}t[9]=l,t[10]=n,t[11]=y,t[12]=x,t[13]=u,t[14]=p,t[15]=r,t[16]=h.description,t[17]=s,t[18]=d,t[19]=g,t[20]=o,t[21]=S,t[22]=C,t[23]=w,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=N}else S=t[21],C=t[22],w=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],N=t[30];if(E!==Symbol.for(`react.early_return_sentinel`))return E;let P;t[96]!==D||t[97]!==O||t[98]!==k||t[99]!==A?(P=(0,L.jsx)(`textarea`,{value:D,onChange:O,placeholder:k,className:A}),t[96]=D,t[97]=O,t[98]=k,t[99]=A,t[100]=P):P=t[100];let F;t[101]!==C||t[102]!==P||t[103]!==N?(F=(0,L.jsxs)(`div`,{className:N,children:[C,P]}),t[101]=C,t[102]=P,t[103]=N,t[104]=F):F=t[104];let I;t[105]!==S||t[106]!==y||t[107]!==p?(I=(0,L.jsx)(q,{examples:y,labels:p,onSelect:S}),t[105]=S,t[106]=y,t[107]=p,t[108]=I):I=t[108];let ee;return t[109]!==w||t[110]!==T||t[111]!==F||t[112]!==I?(ee=(0,L.jsxs)(`div`,{className:w,children:[T,F,I]}),t[109]=w,t[110]=T,t[111]=F,t[112]=I,t[113]=ee):ee=t[113],ee}function se(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?v(t.agentScaleExact,{count:n.min}):v(t.agentScaleRange,{min:n.min,max:n.max}):v(t.agentScaleExact,{count:e.defaults.maxSubagents})}function ce(e){let t=(0,M.c)(41),{definition:n,language:r,value:o,onChange:s,mode:u,badgeLabel:d,aiAssist:f,inputClassName:m,showTimeout:h,defaultAdvancedOpen:g,onValidityChange:_}=e,y=h===void 0?!1:h,b=g===void 0?!1:g,x=a(r).workflows,[S,C]=(0,j.useState)(b),w;t[0]!==n||t[1]!==r?(w=c(n,r),t[0]=n,t[1]=r,t[2]=w):w=t[2];let E=w,D;t[3]!==n.defaults||t[4]!==o.concurrency?(D=o.concurrency.trim()?Number(o.concurrency):n.defaults.concurrency,t[3]=n.defaults,t[4]=o.concurrency,t[5]=D):D=t[5];let k=D,N;t[6]!==n.defaults||t[7]!==o.maxSubagents?(N=o.maxSubagents.trim()?Number(o.maxSubagents):n.defaults.maxSubagents,t[6]=n.defaults,t[7]=o.maxSubagents,t[8]=N):N=t[8];let P=N,F;t[9]!==n||t[10]!==r||t[11]!==o?(F=Y(n,r,o),t[9]=n,t[10]=r,t[11]=o,t[12]=F):F=t[12];let I=F,ee=d??x.readyToStart,te;t[13]!==s||t[14]!==o?(te=e=>s({...o,...e}),t[13]=s,t[14]=o,t[15]=te):te=t[15];let ne=te,R=u===`automation`&&`rounded-xl border border-edge-subtle bg-surface-base/30 p-3`,re;t[16]===R?re=t[17]:(re=i(`space-y-4`,R),t[16]=R,t[17]=re);let ie=I||E.description,z;t[18]===ie?z=t[19]:(z=(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:ie}),t[18]=ie,t[19]=z);let B;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,L.jsx)(p,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[20]=B):B=t[20];let V;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,L.jsx)(O,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[21]=V):V=t[21];let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,L.jsx)(l,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[22]=H):H=t[22];let U;t[23]!==s||t[24]!==o?(U=e=>s({...o,...e}),t[23]=s,t[24]=o,t[25]=U):U=t[25];let W;t[26]===_?W=t[27]:(W=e=>{_?.(e)},t[26]=_,t[27]=W);let G;t[28]!==f||t[29]!==n||t[30]!==m||t[31]!==r||t[32]!==U||t[33]!==W||t[34]!==o?(G=(0,L.jsx)(Z,{definition:n,language:r,value:o,onChange:U,onValidityChange:W,aiAssist:f,inputClassName:m}),t[28]=f,t[29]=n,t[30]=m,t[31]=r,t[32]=U,t[33]=W,t[34]=o,t[35]=G):G=t[35];let K;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>C(le),t[36]=K):K=t[36];let ae=x.advancedSettings,oe=S&&`rotate-180`,q;t[37]===oe?q=t[38]:(q=i(`size-4 transition-transform`,oe),t[37]=oe,t[38]=q);let J;return t[39]===q?J=t[40]:(J=(0,L.jsx)(T,{className:q}),t[39]=q,t[40]=J),(0,L.jsxs)(`div`,{className:re,children:[(0,L.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base/70 p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:x.runPlanPreview}),z]}),(0,L.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2 py-1 text-[11px] font-medium text-accent-fg`,children:ee})]}),(0,L.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs text-fg-muted sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[B,(0,L.jsx)(`span`,{children:v(x.phaseCount,{count:n.phases.length})})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[V,(0,L.jsx)(`span`,{children:se(n,x)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[H,(0,L.jsx)(`span`,{children:v(x.runLimitsSummary,{concurrency:k,max:P})})]})]}),n.phases.length>0?(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[(0,L.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),x.startPlanPhases]}),(0,L.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:n.phases.map(Q)})]}):null]}),G,(0,L.jsxs)(`div`,{className:`rounded-xl border border-edge`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between px-3 py-2.5 text-left text-sm text-fg`,onClick:K,children:[ae,J]}),S?(0,L.jsxs)(`div`,{className:`grid gap-3 border-t border-edge px-3 pb-3 pt-3 sm:grid-cols-2`,children:[(0,L.jsx)(`input`,{value:o.concurrency,onChange:e=>ne({concurrency:e.target.value}),placeholder:v(x.concurrencyPlaceholder,{default:n.defaults.concurrency}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,L.jsx)(`input`,{value:o.maxSubagents,onChange:e=>ne({maxSubagents:e.target.value}),placeholder:v(x.maxSubagentsPlaceholder,{default:n.defaults.maxSubagents}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),y?(0,L.jsx)(`input`,{value:o.timeoutSeconds??``,onChange:e=>ne({timeoutSeconds:e.target.value}),placeholder:v(x.timeoutSecondsPlaceholder,{default:n.defaults.timeoutSec}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}):null]}):null]})]})}function le(e){return!e}function Q(e,t){return(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t>0?(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`→`}):null,(0,L.jsx)(`span`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1 text-[11px] text-fg-muted`,children:e.title})]},e.id)}export{R as i,J as n,X as r,ce as t};
|