@xopcai/xopc 0.0.147 → 0.0.148

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.
Files changed (97) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DXeSSlw1.js → activity-store-B5h0UGWn.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CFdJKSjY.js → agent-avatar-dicebear-Dy5VvLUq.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-DKjbRpbA.js → agents-Ci1U96gj.js} +1 -1
  6. package/dist/gateway/static/root/assets/{api-Bs69B5zA.js → api-B3J2AmQW.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-ag1ViXT_.js → app-management-settings-panel-BbSLDubO.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-C6iMpwOM.js → appearance-settings-D9wK0UKA.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-Z6cQTPS6.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-Dwi3mIBy.js → archive-plugin-DaDK-FYa.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-BaCDoq40.js → attachment-load-CKiBdU_s.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-CwqtFgnw.js → automation-suggestion-card-8Qbnxq-p.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-DlupOxFQ.js → automations-page-D7HmeFdr.js} +1 -1
  14. package/dist/gateway/static/root/assets/{binary-plugins-DoAYhsxa.js → binary-plugins-ByZbwN2A.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-Bw72pO7S.js → block-editor-DGaI2ucU.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-settings-page-BwLoUBcZ.js → browser-settings-page-BZ25v96s.js} +1 -1
  17. package/dist/gateway/static/root/assets/{capability-presets-api-vdbAR65Q.js → capability-presets-api-DaPf3b5d.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-BAsKbJgm.js → capability-presets-settings-panel-C0iHFbY9.js} +1 -1
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-rTG26jpV.js → channel-recipient-api-DrbkoYyF.js} +1 -1
  20. package/dist/gateway/static/root/assets/{channels-settings-CxFWy0cE.js → channels-settings-Bc7FVeqs.js} +1 -1
  21. package/dist/gateway/static/root/assets/channels-status-swr-P3J5voxb.js +1 -0
  22. package/dist/gateway/static/root/assets/{connector-logo-DIMP4NWY.js → connector-logo-CiHea96v.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-page-BjQQwX62.js → connectors-page-oi41mE3U.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-kQq2e0BN.js → desktop-pet-DzdsBRdD.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-B6vtozMY.js → desktop-pet-settings-B-URlTdB.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-Dn5-e3v4.js → directory-picker-path-field-g_N_ROC-.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-BzwIujPG.js → dreaming-settings-DnEe0Mxg.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-debug-page-D_e_hsEy.js → extension-debug-page-DPkoOQED.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-D15CWHBd.js → extension-page-Cf_gDelx.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-D4P0n1om.js → extension-settings-page-YlXpJV9k.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-B4qZctjG.js → gateway-config-api-BxHgXB-I.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-BvndV7TP.js → gateway-settings-CGphLe9T.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-startup-retry-BpgMunEb.js → gateway-startup-retry-ChI88pp7.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goal-create-dialog-DrVHKXHq.js → goal-create-dialog-ClzciTH5.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goal-detail-page-PHlCwv68.js → goal-detail-page-CyaLkWhd.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goals-config-api-B6YJB_ct.js → goals-config-api-NoJKU8UZ.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goals-page-Hg9uyO6e.js → goals-page-C-srWhsP.js} +1 -1
  38. package/dist/gateway/static/root/assets/{goals-settings-BROWCIcL.js → goals-settings-kQ1pBOM9.js} +1 -1
  39. package/dist/gateway/static/root/assets/{heartbeat-settings-CoCwIOIg.js → heartbeat-settings-C6jSQCXQ.js} +1 -1
  40. package/dist/gateway/static/root/assets/index-DktduA8Z.css +1 -0
  41. package/dist/gateway/static/root/assets/{index-CxkNzw3e.js → index-twNrYC3D.js} +59 -59
  42. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Bm_AIYQ7.js → keyboard-shortcuts-settings-CIQ6wLqH.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-app-workbench-page-BJWFcxwG.js → local-app-workbench-page-DcaqgchY.js} +1 -1
  44. package/dist/gateway/static/root/assets/local-apps-page-BO6odwNn.js +1 -0
  45. package/dist/gateway/static/root/assets/{locale-store-Bp8joZck.js → locale-store-BP67jtYG.js} +1 -1
  46. package/dist/gateway/static/root/assets/{logs-page-DOmK61ey.js → logs-page-B_13EkK7.js} +1 -1
  47. package/dist/gateway/static/root/assets/{markdown-split-Dy7QpaAz.js → markdown-split-DbJZwtmM.js} +1 -1
  48. package/dist/gateway/static/root/assets/{media-plugins-3Lxliy9D.js → media-plugins-B0WH561o.js} +1 -1
  49. package/dist/gateway/static/root/assets/{messages-CQGpD-dC.js → messages-BIsSVgW7.js} +5 -5
  50. package/dist/gateway/static/root/assets/{models-hub-panel-DGCZom4o.js → models-hub-panel-DkCTjUj_.js} +1 -1
  51. package/dist/gateway/static/root/assets/{notes-page-BJtT4vSf.js → notes-page-B72S7M1Z.js} +1 -1
  52. package/dist/gateway/static/root/assets/{notes-workbench-B_bN7cOR.js → notes-workbench-CfWQczho.js} +2 -2
  53. package/dist/gateway/static/root/assets/{page-tabs-DKB6RDre.js → page-tabs-LjSEtOvG.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-Br_YhYHp.js → preview-open-alternatives-Cn8Jp9jw.js} +1 -1
  55. package/dist/gateway/static/root/assets/project-detail-page-BWOTQX4M.js +1 -0
  56. package/dist/gateway/static/root/assets/{projects-page-DvfL7fSe.js → projects-page-C81dHQ5i.js} +1 -1
  57. package/dist/gateway/static/root/assets/{remote-access-hub-DqwMXSXP.js → remote-access-hub-U1FQUBtJ.js} +1 -1
  58. package/dist/gateway/static/root/assets/{save-bar-controls-BgIE9BBh.js → save-bar-controls-BDUPII5R.js} +1 -1
  59. package/dist/gateway/static/root/assets/{schedule-field-BXDP-oMz.js → schedule-field-B1NY9MNs.js} +1 -1
  60. package/dist/gateway/static/root/assets/{schema-form-Dhv-SmjG.js → schema-form-CnsFMun1.js} +1 -1
  61. package/dist/gateway/static/root/assets/{sessions-page-B_mOZkQk.js → sessions-page-t6DzYLpM.js} +1 -1
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-DggKrWED.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-collapsible-section-CUTExnlK.js → settings-collapsible-section-D9jJ6KlR.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-form-section-CmnDhsf0.js → settings-form-section-36IjMuUY.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-loading-skeleton-B79dq-XY.js → settings-loading-skeleton-DyYMmawg.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-layout-DaFwstQw.js → settings-page-layout-BAP5LguT.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-page-Db8uAv3X.js → settings-page-yv4TeHfF.js} +1 -1
  68. package/dist/gateway/static/root/assets/{setup-status-panel-BUSEj0KK.js → setup-status-panel-DncjFopP.js} +1 -1
  69. package/dist/gateway/static/root/assets/{share-preview-page-Bi00uXzV.js → share-preview-page-BBxZ9lX5.js} +1 -1
  70. package/dist/gateway/static/root/assets/{shares-settings-DzsTYfuX.js → shares-settings-Brx1LsY9.js} +1 -1
  71. package/dist/gateway/static/root/assets/skill-reload-api-C_sLcSxh.js +1 -0
  72. package/dist/gateway/static/root/assets/{skills-page-DeB1tQZL.js → skills-page-BPzqM78D.js} +1 -1
  73. package/dist/gateway/static/root/assets/{system-settings-panel-Cxaph7hW.js → system-settings-panel-B3ceUo4i.js} +1 -1
  74. package/dist/gateway/static/root/assets/{theme-store-eCTN1RpG.js → theme-store-_efiWyB8.js} +1 -1
  75. package/dist/gateway/static/root/assets/{typed-models-lib-CcZ_tyFY.js → typed-models-lib-Dp1PvxGZ.js} +1 -1
  76. package/dist/gateway/static/root/assets/{use-channel-catalog-C4PWbNoi.js → use-channel-catalog-XHelnCa_.js} +1 -1
  77. package/dist/gateway/static/root/assets/{user-context-page-QTVMx_hG.js → user-context-page-Dg_4sJJz.js} +1 -1
  78. package/dist/gateway/static/root/assets/{user-profile-fields-editor-CPOO9Jz5.js → user-profile-fields-editor-nOOg0uBi.js} +1 -1
  79. package/dist/gateway/static/root/assets/{user-profile-settings-panel-C8cgtSF7.js → user-profile-settings-panel-9fBPCoA9.js} +1 -1
  80. package/dist/gateway/static/root/assets/{utils-CiZK2KwH.js → utils-3AORlPIm.js} +1 -1
  81. package/dist/gateway/static/root/assets/{voice-api-key-field-b-YZtvUu.js → voice-api-key-field-Bc-xxEHw.js} +1 -1
  82. package/dist/gateway/static/root/assets/{work-discovery-page-4zVDOl2G.js → work-discovery-page-CCMe2E98.js} +1 -1
  83. package/dist/gateway/static/root/assets/{work-item-detail-page-CHe2tfkc.js → work-item-detail-page-CnVze8sW.js} +1 -1
  84. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-8SLCYeXE.js → workflow-run-setup-panel-DUKlCVcY.js} +1 -1
  85. package/dist/gateway/static/root/assets/{workflows-page-DEOFqiWn.js → workflows-page-1Hh-__Ur.js} +1 -1
  86. package/dist/gateway/static/root/index.html +7 -7
  87. package/dist/package.js +1 -1
  88. package/dist/src/config/agent-profile.js +1 -1
  89. package/dist/src/gateway/agents-admin.js +1 -1
  90. package/package.json +1 -1
  91. package/dist/gateway/static/root/assets/apps-page-CpX3lBFF.js +0 -1
  92. package/dist/gateway/static/root/assets/channels-status-swr-OKlqTtKJ.js +0 -1
  93. package/dist/gateway/static/root/assets/index-DjCSOyaN.css +0 -1
  94. package/dist/gateway/static/root/assets/local-apps-page-BsiZMrEf.js +0 -1
  95. package/dist/gateway/static/root/assets/project-detail-page-Dq8JouJj.js +0 -1
  96. package/dist/gateway/static/root/assets/settings-advanced-gate-BHGmH6YS.js +0 -1
  97. package/dist/gateway/static/root/assets/skill-reload-api-DSsdU081.js +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-CQGpD-dC.js";import{n as a}from"./locale-store-Bp8joZck.js";import{Dl as o,Io as s,bi as c,cs as l,kt as u,qs as d,sc as f,yi as p}from"./index-CxkNzw3e.js";import{n as m,t as h}from"./settings-page-layout-DaFwstQw.js";import{r as g,t as _}from"./settings-form-section-CmnDhsf0.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)(u,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)(()=>{s()&&R&&z()},[R,z]),!s()||!R)return(0,y.jsxs)(h,{gap:`gap-3`,children:[(0,y.jsx)(m,{title:t.title}),(0,y.jsxs)(`div`,{className:g(),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)&&p()}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)(h,{gap:`gap-6`,children:[(0,y.jsx)(m,{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)(_,{children:[(0,y.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,y.jsx)(d,{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:g(),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`,l.press),onClick:()=>void B(),children:[(0,y.jsx)(f,{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]),s=t.perm[n],c=N[n]===`unknown`?j(e,n,O.platform):null;return s?(0,y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface 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:s.title}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.desc}),(0,y.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),c?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:c}):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`,l.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`,l.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`,l.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`,l.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`,l.press),onClick:()=>void U(i),children:[t.openSettings,(0,y.jsx)(o,{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-BIsSVgW7.js";import{n as a}from"./locale-store-BP67jtYG.js";import{Dl as o,Io as s,bi as c,cs as l,kt as u,qs as d,sc as f,yi as p}from"./index-twNrYC3D.js";import{n as m,t as h}from"./settings-page-layout-BAP5LguT.js";import{r as g,t as _}from"./settings-form-section-36IjMuUY.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)(u,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)(()=>{s()&&R&&z()},[R,z]),!s()||!R)return(0,y.jsxs)(h,{gap:`gap-3`,children:[(0,y.jsx)(m,{title:t.title}),(0,y.jsxs)(`div`,{className:g(),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)&&p()}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)(h,{gap:`gap-6`,children:[(0,y.jsx)(m,{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)(_,{children:[(0,y.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,y.jsx)(d,{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:g(),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`,l.press),onClick:()=>void B(),children:[(0,y.jsx)(f,{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]),s=t.perm[n],c=N[n]===`unknown`?j(e,n,O.platform):null;return s?(0,y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface 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:s.title}),(0,y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.desc}),(0,y.jsx)(`p`,{className:`mt-1 text-xs font-medium ${a.className}`,children:a.label}),c?(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:c}):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`,l.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`,l.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`,l.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`,l.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`,l.press),onClick:()=>void U(i),children:[t.openSettings,(0,y.jsx)(o,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}export{N as SystemSettingsPanel};
@@ -1 +1 @@
1
- import{u as e}from"./locale-store-Bp8joZck.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
+ import{u as e}from"./locale-store-BP67jtYG.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{ds as t,fs as n,ps as r}from"./index-CxkNzw3e.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(n,t)}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
+ import{t as e}from"./cn-BQ_8x0bT.js";import{ds as t,fs as n,ps as r}from"./index-twNrYC3D.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(n,t)}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{d as t,i as n}from"./locale-store-Bp8joZck.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
+ import{n as e}from"./vendor-react-BOUWij0V.js";import{d as t,i as n}from"./locale-store-BP67jtYG.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,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-CQGpD-dC.js";import{n as l}from"./locale-store-Bp8joZck.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$t as d,Al as f,Ao as p,As as m,Ds as h,Es as g,Fo as _,Gl as v,Js as y,Jt as b,Ko as x,Lo as S,Mo as C,No as w,Oo as T,Po as E,Ps as D,Ql as O,Qt as k,Wo as A,Ws as j,Xt as M,Yt as N,Zs as P,Zt as F,an as I,bc as L,cl as ee,cn as R,dn as te,en as ne,er as re,fn as ie,in as ae,io as z,iu as oe,jl as se,jo as B,ko as ce,ln as le,lu as ue,mc as de,mn as fe,ms as V,nn as pe,ol as me,on as he,pn as ge,qc as _e,rn as ve,sn as ye,tn as be,un as xe,vs as Se,yn as Ce}from"./index-CxkNzw3e.js";import{t as we}from"./page-tabs-DKB6RDre.js";import{t as Te}from"./user-profile-fields-editor-CPOO9Jz5.js";import{t as Ee}from"./connector-logo-DIMP4NWY.js";var H=e(t(),1),U=n(),De={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function Oe(e){if(e.branding?.logoUrl)return e.branding;let t=De[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}var W=r();function ke(e){let t=(0,U.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:s}=e,l=c(r).you,[u,d]=(0,H.useState)(!1),f,g;t[0]===n?(f=t[1],g=t[2]):(f=()=>{n&&d(!1)},g=[n],t[0]=n,t[1]=f,t[2]=g),(0,H.useEffect)(f,g);let _;t[3]!==i||t[4]!==a?(_=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=_):_=t[5];let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,W.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=v):v=t[6];let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,W.jsx)(Se,{className:`size-4`,"aria-hidden":!0}),t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>d(!1),t[8]=b):b=t[8];let x=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,S;t[9]===x?S=t[10]:(S=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,x),t[9]=x,t[10]=S);let D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,W.jsx)(se,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=D):D=t[11];let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>d(!0),t[12]=O):O=t[12];let k=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,A;t[13]===k?A=t[14]:(A=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,k),t[13]=k,t[14]=A);let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,W.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=j):j=t[15];let M=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),N;t[16]===M?N=t[17]:(N=(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:M}),t[16]=M,t[17]=N);let P;t[18]!==i||t[19]!==l.cancel?(P=(0,W.jsx)(ce,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=P):P=t[20];let F=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,I;t[21]!==u||t[22]!==s?(I=()=>s(u),t[21]=u,t[22]=s,t[23]=I):I=t[23];let L;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,W.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t[24]=L):L=t[24];let ee=i?l.disconnecting:l.disconnectAction,R;t[25]!==i||t[26]!==F||t[27]!==I||t[28]!==ee?(R=(0,W.jsxs)(V,{type:`button`,variant:`secondary`,className:F,disabled:i,onClick:I,children:[L,ee]}),t[25]=i,t[26]=F,t[27]=I,t[28]=ee,t[29]=R):R=t[29];let te;return t[30]!==P||t[31]!==R?(te=(0,W.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[P,R]}),t[30]=P,t[31]=R,t[32]=te):te=t[32],(0,W.jsx)(T,{open:n!==null,onOpenChange:_,children:(0,W.jsxs)(w,{children:[v,(0,W.jsxs)(p,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(E,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,W.jsx)(B,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,W.jsx)(ce,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:y})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[n?.accountLabel?(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,n.accountLabel)}):null,(0,W.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:b,className:S,children:[D,(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:O,disabled:!n?.derivedUnderstandingCount,className:A,children:[j,(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),N]})]})]}),te]})]})})}var Ae=new Set([`overview`,`understanding`,`sources`,`controls`]),je=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],G=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function K(e,t){return e.replace(`{{count}}`,String(t))}function q(e,t){let n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(n):e}function Me(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Ae.has(e)?e:`overview`}function Ne(){let e=(0,U.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(z,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(z,{className:`h-64 rounded-2xl`}),(0,W.jsx)(z,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Pe(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function Fe(e){let t=(0,U.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,H.useState)(!1),[h,g]=(0,H.useState)(n.statement),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!1),x=n.status!==`active`,S=x?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,C;t[0]===S?C=t[1]:(C=o(`rounded-xl border p-3.5`,S),t[0]=S,t[1]=C);let w;t[2]!==a||t[3]!==h||t[4]!==f||t[5]!==_||t[6]!==y||t[7]!==n||t[8]!==r||t[9]!==x||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(w=f?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-20 resize-y`),value:h,onChange:e=>g(e.target.value),placeholder:i.updatePlaceholder,autoFocus:!0}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{g(n.statement),p(!1)},children:i.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!h.trim(),onClick:()=>{u(h.trim()),p(!1)},children:i.save})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(j,{className:`size-3 text-accent`,"aria-hidden":!0}),Pe(n,i)]}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,W.jsx)(`span`,{children:K(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,W.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,q(n.latestEvidenceAt,r))}):null]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[x?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,W.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,W.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,W.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:y,onClick:()=>{if(_){v(null);return}b(!0),be(n.id).then(e=>v(e.history)).finally(()=>b(!1))},children:[(0,W.jsx)(me,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,W.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,W.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,W.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,W.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,W.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,W.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:q(n.updatedAt,r)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,W.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:K(i.evidenceCount,n.evidenceCount)})]})]})]}),_?(0,W.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),_.map(e=>(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,W.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,W.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:q(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=h,t[4]=f,t[5]=_,t[6]=y,t[7]=n,t[8]=r,t[9]=x,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=w):w=t[15];let T;return t[16]!==C||t[17]!==w?(T=(0,W.jsx)(`article`,{className:C,children:w}),t[16]=C,t[17]=w,t[18]=T):T=t[18],T}function Ie(e){let t=(0,U.c)(79),{source:n,language:r,t:i,onConfigure:a,onDisconnect:s}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.lastHealthStatus||t[1]!==i.healthIssue||t[2]!==i.healthOk||t[3]!==i.sourceHealth?(l=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[0]=n.lastHealthStatus,t[1]=i.healthIssue,t[2]=i.healthOk,t[3]=i.sourceHealth,t[4]=l):l=t[4];let u=l,d=`${i.manageSources}: ${n.displayName}`,f;t[5]===a?f=t[6]:(f=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[5]=a,t[6]=f);let p=n.displayName,m;t[7]===n?m=t[8]:(m=Oe(n),t[7]=n,t[8]=m);let h;t[9]!==n.displayName||t[10]!==m?(h=(0,W.jsx)(Ee,{connector:{displayName:p,branding:m},size:`sm`}),t[9]=n.displayName,t[10]=m,t[11]=h):h=t[11];let g;t[12]===n.displayName?g=t[13]:(g=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[12]=n.displayName,t[13]=g);let _;t[14]===n.accountLabel?_=t[15]:(_=n.accountLabel?(0,W.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:n.accountLabel}):null,t[14]=n.accountLabel,t[15]=_);let v;t[16]===n.description?v=t[17]:(v=(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[16]=n.description,t[17]=v);let y;t[18]!==g||t[19]!==_||t[20]!==v?(y=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,_,v]}),t[18]=g,t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==y||t[23]!==h?(b=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,y]}),t[22]=y,t[23]=h,t[24]=b):b=t[24];let x=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,S;t[25]===x?S=t[26]:(S=o(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,x),t[25]=x,t[26]=S);let C;t[27]!==c||t[28]!==S?(C=(0,W.jsx)(`span`,{className:S,children:c}),t[27]=c,t[28]=S,t[29]=C):C=t[29];let w;t[30]!==b||t[31]!==C?(w=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,C]}),t[30]=b,t[31]=C,t[32]=w):w=t[32];let T;t[33]!==n.access.context||t[34]!==i.sourceContext?(T=n.access.context?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[33]=n.access.context,t[34]=i.sourceContext,t[35]=T):T=t[35];let E;t[36]!==n.access.memory||t[37]!==i.sourceMemory?(E=n.access.memory?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[36]=n.access.memory,t[37]=i.sourceMemory,t[38]=E):E=t[38];let D;t[39]!==n.access.read||t[40]!==i.sourceRead?(D=n.access.read?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[39]=n.access.read,t[40]=i.sourceRead,t[41]=D):D=t[41];let O;t[42]!==n.access.write||t[43]!==i.sourceWrite?(O=n.access.write?(0,W.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[42]=n.access.write,t[43]=i.sourceWrite,t[44]=O):O=t[44];let k;t[45]!==T||t[46]!==E||t[47]!==D||t[48]!==O?(k=(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[T,E,D,O]}),t[45]=T,t[46]=E,t[47]=D,t[48]=O,t[49]=k):k=t[49];let A;t[50]!==u||t[51]!==r||t[52]!==n.derivedUnderstandingCount||t[53]!==n.installed||t[54]!==n.knowledgeItemCount||t[55]!==n.lastActivityAt||t[56]!==n.lastSyncAt||t[57]!==n.lastSyncError||t[58]!==n.lastSyncStatus||t[59]!==i.sourceDerivedCount||t[60]!==i.sourceKnowledgeCount||t[61]!==i.sourceLastSync||t[62]!==i.sourceLastUsed||t[63]!==i.sourceNeverUsed||t[64]!==i.sourceSyncFailed?(A=n.installed?(0,W.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[u?(0,W.jsx)(`p`,{children:u}):null,(0,W.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,q(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,W.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,q(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,W.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,W.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,W.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[50]=u,t[51]=r,t[52]=n.derivedUnderstandingCount,t[53]=n.installed,t[54]=n.knowledgeItemCount,t[55]=n.lastActivityAt,t[56]=n.lastSyncAt,t[57]=n.lastSyncError,t[58]=n.lastSyncStatus,t[59]=i.sourceDerivedCount,t[60]=i.sourceKnowledgeCount,t[61]=i.sourceLastSync,t[62]=i.sourceLastUsed,t[63]=i.sourceNeverUsed,t[64]=i.sourceSyncFailed,t[65]=A):A=t[65];let j;t[66]!==s||t[67]!==n.installed||t[68]!==n.instanceId||t[69]!==i.disconnect?(j=n.installed&&n.instanceId?(0,W.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),s()},children:i.disconnect})}):null,t[66]=s,t[67]=n.installed,t[68]=n.instanceId,t[69]=i.disconnect,t[70]=j):j=t[70];let M;return t[71]!==a||t[72]!==w||t[73]!==d||t[74]!==k||t[75]!==A||t[76]!==j||t[77]!==f?(M=(0,W.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":d,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:f,children:[w,k,A,j]}),t[71]=a,t[72]=w,t[73]=d,t[74]=k,t[75]=A,t[76]=j,t[77]=f,t[78]=M):M=t[78],M}function Le(e){let t=(0,U.c)(58),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:s,onUpdate:c,onDelete:l}=e,[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(null),[h,g]=(0,H.useState)(``),_=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,v;t[0]===_?v=t[1]:(v=o(`rounded-xl border p-4`,_),t[0]=_,t[1]=v);let y=i.playbookNames[n.id],b;t[2]===y?b=t[3]:(b=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:y}),t[2]=y,t[3]=b);let x;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(x=K(i.playbookRuleCount,n.rules.filter(Re).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=x):x=t[6];let S;t[7]===x?S=t[8]:(S=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[7]=x,t[8]=S);let C;t[9]!==b||t[10]!==S?(C=(0,W.jsxs)(`div`,{children:[b,S]}),t[9]=b,t[10]=S,t[11]=C):C=t[11];let w=n.enabled?i.pausePlaybook:i.resumePlaybook,T;t[12]!==r||t[13]!==a||t[14]!==w?(T=(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:w}),t[12]=r,t[13]=a,t[14]=w,t[15]=T):T=t[15];let E;t[16]!==C||t[17]!==T?(E=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,T]}),t[16]=C,t[17]=T,t[18]=E):E=t[18];let D;t[19]!==r||t[20]!==f||t[21]!==h||t[22]!==l||t[23]!==c||t[24]!==n.rules||t[25]!==i.cancel||t[26]!==i.deleteRule||t[27]!==i.disableRule||t[28]!==i.edit||t[29]!==i.enableRule||t[30]!==i.moveDown||t[31]!==i.moveUp||t[32]!==i.save?(D=n.rules.map((e,t)=>(0,W.jsx)(`li`,{className:o(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:f===e.id?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-16 resize-y`),value:h,onChange:e=>g(e.target.value)}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>p(null),children:i.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!h.trim(),onClick:()=>{c(e.id,{statement:h.trim()}),p(null)},children:i.save})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{p(e.id),g(e.statement)},children:[(0,W.jsx)(L,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,W.jsx)(m,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]})]})},e.id)),t[19]=r,t[20]=f,t[21]=h,t[22]=l,t[23]=c,t[24]=n.rules,t[25]=i.cancel,t[26]=i.deleteRule,t[27]=i.disableRule,t[28]=i.edit,t[29]=i.enableRule,t[30]=i.moveDown,t[31]=i.moveUp,t[32]=i.save,t[33]=D):D=t[33];let O;t[34]===D?O=t[35]:(O=(0,W.jsx)(`ul`,{className:`mt-3 space-y-2`,children:D}),t[34]=D,t[35]=O);let k;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>d(e.target.value),t[36]=k):k=t[36];let A;t[37]!==u||t[38]!==i.newRulePlaceholder?(A=(0,W.jsx)(`input`,{className:G,value:u,onChange:k,placeholder:i.newRulePlaceholder}),t[37]=u,t[38]=i.newRulePlaceholder,t[39]=A):A=t[39];let j;t[40]!==r||t[41]!==u?(j=r||!u.trim(),t[40]=r,t[41]=u,t[42]=j):j=t[42];let M;t[43]!==u||t[44]!==s?(M=()=>{s(u.trim()),d(``)},t[43]=u,t[44]=s,t[45]=M):M=t[45];let N;t[46]!==i.addRule||t[47]!==j||t[48]!==M?(N=(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:j,onClick:M,children:i.addRule}),t[46]=i.addRule,t[47]=j,t[48]=M,t[49]=N):N=t[49];let P;t[50]!==A||t[51]!==N?(P=(0,W.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[A,N]}),t[50]=A,t[51]=N,t[52]=P):P=t[52];let F;return t[53]!==E||t[54]!==O||t[55]!==P||t[56]!==v?(F=(0,W.jsxs)(`article`,{className:v,children:[E,O,P]}),t[53]=E,t[54]=O,t[55]=P,t[56]=v,t[57]=F):F=t[57],F}function Re(e){return e.enabled}function ze(e){let t=(0,U.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:s,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let d;t[4]===u?d=t[5]:(d=(0,W.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=d);let f=n?l.meetSuggestedBody:l.meetBody,p;t[6]===f?p=t[7]:(p=(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:f}),t[6]=f,t[7]=p);let m;t[8]===l.callName?m=t[9]:(m=(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=m);let h;t[10]===a?h=t[11]:(h=e=>a(e.target.value),t[10]=a,t[11]=h);let g;t[12]!==i||t[13]!==r||t[14]!==s?(g=e=>{e.key===`Enter`&&r.trim()&&!i&&s()},t[12]=i,t[13]=r,t[14]=s,t[15]=g):g=t[15];let _=l.meetPlaceholder,v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=o(G,`h-10 flex-1 bg-surface-base/90`),t[16]=v):v=t[16];let b;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==h||t[20]!==g?(b=(0,W.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,autoFocus:!0,onChange:h,onKeyDown:g,placeholder:_,className:v}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=h,t[20]=g,t[21]=b):b=t[21];let x;t[22]!==i||t[23]!==r?(x=i||!r.trim(),t[22]=i,t[23]=r,t[24]=x):x=t[24];let S=i?l.meetSaving:l.meetSave,C;t[25]!==s||t[26]!==x||t[27]!==S?(C=(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:x,onClick:s,children:S}),t[25]=s,t[26]=x,t[27]=S,t[28]=C):C=t[28];let w;t[29]!==b||t[30]!==C||t[31]!==m?(w=(0,W.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[m,b,C]}),t[29]=b,t[30]=C,t[31]=m,t[32]=w):w=t[32];let T;t[33]!==n||t[34]!==l.meetSource?(T=n?(0,W.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,W.jsx)(y,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=T):T=t[35];let E;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(E=(0,W.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=E):E=t[39];let D;return t[40]!==w||t[41]!==T||t[42]!==E||t[43]!==d||t[44]!==p?(D=(0,W.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,W.jsxs)(`div`,{className:`relative max-w-2xl`,children:[d,p,w,T,E]})}),t[40]=w,t[41]=T,t[42]=E,t[43]=d,t[44]=p,t[45]=D):D=t[45],D}function Be(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,p]=i(),m=Me(r.get(`tab`)),h=_(e=>e.setPageHeader),C=_(e=>e.clearPageHeader),{data:w,error:T,isLoading:E,mutate:j}=u(`/api/you`,pe),[z,B]=(0,H.useState)(null),[ce,me]=(0,H.useState)(!1),[be,Se]=(0,H.useState)(``),[Ee,U]=(0,H.useState)(`preference`),[De,Oe]=(0,H.useState)(null),[Ae,Re]=(0,H.useState)(!1),[Be,Ve]=(0,H.useState)(null),[He,Ue]=(0,H.useState)(!1),[We,Ge]=(0,H.useState)(``),[Ke,qe]=(0,H.useState)(!1),[Je,Ye]=(0,H.useState)(null),[Xe,Ze]=(0,H.useState)(!1),[Qe,$e]=(0,H.useState)(!1),[et,tt]=(0,H.useState)(null),[nt,rt]=(0,H.useState)(null),[it,at]=(0,H.useState)(!1),[J,ot]=(0,H.useState)(null),st=(0,H.useRef)(null),ct=(0,H.useRef)(null),Y=w?.profile??{callName:``,pronouns:``,timezone:``,notes:``},X=(0,H.useMemo)(()=>w?.understanding.filter(e=>e.status===`active`)??[],[w]),Z=(0,H.useMemo)(()=>w?.understanding.filter(e=>e.status!==`active`)??[],[w]),lt=(0,H.useMemo)(()=>new Map(je.map(e=>[e,X.filter(t=>t.facet===e)])),[X]),Q=Je??w?.controls??null,ut=w?.sources.filter(e=>e.installed&&e.enabled)??[],dt=ut.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)),$=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),p(n,{replace:!0})},ft=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,H.useLayoutEffect)(()=>(h({startExtra:null,main:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:null}),()=>C()),[C,h,t.subtitle,t.title]),(0,H.useEffect)(()=>{!w||w.profile.callName||Ge(w.profileSetup.callNameSuggestion?.value??``)},[w,w?.profile.callName,w?.profileSetup.callNameSuggestion?.id]);async function pt(e,n,r){B(e.id);try{let t=await xe(e.id,{action:n,content:r});await j(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),j()}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{B(null)}}async function mt(e,n){B(`consent:${e}`);try{await F(e,n),await j(),S({type:`success`,title:t.title,message:t.saved})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{B(null)}}async function ht(){let e=be.trim();if(e){B(`understanding:new`);try{await M({content:e,kind:Ee}),Se(``),me(!1),await j(),S({type:`success`,title:t.understandingTitle,message:t.saved})}catch{S({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{B(null)}}}async function gt(){if(Z.length){B(`understanding:batch`);try{await b(Z.map(e=>e.id),`confirm`),await j()}catch{S({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{B(null)}}}async function _t(e,n){B(`conflict:${e}`);try{await I(e,n),await j()}catch{S({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{B(null)}}async function vt(e){B(`grant:${e}`);try{await he(e),await j()}catch{S({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{B(null)}}async function yt(r,i){B(`insight:${r.id}`);try{let t=await R(r.id,{action:i,uiLocale:e});await j(),i===`apply`&&t.href&&n(t.href)}catch{S({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{B(null)}}async function bt(e){B(`playbook:${e.id}`);try{await ye(e.id,!e.enabled),await j()}catch{S({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{B(null)}}async function xt(e,n){B(`playbook:${e}`);try{await n(),await j()}catch{S({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{B(null)}}async function St(){if(De){B(De.id);try{await ve(De.id);let e=De.id;Oe(null),await j(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),j()}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{B(null)}}}async function Ct(){if(Be){Ue(!0);try{let e=await ie(Be);Re(!1),Ve(null),await j(t=>t&&{...t,...e},{revalidate:!1})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{Ue(!1)}}}async function wt(){let e=We.trim();if(!(!e||Ke)){qe(!0);try{let t=await ie({callName:e,timezone:Y.timezone||Ce()});await j(e=>e&&{...e,...t},{revalidate:!1})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}async function Tt(){if(!Ke){qe(!0);try{let e=await ge(`snooze`);await j(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}function Et(){Ve(Y),Re(!0),requestAnimationFrame(()=>st.current?.scrollIntoView({behavior:`smooth`,block:`center`}))}async function Dt(){if(Q){Ze(!0);try{Ye(await te(Q)),await j(),S({type:`success`,title:t.title,message:t.saved})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{Ze(!1)}}}async function Ot(e){if(!(Qe||e===w?.trust.defaultActionLevel)){$e(!0);try{let t=await fe(e);await j(e=>e&&{...e,trust:t},{revalidate:!1})}catch{S({type:`error`,title:t.trustTitle,message:t.saveError})}finally{$e(!1),tt(null)}}}async function kt(e){if(!(!nt?.instanceId||it)){at(!0);try{let n=await d(nt.instanceId,e);rt(null),await j(),S({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{S({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{at(!1)}}}async function At(){if(!J){ot(`export`);try{let e=await ne(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{S({type:`error`,title:t.transferTitle,message:t.saveError})}finally{ot(null)}}}async function jt(e){if(!(!e||J)){ot(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await ae(JSON.parse(await e.text()));await j(),$(`understanding`,`review`),S({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{S({type:`error`,title:t.transferTitle,message:t.importError})}finally{ct.current&&(ct.current.value=``),ot(null)}}}return(0,W.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,W.jsx)(we,{items:[{id:`overview`,label:t.tabs.overview,icon:ee},{id:`understanding`,label:t.tabs.understanding,icon:oe,count:Z.length||void 0},{id:`sources`,label:t.tabs.sources,icon:se},{id:`controls`,label:t.tabs.controls,icon:P}],activeTab:m,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`}),E?(0,W.jsx)(Ne,{}):T||!w?(0,W.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,w&&m===`overview`?(0,W.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Y.callName&&w.profileSetup.shouldPrompt?(0,W.jsx)(ze,{suggestion:w.profileSetup.callNameSuggestion,draft:We,busy:Ke,onDraftChange:Ge,onSave:()=>void wt(),onLater:()=>void Tt(),t}):null,Z.length>0||dt.length>0||!Y.callName?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[Z.length>0?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[K(t.reviewCount,Z.length),(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})]}):null,dt.length>0?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[K(t.sourceIssues,dt.length),(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})]}):null,Y.callName?null:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:Et,children:[t.completeProfile,(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})]})]})]}):(0,W.jsxs)(`section`,{className:`rounded-2xl border border-success/20 bg-success-soft p-4 text-sm text-fg`,children:[(0,W.jsx)(s,{className:`mr-2 inline size-4 text-success`,"aria-hidden":!0}),t.upToDate]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/55 via-surface-panel to-surface-panel p-5`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.heroTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.heroBody}),(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`),children:[(0,W.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:X.length}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`sources`),children:[(0,W.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:ut.length}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`controls`),children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.trustLevels[w.trust.defaultActionLevel]}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.currentTrust})]})]})]}),w.insights.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(_e,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.insightsHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:w.insights.map(e=>(0,W.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?K(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:z===`insight:${e.id}`,onClick:()=>void yt(e,`dismiss`),children:t.notNow}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:z===`insight:${e.id}`,onClick:()=>void yt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,W.jsxs)(`section`,{ref:st,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(v,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),Ae?null:(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:Et,children:[(0,W.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),Ae&&Be?(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(Te,{value:Be,onChange:Ve,language:e,inputClassName:G,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{Re(!1),Ve(null)},children:t.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:He,onClick:()=>void Ct(),children:He?t.saving:t.save})]})]}):(0,W.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.callName||`—`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.timezone||`—`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.pronouns||`—`})]}),Y.notes?(0,W.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,W.jsx)(`dd`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg`,children:Y.notes})]}):null]})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})})]}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[X.slice(0,4).map(e=>(0,W.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),X.length===0?(0,W.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]}),w.playbooks.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(ue,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.playbooksHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:w.playbooks.map(e=>(0,W.jsx)(Le,{playbook:e,busy:z===`playbook:${e.id}`,t,onToggleGroup:()=>void bt(e),onCreate:t=>void xt(e.id,()=>N(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void xt(e.id,()=>le(e.id,t,n)),onDelete:t=>void xt(e.id,()=>k(e.id,t))},e.id))})]}):null]}):null,w&&m===`understanding`?(0,W.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs text-fg-muted`,children:t.memoryScope}),(0,W.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),ce?null:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>me(!0),children:[(0,W.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),ce?(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-24 resize-y`),value:be,onChange:e=>Se(e.target.value),placeholder:t.understandingPlaceholder,autoFocus:!0}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,W.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,W.jsx)(A,{value:Ee,onChange:e=>U(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,W.jsx)(x,{value:e,children:t},e))})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{me(!1),Se(``)},children:t.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:!be.trim()||z===`understanding:new`,onClick:()=>void ht(),children:t.add})]})]})]}):null]}),w.conflictGroups.some(e=>e.unresolved)?(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,W.jsx)(`div`,{className:`mt-3 space-y-3`,children:w.conflictGroups.filter(e=>e.unresolved).map(n=>(0,W.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Pe(r,t),` · `,q(r.updatedAt,e)]})]}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:z===`conflict:${n.id}`,onClick:()=>void _t(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,w.consentRequests.length>0?(0,W.jsxs)(`section`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),w.consentRequests.map(e=>(0,W.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,disabled:z===`consent:${e.id}`,onClick:()=>void mt(e.id,`deny`),children:t.consentDeny}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:z===`consent:${e.id}`,onClick:()=>void mt(e.id,`once`),children:t.consentOnce}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:z===`consent:${e.id}`,onClick:()=>void mt(e.id,`session`),children:t.consentSession}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:z===`consent:${e.id}`,onClick:()=>void mt(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,Z.length>0?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:z===`understanding:batch`,onClick:()=>void gt(),children:t.reviewAll})]}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:Z.map(n=>(0,W.jsx)(Fe,{item:n,language:e,t,busy:z===n.id,onConfirm:()=>void pt(n,`confirm`),onReject:()=>void pt(n,`reject`),onUpdate:e=>void pt(n,`update`,e),onForget:()=>Oe(n)},n.id))})]}):X.length>0?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,W.jsx)(s,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,je.map(n=>{let r=lt.get(n)??[];return r.length===0?null:(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,W.jsx)(Fe,{item:n,language:e,t,busy:z===n.id,onConfirm:()=>void pt(n,`confirm`),onReject:()=>void pt(n,`reject`),onUpdate:e=>void pt(n,`update`,e),onForget:()=>Oe(n)},n.id))})]},n)}),w.understanding.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,w&&m===`sources`?(0,W.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.sourcesHint})]}),(0,W.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})]})]}),w.sourceRecommendations.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(D,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.recommendationsHint}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:w.sourceRecommendations.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>ft({id:e.sourceId}),children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:w.sources.map(n=>(0,W.jsx)(Ie,{source:n,language:e,t,onConfigure:()=>ft(n),onDisconnect:()=>rt(n)},`${n.id}:${n.instanceId??`catalog`}`))}),w.sources.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,w&&m===`controls`&&Q?(0,W.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-2`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.controlHint}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,W.jsx)(A,{value:Q.mode,onChange:e=>Ye({...Q,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,W.jsx)(x,{value:e,children:t},e))})]}),(0,W.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,W.jsx)(A,{value:Q.sensitiveWritePolicy,onChange:e=>Ye({...Q,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,W.jsx)(x,{value:e,children:t},e))})]}),(0,W.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-accent-soft/40 p-3 text-xs leading-5 text-fg-muted`,children:[(0,W.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:t.transientPromise})]}),(0,W.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:Xe,onClick:()=>void Dt(),children:Xe?t.saving:t.save})})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.trustTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.trustHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:w.trust.levels.map(e=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e===w.trust.defaultActionLevel,disabled:Qe,onClick:()=>e===`auto`?tt(e):void Ot(e),className:o(`rounded-xl border p-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-70`,e===w.trust.defaultActionLevel?`border-accent/35 bg-accent-soft/35`:`border-edge-subtle bg-surface-panel hover:border-accent/25 hover:bg-surface-hover`),children:[(0,W.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:t.trustLevels[e]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustLevelHints[e]}),e===w.trust.defaultActionLevel?(0,W.jsx)(`span`,{className:`mt-2 inline-block rounded-full bg-accent-soft px-2 py-0.5 text-[11px] text-accent-fg`,children:t.defaultTrust}):null]},e))}),(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.autoOptInPromise})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),w.referenceGrants.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:w.referenceGrants.map(n=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${q(n.expiresAt,e)}`:``]})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:z===`grant:${n.id}`,onClick:()=>void vt(n.id),children:t.revoke})]},n.id))}):(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.transferHint}),(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:J!==null,onClick:()=>void At(),children:[(0,W.jsx)(f,{className:`size-4`,"aria-hidden":!0}),J===`export`?t.exporting:t.exportAction]}),(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:J!==null,onClick:()=>ct.current?.click(),children:[(0,W.jsx)(g,{className:`size-4`,"aria-hidden":!0}),J===`import`?t.importing:t.importAction]}),(0,W.jsx)(`input`,{ref:ct,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>void jt(e.target.files?.[0])})]}),(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.importPromise})]})]}):null,(0,W.jsx)(re,{open:De!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void St(),onCancel:()=>Oe(null)}),(0,W.jsx)(re,{open:et===`auto`,title:t.autoConfirmTitle,description:t.autoConfirmBody,confirmLabel:t.autoConfirmAction,cancelLabel:t.cancel,onConfirm:()=>void Ot(`auto`),onCancel:()=>tt(null)}),(0,W.jsx)(ke,{source:nt,language:e,busy:it,onOpenChange:e=>{e||rt(null)},onConfirm:e=>void kt(e)})]})}export{Be as UserContextPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-BIsSVgW7.js";import{n as l}from"./locale-store-BP67jtYG.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$t as d,Al as f,Ao as p,As as m,Ds as h,Es as g,Fo as _,Gl as v,Js as y,Jt as b,Ko as x,Lo as S,Mo as C,No as w,Oo as T,Po as E,Ps as D,Ql as O,Qt as k,Wo as A,Ws as j,Xt as M,Yt as N,Zs as P,Zt as F,an as I,bc as L,cl as ee,cn as R,dn as te,en as ne,er as re,fn as ie,in as ae,io as z,iu as oe,jl as se,jo as B,ko as ce,ln as le,lu as ue,mc as de,mn as fe,ms as V,nn as pe,ol as me,on as he,pn as ge,qc as _e,rn as ve,sn as ye,tn as be,un as xe,vs as Se,yn as Ce}from"./index-twNrYC3D.js";import{t as we}from"./page-tabs-LjSEtOvG.js";import{t as Te}from"./user-profile-fields-editor-nOOg0uBi.js";import{t as Ee}from"./connector-logo-CiHea96v.js";var H=e(t(),1),U=n(),De={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function Oe(e){if(e.branding?.logoUrl)return e.branding;let t=De[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}var W=r();function ke(e){let t=(0,U.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:s}=e,l=c(r).you,[u,d]=(0,H.useState)(!1),f,g;t[0]===n?(f=t[1],g=t[2]):(f=()=>{n&&d(!1)},g=[n],t[0]=n,t[1]=f,t[2]=g),(0,H.useEffect)(f,g);let _;t[3]!==i||t[4]!==a?(_=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=_):_=t[5];let v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,W.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=v):v=t[6];let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,W.jsx)(Se,{className:`size-4`,"aria-hidden":!0}),t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>d(!1),t[8]=b):b=t[8];let x=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,S;t[9]===x?S=t[10]:(S=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,x),t[9]=x,t[10]=S);let D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,W.jsx)(se,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=D):D=t[11];let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>d(!0),t[12]=O):O=t[12];let k=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,A;t[13]===k?A=t[14]:(A=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,k),t[13]=k,t[14]=A);let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,W.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=j):j=t[15];let M=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),N;t[16]===M?N=t[17]:(N=(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:M}),t[16]=M,t[17]=N);let P;t[18]!==i||t[19]!==l.cancel?(P=(0,W.jsx)(ce,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=P):P=t[20];let F=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,I;t[21]!==u||t[22]!==s?(I=()=>s(u),t[21]=u,t[22]=s,t[23]=I):I=t[23];let L;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,W.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t[24]=L):L=t[24];let ee=i?l.disconnecting:l.disconnectAction,R;t[25]!==i||t[26]!==F||t[27]!==I||t[28]!==ee?(R=(0,W.jsxs)(V,{type:`button`,variant:`secondary`,className:F,disabled:i,onClick:I,children:[L,ee]}),t[25]=i,t[26]=F,t[27]=I,t[28]=ee,t[29]=R):R=t[29];let te;return t[30]!==P||t[31]!==R?(te=(0,W.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[P,R]}),t[30]=P,t[31]=R,t[32]=te):te=t[32],(0,W.jsx)(T,{open:n!==null,onOpenChange:_,children:(0,W.jsxs)(w,{children:[v,(0,W.jsxs)(p,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(E,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,W.jsx)(B,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,W.jsx)(ce,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:y})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[n?.accountLabel?(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,n.accountLabel)}):null,(0,W.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:b,className:S,children:[D,(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:O,disabled:!n?.derivedUnderstandingCount,className:A,children:[j,(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),N]})]})]}),te]})]})})}var Ae=new Set([`overview`,`understanding`,`sources`,`controls`]),je=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],G=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function K(e,t){return e.replace(`{{count}}`,String(t))}function q(e,t){let n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(n):e}function Me(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Ae.has(e)?e:`overview`}function Ne(){let e=(0,U.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(z,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(z,{className:`h-64 rounded-2xl`}),(0,W.jsx)(z,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Pe(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function Fe(e){let t=(0,U.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,H.useState)(!1),[h,g]=(0,H.useState)(n.statement),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!1),x=n.status!==`active`,S=x?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,C;t[0]===S?C=t[1]:(C=o(`rounded-xl border p-3.5`,S),t[0]=S,t[1]=C);let w;t[2]!==a||t[3]!==h||t[4]!==f||t[5]!==_||t[6]!==y||t[7]!==n||t[8]!==r||t[9]!==x||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(w=f?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-20 resize-y`),value:h,onChange:e=>g(e.target.value),placeholder:i.updatePlaceholder,autoFocus:!0}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{g(n.statement),p(!1)},children:i.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!h.trim(),onClick:()=>{u(h.trim()),p(!1)},children:i.save})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(j,{className:`size-3 text-accent`,"aria-hidden":!0}),Pe(n,i)]}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,W.jsx)(`span`,{children:K(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,W.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,q(n.latestEvidenceAt,r))}):null]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[x?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,W.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,W.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,W.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:y,onClick:()=>{if(_){v(null);return}b(!0),be(n.id).then(e=>v(e.history)).finally(()=>b(!1))},children:[(0,W.jsx)(me,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,W.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,W.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,W.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,W.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,W.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,W.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:q(n.updatedAt,r)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,W.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:K(i.evidenceCount,n.evidenceCount)})]})]})]}),_?(0,W.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),_.map(e=>(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,W.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,W.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:q(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=h,t[4]=f,t[5]=_,t[6]=y,t[7]=n,t[8]=r,t[9]=x,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=w):w=t[15];let T;return t[16]!==C||t[17]!==w?(T=(0,W.jsx)(`article`,{className:C,children:w}),t[16]=C,t[17]=w,t[18]=T):T=t[18],T}function Ie(e){let t=(0,U.c)(79),{source:n,language:r,t:i,onConfigure:a,onDisconnect:s}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.lastHealthStatus||t[1]!==i.healthIssue||t[2]!==i.healthOk||t[3]!==i.sourceHealth?(l=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[0]=n.lastHealthStatus,t[1]=i.healthIssue,t[2]=i.healthOk,t[3]=i.sourceHealth,t[4]=l):l=t[4];let u=l,d=`${i.manageSources}: ${n.displayName}`,f;t[5]===a?f=t[6]:(f=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[5]=a,t[6]=f);let p=n.displayName,m;t[7]===n?m=t[8]:(m=Oe(n),t[7]=n,t[8]=m);let h;t[9]!==n.displayName||t[10]!==m?(h=(0,W.jsx)(Ee,{connector:{displayName:p,branding:m},size:`sm`}),t[9]=n.displayName,t[10]=m,t[11]=h):h=t[11];let g;t[12]===n.displayName?g=t[13]:(g=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[12]=n.displayName,t[13]=g);let _;t[14]===n.accountLabel?_=t[15]:(_=n.accountLabel?(0,W.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:n.accountLabel}):null,t[14]=n.accountLabel,t[15]=_);let v;t[16]===n.description?v=t[17]:(v=(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[16]=n.description,t[17]=v);let y;t[18]!==g||t[19]!==_||t[20]!==v?(y=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,_,v]}),t[18]=g,t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==y||t[23]!==h?(b=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,y]}),t[22]=y,t[23]=h,t[24]=b):b=t[24];let x=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,S;t[25]===x?S=t[26]:(S=o(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,x),t[25]=x,t[26]=S);let C;t[27]!==c||t[28]!==S?(C=(0,W.jsx)(`span`,{className:S,children:c}),t[27]=c,t[28]=S,t[29]=C):C=t[29];let w;t[30]!==b||t[31]!==C?(w=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,C]}),t[30]=b,t[31]=C,t[32]=w):w=t[32];let T;t[33]!==n.access.context||t[34]!==i.sourceContext?(T=n.access.context?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[33]=n.access.context,t[34]=i.sourceContext,t[35]=T):T=t[35];let E;t[36]!==n.access.memory||t[37]!==i.sourceMemory?(E=n.access.memory?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[36]=n.access.memory,t[37]=i.sourceMemory,t[38]=E):E=t[38];let D;t[39]!==n.access.read||t[40]!==i.sourceRead?(D=n.access.read?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[39]=n.access.read,t[40]=i.sourceRead,t[41]=D):D=t[41];let O;t[42]!==n.access.write||t[43]!==i.sourceWrite?(O=n.access.write?(0,W.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[42]=n.access.write,t[43]=i.sourceWrite,t[44]=O):O=t[44];let k;t[45]!==T||t[46]!==E||t[47]!==D||t[48]!==O?(k=(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[T,E,D,O]}),t[45]=T,t[46]=E,t[47]=D,t[48]=O,t[49]=k):k=t[49];let A;t[50]!==u||t[51]!==r||t[52]!==n.derivedUnderstandingCount||t[53]!==n.installed||t[54]!==n.knowledgeItemCount||t[55]!==n.lastActivityAt||t[56]!==n.lastSyncAt||t[57]!==n.lastSyncError||t[58]!==n.lastSyncStatus||t[59]!==i.sourceDerivedCount||t[60]!==i.sourceKnowledgeCount||t[61]!==i.sourceLastSync||t[62]!==i.sourceLastUsed||t[63]!==i.sourceNeverUsed||t[64]!==i.sourceSyncFailed?(A=n.installed?(0,W.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[u?(0,W.jsx)(`p`,{children:u}):null,(0,W.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,q(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,W.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,q(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,W.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,W.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,W.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[50]=u,t[51]=r,t[52]=n.derivedUnderstandingCount,t[53]=n.installed,t[54]=n.knowledgeItemCount,t[55]=n.lastActivityAt,t[56]=n.lastSyncAt,t[57]=n.lastSyncError,t[58]=n.lastSyncStatus,t[59]=i.sourceDerivedCount,t[60]=i.sourceKnowledgeCount,t[61]=i.sourceLastSync,t[62]=i.sourceLastUsed,t[63]=i.sourceNeverUsed,t[64]=i.sourceSyncFailed,t[65]=A):A=t[65];let j;t[66]!==s||t[67]!==n.installed||t[68]!==n.instanceId||t[69]!==i.disconnect?(j=n.installed&&n.instanceId?(0,W.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),s()},children:i.disconnect})}):null,t[66]=s,t[67]=n.installed,t[68]=n.instanceId,t[69]=i.disconnect,t[70]=j):j=t[70];let M;return t[71]!==a||t[72]!==w||t[73]!==d||t[74]!==k||t[75]!==A||t[76]!==j||t[77]!==f?(M=(0,W.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":d,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:f,children:[w,k,A,j]}),t[71]=a,t[72]=w,t[73]=d,t[74]=k,t[75]=A,t[76]=j,t[77]=f,t[78]=M):M=t[78],M}function Le(e){let t=(0,U.c)(58),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:s,onUpdate:c,onDelete:l}=e,[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(null),[h,g]=(0,H.useState)(``),_=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,v;t[0]===_?v=t[1]:(v=o(`rounded-xl border p-4`,_),t[0]=_,t[1]=v);let y=i.playbookNames[n.id],b;t[2]===y?b=t[3]:(b=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:y}),t[2]=y,t[3]=b);let x;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(x=K(i.playbookRuleCount,n.rules.filter(Re).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=x):x=t[6];let S;t[7]===x?S=t[8]:(S=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[7]=x,t[8]=S);let C;t[9]!==b||t[10]!==S?(C=(0,W.jsxs)(`div`,{children:[b,S]}),t[9]=b,t[10]=S,t[11]=C):C=t[11];let w=n.enabled?i.pausePlaybook:i.resumePlaybook,T;t[12]!==r||t[13]!==a||t[14]!==w?(T=(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:w}),t[12]=r,t[13]=a,t[14]=w,t[15]=T):T=t[15];let E;t[16]!==C||t[17]!==T?(E=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,T]}),t[16]=C,t[17]=T,t[18]=E):E=t[18];let D;t[19]!==r||t[20]!==f||t[21]!==h||t[22]!==l||t[23]!==c||t[24]!==n.rules||t[25]!==i.cancel||t[26]!==i.deleteRule||t[27]!==i.disableRule||t[28]!==i.edit||t[29]!==i.enableRule||t[30]!==i.moveDown||t[31]!==i.moveUp||t[32]!==i.save?(D=n.rules.map((e,t)=>(0,W.jsx)(`li`,{className:o(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:f===e.id?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-16 resize-y`),value:h,onChange:e=>g(e.target.value)}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>p(null),children:i.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!h.trim(),onClick:()=>{c(e.id,{statement:h.trim()}),p(null)},children:i.save})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{p(e.id),g(e.statement)},children:[(0,W.jsx)(L,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,W.jsx)(m,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]})]})},e.id)),t[19]=r,t[20]=f,t[21]=h,t[22]=l,t[23]=c,t[24]=n.rules,t[25]=i.cancel,t[26]=i.deleteRule,t[27]=i.disableRule,t[28]=i.edit,t[29]=i.enableRule,t[30]=i.moveDown,t[31]=i.moveUp,t[32]=i.save,t[33]=D):D=t[33];let O;t[34]===D?O=t[35]:(O=(0,W.jsx)(`ul`,{className:`mt-3 space-y-2`,children:D}),t[34]=D,t[35]=O);let k;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>d(e.target.value),t[36]=k):k=t[36];let A;t[37]!==u||t[38]!==i.newRulePlaceholder?(A=(0,W.jsx)(`input`,{className:G,value:u,onChange:k,placeholder:i.newRulePlaceholder}),t[37]=u,t[38]=i.newRulePlaceholder,t[39]=A):A=t[39];let j;t[40]!==r||t[41]!==u?(j=r||!u.trim(),t[40]=r,t[41]=u,t[42]=j):j=t[42];let M;t[43]!==u||t[44]!==s?(M=()=>{s(u.trim()),d(``)},t[43]=u,t[44]=s,t[45]=M):M=t[45];let N;t[46]!==i.addRule||t[47]!==j||t[48]!==M?(N=(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:j,onClick:M,children:i.addRule}),t[46]=i.addRule,t[47]=j,t[48]=M,t[49]=N):N=t[49];let P;t[50]!==A||t[51]!==N?(P=(0,W.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[A,N]}),t[50]=A,t[51]=N,t[52]=P):P=t[52];let F;return t[53]!==E||t[54]!==O||t[55]!==P||t[56]!==v?(F=(0,W.jsxs)(`article`,{className:v,children:[E,O,P]}),t[53]=E,t[54]=O,t[55]=P,t[56]=v,t[57]=F):F=t[57],F}function Re(e){return e.enabled}function ze(e){let t=(0,U.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:s,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let d;t[4]===u?d=t[5]:(d=(0,W.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=d);let f=n?l.meetSuggestedBody:l.meetBody,p;t[6]===f?p=t[7]:(p=(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:f}),t[6]=f,t[7]=p);let m;t[8]===l.callName?m=t[9]:(m=(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=m);let h;t[10]===a?h=t[11]:(h=e=>a(e.target.value),t[10]=a,t[11]=h);let g;t[12]!==i||t[13]!==r||t[14]!==s?(g=e=>{e.key===`Enter`&&r.trim()&&!i&&s()},t[12]=i,t[13]=r,t[14]=s,t[15]=g):g=t[15];let _=l.meetPlaceholder,v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=o(G,`h-10 flex-1 bg-surface-base/90`),t[16]=v):v=t[16];let b;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==h||t[20]!==g?(b=(0,W.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,autoFocus:!0,onChange:h,onKeyDown:g,placeholder:_,className:v}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=h,t[20]=g,t[21]=b):b=t[21];let x;t[22]!==i||t[23]!==r?(x=i||!r.trim(),t[22]=i,t[23]=r,t[24]=x):x=t[24];let S=i?l.meetSaving:l.meetSave,C;t[25]!==s||t[26]!==x||t[27]!==S?(C=(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:x,onClick:s,children:S}),t[25]=s,t[26]=x,t[27]=S,t[28]=C):C=t[28];let w;t[29]!==b||t[30]!==C||t[31]!==m?(w=(0,W.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[m,b,C]}),t[29]=b,t[30]=C,t[31]=m,t[32]=w):w=t[32];let T;t[33]!==n||t[34]!==l.meetSource?(T=n?(0,W.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,W.jsx)(y,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=T):T=t[35];let E;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(E=(0,W.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=E):E=t[39];let D;return t[40]!==w||t[41]!==T||t[42]!==E||t[43]!==d||t[44]!==p?(D=(0,W.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,W.jsxs)(`div`,{className:`relative max-w-2xl`,children:[d,p,w,T,E]})}),t[40]=w,t[41]=T,t[42]=E,t[43]=d,t[44]=p,t[45]=D):D=t[45],D}function Be(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,p]=i(),m=Me(r.get(`tab`)),h=_(e=>e.setPageHeader),C=_(e=>e.clearPageHeader),{data:w,error:T,isLoading:E,mutate:j}=u(`/api/you`,pe),[z,B]=(0,H.useState)(null),[ce,me]=(0,H.useState)(!1),[be,Se]=(0,H.useState)(``),[Ee,U]=(0,H.useState)(`preference`),[De,Oe]=(0,H.useState)(null),[Ae,Re]=(0,H.useState)(!1),[Be,Ve]=(0,H.useState)(null),[He,Ue]=(0,H.useState)(!1),[We,Ge]=(0,H.useState)(``),[Ke,qe]=(0,H.useState)(!1),[Je,Ye]=(0,H.useState)(null),[Xe,Ze]=(0,H.useState)(!1),[Qe,$e]=(0,H.useState)(!1),[et,tt]=(0,H.useState)(null),[nt,rt]=(0,H.useState)(null),[it,at]=(0,H.useState)(!1),[J,ot]=(0,H.useState)(null),st=(0,H.useRef)(null),ct=(0,H.useRef)(null),Y=w?.profile??{callName:``,pronouns:``,timezone:``,notes:``},X=(0,H.useMemo)(()=>w?.understanding.filter(e=>e.status===`active`)??[],[w]),Z=(0,H.useMemo)(()=>w?.understanding.filter(e=>e.status!==`active`)??[],[w]),lt=(0,H.useMemo)(()=>new Map(je.map(e=>[e,X.filter(t=>t.facet===e)])),[X]),Q=Je??w?.controls??null,ut=w?.sources.filter(e=>e.installed&&e.enabled)??[],dt=ut.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)),$=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),p(n,{replace:!0})},ft=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,H.useLayoutEffect)(()=>(h({startExtra:null,main:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:null}),()=>C()),[C,h,t.subtitle,t.title]),(0,H.useEffect)(()=>{!w||w.profile.callName||Ge(w.profileSetup.callNameSuggestion?.value??``)},[w,w?.profile.callName,w?.profileSetup.callNameSuggestion?.id]);async function pt(e,n,r){B(e.id);try{let t=await xe(e.id,{action:n,content:r});await j(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),j()}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{B(null)}}async function mt(e,n){B(`consent:${e}`);try{await F(e,n),await j(),S({type:`success`,title:t.title,message:t.saved})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{B(null)}}async function ht(){let e=be.trim();if(e){B(`understanding:new`);try{await M({content:e,kind:Ee}),Se(``),me(!1),await j(),S({type:`success`,title:t.understandingTitle,message:t.saved})}catch{S({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{B(null)}}}async function gt(){if(Z.length){B(`understanding:batch`);try{await b(Z.map(e=>e.id),`confirm`),await j()}catch{S({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{B(null)}}}async function _t(e,n){B(`conflict:${e}`);try{await I(e,n),await j()}catch{S({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{B(null)}}async function vt(e){B(`grant:${e}`);try{await he(e),await j()}catch{S({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{B(null)}}async function yt(r,i){B(`insight:${r.id}`);try{let t=await R(r.id,{action:i,uiLocale:e});await j(),i===`apply`&&t.href&&n(t.href)}catch{S({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{B(null)}}async function bt(e){B(`playbook:${e.id}`);try{await ye(e.id,!e.enabled),await j()}catch{S({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{B(null)}}async function xt(e,n){B(`playbook:${e}`);try{await n(),await j()}catch{S({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{B(null)}}async function St(){if(De){B(De.id);try{await ve(De.id);let e=De.id;Oe(null),await j(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),j()}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{B(null)}}}async function Ct(){if(Be){Ue(!0);try{let e=await ie(Be);Re(!1),Ve(null),await j(t=>t&&{...t,...e},{revalidate:!1})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{Ue(!1)}}}async function wt(){let e=We.trim();if(!(!e||Ke)){qe(!0);try{let t=await ie({callName:e,timezone:Y.timezone||Ce()});await j(e=>e&&{...e,...t},{revalidate:!1})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}async function Tt(){if(!Ke){qe(!0);try{let e=await ge(`snooze`);await j(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}function Et(){Ve(Y),Re(!0),requestAnimationFrame(()=>st.current?.scrollIntoView({behavior:`smooth`,block:`center`}))}async function Dt(){if(Q){Ze(!0);try{Ye(await te(Q)),await j(),S({type:`success`,title:t.title,message:t.saved})}catch{S({type:`error`,title:t.title,message:t.saveError})}finally{Ze(!1)}}}async function Ot(e){if(!(Qe||e===w?.trust.defaultActionLevel)){$e(!0);try{let t=await fe(e);await j(e=>e&&{...e,trust:t},{revalidate:!1})}catch{S({type:`error`,title:t.trustTitle,message:t.saveError})}finally{$e(!1),tt(null)}}}async function kt(e){if(!(!nt?.instanceId||it)){at(!0);try{let n=await d(nt.instanceId,e);rt(null),await j(),S({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{S({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{at(!1)}}}async function At(){if(!J){ot(`export`);try{let e=await ne(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{S({type:`error`,title:t.transferTitle,message:t.saveError})}finally{ot(null)}}}async function jt(e){if(!(!e||J)){ot(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await ae(JSON.parse(await e.text()));await j(),$(`understanding`,`review`),S({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{S({type:`error`,title:t.transferTitle,message:t.importError})}finally{ct.current&&(ct.current.value=``),ot(null)}}}return(0,W.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,W.jsx)(we,{items:[{id:`overview`,label:t.tabs.overview,icon:ee},{id:`understanding`,label:t.tabs.understanding,icon:oe,count:Z.length||void 0},{id:`sources`,label:t.tabs.sources,icon:se},{id:`controls`,label:t.tabs.controls,icon:P}],activeTab:m,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`}),E?(0,W.jsx)(Ne,{}):T||!w?(0,W.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,w&&m===`overview`?(0,W.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Y.callName&&w.profileSetup.shouldPrompt?(0,W.jsx)(ze,{suggestion:w.profileSetup.callNameSuggestion,draft:We,busy:Ke,onDraftChange:Ge,onSave:()=>void wt(),onLater:()=>void Tt(),t}):null,Z.length>0||dt.length>0||!Y.callName?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[Z.length>0?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[K(t.reviewCount,Z.length),(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})]}):null,dt.length>0?(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[K(t.sourceIssues,dt.length),(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})]}):null,Y.callName?null:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:Et,children:[t.completeProfile,(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/55 via-surface-panel to-surface-panel p-5`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.heroTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.heroBody}),(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`),children:[(0,W.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:X.length}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`sources`),children:[(0,W.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:ut.length}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`controls`),children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.trustLevels[w.trust.defaultActionLevel]}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.currentTrust})]})]})]}),w.insights.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(_e,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.insightsHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:w.insights.map(e=>(0,W.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?K(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:z===`insight:${e.id}`,onClick:()=>void yt(e,`dismiss`),children:t.notNow}),(0,W.jsx)(V,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:z===`insight:${e.id}`,onClick:()=>void yt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,W.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,W.jsxs)(`section`,{ref:st,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(v,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),Ae?null:(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:Et,children:[(0,W.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),Ae&&Be?(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(Te,{value:Be,onChange:Ve,language:e,inputClassName:G,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{Re(!1),Ve(null)},children:t.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:He,onClick:()=>void Ct(),children:He?t.saving:t.save})]})]}):(0,W.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.callName||`—`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.timezone||`—`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,W.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Y.pronouns||`—`})]}),Y.notes?(0,W.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,W.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,W.jsx)(`dd`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg`,children:Y.notes})]}):null]})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})})]}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[X.slice(0,4).map(e=>(0,W.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),X.length===0?(0,W.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]}),w.playbooks.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(ue,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.playbooksHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:w.playbooks.map(e=>(0,W.jsx)(Le,{playbook:e,busy:z===`playbook:${e.id}`,t,onToggleGroup:()=>void bt(e),onCreate:t=>void xt(e.id,()=>N(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void xt(e.id,()=>le(e.id,t,n)),onDelete:t=>void xt(e.id,()=>k(e.id,t))},e.id))})]}):null]}):null,w&&m===`understanding`?(0,W.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs text-fg-muted`,children:t.memoryScope}),(0,W.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),ce?null:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>me(!0),children:[(0,W.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),ce?(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,W.jsx)(`textarea`,{className:o(G,`min-h-24 resize-y`),value:be,onChange:e=>Se(e.target.value),placeholder:t.understandingPlaceholder,autoFocus:!0}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,W.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,W.jsx)(A,{value:Ee,onChange:e=>U(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,W.jsx)(x,{value:e,children:t},e))})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{me(!1),Se(``)},children:t.cancel}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:!be.trim()||z===`understanding:new`,onClick:()=>void ht(),children:t.add})]})]})]}):null]}),w.conflictGroups.some(e=>e.unresolved)?(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,W.jsx)(`div`,{className:`mt-3 space-y-3`,children:w.conflictGroups.filter(e=>e.unresolved).map(n=>(0,W.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Pe(r,t),` · `,q(r.updatedAt,e)]})]}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:z===`conflict:${n.id}`,onClick:()=>void _t(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,w.consentRequests.length>0?(0,W.jsxs)(`section`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),w.consentRequests.map(e=>(0,W.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,disabled:z===`consent:${e.id}`,onClick:()=>void mt(e.id,`deny`),children:t.consentDeny}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:z===`consent:${e.id}`,onClick:()=>void mt(e.id,`once`),children:t.consentOnce}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:z===`consent:${e.id}`,onClick:()=>void mt(e.id,`session`),children:t.consentSession}),(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:z===`consent:${e.id}`,onClick:()=>void mt(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,Z.length>0?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,W.jsx)(V,{type:`button`,variant:`secondary`,disabled:z===`understanding:batch`,onClick:()=>void gt(),children:t.reviewAll})]}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:Z.map(n=>(0,W.jsx)(Fe,{item:n,language:e,t,busy:z===n.id,onConfirm:()=>void pt(n,`confirm`),onReject:()=>void pt(n,`reject`),onUpdate:e=>void pt(n,`update`,e),onForget:()=>Oe(n)},n.id))})]}):X.length>0?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,W.jsx)(s,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,je.map(n=>{let r=lt.get(n)??[];return r.length===0?null:(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,W.jsx)(Fe,{item:n,language:e,t,busy:z===n.id,onConfirm:()=>void pt(n,`confirm`),onReject:()=>void pt(n,`reject`),onUpdate:e=>void pt(n,`update`,e),onForget:()=>Oe(n)},n.id))})]},n)}),w.understanding.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,w&&m===`sources`?(0,W.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.sourcesHint})]}),(0,W.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,W.jsx)(O,{className:`size-4`,"aria-hidden":!0})]})]}),w.sourceRecommendations.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(D,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.recommendationsHint}),(0,W.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:w.sourceRecommendations.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>ft({id:e.sourceId}),children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:w.sources.map(n=>(0,W.jsx)(Ie,{source:n,language:e,t,onConfigure:()=>ft(n),onDisconnect:()=>rt(n)},`${n.id}:${n.instanceId??`catalog`}`))}),w.sources.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,w&&m===`controls`&&Q?(0,W.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-2`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.controlHint}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,W.jsx)(A,{value:Q.mode,onChange:e=>Ye({...Q,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,W.jsx)(x,{value:e,children:t},e))})]}),(0,W.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,W.jsx)(A,{value:Q.sensitiveWritePolicy,onChange:e=>Ye({...Q,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,W.jsx)(x,{value:e,children:t},e))})]}),(0,W.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-accent-soft/40 p-3 text-xs leading-5 text-fg-muted`,children:[(0,W.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:t.transientPromise})]}),(0,W.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,W.jsx)(V,{type:`button`,variant:`primary`,disabled:Xe,onClick:()=>void Dt(),children:Xe?t.saving:t.save})})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.trustTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.trustHint}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:w.trust.levels.map(e=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e===w.trust.defaultActionLevel,disabled:Qe,onClick:()=>e===`auto`?tt(e):void Ot(e),className:o(`rounded-xl border p-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-70`,e===w.trust.defaultActionLevel?`border-accent/35 bg-accent-soft/35`:`border-edge-subtle bg-surface-panel hover:border-accent/25 hover:bg-surface-hover`),children:[(0,W.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:t.trustLevels[e]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustLevelHints[e]}),e===w.trust.defaultActionLevel?(0,W.jsx)(`span`,{className:`mt-2 inline-block rounded-full bg-accent-soft px-2 py-0.5 text-[11px] text-accent-fg`,children:t.defaultTrust}):null]},e))}),(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.autoOptInPromise})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),w.referenceGrants.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:w.referenceGrants.map(n=>(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${q(n.expiresAt,e)}`:``]})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:z===`grant:${n.id}`,onClick:()=>void vt(n.id),children:t.revoke})]},n.id))}):(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.transferHint}),(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:J!==null,onClick:()=>void At(),children:[(0,W.jsx)(f,{className:`size-4`,"aria-hidden":!0}),J===`export`?t.exporting:t.exportAction]}),(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:J!==null,onClick:()=>ct.current?.click(),children:[(0,W.jsx)(g,{className:`size-4`,"aria-hidden":!0}),J===`import`?t.importing:t.importAction]}),(0,W.jsx)(`input`,{ref:ct,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>void jt(e.target.files?.[0])})]}),(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.importPromise})]})]}):null,(0,W.jsx)(re,{open:De!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void St(),onCancel:()=>Oe(null)}),(0,W.jsx)(re,{open:et===`auto`,title:t.autoConfirmTitle,description:t.autoConfirmBody,confirmLabel:t.autoConfirmAction,cancelLabel:t.cancel,onConfirm:()=>void Ot(`auto`),onCancel:()=>tt(null)}),(0,W.jsx)(ke,{source:nt,language:e,busy:it,onOpenChange:e=>{e||rt(null)},onConfirm:e=>void kt(e)})]})}export{Be as UserContextPage};
@@ -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{Ko as a,Wo as ee,cs as te,gn as ne,vn as o,yn as re}from"./index-CxkNzw3e.js";var ie=n(),ae=e(t(),1),s=r();function c(e){let t=(0,ie.c)(104),{value:n,onChange:r,labels:c,language:l,inputClassName:u}=e,d;t[0]===n.timezone?d=t[1]:(d=()=>o.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=d);let[f,p]=(0,ae.useState)(d),m;t[2]===n.timezone?m=t[3]:(m=()=>!!n.timezone&&!o.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=m);let[h,g]=(0,ae.useState)(m),_;t[4]===n.pronouns?_=t[5]:(_=()=>!!n.pronouns&&!ne.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=_);let[v,oe]=(0,ae.useState)(_),se;bb0:{if(h){se=`__custom__`;break bb0}se=o.some(e=>e.value===n.timezone)?n.timezone:`__custom__`}let ce=se,y;t[6]!==r||t[7]!==n?(y=e=>r({...n,...e}),t[6]=r,t[7]=n,t[8]=y):y=t[8];let b=y,x;t[9]===l?x=t[10]:(x=(e,t)=>l===`zh`?t:e,t[9]=l,t[10]=x);let S=x,C;t[11]===c.callName?C=t[12]:(C=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.callName}),t[11]=c.callName,t[12]=C);let w;t[13]===b?w=t[14]:(w=e=>b({callName:e.target.value}),t[13]=b,t[14]=w);let T;t[15]!==u||t[16]!==c.callNamePlaceholder||t[17]!==w||t[18]!==n.callName?(T=(0,s.jsx)(`input`,{className:u,value:n.callName,onChange:w,placeholder:c.callNamePlaceholder,autoComplete:`off`}),t[15]=u,t[16]=c.callNamePlaceholder,t[17]=w,t[18]=n.callName,t[19]=T):T=t[19];let E;t[20]!==C||t[21]!==T?(E=(0,s.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[C,T]}),t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]===c.pronouns?D=t[24]:(D=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.pronouns}),t[23]=c.pronouns,t[24]=D);let O=v?`__custom__`:n.pronouns,k;t[25]!==b||t[26]!==n.pronouns?(k=e=>{if(e.target.value===`__custom__`){oe(!0),ne.some(e=>e.value===n.pronouns)&&b({pronouns:``});return}oe(!1),b({pronouns:e.target.value})},t[25]=b,t[26]=n.pronouns,t[27]=k):k=t[27];let A;t[28]===c.pronounsPlaceholder?A=t[29]:(A=(0,s.jsx)(a,{value:``,children:c.pronounsPlaceholder}),t[28]=c.pronounsPlaceholder,t[29]=A);let j;t[30]===S?j=t[31]:(j=ne.map(e=>(0,s.jsx)(a,{value:e.value,children:S(e.labelEn,e.labelZh)},e.value)),t[30]=S,t[31]=j);let M;t[32]===c.custom?M=t[33]:(M=(0,s.jsx)(a,{value:`__custom__`,children:c.custom}),t[32]=c.custom,t[33]=M);let N;t[34]!==u||t[35]!==O||t[36]!==k||t[37]!==A||t[38]!==j||t[39]!==M?(N=(0,s.jsxs)(ee,{className:u,value:O,onChange:k,children:[A,j,M]}),t[34]=u,t[35]=O,t[36]=k,t[37]=A,t[38]=j,t[39]=M,t[40]=N):N=t[40];let P;t[41]!==u||t[42]!==c.pronounsPlaceholder||t[43]!==v||t[44]!==b||t[45]!==n.pronouns?(P=v?(0,s.jsx)(`input`,{className:i(u,`mt-1 text-xs`),value:n.pronouns,onChange:e=>b({pronouns:e.target.value}),placeholder:c.pronounsPlaceholder,autoComplete:`off`}):null,t[41]=u,t[42]=c.pronounsPlaceholder,t[43]=v,t[44]=b,t[45]=n.pronouns,t[46]=P):P=t[46];let F;t[47]!==D||t[48]!==N||t[49]!==P?(F=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[D,N,P]}),t[47]=D,t[48]=N,t[49]=P,t[50]=F):F=t[50];let I;t[51]===c.timezone?I=t[52]:(I=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.timezone}),t[51]=c.timezone,t[52]=I);let L;t[53]===u?L=t[54]:(L=i(u,`min-w-0 flex-1`),t[53]=u,t[54]=L);let R;t[55]===b?R=t[56]:(R=e=>{if(e.target.value===`__custom__`){g(!0);return}g(!1),p(``),b({timezone:e.target.value})},t[55]=b,t[56]=R);let z;t[57]===S?z=t[58]:(z=o.map(e=>(0,s.jsx)(a,{value:e.value,children:S(e.labelEn,e.labelZh)},e.value)),t[57]=S,t[58]=z);let B;t[59]===c.timezoneCustom?B=t[60]:(B=(0,s.jsx)(a,{value:`__custom__`,children:c.timezoneCustom}),t[59]=c.timezoneCustom,t[60]=B);let V;t[61]!==L||t[62]!==R||t[63]!==z||t[64]!==B||t[65]!==ce?(V=(0,s.jsxs)(ee,{className:L,value:ce,onChange:R,children:[z,B]}),t[61]=L,t[62]=R,t[63]=z,t[64]=B,t[65]=ce,t[66]=V):V=t[66];let H;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(H=i(`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`,te.press),t[67]=H):H=t[67];let U;t[68]===b?U=t[69]:(U=()=>{let e=re();if(!e)return;let t=o.some(t=>t.value===e);g(!t),p(t?``:e),b({timezone:e})},t[68]=b,t[69]=U);let W;t[70]!==c.timezoneDetect||t[71]!==U?(W=(0,s.jsx)(`button`,{type:`button`,className:H,onClick:U,children:c.timezoneDetect}),t[70]=c.timezoneDetect,t[71]=U,t[72]=W):W=t[72];let G;t[73]!==V||t[74]!==W?(G=(0,s.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[V,W]}),t[73]=V,t[74]=W,t[75]=G):G=t[75];let K;t[76]!==f||t[77]!==u||t[78]!==h||t[79]!==b?(K=h?(0,s.jsx)(`input`,{className:i(u,`mt-1 font-mono text-xs`),value:f,onChange:e=>{p(e.target.value),b({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null,t[76]=f,t[77]=u,t[78]=h,t[79]=b,t[80]=K):K=t[80];let q;t[81]!==I||t[82]!==G||t[83]!==K?(q=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[I,G,K]}),t[81]=I,t[82]=G,t[83]=K,t[84]=q):q=t[84];let J;t[85]===c.notes?J=t[86]:(J=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.notes}),t[85]=c.notes,t[86]=J);let Y;t[87]===u?Y=t[88]:(Y=i(u,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=u,t[88]=Y);let X;t[89]===b?X=t[90]:(X=e=>b({notes:e.target.value}),t[89]=b,t[90]=X);let Z;t[91]!==c.notesPlaceholder||t[92]!==Y||t[93]!==X||t[94]!==n.notes?(Z=(0,s.jsx)(`textarea`,{className:Y,value:n.notes,onChange:X,placeholder:c.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=c.notesPlaceholder,t[92]=Y,t[93]=X,t[94]=n.notes,t[95]=Z):Z=t[95];let Q;t[96]!==J||t[97]!==Z?(Q=(0,s.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[J,Z]}),t[96]=J,t[97]=Z,t[98]=Q):Q=t[98];let $;return t[99]!==E||t[100]!==F||t[101]!==q||t[102]!==Q?($=(0,s.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[E,F,q,Q]}),t[99]=E,t[100]=F,t[101]=q,t[102]=Q,t[103]=$):$=t[103],$}export{c as t};
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{Ko as a,Wo as ee,cs as te,gn as ne,vn as o,yn as re}from"./index-twNrYC3D.js";var ie=n(),ae=e(t(),1),s=r();function c(e){let t=(0,ie.c)(104),{value:n,onChange:r,labels:c,language:l,inputClassName:u}=e,d;t[0]===n.timezone?d=t[1]:(d=()=>o.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=d);let[f,p]=(0,ae.useState)(d),m;t[2]===n.timezone?m=t[3]:(m=()=>!!n.timezone&&!o.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=m);let[h,g]=(0,ae.useState)(m),_;t[4]===n.pronouns?_=t[5]:(_=()=>!!n.pronouns&&!ne.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=_);let[v,oe]=(0,ae.useState)(_),se;bb0:{if(h){se=`__custom__`;break bb0}se=o.some(e=>e.value===n.timezone)?n.timezone:`__custom__`}let ce=se,y;t[6]!==r||t[7]!==n?(y=e=>r({...n,...e}),t[6]=r,t[7]=n,t[8]=y):y=t[8];let b=y,x;t[9]===l?x=t[10]:(x=(e,t)=>l===`zh`?t:e,t[9]=l,t[10]=x);let S=x,C;t[11]===c.callName?C=t[12]:(C=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.callName}),t[11]=c.callName,t[12]=C);let w;t[13]===b?w=t[14]:(w=e=>b({callName:e.target.value}),t[13]=b,t[14]=w);let T;t[15]!==u||t[16]!==c.callNamePlaceholder||t[17]!==w||t[18]!==n.callName?(T=(0,s.jsx)(`input`,{className:u,value:n.callName,onChange:w,placeholder:c.callNamePlaceholder,autoComplete:`off`}),t[15]=u,t[16]=c.callNamePlaceholder,t[17]=w,t[18]=n.callName,t[19]=T):T=t[19];let E;t[20]!==C||t[21]!==T?(E=(0,s.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[C,T]}),t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]===c.pronouns?D=t[24]:(D=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.pronouns}),t[23]=c.pronouns,t[24]=D);let O=v?`__custom__`:n.pronouns,k;t[25]!==b||t[26]!==n.pronouns?(k=e=>{if(e.target.value===`__custom__`){oe(!0),ne.some(e=>e.value===n.pronouns)&&b({pronouns:``});return}oe(!1),b({pronouns:e.target.value})},t[25]=b,t[26]=n.pronouns,t[27]=k):k=t[27];let A;t[28]===c.pronounsPlaceholder?A=t[29]:(A=(0,s.jsx)(a,{value:``,children:c.pronounsPlaceholder}),t[28]=c.pronounsPlaceholder,t[29]=A);let j;t[30]===S?j=t[31]:(j=ne.map(e=>(0,s.jsx)(a,{value:e.value,children:S(e.labelEn,e.labelZh)},e.value)),t[30]=S,t[31]=j);let M;t[32]===c.custom?M=t[33]:(M=(0,s.jsx)(a,{value:`__custom__`,children:c.custom}),t[32]=c.custom,t[33]=M);let N;t[34]!==u||t[35]!==O||t[36]!==k||t[37]!==A||t[38]!==j||t[39]!==M?(N=(0,s.jsxs)(ee,{className:u,value:O,onChange:k,children:[A,j,M]}),t[34]=u,t[35]=O,t[36]=k,t[37]=A,t[38]=j,t[39]=M,t[40]=N):N=t[40];let P;t[41]!==u||t[42]!==c.pronounsPlaceholder||t[43]!==v||t[44]!==b||t[45]!==n.pronouns?(P=v?(0,s.jsx)(`input`,{className:i(u,`mt-1 text-xs`),value:n.pronouns,onChange:e=>b({pronouns:e.target.value}),placeholder:c.pronounsPlaceholder,autoComplete:`off`}):null,t[41]=u,t[42]=c.pronounsPlaceholder,t[43]=v,t[44]=b,t[45]=n.pronouns,t[46]=P):P=t[46];let F;t[47]!==D||t[48]!==N||t[49]!==P?(F=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[D,N,P]}),t[47]=D,t[48]=N,t[49]=P,t[50]=F):F=t[50];let I;t[51]===c.timezone?I=t[52]:(I=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.timezone}),t[51]=c.timezone,t[52]=I);let L;t[53]===u?L=t[54]:(L=i(u,`min-w-0 flex-1`),t[53]=u,t[54]=L);let R;t[55]===b?R=t[56]:(R=e=>{if(e.target.value===`__custom__`){g(!0);return}g(!1),p(``),b({timezone:e.target.value})},t[55]=b,t[56]=R);let z;t[57]===S?z=t[58]:(z=o.map(e=>(0,s.jsx)(a,{value:e.value,children:S(e.labelEn,e.labelZh)},e.value)),t[57]=S,t[58]=z);let B;t[59]===c.timezoneCustom?B=t[60]:(B=(0,s.jsx)(a,{value:`__custom__`,children:c.timezoneCustom}),t[59]=c.timezoneCustom,t[60]=B);let V;t[61]!==L||t[62]!==R||t[63]!==z||t[64]!==B||t[65]!==ce?(V=(0,s.jsxs)(ee,{className:L,value:ce,onChange:R,children:[z,B]}),t[61]=L,t[62]=R,t[63]=z,t[64]=B,t[65]=ce,t[66]=V):V=t[66];let H;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(H=i(`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`,te.press),t[67]=H):H=t[67];let U;t[68]===b?U=t[69]:(U=()=>{let e=re();if(!e)return;let t=o.some(t=>t.value===e);g(!t),p(t?``:e),b({timezone:e})},t[68]=b,t[69]=U);let W;t[70]!==c.timezoneDetect||t[71]!==U?(W=(0,s.jsx)(`button`,{type:`button`,className:H,onClick:U,children:c.timezoneDetect}),t[70]=c.timezoneDetect,t[71]=U,t[72]=W):W=t[72];let G;t[73]!==V||t[74]!==W?(G=(0,s.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[V,W]}),t[73]=V,t[74]=W,t[75]=G):G=t[75];let K;t[76]!==f||t[77]!==u||t[78]!==h||t[79]!==b?(K=h?(0,s.jsx)(`input`,{className:i(u,`mt-1 font-mono text-xs`),value:f,onChange:e=>{p(e.target.value),b({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null,t[76]=f,t[77]=u,t[78]=h,t[79]=b,t[80]=K):K=t[80];let q;t[81]!==I||t[82]!==G||t[83]!==K?(q=(0,s.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[I,G,K]}),t[81]=I,t[82]=G,t[83]=K,t[84]=q):q=t[84];let J;t[85]===c.notes?J=t[86]:(J=(0,s.jsx)(`span`,{className:`font-medium text-fg`,children:c.notes}),t[85]=c.notes,t[86]=J);let Y;t[87]===u?Y=t[88]:(Y=i(u,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=u,t[88]=Y);let X;t[89]===b?X=t[90]:(X=e=>b({notes:e.target.value}),t[89]=b,t[90]=X);let Z;t[91]!==c.notesPlaceholder||t[92]!==Y||t[93]!==X||t[94]!==n.notes?(Z=(0,s.jsx)(`textarea`,{className:Y,value:n.notes,onChange:X,placeholder:c.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=c.notesPlaceholder,t[92]=Y,t[93]=X,t[94]=n.notes,t[95]=Z):Z=t[95];let Q;t[96]!==J||t[97]!==Z?(Q=(0,s.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[J,Z]}),t[96]=J,t[97]=Z,t[98]=Q):Q=t[98];let $;return t[99]!==E||t[100]!==F||t[101]!==q||t[102]!==Q?($=(0,s.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[E,F,q,Q]}),t[99]=E,t[100]=F,t[101]=q,t[102]=Q,t[103]=$):$=t[103],$}export{c 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"./messages-CQGpD-dC.js";import{n as a}from"./locale-store-Bp8joZck.js";import{Gr as o,Sn as s,Wl as c,Xr as l,io as u,ms as d,rc as f,tl as p,wn as m,yn as h}from"./index-CxkNzw3e.js";import{n as g,t as _}from"./settings-page-layout-DaFwstQw.js";import{n as v,t as y}from"./settings-form-section-CmnDhsf0.js";import{t as b}from"./utils-CiZK2KwH.js";import{t as x}from"./user-profile-fields-editor-CPOO9Jz5.js";var S=n(),C=e(t(),1),w=r(),T={callName:``,pronouns:``,timezone:``,notes:``};function E(e){if(e.timezone)return e;let t=h();return t?{...e,timezone:t}:e}function D(){let e=(0,S.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,w.jsxs)(`div`,{className:`grid gap-2`,children:[(0,w.jsx)(u,{className:`h-4 w-24`}),(0,w.jsx)(u,{className:`h-10 rounded-lg`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,w.jsxs)(`div`,{className:`grid gap-2`,children:[(0,w.jsx)(u,{className:`h-4 w-24`}),(0,w.jsx)(u,{className:`h-10 rounded-lg`})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,w.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"aria-hidden":`true`,children:[t,n,(0,w.jsxs)(`div`,{className:`grid gap-2 sm:col-span-2`,children:[(0,w.jsx)(u,{className:`h-4 w-28`}),(0,w.jsx)(u,{className:`h-28 rounded-lg`})]})]}),e[2]=r):r=e[2],r}function O(){let e=a(e=>e.language),t=i(e).userProfileSettings,n=b(),[r,u]=(0,C.useState)(T),[h,S]=(0,C.useState)(JSON.stringify(T)),[O,k]=(0,C.useState)(!0),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)(!1),[P,F]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return k(!0),F(null),o().then(t=>{if(e)return;let n=E(s(t));u(n),S(JSON.stringify(n))}).catch(n=>{e||F(n instanceof Error?n.message:t.loadError)}).finally(()=>{e||k(!1)}),()=>{e=!0}},[t.loadError]);let I=JSON.stringify(r)!==h;async function L(){j(!0),F(null);try{await l(m(r)),S(JSON.stringify(r)),N(!0)}catch(e){F(e instanceof Error?e.message:t.saveError)}finally{j(!1)}}return(0,w.jsxs)(_,{gap:`gap-6`,children:[(0,w.jsx)(g,{title:t.title,subtitle:t.subtitle,actions:(0,w.jsxs)(d,{type:`button`,variant:`primary`,disabled:O||A||!I,onClick:()=>void L(),children:[(0,w.jsx)(f,{className:`size-4`,"aria-hidden":!0}),A?t.saving:M?t.saved:t.save]})}),(0,w.jsxs)(y,{children:[(0,w.jsx)(v,{icon:c,title:t.sectionTitle,subtitle:t.sectionSubtitle}),O?(0,w.jsx)(D,{}):(0,w.jsx)(x,{value:r,onChange:e=>{u(e),N(!1)},labels:t,language:e,inputClassName:n}),(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)(p,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,w.jsx)(`span`,{children:t.note})]}),P?(0,w.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:P}):null]})]})}export{O as UserProfileSettingsPanel};
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"./messages-BIsSVgW7.js";import{n as a}from"./locale-store-BP67jtYG.js";import{Gr as o,Sn as s,Wl as c,Xr as l,io as u,ms as d,rc as f,tl as p,wn as m,yn as h}from"./index-twNrYC3D.js";import{n as g,t as _}from"./settings-page-layout-BAP5LguT.js";import{n as v,t as y}from"./settings-form-section-36IjMuUY.js";import{t as b}from"./utils-3AORlPIm.js";import{t as x}from"./user-profile-fields-editor-nOOg0uBi.js";var S=n(),C=e(t(),1),w=r(),T={callName:``,pronouns:``,timezone:``,notes:``};function E(e){if(e.timezone)return e;let t=h();return t?{...e,timezone:t}:e}function D(){let e=(0,S.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,w.jsxs)(`div`,{className:`grid gap-2`,children:[(0,w.jsx)(u,{className:`h-4 w-24`}),(0,w.jsx)(u,{className:`h-10 rounded-lg`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,w.jsxs)(`div`,{className:`grid gap-2`,children:[(0,w.jsx)(u,{className:`h-4 w-24`}),(0,w.jsx)(u,{className:`h-10 rounded-lg`})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,w.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"aria-hidden":`true`,children:[t,n,(0,w.jsxs)(`div`,{className:`grid gap-2 sm:col-span-2`,children:[(0,w.jsx)(u,{className:`h-4 w-28`}),(0,w.jsx)(u,{className:`h-28 rounded-lg`})]})]}),e[2]=r):r=e[2],r}function O(){let e=a(e=>e.language),t=i(e).userProfileSettings,n=b(),[r,u]=(0,C.useState)(T),[h,S]=(0,C.useState)(JSON.stringify(T)),[O,k]=(0,C.useState)(!0),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)(!1),[P,F]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return k(!0),F(null),o().then(t=>{if(e)return;let n=E(s(t));u(n),S(JSON.stringify(n))}).catch(n=>{e||F(n instanceof Error?n.message:t.loadError)}).finally(()=>{e||k(!1)}),()=>{e=!0}},[t.loadError]);let I=JSON.stringify(r)!==h;async function L(){j(!0),F(null);try{await l(m(r)),S(JSON.stringify(r)),N(!0)}catch(e){F(e instanceof Error?e.message:t.saveError)}finally{j(!1)}}return(0,w.jsxs)(_,{gap:`gap-6`,children:[(0,w.jsx)(g,{title:t.title,subtitle:t.subtitle,actions:(0,w.jsxs)(d,{type:`button`,variant:`primary`,disabled:O||A||!I,onClick:()=>void L(),children:[(0,w.jsx)(f,{className:`size-4`,"aria-hidden":!0}),A?t.saving:M?t.saved:t.save]})}),(0,w.jsxs)(y,{children:[(0,w.jsx)(v,{icon:c,title:t.sectionTitle,subtitle:t.sectionSubtitle}),O?(0,w.jsx)(D,{}):(0,w.jsx)(x,{value:r,onChange:e=>{u(e),N(!1)},labels:t,language:e,inputClassName:n}),(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)(p,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,w.jsx)(`span`,{children:t.note})]}),P?(0,w.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:P}):null]})]})}export{O as UserProfileSettingsPanel};
@@ -1 +1 @@
1
- import{t as e}from"./cn-BQ_8x0bT.js";import{ps as t}from"./index-CxkNzw3e.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
+ import{t as e}from"./cn-BQ_8x0bT.js";import{ps as t}from"./index-twNrYC3D.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"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{d as o,i as s,o as c}from"./locale-store-Bp8joZck.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{Dl as u,Gt as d,Hn as f,Ko as p,Rc as m,Wo as h,Wt as g,as as _,eu as v,ms as y,no as b,ps as x,rc as ee,ro as S}from"./index-CxkNzw3e.js";var C=`/api/image/providers`;async function w(){return(await s(o(`/api/image/providers`)))?.payload?.providers??[]}var T=e(t(),1),te=n();function E(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function ne(e){return e?.apiKey?`••••••••••••`:``}function D(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:ne(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function O(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function k(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(f(n)&&f(r)))return n||(r?null:void 0)}function re(e,t,n){let r={};for(let i of e){let e=t[i]??E(),a=n[i]??E();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=k(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=O(e,a,`region`);c!==void 0&&(o.region=c);let l=O(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=O(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 ie(e){Object.keys(e).length!==0&&(await s(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await b())}var j=r();function ae(e){let t=(0,te.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(M),t[0]=n,t[1]=c);let l=c,f=`img-cred-key-${n}`,p;t[2]!==a.apiKeyLabel||t[3]!==f?(p=(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:f,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=f,t[4]=p):p=t[4];let m;t[5]!==s||t[6]!==o?(m=o.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,j.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:[d(e.kind,s),(0,j.jsx)(u,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=m):m=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,j.jsx)(_,{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 v;return t[14]!==p||t[15]!==m||t[16]!==g?(v=(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[p,m,g]}),t[14]=p,t[15]=m,t[16]=g,t[17]=v):v=t[17],v}function M(e){return e.apiKey??null}function N(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x)}function oe(){return a(N(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var P=`__custom__`;function se(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:P}function ce(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:P}function le(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function ue(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function de(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function fe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function pe(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function me(e){let t=(0,te.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:d,credNoopFlash:f,updateCredRow:_,onDiscardCredentials:b,onSaveCredentials:x,extensionIds:S,showExtensionLinks:C,showImageModelsLink:w,hideActions:ne,language:D,apiKeyLinkLabels:O,messages:k}=e,re=ne===void 0?!1:ne,A;t[0]===n?A=t[1]:(A=n.some(ye),t[0]=n,t[1]=A);let ie=A,M;t[2]===n?M=t[3]:(M=n.some(ve),t[2]=n,t[3]=M);let me=M,[F,be]=(0,T.useState)(_e),[I,L]=(0,T.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)fe(r[e.id]??E(),o[e.id]??E())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,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)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(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]===k.credentialsIntro?W=t[15]:(W=(0,j.jsx)(`p`,{children:k.credentialsIntro}),t[14]=k.credentialsIntro,t[15]=W);let G;t[16]!==ie||t[17]!==k.regionHint?(G=ie?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.regionHint}):null,t[16]=ie,t[17]=k.regionHint,t[18]=G):G=t[18];let K;t[19]!==me||t[20]!==k.endpointPresetsHint?(K=me?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.endpointPresetsHint}):null,t[19]=me,t[20]=k.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==w||t[23]!==k.imageModelsLinkTitle||t[24]!==k.openImageModelsPage?(q=w?(0,j.jsx)(`p`,{children:(0,j.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:k.imageModelsLinkTitle,children:k.openImageModelsPage})}):null,t[22]=w,t[23]=k.imageModelsLinkTitle,t[24]=k.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,j.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]===l?Y=t[32]:(Y=l?(0,j.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:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==f||t[35]!==d||t[36]!==c||t[37]!==re||t[38]!==b||t[39]!==x||t[40]!==k.credentialsNothingToSave||t[41]!==k.credentialsSaved||t[42]!==k.discardCredentials||t[43]!==k.saveCredentials||t[44]!==k.savingCredentials?(X=re?null:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[d?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsSaved}):null,f?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsNothingToSave}):null,(0,j.jsx)(y,{type:`button`,variant:`secondary`,onClick:b,disabled:!s||c,children:k.discardCredentials}),(0,j.jsx)(y,{type:`button`,variant:`primary`,onClick:x,disabled:!s||c,children:c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(m,{className:`size-3.5 animate-spin`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.savingCredentials})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ee,{className:`size-3.5`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.saveCredentials})]})})]}),t[33]=s,t[34]=f,t[35]=d,t[36]=c,t[37]=re,t[38]=b,t[39]=x,t[40]=k.credentialsNothingToSave,t[41]=k.credentialsSaved,t[42]=k.discardCredentials,t[43]=k.saveCredentials,t[44]=k.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==O||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==D||t[52]!==C||t[53]!==n||t[54]!==k||t[55]!==U||t[56]!==_){let e;t[58]!==O||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==D||t[64]!==C||t[65]!==k||t[66]!==U||t[67]!==_?(e=e=>{let t=r[e.id]??E(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=fe(t,o[e.id]??E()),l=V(e.id),d=e.label??e.id,f=pe(k,e.models.length);return(0,j.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,j.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":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:d}),(0,j.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.unsavedChanges}):null,e.configured?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.configured}):(0,j.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:k.missingKey})]}),(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,j.jsx)(`span`,{children:f}),e.defaultModel?(0,j.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,j.jsx)(v,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`sr-only`,children:l?k.collapseProvider:k.expandProvider})]}),l?(0,j.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 px-4 py-4`,children:[s?(0,j.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:k.extensionSettingsLinkTitle,children:[(0,j.jsx)(u,{className:`size-3`}),k.openExtensionSettings]}):null,e.models.length>0?(0,j.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,j.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,j.jsx)(ae,{providerId:e.id,value:t.apiKey,onChange:t=>_(e.id,{apiKey:t}),apiKeyLinks:g(e.id,D),apiKeyLinkLabels:O,labels:{apiKeyLabel:k.apiKeyLabel,optionalPlaceholder:k.optionalPlaceholder,maskedHelp:k.apiKeyMaskedHelp,copy:k.apiKeyCopy,copied:k.apiKeyCopied,show:k.apiKeyShow,hide:k.apiKeyHide,notInConfigFile:k.apiKeyNotInConfigFile,loadFailed:k.apiKeyRevealFailed}}),n?.regions?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:k.regionLabel}),(0,j.jsxs)(h,{id:`img-cred-region-preset-${e.id}`,className:oe(),value:se(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){_(e.id,{region:``,imageBaseUrl:``});return}if(r===P){_(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&_(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,j.jsx)(p,{value:``,children:k.regionPresetDefault}),n.regions.map(e=>(0,j.jsx)(p,{value:e.value,children:le(k,e.value,e.label)},e.value)),(0,j.jsx)(p,{value:P,children:k.regionPresetCustom})]}),se(t,n.regions)===P?(0,j.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,j.jsx)(`input`,{type:`text`,className:N(),value:t.region,placeholder:`region`,onChange:t=>_(e.id,{region:t.target.value})}),(0,j.jsx)(`input`,{type:`url`,className:N(),value:t.imageBaseUrl,placeholder:k.imageBaseUrlLabel,onChange:t=>_(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:ue(k,n.baseUrlPresetKind)}),de(k,n.baseUrlPresetKind)?(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:de(k,n.baseUrlPresetKind)}):null,(0,j.jsxs)(h,{id:`img-cred-base-preset-${e.id}`,className:oe(),value:ce(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){_(e.id,{baseUrl:``});return}if(n===P){_(e.id,{baseUrl:``});return}_(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,j.jsx)(p,{value:``,children:k.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,j.jsx)(p,{value:P,children:k.baseUrlPresetCustom})]}),ce(t,n.baseUrlPresets)===P?(0,j.jsx)(`input`,{type:`url`,className:a(N(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>_(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&se(t,n.regions)!==P?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:k.imageBaseUrlLabel}),(0,j.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(N(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:k.imageBaseUrlPresetHint}),(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:k.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=O,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=D,t[64]=C,t[65]=k,t[66]=U,t[67]=_,t[68]=e):e=t[68],Z=n.map(e),t[46]=O,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=D,t[52]=C,t[53]=n,t[54]=k,t[55]=U,t[56]=_,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,j.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,j.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 he(e){return(0,j.jsx)(p,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=S(c(e=>!!e.token)),n=t.data,r=(0,T.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,T.useRef)(!1),[a,s]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),[f,p]=(0,T.useState)(null),[m,h]=(0,T.useState)(!1),[g,_]=(0,T.useState)(!1),v=(0,T.useMemo)(()=>D(n?.payload?.config,r),[n?.payload?.config,r]),y=a??v,b=v;return{gwSwr:t,credDraft:y,credBaseline:b,credDirty:(0,T.useMemo)(()=>JSON.stringify(y)!==JSON.stringify(b),[y,b]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,T.useCallback)((e,t)=>{i.current=!0,s(n=>{let r=n??v,i=r[e]??E();return{...r,[e]:{...i,...t}}})},[v]),onDiscardCredentials:(0,T.useCallback)(()=>{i.current=!1,s(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,T.useCallback)(async e=>{let n=re(r,y,b);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ie(n),await t.mutate?.(),l(o(C)),i.current=!1,s(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,y,b,t])}}function be(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function I(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},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():`xopc-local`}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=be();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:!1,order:[`xopc-local`]};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=I();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:`inbound`,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:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}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),voice:e.voice})}),e.voice.languageMode===`auto`&&await s(o(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),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(){let e=await s(o(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await s(o(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await s(o(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(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 Se(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 Ce(e){let t=(0,te.c)(15),{kind:n,providerId:r,fieldId:i,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=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let h;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(h=(0,j.jsx)(_,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,j.jsx)(`div`,{className:m,children:h}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,w as m,Z as n,X as o,me as p,J as r,Q as s,Ce as t,$ 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"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{d as o,i as s,o as c}from"./locale-store-BP67jtYG.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{Dl as u,Gt as d,Hn as f,Ko as p,Rc as m,Wo as h,Wt as g,as as _,eu as v,ms as y,no as b,ps as x,rc as ee,ro as S}from"./index-twNrYC3D.js";var C=`/api/image/providers`;async function w(){return(await s(o(`/api/image/providers`)))?.payload?.providers??[]}var T=e(t(),1),te=n();function E(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function ne(e){return e?.apiKey?`••••••••••••`:``}function D(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:ne(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function O(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function k(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(f(n)&&f(r)))return n||(r?null:void 0)}function re(e,t,n){let r={};for(let i of e){let e=t[i]??E(),a=n[i]??E();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=k(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=O(e,a,`region`);c!==void 0&&(o.region=c);let l=O(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=O(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 ie(e){Object.keys(e).length!==0&&(await s(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await b())}var j=r();function ae(e){let t=(0,te.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(M),t[0]=n,t[1]=c);let l=c,f=`img-cred-key-${n}`,p;t[2]!==a.apiKeyLabel||t[3]!==f?(p=(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:f,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=f,t[4]=p):p=t[4];let m;t[5]!==s||t[6]!==o?(m=o.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,j.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:[d(e.kind,s),(0,j.jsx)(u,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=m):m=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,j.jsx)(_,{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 v;return t[14]!==p||t[15]!==m||t[16]!==g?(v=(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[p,m,g]}),t[14]=p,t[15]=m,t[16]=g,t[17]=v):v=t[17],v}function M(e){return e.apiKey??null}function N(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x)}function oe(){return a(N(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var P=`__custom__`;function se(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:P}function ce(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:P}function le(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function ue(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function de(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function fe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function pe(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function me(e){let t=(0,te.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:d,credNoopFlash:f,updateCredRow:_,onDiscardCredentials:b,onSaveCredentials:x,extensionIds:S,showExtensionLinks:C,showImageModelsLink:w,hideActions:ne,language:D,apiKeyLinkLabels:O,messages:k}=e,re=ne===void 0?!1:ne,A;t[0]===n?A=t[1]:(A=n.some(ye),t[0]=n,t[1]=A);let ie=A,M;t[2]===n?M=t[3]:(M=n.some(ve),t[2]=n,t[3]=M);let me=M,[F,be]=(0,T.useState)(_e),[I,L]=(0,T.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)fe(r[e.id]??E(),o[e.id]??E())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,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)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(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]===k.credentialsIntro?W=t[15]:(W=(0,j.jsx)(`p`,{children:k.credentialsIntro}),t[14]=k.credentialsIntro,t[15]=W);let G;t[16]!==ie||t[17]!==k.regionHint?(G=ie?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.regionHint}):null,t[16]=ie,t[17]=k.regionHint,t[18]=G):G=t[18];let K;t[19]!==me||t[20]!==k.endpointPresetsHint?(K=me?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.endpointPresetsHint}):null,t[19]=me,t[20]=k.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==w||t[23]!==k.imageModelsLinkTitle||t[24]!==k.openImageModelsPage?(q=w?(0,j.jsx)(`p`,{children:(0,j.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:k.imageModelsLinkTitle,children:k.openImageModelsPage})}):null,t[22]=w,t[23]=k.imageModelsLinkTitle,t[24]=k.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,j.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]===l?Y=t[32]:(Y=l?(0,j.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:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==f||t[35]!==d||t[36]!==c||t[37]!==re||t[38]!==b||t[39]!==x||t[40]!==k.credentialsNothingToSave||t[41]!==k.credentialsSaved||t[42]!==k.discardCredentials||t[43]!==k.saveCredentials||t[44]!==k.savingCredentials?(X=re?null:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[d?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsSaved}):null,f?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsNothingToSave}):null,(0,j.jsx)(y,{type:`button`,variant:`secondary`,onClick:b,disabled:!s||c,children:k.discardCredentials}),(0,j.jsx)(y,{type:`button`,variant:`primary`,onClick:x,disabled:!s||c,children:c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(m,{className:`size-3.5 animate-spin`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.savingCredentials})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ee,{className:`size-3.5`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.saveCredentials})]})})]}),t[33]=s,t[34]=f,t[35]=d,t[36]=c,t[37]=re,t[38]=b,t[39]=x,t[40]=k.credentialsNothingToSave,t[41]=k.credentialsSaved,t[42]=k.discardCredentials,t[43]=k.saveCredentials,t[44]=k.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==O||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==D||t[52]!==C||t[53]!==n||t[54]!==k||t[55]!==U||t[56]!==_){let e;t[58]!==O||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==D||t[64]!==C||t[65]!==k||t[66]!==U||t[67]!==_?(e=e=>{let t=r[e.id]??E(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=fe(t,o[e.id]??E()),l=V(e.id),d=e.label??e.id,f=pe(k,e.models.length);return(0,j.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,j.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":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:d}),(0,j.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.unsavedChanges}):null,e.configured?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.configured}):(0,j.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:k.missingKey})]}),(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,j.jsx)(`span`,{children:f}),e.defaultModel?(0,j.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,j.jsx)(v,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`sr-only`,children:l?k.collapseProvider:k.expandProvider})]}),l?(0,j.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 px-4 py-4`,children:[s?(0,j.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:k.extensionSettingsLinkTitle,children:[(0,j.jsx)(u,{className:`size-3`}),k.openExtensionSettings]}):null,e.models.length>0?(0,j.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,j.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,j.jsx)(ae,{providerId:e.id,value:t.apiKey,onChange:t=>_(e.id,{apiKey:t}),apiKeyLinks:g(e.id,D),apiKeyLinkLabels:O,labels:{apiKeyLabel:k.apiKeyLabel,optionalPlaceholder:k.optionalPlaceholder,maskedHelp:k.apiKeyMaskedHelp,copy:k.apiKeyCopy,copied:k.apiKeyCopied,show:k.apiKeyShow,hide:k.apiKeyHide,notInConfigFile:k.apiKeyNotInConfigFile,loadFailed:k.apiKeyRevealFailed}}),n?.regions?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:k.regionLabel}),(0,j.jsxs)(h,{id:`img-cred-region-preset-${e.id}`,className:oe(),value:se(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){_(e.id,{region:``,imageBaseUrl:``});return}if(r===P){_(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&_(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,j.jsx)(p,{value:``,children:k.regionPresetDefault}),n.regions.map(e=>(0,j.jsx)(p,{value:e.value,children:le(k,e.value,e.label)},e.value)),(0,j.jsx)(p,{value:P,children:k.regionPresetCustom})]}),se(t,n.regions)===P?(0,j.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,j.jsx)(`input`,{type:`text`,className:N(),value:t.region,placeholder:`region`,onChange:t=>_(e.id,{region:t.target.value})}),(0,j.jsx)(`input`,{type:`url`,className:N(),value:t.imageBaseUrl,placeholder:k.imageBaseUrlLabel,onChange:t=>_(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:ue(k,n.baseUrlPresetKind)}),de(k,n.baseUrlPresetKind)?(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:de(k,n.baseUrlPresetKind)}):null,(0,j.jsxs)(h,{id:`img-cred-base-preset-${e.id}`,className:oe(),value:ce(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){_(e.id,{baseUrl:``});return}if(n===P){_(e.id,{baseUrl:``});return}_(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,j.jsx)(p,{value:``,children:k.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,j.jsx)(p,{value:P,children:k.baseUrlPresetCustom})]}),ce(t,n.baseUrlPresets)===P?(0,j.jsx)(`input`,{type:`url`,className:a(N(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>_(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&se(t,n.regions)!==P?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:k.imageBaseUrlLabel}),(0,j.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(N(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:k.imageBaseUrlPresetHint}),(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:k.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=O,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=D,t[64]=C,t[65]=k,t[66]=U,t[67]=_,t[68]=e):e=t[68],Z=n.map(e),t[46]=O,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=D,t[52]=C,t[53]=n,t[54]=k,t[55]=U,t[56]=_,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,j.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,j.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 he(e){return(0,j.jsx)(p,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=S(c(e=>!!e.token)),n=t.data,r=(0,T.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,T.useRef)(!1),[a,s]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),[f,p]=(0,T.useState)(null),[m,h]=(0,T.useState)(!1),[g,_]=(0,T.useState)(!1),v=(0,T.useMemo)(()=>D(n?.payload?.config,r),[n?.payload?.config,r]),y=a??v,b=v;return{gwSwr:t,credDraft:y,credBaseline:b,credDirty:(0,T.useMemo)(()=>JSON.stringify(y)!==JSON.stringify(b),[y,b]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,T.useCallback)((e,t)=>{i.current=!0,s(n=>{let r=n??v,i=r[e]??E();return{...r,[e]:{...i,...t}}})},[v]),onDiscardCredentials:(0,T.useCallback)(()=>{i.current=!1,s(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,T.useCallback)(async e=>{let n=re(r,y,b);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ie(n),await t.mutate?.(),l(o(C)),i.current=!1,s(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,y,b,t])}}function be(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function I(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},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():`xopc-local`}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=be();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:!1,order:[`xopc-local`]};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=I();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:`inbound`,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:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}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),voice:e.voice})}),e.voice.languageMode===`auto`&&await s(o(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),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(){let e=await s(o(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await s(o(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await s(o(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(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 Se(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 Ce(e){let t=(0,te.c)(15),{kind:n,providerId:r,fieldId:i,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=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let h;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(h=(0,j.jsx)(_,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,j.jsx)(`div`,{className:m,children:h}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,w as m,Z as n,X as o,me as p,J as r,Q as s,Ce as t,$ as u};
@@ -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{d as r,l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./check-BODqo66o.js";import{t as o}from"./messages-CQGpD-dC.js";import{n as s}from"./locale-store-Bp8joZck.js";import{At as c,Bt as l,Et as u,Ft as d,Ht as f,It as p,Js as m,Lt as h,Ql as g,Rc as _,Rt as v,Vt as y,_l as b,hs as x,io as S,ms as C,pl as w,vs as T,xl as E,zt as D}from"./index-CxkNzw3e.js";var O=e(t(),1),k=n(),A=[`folder_structure`,`recent_progress`,`next_steps`];function j(e){return e instanceof Error?e.message:String(e)}function M(){let e=s(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,M=i(),[N]=r(),P=N.get(`new`)===`1`,[F,I]=(0,O.useState)(`loading`),[L,R]=(0,O.useState)(null),[z,B]=(0,O.useState)(null),[V,H]=(0,O.useState)(!1),[U,W]=(0,O.useState)(null),G=(0,O.useCallback)(e=>{B(e),e.status===`completed`?I(`result`):e.status===`failed`||e.status===`canceled`?I(`error`):I(`running`)},[]),K=c({onPicked:(0,O.useCallback)(async e=>{H(!0),W(null);try{R(await D(e)),I(`consent`)}catch(e){W(j(e)),I(`intro`)}finally{H(!1)}},[])});(0,O.useEffect)(()=>{let e=!1;return h().then(async({enabled:t,state:n})=>{if(!e){if(!t){M(`/chat`,{replace:!0});return}if(!P&&n.activeRunId)try{let t=await v(n.activeRunId);e||G(t);return}catch{}e||I(`intro`)}}).catch(t=>{e||(W(j(t)),I(`intro`))}),()=>{e=!0}},[G,M,P]),(0,O.useEffect)(()=>{if(!z||F!==`running`)return;let e=!1,t=async()=>{try{let t=await v(z.id);e||G(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===z.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[G,F,z]);let q=async()=>{H(!0);try{await p()}finally{M(`/chat`,{replace:!0})}},J=async()=>{if(L){H(!0),W(null);try{G(await f(L.canonicalRootPath))}catch(e){W(j(e)),I(`consent`)}finally{H(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;M(`/chat/${encodeURIComponent(e)}${n}`)},X=async(t,n)=>{if(!z)return;await y(z.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(z.sessionKey,r)};return(0,k.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,k.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,k.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,k.jsx)(x,{className:`size-11`})}),F===`loading`?(0,k.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,k.jsx)(S,{className:`mx-auto h-8 w-64`}),(0,k.jsx)(S,{className:`mx-auto h-4 w-full max-w-lg`}),(0,k.jsx)(S,{className:`mx-auto h-4 w-4/5 max-w-md`}),(0,k.jsx)(S,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,F===`intro`?(0,k.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,k.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,k.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,k.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,k.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,k.jsxs)(C,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:K.pick,disabled:V||K.picking,children:[V||K.picking?(0,k.jsx)(_,{className:`size-4 animate-spin`}):(0,k.jsx)(b,{className:`size-4`}),t.chooseFolder]}),(0,k.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,k.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,k.jsx)(`span`,{children:t.readOnlyNote})]}),U?(0,k.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:U}):null]}),(0,k.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void q(),disabled:V,children:t.skip})]}):null,F===`consent`&&L?(0,k.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,k.jsxs)(`div`,{className:`text-center`,children:[(0,k.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,k.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,k.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,k.jsx)(b,{className:`size-5 shrink-0 text-accent-fg`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:L.displayName}),(0,k.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:L.canonicalRootPath})]}),(0,k.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:L.projectKind===`coding`?t.codingProject:L.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,k.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,k.jsx)(E,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,k.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,k.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,k.jsx)(T,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,k.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,k.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,k.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,k.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:L.remoteModel?t.providerDisclosure.replace(`{{provider}}`,L.provider):t.localDisclosure})]})]})]}),U?(0,k.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:U}):null,(0,k.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,k.jsxs)(C,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:V,onClick:()=>void J(),children:[V?(0,k.jsx)(_,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,k.jsx)(C,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:V,onClick:K.pick,children:t.changeFolder})]}),(0,k.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void q(),children:t.skip})]}):null,F===`running`&&z?(0,k.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,k.jsxs)(`div`,{className:`text-center`,children:[(0,k.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,k.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle})]}),(0,k.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:A.map((e,n)=>{let r=Math.max(0,A.indexOf(z.stage??`folder_structure`)),i=n<r,o=n===r;return(0,k.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,k.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,k.jsx)(a,{className:`size-4`}):o?(0,k.jsx)(_,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,k.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,k.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,k.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:z.rootPath}),(0,k.jsx)(`button`,{type:`button`,className:`mx-auto mt-7 block text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void d(z.id).then(G),children:t.cancelAnalysis})]}):null,F===`result`&&z?.result?(0,k.jsxs)(`section`,{"aria-labelledby":`work-discovery-result-title`,children:[(0,k.jsxs)(`div`,{className:`text-center`,children:[(0,k.jsx)(`h1`,{id:`work-discovery-result-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:z.result.lowConfidence?t.lowConfidenceTitle:t.foundTitle}),(0,k.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:z.result.projectSummary}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:z.result.currentState})]}),z.result.lowConfidence?(0,k.jsxs)(`div`,{className:`mt-8 rounded-xl border border-edge bg-surface-panel p-5 text-center`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:z.result.contextQuestion}),(0,k.jsx)(C,{className:`mt-5 bg-accent text-white hover:bg-accent-hover`,onClick:()=>Y(z.sessionKey,z.result?.contextQuestion),children:t.openConversation})]}):(0,k.jsxs)(`div`,{className:`mt-9`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.suggestionsTitle}),(0,k.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle border-y border-edge-subtle`,children:z.result.suggestions.map(e=>(0,k.jsx)(`article`,{className:`py-5`,children:(0,k.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,k.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,k.jsx)(g,{className:`size-4`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:e.title}),(0,k.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:e.rationale}),(0,k.jsx)(`ul`,{className:`mt-3 space-y-1.5`,children:e.evidence.map((t,n)=>(0,k.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,k.jsx)(w,{className:`mt-0.5 size-3.5 shrink-0`}),(0,k.jsxs)(`span`,{children:[t.path?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`code`,{className:`font-mono text-fg`,children:t.path}),`: `]}):null,t.observation]})]},`${e.id}-${n}`))}),(0,k.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,k.jsx)(C,{className:`h-9 bg-accent px-3 py-1.5 text-white hover:bg-accent-hover`,onClick:()=>void X(e,!1),children:t.continue}),(0,k.jsx)(C,{className:`h-9 px-3 py-1.5`,variant:`secondary`,onClick:()=>void X(e,!0),children:t.discussFirst})]})]})]})},e.id))})]}),(0,k.jsxs)(`div`,{className:`mt-7 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,k.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(z.sessionKey),children:t.openConversation}),(0,k.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{B(null),R(null),I(`intro`)},children:t.notAccurate})]})]}):null,F===`error`&&z?(0,k.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,k.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,k.jsx)(T,{className:`size-5`})}),(0,k.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,k.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:z.errorMessage}),(0,k.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,k.jsx)(C,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void l(z.id).then(G),children:t.retry}),(0,k.jsx)(C,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{B(null),R(null),I(`intro`)},children:t.chooseDifferent})]}),(0,k.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(z.sessionKey),children:t.openConversation})]}):null]}),K.hasNativePicker?null:(0,k.jsx)(u,{open:K.modalOpen,onOpenChange:K.setModalOpen,initialAbsolutePath:L?.canonicalRootPath,onConfirm:K.confirmPick,wd:n})]})}export{M as WorkDiscoveryPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./check-BODqo66o.js";import{t as o}from"./messages-BIsSVgW7.js";import{n as s}from"./locale-store-BP67jtYG.js";import{At as c,Bt as l,Et as u,Ft as d,Ht as f,It as p,Js as m,Lt as h,Ql as g,Rc as _,Rt as v,Vt as y,_l as b,hs as x,io as S,ms as C,pl as w,vs as T,xl as E,zt as D}from"./index-twNrYC3D.js";var O=e(t(),1),k=n(),A=[`folder_structure`,`recent_progress`,`next_steps`];function j(e){return e instanceof Error?e.message:String(e)}function M(){let e=s(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,M=i(),[N]=r(),P=N.get(`new`)===`1`,[F,I]=(0,O.useState)(`loading`),[L,R]=(0,O.useState)(null),[z,B]=(0,O.useState)(null),[V,H]=(0,O.useState)(!1),[U,W]=(0,O.useState)(null),G=(0,O.useCallback)(e=>{B(e),e.status===`completed`?I(`result`):e.status===`failed`||e.status===`canceled`?I(`error`):I(`running`)},[]),K=c({onPicked:(0,O.useCallback)(async e=>{H(!0),W(null);try{R(await D(e)),I(`consent`)}catch(e){W(j(e)),I(`intro`)}finally{H(!1)}},[])});(0,O.useEffect)(()=>{let e=!1;return h().then(async({enabled:t,state:n})=>{if(!e){if(!t){M(`/chat`,{replace:!0});return}if(!P&&n.activeRunId)try{let t=await v(n.activeRunId);e||G(t);return}catch{}e||I(`intro`)}}).catch(t=>{e||(W(j(t)),I(`intro`))}),()=>{e=!0}},[G,M,P]),(0,O.useEffect)(()=>{if(!z||F!==`running`)return;let e=!1,t=async()=>{try{let t=await v(z.id);e||G(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===z.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[G,F,z]);let q=async()=>{H(!0);try{await p()}finally{M(`/chat`,{replace:!0})}},J=async()=>{if(L){H(!0),W(null);try{G(await f(L.canonicalRootPath))}catch(e){W(j(e)),I(`consent`)}finally{H(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;M(`/chat/${encodeURIComponent(e)}${n}`)},X=async(t,n)=>{if(!z)return;await y(z.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(z.sessionKey,r)};return(0,k.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,k.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,k.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,k.jsx)(x,{className:`size-11`})}),F===`loading`?(0,k.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,k.jsx)(S,{className:`mx-auto h-8 w-64`}),(0,k.jsx)(S,{className:`mx-auto h-4 w-full max-w-lg`}),(0,k.jsx)(S,{className:`mx-auto h-4 w-4/5 max-w-md`}),(0,k.jsx)(S,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,F===`intro`?(0,k.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,k.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,k.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,k.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,k.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,k.jsxs)(C,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:K.pick,disabled:V||K.picking,children:[V||K.picking?(0,k.jsx)(_,{className:`size-4 animate-spin`}):(0,k.jsx)(b,{className:`size-4`}),t.chooseFolder]}),(0,k.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,k.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,k.jsx)(`span`,{children:t.readOnlyNote})]}),U?(0,k.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:U}):null]}),(0,k.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void q(),disabled:V,children:t.skip})]}):null,F===`consent`&&L?(0,k.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,k.jsxs)(`div`,{className:`text-center`,children:[(0,k.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,k.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,k.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,k.jsx)(b,{className:`size-5 shrink-0 text-accent-fg`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:L.displayName}),(0,k.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:L.canonicalRootPath})]}),(0,k.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:L.projectKind===`coding`?t.codingProject:L.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,k.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,k.jsx)(E,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,k.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,k.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,k.jsx)(T,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,k.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,k.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,k.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,k.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:L.remoteModel?t.providerDisclosure.replace(`{{provider}}`,L.provider):t.localDisclosure})]})]})]}),U?(0,k.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:U}):null,(0,k.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,k.jsxs)(C,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:V,onClick:()=>void J(),children:[V?(0,k.jsx)(_,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,k.jsx)(C,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:V,onClick:K.pick,children:t.changeFolder})]}),(0,k.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void q(),children:t.skip})]}):null,F===`running`&&z?(0,k.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,k.jsxs)(`div`,{className:`text-center`,children:[(0,k.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,k.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle})]}),(0,k.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:A.map((e,n)=>{let r=Math.max(0,A.indexOf(z.stage??`folder_structure`)),i=n<r,o=n===r;return(0,k.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,k.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,k.jsx)(a,{className:`size-4`}):o?(0,k.jsx)(_,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,k.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,k.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,k.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:z.rootPath}),(0,k.jsx)(`button`,{type:`button`,className:`mx-auto mt-7 block text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void d(z.id).then(G),children:t.cancelAnalysis})]}):null,F===`result`&&z?.result?(0,k.jsxs)(`section`,{"aria-labelledby":`work-discovery-result-title`,children:[(0,k.jsxs)(`div`,{className:`text-center`,children:[(0,k.jsx)(`h1`,{id:`work-discovery-result-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:z.result.lowConfidence?t.lowConfidenceTitle:t.foundTitle}),(0,k.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:z.result.projectSummary}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:z.result.currentState})]}),z.result.lowConfidence?(0,k.jsxs)(`div`,{className:`mt-8 rounded-xl border border-edge bg-surface-panel p-5 text-center`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:z.result.contextQuestion}),(0,k.jsx)(C,{className:`mt-5 bg-accent text-white hover:bg-accent-hover`,onClick:()=>Y(z.sessionKey,z.result?.contextQuestion),children:t.openConversation})]}):(0,k.jsxs)(`div`,{className:`mt-9`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.suggestionsTitle}),(0,k.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle border-y border-edge-subtle`,children:z.result.suggestions.map(e=>(0,k.jsx)(`article`,{className:`py-5`,children:(0,k.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,k.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,k.jsx)(g,{className:`size-4`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:e.title}),(0,k.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:e.rationale}),(0,k.jsx)(`ul`,{className:`mt-3 space-y-1.5`,children:e.evidence.map((t,n)=>(0,k.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,k.jsx)(w,{className:`mt-0.5 size-3.5 shrink-0`}),(0,k.jsxs)(`span`,{children:[t.path?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`code`,{className:`font-mono text-fg`,children:t.path}),`: `]}):null,t.observation]})]},`${e.id}-${n}`))}),(0,k.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,k.jsx)(C,{className:`h-9 bg-accent px-3 py-1.5 text-white hover:bg-accent-hover`,onClick:()=>void X(e,!1),children:t.continue}),(0,k.jsx)(C,{className:`h-9 px-3 py-1.5`,variant:`secondary`,onClick:()=>void X(e,!0),children:t.discussFirst})]})]})]})},e.id))})]}),(0,k.jsxs)(`div`,{className:`mt-7 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,k.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(z.sessionKey),children:t.openConversation}),(0,k.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{B(null),R(null),I(`intro`)},children:t.notAccurate})]})]}):null,F===`error`&&z?(0,k.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,k.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,k.jsx)(T,{className:`size-5`})}),(0,k.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,k.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:z.errorMessage}),(0,k.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,k.jsx)(C,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void l(z.id).then(G),children:t.retry}),(0,k.jsx)(C,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{B(null),R(null),I(`intro`)},children:t.chooseDifferent})]}),(0,k.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(z.sessionKey),children:t.openConversation})]}):null]}),K.hasNativePicker?null:(0,k.jsx)(u,{open:K.modalOpen,onOpenChange:K.setModalOpen,initialAbsolutePath:L?.canonicalRootPath,onConfirm:K.confirmPick,wd:n})]})}export{M as WorkDiscoveryPage};