@xopcai/xopc 0.0.147 → 0.0.149

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 (143) 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-B4s0ipx2.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CFdJKSjY.js → agent-avatar-dicebear-BSccACje.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DZDOcgz5.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-Bs69B5zA.js → api-BMdUsNCV.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-ag1ViXT_.js → app-management-settings-panel-DrLGhYkI.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-C6iMpwOM.js → appearance-settings-BNasnY9D.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-Cmr-Hvm9.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-Dwi3mIBy.js → archive-plugin-BQ17IK9x.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-BaCDoq40.js → attachment-load-HXvgWHXu.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-CwqtFgnw.js → automation-suggestion-card-CjIWpsch.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-TWgUAI8t.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-DoAYhsxa.js → binary-plugins-DifWJzNZ.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-Bw72pO7S.js → block-editor-DtRzIkPU.js} +4 -4
  16. package/dist/gateway/static/root/assets/browser-settings-page-DBsFItW_.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-presets-api-vdbAR65Q.js → capability-presets-api-DazKjWW1.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-BAsKbJgm.js → capability-presets-settings-panel-Cvrw4fD1.js} +2 -2
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-rTG26jpV.js → channel-recipient-api-Bea6if_6.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-settings-BBkzrBYy.js +1 -0
  21. package/dist/gateway/static/root/assets/channels-status-swr-CuU6ez3y.js +1 -0
  22. package/dist/gateway/static/root/assets/{connector-logo-DIMP4NWY.js → connector-logo-BjbYbJjQ.js} +1 -1
  23. package/dist/gateway/static/root/assets/connectors-page-DLsZCAw7.js +2 -0
  24. package/dist/gateway/static/root/assets/{desktop-pet-kQq2e0BN.js → desktop-pet-C6V-PHwi.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-B6vtozMY.js → desktop-pet-settings-5Fcz47XQ.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-Dn5-e3v4.js → directory-picker-path-field-C8zZNUzC.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-BzwIujPG.js → dreaming-settings-gJSw7Adk.js} +3 -3
  28. package/dist/gateway/static/root/assets/{extension-debug-page-D_e_hsEy.js → extension-debug-page-DFE5ADJ0.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-D15CWHBd.js → extension-page-CfR-aW8G.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-D4P0n1om.js → extension-settings-page-CFIEbs2L.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-B4qZctjG.js → gateway-config-api-B6M_ra8U.js} +1 -1
  32. package/dist/gateway/static/root/assets/gateway-settings-BrxzyVW2.js +1 -0
  33. package/dist/gateway/static/root/assets/{gateway-startup-retry-BpgMunEb.js → gateway-startup-retry-DNA3OOzV.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goal-create-dialog-DrVHKXHq.js → goal-create-dialog-DRVRLc5Z.js} +1 -1
  35. package/dist/gateway/static/root/assets/goal-detail-page-8F7NElzP.js +4 -0
  36. package/dist/gateway/static/root/assets/{goals-config-api-B6YJB_ct.js → goals-config-api-D88opgcs.js} +1 -1
  37. package/dist/gateway/static/root/assets/goals-page-BaoLiV8G.js +2 -0
  38. package/dist/gateway/static/root/assets/{goals-settings-BROWCIcL.js → goals-settings-D07UL8Jo.js} +1 -1
  39. package/dist/gateway/static/root/assets/{heartbeat-settings-CoCwIOIg.js → heartbeat-settings-YCSNOcXC.js} +1 -1
  40. package/dist/gateway/static/root/assets/{index-CxkNzw3e.js → index-CH7XN6KY.js} +43 -43
  41. package/dist/gateway/static/root/assets/index-Dfnl9tp_.css +1 -0
  42. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Bm_AIYQ7.js → keyboard-shortcuts-settings-BHnh5OoY.js} +1 -1
  43. package/dist/gateway/static/root/assets/local-app-workbench-page-Boe8n4zH.js +2 -0
  44. package/dist/gateway/static/root/assets/local-apps-page-CKvtLzsF.js +1 -0
  45. package/dist/gateway/static/root/assets/{locale-store-Bp8joZck.js → locale-store-BneNAR8R.js} +1 -1
  46. package/dist/gateway/static/root/assets/logs-page-Cb4Uptct.js +7 -0
  47. package/dist/gateway/static/root/assets/{markdown-split-Dy7QpaAz.js → markdown-split-BVSFG99p.js} +1 -1
  48. package/dist/gateway/static/root/assets/{media-plugins-3Lxliy9D.js → media-plugins-DdOjIVk3.js} +1 -1
  49. package/dist/gateway/static/root/assets/{messages-CQGpD-dC.js → messages-t1yPaVCt.js} +5 -5
  50. package/dist/gateway/static/root/assets/models-hub-panel-CNiUKZUV.js +2 -0
  51. package/dist/gateway/static/root/assets/{notes-page-BJtT4vSf.js → notes-page-ZbLR3awn.js} +1 -1
  52. package/dist/gateway/static/root/assets/notes-workbench-C9__VkD6.js +4 -0
  53. package/dist/gateway/static/root/assets/{page-tabs-DKB6RDre.js → page-tabs-DMlQERNg.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-Br_YhYHp.js → preview-open-alternatives-CbiJRPxK.js} +1 -1
  55. package/dist/gateway/static/root/assets/project-detail-page-CZhuB5kO.js +1 -0
  56. package/dist/gateway/static/root/assets/projects-page-BOq4WVdR.js +1 -0
  57. package/dist/gateway/static/root/assets/remote-access-hub-BxGq0ebQ.js +1 -0
  58. package/dist/gateway/static/root/assets/{save-bar-controls-BgIE9BBh.js → save-bar-controls-BZTj3hxl.js} +1 -1
  59. package/dist/gateway/static/root/assets/{schedule-field-BXDP-oMz.js → schedule-field-CxYDObjT.js} +1 -1
  60. package/dist/gateway/static/root/assets/{schema-form-Dhv-SmjG.js → schema-form-CBbXgpKQ.js} +1 -1
  61. package/dist/gateway/static/root/assets/sessions-page-B6gSU_Au.js +1 -0
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-DwuBL834.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-collapsible-section-CUTExnlK.js → settings-collapsible-section-BySKZ8rp.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-form-section-CmnDhsf0.js → settings-form-section-CjINay6t.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-loading-skeleton-B79dq-XY.js → settings-loading-skeleton-vitElc-n.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-Db8uAv3X.js → settings-page-BNrVwuL7.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-page-layout-DaFwstQw.js → settings-page-layout-HdlQOOqp.js} +1 -1
  68. package/dist/gateway/static/root/assets/setup-status-panel-BJeA4mmk.js +1 -0
  69. package/dist/gateway/static/root/assets/{share-preview-page-Bi00uXzV.js → share-preview-page-DC-eQONB.js} +1 -1
  70. package/dist/gateway/static/root/assets/shares-settings-DB2KYA2_.js +1 -0
  71. package/dist/gateway/static/root/assets/skill-reload-api-DQtZiejw.js +1 -0
  72. package/dist/gateway/static/root/assets/skills-page-Pm0fNe_p.js +2 -0
  73. package/dist/gateway/static/root/assets/{system-settings-panel-Cxaph7hW.js → system-settings-panel-CVa90q2f.js} +1 -1
  74. package/dist/gateway/static/root/assets/{theme-store-eCTN1RpG.js → theme-store-D1cOpgsy.js} +1 -1
  75. package/dist/gateway/static/root/assets/{typed-models-lib-CcZ_tyFY.js → typed-models-lib-DIKF9vpz.js} +1 -1
  76. package/dist/gateway/static/root/assets/{use-channel-catalog-C4PWbNoi.js → use-channel-catalog-DnvpI0Ys.js} +1 -1
  77. package/dist/gateway/static/root/assets/user-context-page-DnLqQyRG.js +1 -0
  78. package/dist/gateway/static/root/assets/{user-profile-fields-editor-CPOO9Jz5.js → user-profile-fields-editor-y8gTmkPX.js} +1 -1
  79. package/dist/gateway/static/root/assets/{user-profile-settings-panel-C8cgtSF7.js → user-profile-settings-panel-C3pvqe28.js} +1 -1
  80. package/dist/gateway/static/root/assets/{utils-CiZK2KwH.js → utils-BK2vwu_3.js} +1 -1
  81. package/dist/gateway/static/root/assets/voice-api-key-field-BiFIIWC4.js +1 -0
  82. package/dist/gateway/static/root/assets/work-discovery-page-D2-_bC0J.js +1 -0
  83. package/dist/gateway/static/root/assets/work-item-detail-page-B0FPG4eJ.js +1 -0
  84. package/dist/gateway/static/root/assets/work-page-BDeVxts_.js +1 -0
  85. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BPzS67fU.js +3 -0
  86. package/dist/gateway/static/root/assets/workflows-page-xPhmrRLs.js +11 -0
  87. package/dist/gateway/static/root/index.html +7 -7
  88. package/dist/package.js +1 -1
  89. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  90. package/dist/src/gateway/hono/routes/work-discovery.js +32 -0
  91. package/dist/src/gateway/hono/routes/work-discovery.js.map +1 -1
  92. package/dist/src/storage/sqlite/migrations/046_work_discovery_feedback.sql +13 -0
  93. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  94. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  95. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  96. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  97. package/dist/src/storage/sqlite/schema.js +1 -1
  98. package/dist/src/work-discovery/analyzer.js +23 -4
  99. package/dist/src/work-discovery/analyzer.js.map +1 -1
  100. package/dist/src/work-discovery/index.js +2 -2
  101. package/dist/src/work-discovery/probe.d.ts +6 -0
  102. package/dist/src/work-discovery/probe.js +12 -1
  103. package/dist/src/work-discovery/probe.js.map +1 -1
  104. package/dist/src/work-discovery/repository.d.ts +7 -1
  105. package/dist/src/work-discovery/repository.js +35 -2
  106. package/dist/src/work-discovery/repository.js.map +1 -1
  107. package/dist/src/work-discovery/service.d.ts +6 -1
  108. package/dist/src/work-discovery/service.js +64 -5
  109. package/dist/src/work-discovery/service.js.map +1 -1
  110. package/dist/src/work-discovery/types.d.ts +21 -0
  111. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  112. package/package.json +1 -1
  113. package/dist/gateway/static/root/assets/agents-DKjbRpbA.js +0 -2
  114. package/dist/gateway/static/root/assets/apps-page-CpX3lBFF.js +0 -1
  115. package/dist/gateway/static/root/assets/automations-page-DlupOxFQ.js +0 -6
  116. package/dist/gateway/static/root/assets/browser-settings-page-BwLoUBcZ.js +0 -8
  117. package/dist/gateway/static/root/assets/channels-settings-CxFWy0cE.js +0 -1
  118. package/dist/gateway/static/root/assets/channels-status-swr-OKlqTtKJ.js +0 -1
  119. package/dist/gateway/static/root/assets/connectors-page-BjQQwX62.js +0 -2
  120. package/dist/gateway/static/root/assets/gateway-settings-BvndV7TP.js +0 -1
  121. package/dist/gateway/static/root/assets/goal-detail-page-PHlCwv68.js +0 -4
  122. package/dist/gateway/static/root/assets/goals-page-Hg9uyO6e.js +0 -2
  123. package/dist/gateway/static/root/assets/index-DjCSOyaN.css +0 -1
  124. package/dist/gateway/static/root/assets/local-app-workbench-page-BJWFcxwG.js +0 -2
  125. package/dist/gateway/static/root/assets/local-apps-page-BsiZMrEf.js +0 -1
  126. package/dist/gateway/static/root/assets/logs-page-DOmK61ey.js +0 -7
  127. package/dist/gateway/static/root/assets/models-hub-panel-DGCZom4o.js +0 -2
  128. package/dist/gateway/static/root/assets/notes-workbench-B_bN7cOR.js +0 -4
  129. package/dist/gateway/static/root/assets/project-detail-page-Dq8JouJj.js +0 -1
  130. package/dist/gateway/static/root/assets/projects-page-DvfL7fSe.js +0 -1
  131. package/dist/gateway/static/root/assets/remote-access-hub-DqwMXSXP.js +0 -1
  132. package/dist/gateway/static/root/assets/sessions-page-B_mOZkQk.js +0 -1
  133. package/dist/gateway/static/root/assets/settings-advanced-gate-BHGmH6YS.js +0 -1
  134. package/dist/gateway/static/root/assets/setup-status-panel-BUSEj0KK.js +0 -1
  135. package/dist/gateway/static/root/assets/shares-settings-DzsTYfuX.js +0 -1
  136. package/dist/gateway/static/root/assets/skill-reload-api-DSsdU081.js +0 -1
  137. package/dist/gateway/static/root/assets/skills-page-DeB1tQZL.js +0 -2
  138. package/dist/gateway/static/root/assets/user-context-page-QTVMx_hG.js +0 -1
  139. package/dist/gateway/static/root/assets/voice-api-key-field-b-YZtvUu.js +0 -1
  140. package/dist/gateway/static/root/assets/work-discovery-page-4zVDOl2G.js +0 -1
  141. package/dist/gateway/static/root/assets/work-item-detail-page-CHe2tfkc.js +0 -1
  142. package/dist/gateway/static/root/assets/workflow-run-setup-panel-8SLCYeXE.js +0 -3
  143. package/dist/gateway/static/root/assets/workflows-page-DEOFqiWn.js +0 -11
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as s}from"./check-BODqo66o.js";import{d as c,n as l}from"./locale-store-Bp8joZck.js";import{a as u,i as d}from"./vendor-swr-BIWyz7Rc.js";import{Ao as f,As as p,Cl as ee,Dl as m,Eo as te,Fo as h,Js as g,Mo as _,Na as v,No as y,Oo as b,Pc as x,Po as ne,Rc as S,Ul as re,Va as ie,Ws as ae,Xl as C,ac as oe,fc as se,hu as ce,io as w,jo as le,ko as T,ks as ue,ms as E,ol as de,pc as fe,sc as pe,vl as me,vs as he,wc as ge,zl as D}from"./index-CxkNzw3e.js";import{a as _e,c as ve,l as ye,n as be,o as xe,r as Se,s as Ce,t as we}from"./api-Bs69B5zA.js";var O=e(t(),1),Te=`build-xopc-local-app`;function Ee(e){return(e.routing?.agentId??e.agentId??``).trim().toLowerCase()}function De(e){return e.find(e=>Ee(e)===`coder`)??null}function Oe(e,t){let n=new URLSearchParams({skill:Te}),r=t?.trim();return r&&n.set(`draft`,r),`/chat/${encodeURIComponent(e)}?${n.toString()}`}var ke=new Set([`document`,`content`,`interaction`,`criteria`]),k=new Set([`passed`,`failed`,`skipped`]);function Ae(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.source!==`xopc-local-app-preview`||t.version!==1)return null;if(t.type===`ready`)return{type:`ready`,detail:{}};if(t.type===`criteria`&&t.detail&&typeof t.detail==`object`){let e=t.detail;if(e.status!==`passed`&&e.status!==`failed`||!Array.isArray(e.scenarios)||e.scenarios.length>10)return null;let n=e.scenarios.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!t.id.trim()||t.id.length>80||typeof t.name!=`string`||!t.name.trim()||t.name.length>120||t.status!==`passed`&&t.status!==`failed`||typeof t.message!=`string`||!t.message.trim()?null:{id:t.id,name:t.name,status:t.status,message:t.message.slice(0,500)}});if(n.some(e=>e===null))return null;let r=typeof e.scenarioCount==`number`&&Number.isInteger(e.scenarioCount)&&e.scenarioCount>=0&&e.scenarioCount<=10?e.scenarioCount:n.length;return{type:`criteria`,detail:{status:e.status,scenarioCount:r,scenarios:n}}}if(t.type===`acceptance`&&t.detail&&typeof t.detail==`object`){let e=t.detail;if(e.status!==`passed`&&e.status!==`failed`||!Array.isArray(e.checks))return null;let n=e.checks.slice(0,10).map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return!ke.has(t.id)||!k.has(t.status)||typeof t.message!=`string`||!t.message.trim()?null:{id:t.id,status:t.status,message:t.message.slice(0,500)}});if(!n.length||n.some(e=>e===null))return null;let r=typeof e.interactiveCount==`number`&&Number.isFinite(e.interactiveCount)&&e.interactiveCount>=0?Math.min(Math.floor(e.interactiveCount),1e4):0;return{type:`acceptance`,detail:{status:e.status,checks:n,interactiveCount:r}}}if(t.type!==`error`||!t.detail||typeof t.detail!=`object`)return null;let n=t.detail;return n.kind!==`script_error`&&n.kind!==`unhandled_rejection`||typeof n.message!=`string`||!n.message.trim()?null:{type:`error`,detail:{kind:n.kind,message:n.message.slice(0,500),filename:typeof n.filename==`string`?n.filename.slice(0,500):void 0,line:typeof n.line==`number`?n.line:void 0,column:typeof n.column==`number`?n.column:void 0}}}function je(e){return e?.checks.filter(e=>e.status===`failed`).map(e=>e.message)??[]}function Me(e){let t=e.filename?` (${e.filename}${e.line?`:${e.line}${e.column?`:${e.column}`:``}`:``})`:``;return`${e.message}${t}`}var Ne=Object.freeze({source:`xopc-local-app-host`,version:1,type:`connect`});function Pe(e,t){let n=null,r=()=>{n?.close();let r=new MessageChannel;n=r.port1,n.onmessage=e=>t(e.data),n.start(),e.contentWindow?.postMessage(Ne,`*`,[r.port2])};return e.addEventListener(`load`,r),()=>{e.removeEventListener(`load`,r),n?.close()}}var A=n(),j=r();function Fe(e){let t=(0,A.c)(36),{scenarios:n,results:r,runningTarget:i,zh:a,onRunAll:o,onRunScenario:s,onAskCoder:c}=e;if(!n.length)return null;let l=a?`产品场景`:`Product scenarios`,u;t[0]===l?u=t[1]:(u=(0,j.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:l}),t[0]=l,t[1]=u);let d=a?`${n.length} 个关键用户路径`:`${n.length} critical user journey${n.length===1?``:`s`}`,f;t[2]===d?f=t[3]:(f=(0,j.jsx)(`p`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:d}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,j.jsxs)(`div`,{children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let ee=i!==null,m;t[7]===i?m=t[8]:(m=i===`all`?(0,j.jsx)(S,{className:`size-3 animate-spin`}):(0,j.jsx)(pe,{className:`size-3`}),t[7]=i,t[8]=m);let te=a?`全部重跑`:`Run all`,h;t[9]!==o||t[10]!==ee||t[11]!==m||t[12]!==te?(h=(0,j.jsxs)(E,{variant:`ghost`,className:`h-7 rounded-lg px-2 text-[11px]`,onClick:o,disabled:ee,children:[m,te]}),t[9]=o,t[10]=ee,t[11]=m,t[12]=te,t[13]=h):h=t[13];let g;t[14]!==p||t[15]!==h?(g=(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[p,h]}),t[14]=p,t[15]=h,t[16]=g):g=t[16];let _=a?`产品场景验收结果`:`Product scenario acceptance results`,v;if(t[17]!==c||t[18]!==s||t[19]!==r||t[20]!==i||t[21]!==n||t[22]!==a){let e;t[24]!==c||t[25]!==s||t[26]!==r||t[27]!==i||t[28]!==a?(e=e=>{let t=r[e.id],n=i===`all`||i===e.id?`running`:t?.status??`pending`;return(0,j.jsx)(`li`,{className:`py-2.5 first:pt-1`,children:(0,j.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,j.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:n===`running`?(0,j.jsx)(S,{className:`size-3.5 animate-spin text-accent`}):n===`passed`?(0,j.jsx)(C,{className:`size-3.5 text-success`}):n===`failed`?(0,j.jsx)(re,{className:`size-3.5 text-danger`}):(0,j.jsx)(D,{className:`size-3.5 text-fg-subtle`})}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`p`,{className:`truncate text-[11px] font-medium text-fg`,children:e.name}),(0,j.jsx)(`p`,{className:`mt-0.5 text-[10px] text-fg-subtle`,children:a?`${e.stepCount} 个步骤`:`${e.stepCount} step${e.stepCount===1?``:`s`}`})]}),(0,j.jsx)(E,{variant:`ghost`,className:`size-7 shrink-0 rounded-lg p-0`,onClick:()=>s(e.id),disabled:i!==null,"aria-label":a?`重跑${e.name}`:`Rerun ${e.name}`,title:a?`单独重跑`:`Rerun scenario`,children:(0,j.jsx)(pe,{className:`size-3`})})]}),n===`running`?(0,j.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`正在隔离预览中执行…`:`Running in an isolated preview…`}):t?.status===`failed`?(0,j.jsxs)(`div`,{className:`mt-1.5`,children:[(0,j.jsx)(`p`,{className:`text-[11px] leading-4 text-danger`,children:t.message}),(0,j.jsxs)(E,{variant:`ghost`,className:`mt-1 h-7 rounded-lg px-2 text-[11px] text-danger hover:text-danger`,onClick:()=>c(e,t),children:[(0,j.jsx)(x,{className:`size-3`}),a?`让 Coder 修复`:`Ask Coder to fix`]})]}):t?.status===`passed`?(0,j.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`场景已通过`:`Scenario passed`}):(0,j.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`等待运行`:`Waiting to run`})]})]})},e.id)},t[24]=c,t[25]=s,t[26]=r,t[27]=i,t[28]=a,t[29]=e):e=t[29],v=n.map(e),t[17]=c,t[18]=s,t[19]=r,t[20]=i,t[21]=n,t[22]=a,t[23]=v}else v=t[23];let y;t[30]!==_||t[31]!==v?(y=(0,j.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,"aria-label":_,children:v}),t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;return t[33]!==g||t[34]!==y?(b=(0,j.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[g,y]}),t[33]=g,t[34]=y,t[35]=b):b=t[35],b}function Ie(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e))}function Le(e,t,n){return!!(t&&n&&e.sourceHash===t&&e.status===n.status&&e.interactiveCount===n.interactiveCount&&JSON.stringify(e.checks)===JSON.stringify(n.checks))}function Re(){let{appId:e}=o(),t=e===`new`,n=l(e=>e.language)===`zh`,r=l(e=>e.language),re=i(),{mutate:D}=u(),Te=te(e=>e.moveToFront),Ee=h(e=>e.setPageHeader),ke=h(e=>e.clearPageHeader),{data:k,isLoading:Ne,error:A,mutate:Re}=d(!t&&e?[`local-app`,e]:null,()=>be(e)),{data:M,isLoading:ze,mutate:N}=d(!t&&e?[`local-app-validation`,e]:null,()=>ye(e)),[Be,Ve]=(0,O.useState)(``),[He,Ue]=(0,O.useState)(``),[P,F]=(0,O.useState)(!1),[I,L]=(0,O.useState)(null),[We,Ge]=(0,O.useState)(!1),[Ke,qe]=(0,O.useState)(!1),[R,Je]=(0,O.useState)(0),[Ye,Xe]=(0,O.useState)(``),[z,Ze]=(0,O.useState)(!1),[Qe,$e]=(0,O.useState)(!1),[B,V]=(0,O.useState)(`booting`),[et,tt]=(0,O.useState)(null),[H,nt]=(0,O.useState)(null),[rt,it]=(0,O.useState)({}),[U,at]=(0,O.useState)(`all`),[ot,st]=(0,O.useState)(0),[ct,lt]=(0,O.useState)(null),[W,ut]=(0,O.useState)(null),[dt,ft]=(0,O.useState)([]),[pt,mt]=(0,O.useState)(!1),ht=(0,O.useRef)(new Set),G=(0,O.useRef)(null),gt=(0,O.useRef)(null),_t=(0,O.useRef)(null),K=(0,O.useRef)(null),q=(0,O.useRef)(``),J=M?.acceptanceScenarios??[],Y=(0,O.useMemo)(()=>{if(!J.length)return null;let e=J.map(e=>rt[e.id]).filter(e=>!!e);return e.length===J.length?{status:e.some(e=>e.status===`failed`)?`failed`:`passed`,scenarioCount:J.length,scenarios:e}:null},[J,rt]),X=(0,O.useMemo)(()=>{if(!H)return null;if(!M?.acceptanceScenarioCount)return H;if(!Y)return null;let e=Y.scenarios.find(e=>e.status===`failed`),t={id:`criteria`,status:Y.status,message:e?`${e.name}: ${e.message}`:`${Y.scenarioCount} product scenario(s) passed`},n=[...H.checks,t];return{status:n.some(e=>e.status===`failed`)?`failed`:`passed`,checks:n,interactiveCount:H.interactiveCount}},[H,Y,M?.acceptanceScenarioCount]),vt=(0,O.useCallback)(async(e,t)=>{let n=De(await ie(e.projectId))??await v(e.projectId,`coder`);ht.current.add(n.key),re(Oe(n.key,t))},[re]),Z=(0,O.useCallback)(async(e=!0)=>{if(!k)return null;$e(!0);try{let t=await ye(k.id);return await N(t,{revalidate:!1}),e&&(K.current=t.sourceHash??null,at(`all`),Je(e=>e+1)),t}catch(e){return L(e instanceof Error?e.message:String(e)),null}finally{$e(!1)}},[k,N]);(0,O.useEffect)(()=>{if(!k)return;let e=!1;ie(k.projectId).then(t=>{e||(ht.current=new Set(t.filter(e=>(e.routing?.agentId??e.agentId)?.toLowerCase()===`coder`).map(e=>e.key)))}).catch(()=>{});let t=e=>{let t=e.detail?.key;!t||!ht.current.has(t)||(G.current!==null&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{G.current=null,Z(!0)},750))};return window.addEventListener(`session-transcript-updated`,t),()=>{e=!0,window.removeEventListener(`session-transcript-updated`,t),G.current!==null&&window.clearTimeout(G.current)}},[k,Z]),(0,O.useEffect)(()=>{ft(k?.acceptanceRuns??[])},[k?.acceptanceRuns]),(0,O.useEffect)(()=>{K.current=null},[k?.id]),(0,O.useEffect)(()=>{!M?.sourceHash||K.current||(K.current=M.sourceHash,at(`all`),Je(e=>e+1))},[M?.sourceHash]),(0,O.useLayoutEffect)(()=>{if(!k)return;V(`booting`),tt(null),nt(null),ut(null),mt(!1),q.current=``;let e=window.setTimeout(()=>V(e=>e===`failed`?e:`timeout`),7e3),t=gt.current?Pe(gt.current,t=>{let n=Ae(t);if(n){if(n.type===`ready`){V(e=>e===`failed`?e:`healthy`);return}if(n.type===`acceptance`){window.clearTimeout(e),nt(n.detail),ut(K.current);return}n.type!==`criteria`&&(window.clearTimeout(e),tt(n.detail),V(`failed`))}}):()=>{};return()=>{window.clearTimeout(e),t()}},[k,R]),(0,O.useLayoutEffect)(()=>{if(!k||M?.status!==`healthy`||!J.length){lt(null);return}let e=U===`all`?J:J.filter(e=>e.id===U);if(!e.length)return;lt(U),it(e=>{if(U===`all`)return{};let t={...e};return delete t[U],t});let t=t=>{it(n=>{let r={...n};for(let n of e)r[n.id]={id:n.id,name:n.name,status:`failed`,message:t};return r}),lt(null)},r=window.setTimeout(()=>t(n?`场景在 10 秒内未完成。`:`Scenario did not finish within 10 seconds.`),1e4),i=_t.current?Pe(_t.current,e=>{let n=Ae(e);n&&(n.type===`criteria`?(window.clearTimeout(r),it(e=>{let t={...e};for(let e of n.detail.scenarios)(t[e.id]?.status!==`failed`||e.status===`failed`)&&(t[e.id]=e);return t}),lt(null)):n.type===`error`&&(window.clearTimeout(r),t(Me(n.detail))))}):()=>{};return()=>{window.clearTimeout(r),i()}},[J,k,ot,U,R,M?.status,n]),(0,O.useEffect)(()=>{if(!k||!X||!W||W!==M?.sourceHash)return;let e=`${k.id}:${W}:${JSON.stringify(X)}`;q.current!==e&&(q.current=e,mt(!0),_e(k.id,W,X).then(t=>{q.current===e&&ft(e=>[t,...e.filter(e=>e.id!==t.id)].toSorted((e,t)=>t.createdAt-e.createdAt).slice(0,20))}).catch(t=>{q.current===e&&(q.current=``,L(t instanceof Error?t.message:String(t)))}).finally(()=>{q.current===e&&mt(!1)}))},[X,W,k,M?.sourceHash]);let Q=(0,O.useCallback)(async e=>{if(k){Ze(!0),L(null);try{await vt(k,e)}catch(e){L(e instanceof Error?e.message:String(e)),Ze(!1)}}},[k,vt]);(0,O.useLayoutEffect)(()=>(Ee({startExtra:(0,j.jsx)(a,{to:`/local-apps`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`返回本地应用`:`Back to local apps`,children:(0,j.jsx)(ce,{className:`size-4`})}),main:(0,j.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:k?.name||(n?`创建本地应用`:`Create local app`)}),end:k?(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(E,{asChild:!0,variant:`ghost`,className:`h-9`,children:(0,j.jsxs)(a,{to:`/projects/${encodeURIComponent(k.projectId)}`,children:[(0,j.jsx)(me,{className:`size-4`}),`Project`]})}),(0,j.jsxs)(E,{className:`h-9`,onClick:()=>void Q(),disabled:z,children:[z?(0,j.jsx)(S,{className:`size-4 animate-spin`}):(0,j.jsx)(x,{className:`size-4`}),n?`继续开发`:`Continue building`]})]}):null}),()=>ke()),[k,z,ke,Q,Ee,n]);async function yt(e){e.preventDefault(),F(!0),L(null);try{let e=await we({name:Be,idea:He});await D(`local-apps-list`);let t=n?`请基于 APP_BRIEF.md 完成这个本地应用的首版。先检查现有草稿,再实现最小可用版本并运行校验;完成后告诉我可以如何预览。`:`Build the first usable version of this local app from APP_BRIEF.md. Inspect the existing draft, implement the smallest useful version, run validation, and tell me how to preview it.`;try{await vt(e,t)}catch{re(`/local-apps/${encodeURIComponent(e.id)}`,{replace:!0})}}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}}async function bt(){if(k){F(!0),L(null);try{let e=await Se(k.id);await Re(e,{revalidate:!1}),await N(),await Promise.all([D(`local-apps-list`),D(`gateway-extensions-list`)]),Te(`ext:${e.extensionId}:app`),Ge(!1)}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}}}async function xt(e,t=!1){F(!0),L(null);try{let n=await e();return await Re(n,{revalidate:!1}),await N(),await Promise.all([D(`local-apps-list`),D(`gateway-extensions-list`)]),t&&Te(`ext:${n.extensionId}:app`),!0}catch(e){return L(e instanceof Error?e.message:String(e)),!1}finally{F(!1)}}async function St(e){k&&await xt(()=>Ce(k.id,e),e)}async function Ct(e){k&&await xt(()=>xe(k.id,e),!0)}async function wt(){k&&await xt(()=>ve(k.id))&&qe(!1)}function Tt(){let e=[...M?.issues.map(e=>e.message)??[],...et?[Me(et)]:[],...je(X),...Object.values(rt).filter(e=>e.status===`failed`).map(e=>`${e.name}: ${e.message}`),...B===`timeout`?[n?`预览在 7 秒内未完成启动,可能存在白屏或阻塞。`:`The preview did not finish booting within 7 seconds and may be blank or blocked.`]:[]];if(!e.length)return;let t=e.map(e=>`- ${e}`).join(`
2
- `);Q(n?`请修复当前本地应用草稿的校验问题,保持扩展 ID 和已安装版本不变。修复后运行完整校验。\n\n${t}`:`Fix the current local-app draft validation issues without changing the extension id or installed release. Run the full validation afterward.\n\n${t}`)}function Et(){at(`all`),st(e=>e+1)}function Dt(e){at(e),st(e=>e+1)}function Ot(e,t){Q(n?`请修复本地应用的产品场景“${e.name}”。当前失败信息:${t.message}\n\n保持扩展 ID 和场景原意不变;优先修复应用行为,不要通过弱化断言来绕过问题。修复后运行完整校验。`:`Fix the local-app product scenario "${e.name}". Current failure: ${t.message}\n\nPreserve the extension id and the scenario intent. Fix the app behavior instead of weakening the assertion. Run the full validation afterward.`)}let kt=dt.findIndex(e=>Le(e,W,X)),$=kt>=0?dt[kt]:null,At=kt>=0?dt[kt+1]??null:dt[0]??null,jt=je(X),Mt=(At?At.checks.filter(e=>e.status===`failed`).map(e=>e.message):[]).filter(e=>!jt.includes(e)).length;async function Nt(){let e=await Z(!1);if(e?.status===`healthy`&&e.sourceHash!==W){K.current=e.sourceHash??null,Je(e=>e+1);return}e?.status===`healthy`&&B===`healthy`&&X?.status===`passed`&&$&&$.sourceHash===e.sourceHash&&Ge(!0)}return t?(0,j.jsx)(`div`,{className:`flex min-h-0 flex-1 bg-surface-panel p-3 sm:p-5 xl:p-6`,children:(0,j.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-surface lg:grid-cols-[minmax(280px,0.8fr)_minmax(0,1.5fr)]`,children:[(0,j.jsxs)(`form`,{onSubmit:yt,className:`flex flex-col border-b border-edge-subtle p-5 lg:border-b-0 lg:border-r`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.14em] text-accent`,children:[(0,j.jsx)(ae,{className:`size-4`}),n?`告诉 Coder 你的想法`:`Tell Coder your idea`]}),(0,j.jsx)(`h2`,{className:`mt-4 text-xl font-semibold tracking-tight text-fg`,children:n?`你想创建什么?`:`What do you want to create?`}),(0,j.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`我们会建立一个 Coder Project,并把应用上下文和开发 Skill 带入对话。`:`We will create a Coder Project and carry the app context and development skill into chat.`}),(0,j.jsxs)(`label`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:[n?`应用名称`:`App name`,(0,j.jsx)(`input`,{value:Be,onChange:e=>Ve(e.target.value),required:!0,autoFocus:!0,className:`mt-2 w-full rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:阅读清单`:`e.g. Reading list`})]}),(0,j.jsxs)(`label`,{className:`mt-4 text-xs font-medium text-fg-muted`,children:[n?`描述你的想法`:`Describe your idea`,(0,j.jsx)(`textarea`,{value:He,onChange:e=>Ue(e.target.value),required:!0,rows:7,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`})]}),I?(0,j.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:I}):null,(0,j.jsxs)(E,{type:`submit`,variant:`primary`,className:`mt-5 h-10`,disabled:P||!Be.trim()||!He.trim(),children:[P?(0,j.jsx)(S,{className:`size-4 animate-spin`}):(0,j.jsx)(x,{className:`size-4`}),n?`进入 Coder 对话`:`Continue with Coder`]})]}),(0,j.jsx)(`div`,{className:`hidden min-h-[620px] place-items-center bg-surface-panel p-8 lg:grid`,children:(0,j.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,j.jsx)(`div`,{className:`mx-auto flex size-16 items-center justify-center rounded-2xl border border-edge bg-surface-base text-accent shadow-surface`,children:(0,j.jsx)(ge,{className:`size-7`})}),(0,j.jsx)(`h3`,{className:`mt-5 text-base font-semibold text-fg`,children:n?`创建后,这里就是实时预览`:`Your live preview appears here`}),(0,j.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`你可以先体验草稿,再决定是否把它添加到左侧导航。`:`Try the draft first, then decide whether to add it to the sidebar.`})]})})]})}):Ne?(0,j.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_260px]`,children:[(0,j.jsx)(w,{className:`rounded-xl`}),(0,j.jsx)(w,{className:`rounded-xl`}),(0,j.jsx)(w,{className:`rounded-xl`})]}):A||!k?(0,j.jsx)(`div`,{className:`m-6 rounded-xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,children:A instanceof Error?A.message:n?`找不到应用`:`App not found`}):(0,j.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_300px]`,children:[(0,j.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.12em] text-accent`,children:[(0,j.jsx)(ae,{className:`size-4`}),n?`创作对话`:`Build conversation`]}),(0,j.jsx)(`div`,{className:`mt-4 rounded-xl bg-surface-panel p-3 text-sm leading-6 text-fg`,children:k.idea}),(0,j.jsxs)(`div`,{className:`mt-4 rounded-xl bg-accent-soft p-3`,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-accent-fg`,children:[(0,j.jsx)(C,{className:`size-4`}),n?`草稿已准备好`:`Draft is ready`]}),(0,j.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`继续迭代会进入对应 Project,由 Coder 读取应用上下文和专属 skill。`:`Continue in the Project where Coder has the app context and dedicated skill.`})]}),(0,j.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),Q(Ye)},children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`local-app-change-request`,children:n?`下一步想改什么?`:`What should change next?`}),(0,j.jsx)(`textarea`,{id:`local-app-change-request`,value:Ye,onChange:e=>Xe(e.target.value),rows:4,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`}),(0,j.jsxs)(E,{type:`submit`,className:`mt-2 w-full`,disabled:z||!Ye.trim(),children:[z?(0,j.jsx)(S,{className:`size-4 animate-spin`}):(0,j.jsx)(x,{className:`size-4`}),n?`让 Coder 修改`:`Ask Coder to update`]})]}),(0,j.jsxs)(E,{variant:`ghost`,className:`mt-2 w-full`,onClick:()=>void Q(),disabled:z,children:[(0,j.jsx)(me,{className:`size-4`}),n?`打开已有开发对话`:`Open development chat`]})]}),(0,j.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,j.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-edge-subtle px-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,j.jsx)(`span`,{className:`size-2 rounded-full ${M?.status===`failed`||B===`failed`||B===`timeout`||X?.status===`failed`?`bg-danger`:M?.status===`healthy`&&B===`healthy`&&X?.status===`passed`&&$?.sourceHash===M.sourceHash&&!pt?`bg-success`:`bg-fg-subtle`}`}),B===`failed`||B===`timeout`?n?`预览运行异常`:`Preview runtime issue`:M?.status===`failed`||X?.status===`failed`?n?`自动验收未通过`:`Acceptance needs attention`:B===`booting`||!X?n?`自动验收中`:`Running acceptance`:pt||$?.sourceHash!==M?.sourceHash?n?`正在保存验收快照`:`Saving acceptance snapshot`:n?`草稿已通过验收`:`Draft accepted`]}),(0,j.jsxs)(E,{variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Z(!0),disabled:Qe,children:[Qe?(0,j.jsx)(S,{className:`size-3.5 animate-spin`}):(0,j.jsx)(pe,{className:`size-3.5`}),n?`重新验收`:`Run again`]})]}),(0,j.jsx)(`iframe`,{ref:gt,title:`${k.name} preview`,src:c(k.previewUrl),sandbox:`allow-scripts`,className:`min-h-0 w-full flex-1 bg-white`,onError:()=>{tt({kind:`script_error`,message:`Preview document failed to load`}),V(`failed`)}},R),M?.status===`healthy`&&M.acceptanceScenarioCount>0?(0,j.jsx)(`iframe`,{ref:_t,title:`${k.name} acceptance runner`,src:`${c(k.previewUrl)}?xopcAcceptance=1${U===`all`?``:`&xopcScenario=${encodeURIComponent(U)}`}`,sandbox:`allow-scripts`,"aria-hidden":`true`,tabIndex:-1,className:`pointer-events-none fixed left-[-200vw] top-0 h-[720px] w-[1024px] opacity-0`},`criteria-${R}-${ot}`):null]}),(0,j.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n?`发布状态`:`Release status`}),(0,j.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:k.installationState===`not_installed`?n?`尚未安装`:`Not installed`:k.enabled?n?`版本 ${k.activeVersion} 正在使用`:`Version ${k.activeVersion} is active`:n?`已禁用,版本仍保留`:`Disabled, release retained`})]}),(0,j.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full ${k.enabled?`bg-success`:`bg-fg-subtle`}`,"aria-hidden":!0})]}),(0,j.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 text-xs`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`当前草稿`:`Draft`}),(0,j.jsxs)(`dd`,{className:`mt-1 font-medium text-fg`,children:[`v`,k.draftVersion]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`已安装`:`Installed`}),(0,j.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:k.activeVersion?`v${k.activeVersion}`:`—`})]})]}),(0,j.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,j.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,j.jsx)(ee,{className:`size-4 text-accent`}),n?`草稿检查`:`Draft checks`]}),ze||Qe?(0,j.jsx)(S,{className:`size-3.5 animate-spin text-fg-muted`}):M?.status===`healthy`?(0,j.jsx)(C,{className:`size-4 text-success`}):(0,j.jsx)(ue,{className:`size-4 text-danger`})]}),M?(0,j.jsxs)(`div`,{className:`mt-2`,children:[(0,j.jsx)(`p`,{className:`text-xs leading-5 ${M.status===`healthy`?`text-fg-muted`:`text-danger`}`,children:M.status===`healthy`?M.hasDraftChanges?n?`${M.changedFileCount} 个文件有改动,可以安装新版本。`:`${M.changedFileCount} changed files are ready for a new release.`:n?`草稿与当前安装版本一致。`:`Draft matches the installed release.`:M.issues[0]?.message}),M.changedFiles.length?(0,j.jsx)(`ul`,{className:`mt-2 space-y-1`,children:M.changedFiles.slice(0,4).map(e=>(0,j.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,j.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,j.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,M.changedFileCount>4?(0,j.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-subtle`,children:n?`还有 ${M.changedFileCount-4} 个文件`:`${M.changedFileCount-4} more files`}):null,(0,j.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,j.jsx)(`span`,{className:`size-2 rounded-full ${B===`healthy`?`bg-success`:B===`booting`?`bg-fg-subtle`:`bg-danger`}`}),n?`预览运行`:`Preview runtime`]}),(0,j.jsx)(`p`,{className:`mt-1 text-xs leading-5 ${B===`failed`||B===`timeout`?`text-danger`:`text-fg-muted`}`,children:et?Me(et):B===`healthy`?n?`已成功启动,未发现未捕获异常。`:`Started successfully with no uncaught errors.`:B===`timeout`?n?`7 秒内未完成启动,可能出现白屏或阻塞。`:`Did not finish booting within 7 seconds.`:n?`正在等待应用启动。`:`Waiting for the app to start.`})]}),(0,j.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,j.jsx)(`span`,{className:`size-2 rounded-full ${X?.status===`passed`?`bg-success`:X?.status===`failed`?`bg-danger`:`bg-fg-subtle`}`}),n?`自动验收`:`Automatic acceptance`]}),X?(0,j.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:X.checks.map(e=>(0,j.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4 ${e.status===`failed`?`text-danger`:`text-fg-muted`}`,children:[(0,j.jsx)(`span`,{className:`mt-1 size-1.5 shrink-0 rounded-full ${e.status===`failed`?`bg-danger`:e.status===`passed`?`bg-success`:`bg-fg-subtle`}`}),(0,j.jsx)(`span`,{children:e.message})]},e.id))}):(0,j.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:M?.acceptanceScenarioCount?n?`正在检查页面基础质量和 ${M.acceptanceScenarioCount} 个产品场景。`:`Checking page quality and ${M.acceptanceScenarioCount} product scenario(s).`:n?`正在检查页面内容和基础交互。`:`Checking rendered content and basic interaction.`}),pt?(0,j.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,j.jsx)(S,{className:`size-3 animate-spin`}),n?`正在保存当前源码对应的验收快照…`:`Saving the acceptance snapshot for this source…`]}):$?(0,j.jsx)(`p`,{className:`mt-2 text-[11px] leading-4 text-fg-muted`,children:At?n?`相比上次:已修复 ${Mt} 项,仍有 ${jt.length} 项。`:`Since the previous run: ${Mt} fixed, ${jt.length} remaining.`:n?`首个验收快照已保存。`:`First acceptance snapshot saved.`}):null,(0,j.jsx)(Fe,{scenarios:J,results:rt,runningTarget:ct,zh:n,onRunAll:Et,onRunScenario:Dt,onAskCoder:Ot})]}),M.status===`failed`||B===`failed`||B===`timeout`||X?.status===`failed`?(0,j.jsxs)(E,{className:`mt-3 w-full`,onClick:Tt,disabled:z,children:[(0,j.jsx)(x,{className:`size-4`}),n?`让 Coder 修复`:`Ask Coder to fix`]}):null]}):(0,j.jsx)(w,{className:`mt-2 h-12 rounded-lg`})]}),(0,j.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,j.jsx)(g,{className:`size-4 text-accent`}),n?`权限`:`Permissions`]}),(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(M?.permissions??k.permissions).map(e=>(0,j.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] text-fg-muted`,children:e},e))})]}),(0,j.jsx)(E,{variant:`primary`,className:`mt-5 w-full`,onClick:()=>void Nt(),disabled:P||ze||Qe||pt||M?.status===`failed`||B!==`healthy`||X?.status!==`passed`||!$||$.sourceHash!==M?.sourceHash||k.installationState===`installed`&&M?.hasDraftChanges===!1,children:k.installationState===`installed`?n?`安装当前更新`:`Install current update`:n?`添加到左侧导航`:`Add to sidebar`}),k.installationState===`installed`?(0,j.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,j.jsxs)(E,{className:`min-w-0 flex-1`,onClick:()=>void St(!k.enabled),disabled:P,children:[k.enabled?(0,j.jsx)(fe,{className:`size-4`}):(0,j.jsx)(se,{className:`size-4`}),k.enabled?n?`禁用`:`Disable`:n?`启用`:`Enable`]}),(0,j.jsx)(E,{variant:`ghost`,className:`text-danger hover:text-danger`,onClick:()=>qe(!0),disabled:P,"aria-label":n?`卸载应用`:`Uninstall app`,children:(0,j.jsx)(p,{className:`size-4`})})]}):null,(0,j.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4`,children:[(0,j.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,j.jsx)(de,{className:`size-4`}),n?`版本历史`:`Release history`]}),k.releases.length?(0,j.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,children:k.releases.map(e=>(0,j.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2.5`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[`v`,e.version,e.isActive?(0,j.jsx)(`span`,{className:`rounded-full bg-success-soft px-1.5 py-0.5 text-[10px] text-success`,children:n?`当前`:`Active`}):null]}),(0,j.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-fg-subtle`,children:Ie(e.createdAt,r)})]}),e.isActive?null:(0,j.jsxs)(E,{variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>void Ct(e.id),disabled:P,children:[(0,j.jsx)(oe,{className:`size-3.5`}),n?`恢复`:`Restore`]})]},e.id))}):(0,j.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n?`安装首个版本后,可以从这里恢复。`:`Install the first version to enable recovery.`})]}),I?(0,j.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-danger`,role:`alert`,children:I}):null]}),(0,j.jsx)(b,{open:We,onOpenChange:Ge,children:(0,j.jsxs)(y,{children:[(0,j.jsx)(_,{className:`fixed inset-0 z-50 bg-black/45`}),(0,j.jsxs)(f,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(560px,calc(100vh-32px))] w-[min(520px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-base shadow-2xl focus:outline-none`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(ne,{className:`text-base font-semibold text-fg`,children:n?`确认安装到 XOPC`:`Confirm installation`}),(0,j.jsx)(le,{className:`mt-1 text-sm text-fg-muted`,children:n?`当前草稿会成为左侧导航中的可用版本。`:`The current draft will become the version available in the sidebar.`})]}),(0,j.jsx)(T,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,j.jsx)(he,{className:`size-4`})})]}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,j.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:k.name}),(0,j.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:k.extensionId})]}),(0,j.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`本次迭代`:`This iteration`}),(0,j.jsxs)(`dl`,{className:`mt-2 grid grid-cols-2 gap-3 text-xs`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`文件变化`:`Changed files`}),(0,j.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:M?.changedFileCount??0})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`自动验收`:`Acceptance`}),(0,j.jsxs)(`dd`,{className:`mt-1 flex items-center gap-1.5 font-medium text-success`,children:[(0,j.jsx)(C,{className:`size-3.5`}),n?`已通过并保存`:`Passed and saved`]})]})]}),M?.changedFiles.length?(0,j.jsx)(`ul`,{className:`mt-3 space-y-1`,children:M.changedFiles.slice(0,5).map(e=>(0,j.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,j.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,j.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,(0,j.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`请求权限`:`Requested permissions`}),(0,j.jsx)(`ul`,{className:`mt-2 space-y-2`,children:(M?.permissions??k.permissions).map(e=>(0,j.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,j.jsx)(s,{className:`size-4 text-success`}),e,k.installationState===`installed`&&M?.permissionDelta.added.includes(e)?(0,j.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-[10px] text-warning`,children:n?`新增`:`New`}):null]},e))}),k.installationState===`installed`&&M?.permissionDelta.added.length?(0,j.jsx)(`p`,{className:`mt-4 rounded-xl bg-warning-soft p-3 text-xs leading-5 text-warning`,children:n?`此更新增加了权限,请确认这些能力符合你的修改意图。`:`This update adds permissions. Confirm they match the change you requested.`}):null,(0,j.jsx)(`p`,{className:`mt-5 rounded-xl bg-accent-soft p-3 text-xs leading-5 text-accent-fg`,children:n?`Phase 1 应用只能使用界面主题和本地存储,不能访问网络或运行系统命令。`:`Phase 1 apps can use theme and local storage only. They cannot access the network or run system commands.`})]}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,j.jsx)(T,{asChild:!0,children:(0,j.jsx)(E,{children:n?`取消`:`Cancel`})}),(0,j.jsxs)(E,{variant:`primary`,onClick:()=>void bt(),disabled:P,children:[P?(0,j.jsx)(S,{className:`size-4 animate-spin`}):(0,j.jsx)(m,{className:`size-4`}),n?`确认安装`:`Install`]})]})]})]})}),(0,j.jsx)(b,{open:Ke,onOpenChange:qe,children:(0,j.jsxs)(y,{children:[(0,j.jsx)(_,{className:`fixed inset-0 z-50 bg-black/45`}),(0,j.jsxs)(f,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(420px,calc(100vh-32px))] w-[min(500px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-base shadow-2xl focus:outline-none`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(ne,{className:`text-base font-semibold text-fg`,children:n?`卸载当前应用?`:`Uninstall this app?`}),(0,j.jsx)(le,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:n?`应用会从侧栏移除,但 Project、源码、版本历史和本地数据都会保留。`:`The app leaves the sidebar, while its Project, source, release history, and local data remain.`})]}),(0,j.jsx)(T,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,j.jsx)(he,{className:`size-4`})})]}),(0,j.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,j.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-4`,children:[(0,j.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:k.name}),(0,j.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`之后可从任意保留版本重新安装。`:`You can reinstall any retained release later.`})]})}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,j.jsx)(T,{asChild:!0,children:(0,j.jsx)(E,{children:n?`取消`:`Cancel`})}),(0,j.jsxs)(E,{variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger`,onClick:()=>void wt(),disabled:P,children:[P?(0,j.jsx)(S,{className:`size-4 animate-spin`}):(0,j.jsx)(p,{className:`size-4`}),n?`卸载但保留 Project`:`Uninstall and keep Project`]})]})]})]})})]})}export{Re as LocalAppWorkbenchPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{n as a}from"./locale-store-Bp8joZck.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{Fo as s,Ws as c,io as l,mc as u,ms as d,mu as f,ou as p}from"./index-CxkNzw3e.js";import{i as m}from"./api-Bs69B5zA.js";var h=n(),g=e(t(),1),_=r();function v(){let e=(0,h.c)(24),t=a(S)===`zh`,n=s(x),r=s(b),{data:l,isLoading:v,error:C}=o(`local-apps-list`,m),w,T;e[0]!==r||e[1]!==n||e[2]!==t?(w=()=>(n({startExtra:null,main:(0,_.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t?`本地应用`:`Local Apps`}),end:(0,_.jsx)(d,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,_.jsxs)(i,{to:`/local-apps/new`,children:[(0,_.jsx)(u,{className:`size-4`}),t?`创建应用`:`Create app`]})})}),()=>r()),T=[r,n,t],e[0]=r,e[1]=n,e[2]=t,e[3]=w,e[4]=T):(w=e[3],T=e[4]),(0,g.useLayoutEffect)(w,T);let E;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,_.jsx)(c,{className:`size-4`}),e[5]=E):E=e[5];let D=t?`从想法开始`:`Start with an idea`,O;e[6]===D?O=e[7]:(O=(0,_.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.14em] text-accent`,children:[E,D]}),e[6]=D,e[7]=O);let k=t?`把自己的工具放进 XOPC`:`Put your own tools inside XOPC`,A;e[8]===k?A=e[9]:(A=(0,_.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight text-fg`,children:k}),e[8]=k,e[9]=A);let j=t?`每个应用都会自动创建一个由 Coder 负责的 Project,可预览、安装到侧栏,并持续迭代。`:`Every app gets a Coder-owned Project for previewing, installing in the sidebar, and ongoing iteration.`,M;e[10]===j?M=e[11]:(M=(0,_.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:j}),e[10]=j,e[11]=M);let N;e[12]!==O||e[13]!==A||e[14]!==M?(N=(0,_.jsxs)(`div`,{className:`mb-6 max-w-2xl`,children:[O,A,M]}),e[12]=O,e[13]=A,e[14]=M,e[15]=N):N=e[15];let P;e[16]!==l||e[17]!==C||e[18]!==v||e[19]!==t?(P=v?(0,_.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:3}).map(y)}):C?(0,_.jsx)(`p`,{className:`rounded-xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,children:C instanceof Error?C.message:String(C)}):l?.length?(0,_.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:l.map(e=>(0,_.jsxs)(i,{to:`/local-apps/${encodeURIComponent(e.id)}`,className:`group flex min-h-44 flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,_.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,_.jsx)(p,{className:`size-5`})}),(0,_.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:e.installationState===`not_installed`?t?`草稿`:`Draft`:e.enabled?t?`已在侧栏`:`In sidebar`:t?`已禁用`:`Disabled`})]}),(0,_.jsx)(`h3`,{className:`mt-4 truncate text-sm font-semibold text-fg`,children:e.name}),(0,_.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description||e.idea}),(0,_.jsxs)(`div`,{className:`mt-auto flex items-center justify-end pt-3 text-xs font-medium text-accent`,children:[t?`打开工作台`:`Open workbench`,(0,_.jsx)(f,{className:`ml-1 size-3.5 transition-transform group-hover:translate-x-0.5`})]})]},e.id))}):(0,_.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge bg-surface-base px-6 py-14 text-center`,children:[(0,_.jsx)(p,{className:`mx-auto size-8 text-fg-subtle`}),(0,_.jsx)(`h3`,{className:`mt-4 text-sm font-semibold text-fg`,children:t?`还没有本地应用`:`No local apps yet`}),(0,_.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm text-fg-muted`,children:t?`描述你想解决的问题,XOPC 会创建应用骨架和可持续开发的 Project。`:`Describe the problem and XOPC will create an app scaffold and an ongoing Project.`}),(0,_.jsx)(d,{asChild:!0,variant:`primary`,className:`mt-5`,children:(0,_.jsxs)(i,{to:`/local-apps/new`,children:[(0,_.jsx)(u,{className:`size-4`}),t?`创建第一个应用`:`Create your first app`]})})]}),e[16]=l,e[17]=C,e[18]=v,e[19]=t,e[20]=P):P=e[20];let F;return e[21]!==P||e[22]!==N?(F=(0,_.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel px-3 py-8 sm:px-5 xl:px-6`,children:(0,_.jsxs)(`div`,{className:`mx-auto max-w-6xl`,children:[N,P]})}),e[21]=P,e[22]=N,e[23]=F):F=e[23],F}function y(e,t){return(0,_.jsx)(l,{className:`h-44 rounded-xl`},t)}function b(e){return e.clearPageHeader}function x(e){return e.setPageHeader}function S(e){return e.language}export{v as LocalAppsPage};
@@ -1,7 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./copy-to-clipboard-HOJ79TWv.js";import{t as s}from"./messages-CQGpD-dC.js";import{d as c,i as l,n as u,o as d}from"./locale-store-Bp8joZck.js";import{$o as f,Al as p,Ao as m,Jo as h,Ko as g,Mo as _,No as v,Ns as y,Oo as b,Po as x,Qo as S,Uc as C,Vl as w,Wo as T,Xo as E,Yo as D,ec as O,es as k,eu as A,fs as j,ha as M,hl as N,io as P,ko as F,ls as I,ml as L,ms as R,oa as z,sc as B,ts as V,vs as ee,xl as H}from"./index-CxkNzw3e.js";import{r as U}from"./segmented-styles-BL8oLBEp.js";var W=e(t(),1),G=n();function K(e){let t=new URLSearchParams;if(!e)return``;e.level?.length&&t.set(`level`,e.level.join(`,`)),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.q&&t.set(`q`,e.q),e.module&&t.set(`module`,e.module),e.requestId&&t.set(`requestId`,e.requestId),e.sessionKey&&t.set(`sessionKey`,e.sessionKey),e.sessionId&&t.set(`sessionId`,e.sessionId),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return n?`?${n}`:``}async function q(e){return l(c(`/api/logs${K(e)}`))}async function J(){return(await l(c(`/api/logs/files`))).files??[]}async function te(){return(await l(c(`/api/logs/modules`))).modules??[]}async function Y(){let e=await l(c(`/api/logs/stats`));return{byLevel:e.byLevel??{},runtime:e.runtime}}async function ne(){return(await l(c(`/api/logs/dir`))).dir??``}async function X(){return(await l(c(`/api/logs/level`))).level??`info`}async function Z(e,t){return l(c(`/api/logs/level`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({level:e,...t==null?{}:{duration:String(t)}})})}async function re(e){let t=new URLSearchParams;e?.from&&t.set(`from`,e.from),e?.to&&t.set(`to`,e.to),e?.limit!=null&&t.set(`limit`,String(e.limit));let n=t.toString();return(await l(c(`/api/logs/errors/summary${n?`?${n}`:``}`))).items??[]}var ie=500,ae=class{_token;_callbacks;_abort;constructor(e,t){this._token=e,this._callbacks=t}connect(e,t){this.disconnect();let n=new AbortController;this._abort=n,this._consume(n,e,t)}async _consume(e,t,n){let r=new URL(c(`/api/logs/stream`));t?.length?r.searchParams.set(`levels`,t.join(`,`)):r.searchParams.set(`levels`,`trace,debug,info,warn,error,fatal`),n&&r.searchParams.set(`module`,n);try{let t=new Headers({Accept:`text/event-stream`});this._token&&t.set(`Authorization`,`Bearer ${this._token}`);let n=await fetch(r.toString(),{headers:t,signal:e.signal});if(!n.ok||!n.body)throw Error(`Log stream failed: ${n.status}`);let i=n.body.getReader(),a=new TextDecoder,o=``;for(;!e.signal.aborted;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let n=o.indexOf(`
2
-
3
- `);for(;n>=0;)this._dispatchChunk(o.slice(0,n)),o=o.slice(n+2),n=o.indexOf(`
4
-
5
- `)}}catch(t){e.signal.aborted||this._callbacks.onError(t instanceof Error?t.message:`Log stream disconnected`)}finally{this._abort===e&&(this._abort=void 0)}}_dispatchChunk(e){let t=e.split(/\r?\n/).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
6
- `);if(t)try{let e=JSON.parse(t);if(e.type===`connected`){this._callbacks.onConnected();return}if(e.type===`heartbeat`)return;this._callbacks.onEntry(e)}catch{}}disconnect(){this._abort?.abort(),this._abort=void 0}};function oe(e,t){let n=`${t.timestamp}-${t.requestId??``}-${t.message}`;return[t,...e.filter(e=>`${e.timestamp}-${e.requestId??``}-${e.message}`!==n)].slice(0,ie)}var Q=[`trace`,`debug`,`info`,`warn`,`error`,`fatal`];function se(e){let t=new Date(String(e.timestamp)).getTime();return Number.isFinite(t)?t:0}function ce(e){return e.toSorted((e,t)=>se(t)-se(e))}var le=new Set(Q),ue=[`error`,`fatal`],de=[`warn`,`error`,`fatal`],fe=[`info`,`warn`,`error`,`fatal`];function pe(e){if(!e)return new Set;let t=new Set;for(let n of e.split(`,`)){let e=n.trim();le.has(e)&&t.add(e)}return t}function me(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function he(e,t){return e.size===t.length?t.every(t=>e.has(t)):!1}function ge(e){return e.size===0?`all`:he(e,ue)?`errors`:he(e,de)?`warnPlus`:he(e,fe)?`infoPlus`:e.size===Q.length&&Q.every(t=>e.has(t))?`verbose`:`custom`}function _e(e){let t=ge(e);return t===`custom`?`other`:t}function ve(e){switch(e){case`all`:return new Set;case`errors`:return new Set(ue);case`warnPlus`:return new Set(de);case`infoPlus`:return new Set(fe);case`verbose`:return new Set(Q)}}function ye(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function be(e){return String(e.module||e.service||e.extension||`—`)}function xe(e){if(typeof e.message==`string`&&e.message)return e.message;try{return JSON.stringify(e)}catch{return``}}function Se(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{return e}}function Ce(e){try{return new Date(e).toLocaleString()}catch{return e}}function we(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Te(e){let t=e.trim();return t.length<=10?t:`${t.slice(0,8)}…`}function Ee(e){return String(e).toLowerCase()}function De(e){let t=e.phase??e.meta?.phase;return typeof t==`string`&&t.trim()?t:`—`}function Oe(e){return`${e.timestamp}-${e.requestId??``}-${e.message}`}function ke(e){let t=e.err??e.meta?.err;if(!t||typeof t!=`object`)return null;let n=t;return{name:typeof n.name==`string`?n.name:void 0,message:typeof n.message==`string`?n.message:void 0,stack:typeof n.stack==`string`?n.stack:void 0}}function Ae(e,t){if(t.selectedLevels.size>0&&!t.selectedLevels.has(e.level)||t.moduleFilter&&be(e)!==t.moduleFilter||t.requestIdFilter&&e.requestId!==t.requestIdFilter||t.sessionIdFilter&&e.sessionId!==t.sessionIdFilter&&e.sessionKey!==t.sessionIdFilter)return!1;if(t.dateFrom){let n=new Date(t.dateFrom).getTime(),r=new Date(String(e.timestamp)).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&r<n)return!1}if(t.dateTo){let n=new Date(t.dateTo).getTime(),r=new Date(String(e.timestamp)).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&r>n)return!1}if(t.debouncedSearch){let n=t.debouncedSearch.toLowerCase();if(![e.message,be(e),De(e),e.requestId,e.sessionKey,e.sessionId,ke(e)?.message,ke(e)?.stack].filter(Boolean).map(String).join(` `).toLowerCase().includes(n))return!1}return!0}function je(e,t){let n=[];for(let r of Q){let i=e[r]??0;i>0&&n.push(`${t[r]} ${i}`)}return n.join(` · `)}function Me(e,t){switch(t.type){case`setSearchInput`:return e.searchInput===t.value?e:{...e,searchInput:t.value};case`setDebouncedSearch`:return e.debouncedSearch===t.value?e:{...e,debouncedSearch:t.value};case`setLevels`:return me(e.selectedLevels,t.value)?e:{...e,selectedLevels:t.value};case`toggleLevel`:{let n=new Set(e.selectedLevels);return n.has(t.level)?n.delete(t.level):n.add(t.level),{...e,selectedLevels:n}}case`setModule`:return e.moduleFilter===t.value?e:{...e,moduleFilter:t.value};case`setRequestIdFilter`:return e.requestIdFilter===t.value?e:{...e,requestIdFilter:t.value};case`setSessionIdFilter`:return e.sessionIdFilter===t.value?e:{...e,sessionIdFilter:t.value};case`setDateFrom`:return e.dateFrom===t.value?e:{...e,dateFrom:t.value};case`setDateTo`:return e.dateTo===t.value?e:{...e,dateTo:t.value};case`setAutoRefresh`:return e.autoRefresh===t.value?e:{...e,autoRefresh:t.value};case`syncFromUrl`:{let n=t.payload;return e.searchInput===n.searchInput&&e.debouncedSearch===n.debouncedSearch&&me(e.selectedLevels,n.selectedLevels)&&e.moduleFilter===n.moduleFilter&&e.requestIdFilter===n.requestIdFilter&&e.sessionIdFilter===n.sessionIdFilter&&e.dateFrom===n.dateFrom&&e.dateTo===n.dateTo&&e.autoRefresh===n.autoRefresh?e:{...e,...n}}case`clearAll`:return{searchInput:``,debouncedSearch:``,selectedLevels:new Set,moduleFilter:``,requestIdFilter:``,sessionIdFilter:``,dateFrom:``,dateTo:``,autoRefresh:e.autoRefresh}}}var Ne={logs:[],loading:!1,error:null,hasMore:!1,modules:[],files:[],stats:null,logDir:null};function Pe(e,t){switch(t.type){case`queryStart`:return{...e,loading:!0,error:null,logs:[]};case`querySuccess`:return{...e,loading:!1,logs:ce(t.logs),hasMore:t.hasMore};case`queryError`:return t.resetLogs?{...e,loading:!1,error:t.message,logs:[],hasMore:!1}:{...e,loading:!1,error:t.message};case`appendSuccess`:return{...e,loading:!1,logs:ce([...e.logs,...t.logs]),hasMore:t.hasMore};case`metaSuccess`:return{...e,modules:t.modules,stats:t.stats,files:t.files};case`filesSuccess`:return{...e,files:t.files,logDir:t.logDir};case`filesClear`:return{...e,files:[]};case`liveTick`:return{...e,logs:ce(t.logs),hasMore:t.hasMore,stats:t.stats};case`appendLiveEntry`:return{...e,logs:ce(oe(e.logs,t.entry))};case`updateStats`:return{...e,stats:t.stats};case`refreshAllSuccess`:return{...e,loading:!1,logs:ce(t.logs),hasMore:t.hasMore,stats:t.stats,files:t.files}}}function Fe(e){let t=s(e).logs,n=d(e=>e.token),r=!!n,[a,o]=i(),c=(0,W.useRef)(a),[l,u]=(0,W.useReducer)(Me,void 0,()=>{let e=c.current,t=e.get(`q`)??``;return{searchInput:t,debouncedSearch:t.trim(),selectedLevels:pe(e.get(`level`)),moduleFilter:e.get(`module`)??``,requestIdFilter:e.get(`requestId`)??``,sessionIdFilter:e.get(`sessionId`)??``,dateFrom:e.get(`from`)??``,dateTo:e.get(`to`)??``,autoRefresh:e.get(`live`)===`1`}}),[f,p]=(0,W.useReducer)(Pe,Ne),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(null),[S,C]=(0,W.useState)([]),[w,T]=(0,W.useState)(!1),{searchInput:E,debouncedSearch:D,selectedLevels:O,moduleFilter:k,requestIdFilter:A,sessionIdFilter:j,dateFrom:N,dateTo:P,autoRefresh:F}=l,{logs:I,loading:L,error:R,hasMore:z,modules:B,files:V,stats:ee,logDir:H}=f,U=(0,W.useCallback)(e=>u({type:`setSearchInput`,value:e}),[]),G=(0,W.useCallback)(e=>u({type:`setLevels`,value:e}),[]),K=(0,W.useCallback)(e=>u({type:`setModule`,value:e}),[]),X=(0,W.useCallback)(e=>u({type:`setRequestIdFilter`,value:e}),[]),Z=(0,W.useCallback)(e=>u({type:`setSessionIdFilter`,value:e}),[]),ie=(0,W.useCallback)(e=>u({type:`setDateFrom`,value:e}),[]),oe=(0,W.useCallback)(e=>u({type:`setDateTo`,value:e}),[]),Q=(0,W.useCallback)(e=>u({type:`setAutoRefresh`,value:e}),[]),se=(0,W.useMemo)(()=>_e(O),[O]),ce=e=>{if(e===`other`){y(!0);return}u({type:`setLevels`,value:ve(e)})},le=D.length>0||O.size>0||!!k||!!A||!!j||!!N||!!P,ue=+(D.length>0)+ +(O.size>0)+ +!!k+ +!!A+ +!!j+(N||P?1:0);(0,W.useEffect)(()=>{let e=setTimeout(()=>u({type:`setDebouncedSearch`,value:E.trim()}),300);return()=>clearTimeout(e)},[E]),(0,W.useEffect)(()=>{let e=a.get(`q`)??``;u({type:`syncFromUrl`,payload:{searchInput:e,debouncedSearch:e.trim(),selectedLevels:pe(a.get(`level`)),moduleFilter:a.get(`module`)??``,requestIdFilter:a.get(`requestId`)??``,sessionIdFilter:a.get(`sessionId`)??``,dateFrom:a.get(`from`)??``,dateTo:a.get(`to`)??``,autoRefresh:a.get(`live`)===`1`}})},[a]),(0,W.useEffect)(()=>{let e=new URLSearchParams(a),t=D.trim();t?e.set(`q`,t):e.delete(`q`),O.size>0?e.set(`level`,Array.from(O).sort().join(`,`)):e.delete(`level`),k?e.set(`module`,k):e.delete(`module`),A?e.set(`requestId`,A):e.delete(`requestId`),j?e.set(`sessionId`,j):e.delete(`sessionId`),N?e.set(`from`,N):e.delete(`from`),P?e.set(`to`,P):e.delete(`to`),F?e.set(`live`,`1`):e.delete(`live`),e.toString()!==a.toString()&&o(e,{replace:!0})},[F,N,P,D,k,A,j,a,O,o]);let de=(0,W.useMemo)(()=>({q:D||void 0,level:O.size>0?Array.from(O):void 0,module:k||void 0,requestId:A||void 0,sessionId:j||void 0,from:N||void 0,to:P||void 0,limit:50}),[D,O,k,A,j,N,P]),fe=(0,W.useMemo)(()=>({debouncedSearch:D,selectedLevels:O,moduleFilter:k,requestIdFilter:A,sessionIdFilter:j,dateFrom:N,dateTo:P}),[D,O,k,A,j,N,P]),me=(0,W.useRef)(fe);return me.current=fe,(0,W.useEffect)(()=>{if(!r)return;let e=!1;return T(!0),re({from:N||void 0,to:P||void 0,limit:12}).then(t=>{e||C(t)}).catch(()=>{e||C([])}).finally(()=>{e||T(!1)}),()=>{e=!0}},[r,N,P]),(0,W.useEffect)(()=>{if(!r)return;let e=!1;return p({type:`queryStart`}),(async()=>{try{let t=await q({...de,offset:0});if(e)return;p({type:`querySuccess`,logs:t.logs,hasMore:t.logs.length===50})}catch(n){e||p({type:`queryError`,message:n instanceof Error?n.message:t.loadError,resetLogs:!0})}})(),()=>{e=!0}},[r,de,t.loadError]),(0,W.useEffect)(()=>{if(!r)return;let e=!1;return(async()=>{try{let[t,n,r]=await Promise.all([te(),Y(),J()]);e||p({type:`metaSuccess`,modules:t,stats:n,files:r})}catch{}})(),()=>{e=!0}},[r]),(0,W.useEffect)(()=>{if(!r||!g)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([J(),ne()]);e||p({type:`filesSuccess`,files:t,logDir:n})}catch{e||p({type:`filesClear`})}})(),()=>{e=!0}},[r,g]),(0,W.useEffect)(()=>{if(!F||!r)return;let e=new ae(n??void 0,{onConnected:()=>{},onEntry:e=>{Ae(e,me.current)&&p({type:`appendLiveEntry`,entry:e})},onError:()=>{}});e.connect(O.size>0?Array.from(O):void 0,k||void 0);let t=window.setInterval(()=>{Y().then(e=>{p({type:`updateStats`,stats:e})}).catch(()=>{})},3e4);return()=>{e.disconnect(),clearInterval(t)}},[F,r,n,O,k]),(0,W.useEffect)(()=>{if(!b)return;let e=window.setTimeout(()=>x(null),2e3);return()=>clearTimeout(e)},[b]),{L:t,hasToken:r,logs:I,loading:L,error:R,hasMore:z,searchInput:E,setSearchInput:U,selectedLevels:O,setSelectedLevels:G,moduleFilter:k,setModuleFilter:K,requestIdFilter:A,sessionIdFilter:j,dateFrom:N,setDateFrom:ie,dateTo:P,setDateTo:oe,modules:B,files:V,stats:ee,selectedLog:m,setSelectedLog:h,filesOpen:g,setFilesOpen:_,filtersOpen:v,setFiltersOpen:y,logDir:H,autoRefresh:F,setAutoRefresh:Q,copiedDetail:b,setCopiedDetail:x,hasActiveFilters:le,activeFilterCount:ue,clearFilters:()=>u({type:`clearAll`}),toggleDialogLevel:e=>u({type:`toggleLevel`,level:e}),handleLoadMore:()=>{L||!z||(async()=>{p({type:`queryStart`});try{let e=await q({...de,offset:I.length});p({type:`appendSuccess`,logs:e.logs,hasMore:e.logs.length===50})}catch(e){p({type:`queryError`,message:e instanceof Error?e.message:t.loadError})}})()},refreshAll:()=>{(async()=>{p({type:`queryStart`});try{let e=await q({...de,offset:0}),[t,n]=await Promise.all([Y(),J()]);p({type:`refreshAllSuccess`,logs:e.logs,hasMore:e.logs.length===50,stats:t,files:n})}catch(e){p({type:`queryError`,message:e instanceof Error?e.message:t.loadError})}})()},levelSegment:se,handleLevelSegment:ce,filterByRequestId:(0,W.useCallback)(e=>{h(null),X(e)},[X]),filterBySessionId:(0,W.useCallback)(e=>{h(null),Z(e)},[Z]),filterByErrorSummary:(0,W.useCallback)(e=>{u({type:`setSearchInput`,value:e.errName}),u({type:`setDebouncedSearch`,value:e.errName}),e.module&&u({type:`setModule`,value:e.module}),u({type:`setLevels`,value:ve(`errors`)})},[]),openChatForSession:(0,W.useCallback)(e=>{let t=e.sessionKey?.trim();if(t){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t}}));return}let n=e.sessionId?.trim();n&&M({sessionId:n}).then(e=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e.sessionKey}}))}).catch(()=>{})},[]),errorSummary:S,errorSummaryLoading:w}}var $=r();function Ie(e){let t=(0,G.c)(36),{L:n,items:r,loading:i,onSelectItem:o}=e,[s,c]=(0,W.useState)(!1);if(!i&&r.length===0)return null;let l;t[0]===r?l=t[1]:(l=r.reduce(Re,0),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>c(Le),t[2]=d):d=t[2];let f;t[3]===n.errorSummaryTitle?f=t[4]:(f=(0,$.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight text-fg`,children:n.errorSummaryTitle}),t[3]=n.errorSummaryTitle,t[4]=f);let p;t[5]===n.errorSummaryHint?p=t[6]:(p=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:n.errorSummaryHint}),t[5]=n.errorSummaryHint,t[6]=p);let m;t[7]!==f||t[8]!==p?(m=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]!==r.length||t[11]!==i||t[12]!==u?(h=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{className:`h-5 w-8 rounded-md`}),(0,$.jsx)(P,{className:`h-5 w-10 rounded-md`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs tabular-nums text-red-600 dark:text-red-400`,children:r.length}),(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-hover px-2 py-0.5 text-xs tabular-nums text-fg-muted`,children:[`×`,u]})]}),t[10]=r.length,t[11]=i,t[12]=u,t[13]=h):h=t[13];let g=s&&`rotate-180`,_;t[14]===g?_=t[15]:(_=a(`size-4 text-fg-muted transition-transform duration-150 ease-out motion-reduce:transition-none`,g),t[14]=g,t[15]=_);let v;t[16]===_?v=t[17]:(v=(0,$.jsx)(A,{className:_,strokeWidth:1.75,"aria-hidden":!0}),t[16]=_,t[17]=v);let y;t[18]!==h||t[19]!==v?(y=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[h,v]}),t[18]=h,t[19]=v,t[20]=y):y=t[20];let b;t[21]!==s||t[22]!==y||t[23]!==m?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:d,"aria-expanded":s,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset`,children:[m,y]}),t[21]=s,t[22]=y,t[23]=m,t[24]=b):b=t[24];let x;t[25]!==n.module||t[26]!==n.phase||t[27]!==n.time||t[28]!==s||t[29]!==r||t[30]!==i||t[31]!==o?(x=s&&!i&&r.length>0?(0,$.jsx)(`ul`,{className:`divide-y divide-edge-subtle border-t border-edge-subtle dark:divide-edge dark:border-edge`,children:r.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o?.(e),className:a(`flex w-full flex-col gap-1 px-4 py-2.5 text-left transition-colors hover:bg-surface-hover`,o&&`cursor-pointer`),children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.errName}),(0,$.jsxs)(`span`,{className:`shrink-0 rounded-md bg-red-500/10 px-2 py-0.5 text-xs tabular-nums text-red-600 dark:text-red-400`,children:[`×`,e.count]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[e.phase?(0,$.jsxs)(`span`,{children:[n.phase,`: `,e.phase]}):null,e.module?(0,$.jsxs)(`span`,{children:[n.module,`: `,e.module]}):null,(0,$.jsxs)(`span`,{children:[n.time,`: `,Se(e.lastSeen)]})]}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.sampleMessage})]})},e.key))}):null,t[25]=n.module,t[26]=n.phase,t[27]=n.time,t[28]=s,t[29]=r,t[30]=i,t[31]=o,t[32]=x):x=t[32];let S;return t[33]!==b||t[34]!==x?(S=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl bg-surface-panel shadow-surface`,children:[b,x]}),t[33]=b,t[34]=x,t[35]=S):S=t[35],S}function Le(e){return!e}function Re(e,t){return e+t.count}function ze(e){let t=(0,G.c)(75),{log:n,labels:r,onFilterByRequestId:i,onFilterBySessionId:o,onOpenChat:s}=e,c=n.level??`info`,l=typeof n.requestId==`string`?n.requestId:``,u=typeof n.sessionKey==`string`?n.sessionKey:``,d=typeof n.sessionId==`string`?n.sessionId:``,f;t[0]===n?f=t[1]:(f=De(n),t[0]=n,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=ke(n),t[2]=n,t[3]=m);let h=m,g=c===`error`||c===`fatal`,_;t[4]===r.message?_=t[5]:(_=(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.message}),t[4]=r.message,t[5]=_);let v=g&&`border-red-500/40`,y;t[6]===v?y=t[7]:(y=a(`mt-2 whitespace-pre-wrap break-words border border-edge bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-edge`,v),t[6]=v,t[7]=y);let b=n.message||`—`,x;t[8]!==y||t[9]!==b?(x=(0,$.jsx)(`pre`,{className:y,children:b}),t[8]=y,t[9]=b,t[10]=x):x=t[10];let S;t[11]!==_||t[12]!==x?(S=(0,$.jsxs)(`div`,{children:[_,x]}),t[11]=_,t[12]=x,t[13]=S):S=t[13];let C;t[14]!==h||t[15]!==r.stackTrace?(C=h?.stack?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.stackTrace}),h.name?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:h.name}):null,(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words border border-red-500/30 bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-red-500/30`,children:h.stack})]}):null,t[14]=h,t[15]=r.stackTrace,t[16]=C):C=t[16];let w;t[17]===r.time?w=t[18]:(w=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.time}),t[17]=r.time,t[18]=w);let T;t[19]===n.timestamp?T=t[20]:(T=(0,$.jsx)(`code`,{className:`break-all text-fg`,children:n.timestamp}),t[19]=n.timestamp,t[20]=T);let E;t[21]===r.level?E=t[22]:(E=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.level}),t[21]=r.level,t[22]=E);let D=g&&`font-medium text-red-600 dark:text-red-400`,O;t[23]===D?O=t[24]:(O=a(`text-fg`,D),t[23]=D,t[24]=O);let k;t[25]===c?k=t[26]:(k=Ee(c),t[25]=c,t[26]=k);let A;t[27]!==O||t[28]!==k?(A=(0,$.jsx)(`span`,{className:O,children:k}),t[27]=O,t[28]=k,t[29]=A):A=t[29];let j;t[30]===r.module?j=t[31]:(j=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.module}),t[30]=r.module,t[31]=j);let M;t[32]===n?M=t[33]:(M=be(n),t[32]=n,t[33]=M);let N;t[34]===M?N=t[35]:(N=(0,$.jsx)(`code`,{className:`break-all text-fg`,children:M}),t[34]=M,t[35]=N);let P;t[36]!==r.phase||t[37]!==p?(P=p===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.phase}),(0,$.jsx)(`code`,{className:`break-all text-fg`,children:p})]}),t[36]=r.phase,t[37]=p,t[38]=P):P=t[38];let F;t[39]!==r.filterByRequestId||t[40]!==r.requestId||t[41]!==i||t[42]!==l?(F=l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.requestId}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:l}),i?(0,$.jsx)(R,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>i(l),children:r.filterByRequestId}):null]})]}):null,t[39]=r.filterByRequestId,t[40]=r.requestId,t[41]=i,t[42]=l,t[43]=F):F=t[43];let I;t[44]!==r.openChat||t[45]!==r.sessionKey||t[46]!==s||t[47]!==u?(I=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.sessionKey}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:u}),s?(0,$.jsx)(R,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>s({sessionKey:u}),children:r.openChat}):null]})]}):null,t[44]=r.openChat,t[45]=r.sessionKey,t[46]=s,t[47]=u,t[48]=I):I=t[48];let L;t[49]!==r.filterBySessionId||t[50]!==r.openChat||t[51]!==r.sessionId||t[52]!==o||t[53]!==s||t[54]!==d?(L=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.sessionId}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:d}),o?(0,$.jsx)(R,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>o(d),children:r.filterBySessionId}):null,s?(0,$.jsx)(R,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>s({sessionId:d}),children:r.openChat}):null]})]}):null,t[49]=r.filterBySessionId,t[50]=r.openChat,t[51]=r.sessionId,t[52]=o,t[53]=s,t[54]=d,t[55]=L):L=t[55];let z;t[56]!==w||t[57]!==T||t[58]!==E||t[59]!==A||t[60]!==j||t[61]!==N||t[62]!==P||t[63]!==F||t[64]!==I||t[65]!==L?(z=(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-2 text-xs`,children:[w,T,E,A,j,N,P,F,I,L]}),t[56]=w,t[57]=T,t[58]=E,t[59]=A,t[60]=j,t[61]=N,t[62]=P,t[63]=F,t[64]=I,t[65]=L,t[66]=z):z=t[66];let B;t[67]!==r.metadata||t[68]!==n.meta?(B=n.meta&&Object.keys(n.meta).length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.metadata}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words border border-edge bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-edge`,children:JSON.stringify(n.meta,null,2)})]}):null,t[67]=r.metadata,t[68]=n.meta,t[69]=B):B=t[69];let V;return t[70]!==z||t[71]!==B||t[72]!==S||t[73]!==C?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[S,C,z,B]}),t[70]=z,t[71]=B,t[72]=S,t[73]=C,t[74]=V):V=t[74],V}function Be(e){let t=(0,G.c)(50),{L:n,log:r,onClose:i,copiedDetail:s,onCopiedMessage:c,onCopiedJson:l,onFilterByRequestId:u,onFilterBySessionId:d,onOpenChat:f}=e,p=r!==null,g;t[0]===i?g=t[1]:(g=e=>!e&&i(),t[0]=i,t[1]=g);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(_,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),t[2]=y):y=t[2];let S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=a(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,h,`dark:border-edge`),t[3]=S):S=t[3];let C;t[4]===n.details?C=t[5]:(C=(0,$.jsx)(x,{className:`text-base font-semibold tracking-tight text-fg`,children:n.details}),t[4]=n.details,t[5]=C);let T;t[6]!==n.copied||t[7]!==n.copyJson||t[8]!==n.copyMessage||t[9]!==s||t[10]!==r||t[11]!==l||t[12]!==c?(T=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{type:`button`,variant:`ghost`,className:`h-9 shrink-0 gap-1 px-2 text-xs`,onClick:()=>{o(typeof r.message==`string`?r.message:``).then(e=>{e&&c()})},children:[(0,$.jsx)(w,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s===`message`?n.copied:n.copyMessage})]}),(0,$.jsxs)(R,{type:`button`,variant:`ghost`,className:`h-9 shrink-0 gap-1 px-2 text-xs`,onClick:()=>{o(JSON.stringify(r,null,2)).then(e=>{e&&l()})},children:[(0,$.jsx)(w,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s===`json`?n.copied:n.copyJson})]})]}):null,t[6]=n.copied,t[7]=n.copyJson,t[8]=n.copyMessage,t[9]=s,t[10]=r,t[11]=l,t[12]=c,t[13]=T):T=t[13];let E;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ee,{className:`size-5`,strokeWidth:1.75}),t[14]=E):E=t[14];let O;t[15]===n.close?O=t[16]:(O=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(R,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:E})}),t[15]=n.close,t[16]=O);let k;t[17]!==T||t[18]!==O?(k=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[T,O]}),t[17]=T,t[18]=O,t[19]=k):k=t[19];let A;t[20]!==C||t[21]!==k?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[C,k]}),t[20]=C,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==n.filterByRequestId||t[24]!==n.filterBySessionId||t[25]!==n.level||t[26]!==n.message||t[27]!==n.metadata||t[28]!==n.module||t[29]!==n.openChat||t[30]!==n.phase||t[31]!==n.requestId||t[32]!==n.sessionId||t[33]!==n.sessionKey||t[34]!==n.stackTrace||t[35]!==n.time||t[36]!==r||t[37]!==u||t[38]!==d||t[39]!==f?(j=r?(0,$.jsx)(ze,{log:r,labels:{time:n.time,level:n.level,module:n.module,message:n.message,metadata:n.metadata,requestId:n.requestId,sessionKey:n.sessionKey,sessionId:n.sessionId,phase:n.phase,stackTrace:n.stackTrace,filterByRequestId:n.filterByRequestId,filterBySessionId:n.filterBySessionId,openChat:n.openChat},onFilterByRequestId:u,onFilterBySessionId:d,onOpenChat:f}):null,t[23]=n.filterByRequestId,t[24]=n.filterBySessionId,t[25]=n.level,t[26]=n.message,t[27]=n.metadata,t[28]=n.module,t[29]=n.openChat,t[30]=n.phase,t[31]=n.requestId,t[32]=n.sessionId,t[33]=n.sessionKey,t[34]=n.stackTrace,t[35]=n.time,t[36]=r,t[37]=u,t[38]=d,t[39]=f,t[40]=j):j=t[40];let M;t[41]===j?M=t[42]:(M=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 font-mono text-sm leading-relaxed`,children:j}),t[41]=j,t[42]=M);let N;t[43]!==A||t[44]!==M?(N=(0,$.jsxs)(v,{children:[y,(0,$.jsxs)(m,{className:S,"aria-describedby":void 0,children:[A,M]})]}),t[43]=A,t[44]=M,t[45]=N):N=t[45];let P;return t[46]!==p||t[47]!==N||t[48]!==g?(P=(0,$.jsx)(b,{open:p,onOpenChange:g,children:N}),t[46]=p,t[47]=N,t[48]=g,t[49]=P):P=t[49],P}function Ve(e){let t=(0,G.c)(25),{L:n,open:r,onOpenChange:i,files:o,logDir:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(_,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),t[0]=c):c=t[0];let l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=a(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(32rem,85vh)] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,h,`dark:border-edge`),t[1]=l):l=t[1];let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(N,{className:`size-4 text-fg-muted`,strokeWidth:1.75}),t[2]=u):u=t[2];let d;t[3]===n.logFiles?d=t[4]:(d=(0,$.jsxs)(x,{className:`flex items-center gap-2 text-base font-semibold tracking-tight text-fg`,children:[u,n.logFiles]}),t[3]=n.logFiles,t[4]=d);let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(ee,{className:`size-5`,strokeWidth:1.75}),t[5]=f):f=t[5];let p;t[6]===n.close?p=t[7]:(p=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(R,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:f})}),t[6]=n.close,t[7]=p);let g;t[8]!==d||t[9]!==p?(g=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[d,p]}),t[8]=d,t[9]=p,t[10]=g):g=t[10];let y;t[11]!==n.filesEmpty||t[12]!==o?(y=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:o.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.filesEmpty}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:o.map(He)})}),t[11]=n.filesEmpty,t[12]=o,t[13]=y):y=t[13];let S;t[14]!==n.logDir||t[15]!==s?(S=s?(0,$.jsxs)(`div`,{className:`shrink-0 border-t border-edge-subtle px-4 py-2 text-xs text-fg-subtle dark:border-edge`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[n.logDir,`: `]}),(0,$.jsx)(`code`,{className:`break-all text-fg-subtle`,children:s})]}):null,t[14]=n.logDir,t[15]=s,t[16]=S):S=t[16];let C;t[17]!==g||t[18]!==y||t[19]!==S?(C=(0,$.jsxs)(v,{children:[c,(0,$.jsxs)(m,{className:l,children:[g,y,S]})]}),t[17]=g,t[18]=y,t[19]=S,t[20]=C):C=t[20];let w;return t[21]!==i||t[22]!==r||t[23]!==C?(w=(0,$.jsx)(b,{open:r,onOpenChange:i,children:C}),t[21]=i,t[22]=r,t[23]=C,t[24]=w):w=t[24],w}function He(e){return(0,$.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 dark:border-edge`,children:[(0,$.jsx)(`span`,{className:`break-all font-mono text-xs text-fg`,children:e.name}),(0,$.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:we(e.size)}),(0,$.jsx)(`span`,{children:Ce(e.modified)})]})]},e.name)}function Ue(e){let t=(0,G.c)(68),{L:n,open:r,onOpenChange:i,dateFrom:o,onDateFromChange:s,dateTo:c,onDateToChange:l,selectedLevels:u,onToggleLevel:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(_,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=a(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(32rem,90vh)] w-[min(100%-2rem,22rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,h,`dark:border-edge`),t[1]=p):p=t[1];let g;t[2]===n.filtersDialogTitle?g=t[3]:(g=(0,$.jsx)(x,{className:`text-base font-semibold tracking-tight text-fg`,children:n.filtersDialogTitle}),t[2]=n.filtersDialogTitle,t[3]=g);let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(ee,{className:`size-5`,strokeWidth:1.75}),t[4]=y):y=t[4];let S;t[5]===n.close?S=t[6]:(S=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(R,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:y})}),t[5]=n.close,t[6]=S);let C;t[7]!==g||t[8]!==S?(C=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[g,S]}),t[7]=g,t[8]=S,t[9]=C):C=t[9];let w;t[10]===n.filtersDialogDesc?w=t[11]:(w=(0,$.jsx)(`div`,{id:`log-filters-desc`,className:`sr-only`,children:n.filtersDialogDesc}),t[10]=n.filtersDialogDesc,t[11]=w);let T;t[12]===n.timeRange?T=t[13]:(T=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.timeRange}),t[12]=n.timeRange,t[13]=T);let E;t[14]===n.from?E=t[15]:(E=(0,$.jsx)(`label`,{htmlFor:`log-from-d`,className:`mb-1 block text-xs text-fg-muted`,children:n.from}),t[14]=n.from,t[15]=E);let O;t[16]===s?O=t[17]:(O=e=>s(e.target.value),t[16]=s,t[17]=O);let k;t[18]!==o||t[19]!==O?(k=(0,$.jsx)(`input`,{id:`log-from-d`,type:`datetime-local`,value:o,onChange:O,className:`w-full rounded-xl border border-edge bg-surface-base p-2 text-sm text-fg dark:border-edge`}),t[18]=o,t[19]=O,t[20]=k):k=t[20];let A;t[21]!==k||t[22]!==E?(A=(0,$.jsxs)(`div`,{children:[E,k]}),t[21]=k,t[22]=E,t[23]=A):A=t[23];let j;t[24]===n.to?j=t[25]:(j=(0,$.jsx)(`label`,{htmlFor:`log-to-d`,className:`mb-1 block text-xs text-fg-muted`,children:n.to}),t[24]=n.to,t[25]=j);let M;t[26]===l?M=t[27]:(M=e=>l(e.target.value),t[26]=l,t[27]=M);let N;t[28]!==c||t[29]!==M?(N=(0,$.jsx)(`input`,{id:`log-to-d`,type:`datetime-local`,value:c,onChange:M,className:`w-full rounded-xl border border-edge bg-surface-base p-2 text-sm text-fg dark:border-edge`}),t[28]=c,t[29]=M,t[30]=N):N=t[30];let P;t[31]!==j||t[32]!==N?(P=(0,$.jsxs)(`div`,{children:[j,N]}),t[31]=j,t[32]=N,t[33]=P):P=t[33];let I;t[34]!==A||t[35]!==P?(I=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3`,children:[A,P]}),t[34]=A,t[35]=P,t[36]=I):I=t[36];let L;t[37]===n.levelCustom?L=t[38]:(L=(0,$.jsx)(`p`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:n.levelCustom}),t[37]=n.levelCustom,t[38]=L);let z;t[39]===n.levelCustomHint?z=t[40]:(z=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:n.levelCustomHint}),t[39]=n.levelCustomHint,t[40]=z);let B=n.level,V;t[41]!==n.levelNames||t[42]!==d||t[43]!==u?(V=Q.map(e=>(0,$.jsx)(`button`,{type:`button`,className:a(`rounded-full border px-3 py-1.5 text-xs font-medium capitalize transition-[color,background-color,border-color] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,u.has(e)?`border-edge bg-surface-active text-fg dark:border-edge`:`border-edge-subtle bg-surface-base text-fg-muted hover:bg-surface-hover dark:border-edge`),onClick:()=>d(e),children:n.levelNames[e]},e)),t[41]=n.levelNames,t[42]=d,t[43]=u,t[44]=V):V=t[44];let H;t[45]!==n.level||t[46]!==V?(H=(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,role:`group`,"aria-label":B,children:V}),t[45]=n.level,t[46]=V,t[47]=H):H=t[47];let U;t[48]!==I||t[49]!==L||t[50]!==z||t[51]!==H||t[52]!==T?(U=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[T,I,L,z,H]}),t[48]=I,t[49]=L,t[50]=z,t[51]=H,t[52]=T,t[53]=U):U=t[53];let W;t[54]===i?W=t[55]:(W=()=>i(!1),t[54]=i,t[55]=W);let K;t[56]!==n.filtersDone||t[57]!==W?(K=(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,$.jsx)(R,{type:`button`,className:`w-full rounded-xl`,onClick:W,children:n.filtersDone})}),t[56]=n.filtersDone,t[57]=W,t[58]=K):K=t[58];let q;t[59]!==U||t[60]!==K||t[61]!==C||t[62]!==w?(q=(0,$.jsxs)(v,{children:[f,(0,$.jsxs)(m,{className:p,"aria-describedby":`log-filters-desc`,children:[C,w,U,K]})]}),t[59]=U,t[60]=K,t[61]=C,t[62]=w,t[63]=q):q=t[63];let J;return t[64]!==i||t[65]!==r||t[66]!==q?(J=(0,$.jsx)(b,{open:r,onOpenChange:i,children:q}),t[64]=i,t[65]=r,t[66]=q,t[67]=J):J=t[67],J}var We=1;function Ge(e,t){let n=0,r=0,i=e;for(;i&&i!==t;)n+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;return i===t?{x:n,y:r}:null}var Ke=`pointer-events-none absolute left-0 top-0 z-[1] rounded-pill bg-surface-panel shadow-sm will-change-transform [backface-visibility:hidden] dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,qe=`relative z-[2] box-border flex h-6 min-h-0 min-w-0 flex-1 cursor-pointer items-center justify-center gap-1 rounded-pill border-0 bg-transparent px-2 py-0 text-center text-xs font-medium leading-none outline-none transition-[color,background-color,box-shadow] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`;function Je({value:e,onChange:t,options:n,"aria-label":r,className:i,buttonClassName:o}){let s=(0,W.useRef)(null),c=(0,W.useRef)([]),[l,u]=(0,W.useState)({x:0,y:0,w:0,h:0}),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),h=(0,W.useCallback)(()=>{let t=s.current;if(!t)return;let r=n.findIndex(t=>t.value===e);if(r<0)return;let i=c.current[r];if(!i)return;let a=We,o=t.getBoundingClientRect(),l=i.getBoundingClientRect(),d=Ge(i,t),p,m;if(d)p=d.x,m=d.y;else{let e=getComputedStyle(t),n=parseFloat(e.borderLeftWidth)||0,r=parseFloat(e.borderTopWidth)||0;p=l.left-o.left-n,m=l.top-o.top-r}u({x:p+a,y:m+a,w:Math.max(0,l.width-a*2),h:Math.max(0,l.height-a*2)}),f(!0)},[n,e]),g=(0,W.useRef)(h);return g.current=h,(0,W.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>h());return()=>cancelAnimationFrame(e)},[h]),(0,W.useEffect)(()=>{let e=requestAnimationFrame(()=>{requestAnimationFrame(()=>m(!0))});return()=>cancelAnimationFrame(e)},[]),(0,W.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>{requestAnimationFrame(()=>g.current())},n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,$.jsxs)(`div`,{ref:s,className:a(U,`relative isolate flex w-full max-w-full flex-row items-center`,i),role:`group`,"aria-label":r,children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:a(Ke,`motion-reduce:!transition-none motion-reduce:!duration-0`,p&&`transition-[transform,width,height] duration-300 [transition-timing-function:cubic-bezier(0.32,0.72,0,1)]`),style:{width:l.w,height:l.h,transform:`translate3d(${l.x}px, ${l.y}px, 0)`,opacity:d&&l.w>0?1:0}}),n.map((n,r)=>{let i=n.icon,s=e===n.value;return(0,$.jsxs)(`button`,{ref:e=>{c.current[r]=e},type:`button`,"aria-pressed":s,title:n.title??n.label,onClick:()=>t(n.value),className:a(qe,s?`text-fg`:`text-fg-subtle`,o),children:[i?(0,$.jsx)(i,{className:`block size-3 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate leading-none`,children:n.label})]},n.value)})]})}function Ye(e){let t=(0,G.c)(76),{L:n,levelSegment:r,onLevelSegment:i,searchInput:o,onSearchInputChange:s,moduleFilter:c,onModuleFilterChange:l,modules:u,onOpenFilters:d,activeFilterCount:f,hasActiveFilters:p,onClearFilters:m,autoRefresh:h}=e,_=n.filters,v;t[0]===n.presetAll?v=t[1]:(v={value:`all`,label:n.presetAll},t[0]=n.presetAll,t[1]=v);let y;t[2]===n.presetErrors?y=t[3]:(y={value:`errors`,label:n.presetErrors},t[2]=n.presetErrors,t[3]=y);let b;t[4]===n.presetWarnPlus?b=t[5]:(b={value:`warnPlus`,label:n.presetWarnPlus},t[4]=n.presetWarnPlus,t[5]=b);let x;t[6]===n.presetInfoPlus?x=t[7]:(x={value:`infoPlus`,label:n.presetInfoPlus},t[6]=n.presetInfoPlus,t[7]=x);let S;t[8]===n.presetVerbose?S=t[9]:(S={value:`verbose`,label:n.presetVerbose},t[8]=n.presetVerbose,t[9]=S);let w;t[10]===n.presetOther?w=t[11]:(w={value:`other`,label:n.presetOther},t[10]=n.presetOther,t[11]=w);let E;t[12]!==v||t[13]!==y||t[14]!==b||t[15]!==x||t[16]!==S||t[17]!==w?(E=[v,y,b,x,S,w],t[12]=v,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=w,t[18]=E):E=t[18];let D;t[19]!==n.levelPresetAria||t[20]!==r||t[21]!==i||t[22]!==E?(D=(0,$.jsx)(`div`,{className:`overflow-x-auto pb-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:(0,$.jsx)(`div`,{className:`min-w-[min(100%,36rem)]`,children:(0,$.jsx)(Je,{"aria-label":n.levelPresetAria,value:r,onChange:i,options:E,buttonClassName:`h-8 px-1.5 text-[11px] sm:px-2 sm:text-xs`})})}),t[19]=n.levelPresetAria,t[20]=r,t[21]=i,t[22]=E,t[23]=D):D=t[23];let k;t[24]===n.searchPlaceholder?k=t[25]:(k=(0,$.jsx)(`span`,{className:`sr-only`,children:n.searchPlaceholder}),t[24]=n.searchPlaceholder,t[25]=k);let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(O,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[26]=A):A=t[26];let M;t[27]===s?M=t[28]:(M=e=>s(e.target.value),t[27]=s,t[28]=M);let N=n.searchPlaceholder,P;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(P=a(`h-10 w-full rounded-md border border-edge bg-surface-panel py-0 pl-10 pr-3 text-sm leading-5 text-fg placeholder:text-fg-subtle dark:border-edge`,I),t[29]=P):P=t[29];let F;t[30]!==n.searchPlaceholder||t[31]!==o||t[32]!==M?(F=(0,$.jsx)(`input`,{type:`search`,value:o,onChange:M,placeholder:N,autoComplete:`off`,spellCheck:!1,className:P}),t[30]=n.searchPlaceholder,t[31]=o,t[32]=M,t[33]=F):F=t[33];let L;t[34]!==k||t[35]!==F?(L=(0,$.jsxs)(`label`,{className:`relative min-w-0 flex-1 sm:min-w-[12rem]`,children:[k,A,F]}),t[34]=k,t[35]=F,t[36]=L):L=t[36];let z;t[37]===l?z=t[38]:(z=e=>l(e.target.value),t[37]=l,t[38]=z);let B=n.module,V=n.module,H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=a(j,`h-10 w-full min-w-0 rounded-md py-0 sm:w-[min(100%,14rem)] sm:shrink-0`),t[39]=H):H=t[39];let U;t[40]===n.allModules?U=t[41]:(U=(0,$.jsx)(g,{value:``,children:n.allModules}),t[40]=n.allModules,t[41]=U);let W;t[42]===u?W=t[43]:(W=u.map(Xe),t[42]=u,t[43]=W);let K;t[44]!==n.module||t[45]!==c||t[46]!==z||t[47]!==U||t[48]!==W?(K=(0,$.jsxs)(T,{id:`log-module`,value:c,onChange:z,"aria-label":B,title:V,className:H,children:[U,W]}),t[44]=n.module,t[45]=c,t[46]=z,t[47]=U,t[48]=W,t[49]=K):K=t[49];let q;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(C,{className:`size-4`,strokeWidth:1.75}),t[50]=q):q=t[50];let J;t[51]===f?J=t[52]:(J=f>0?(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 text-xs tabular-nums text-fg-muted`,children:f}):null,t[51]=f,t[52]=J);let te;t[53]!==n.filtersMore||t[54]!==d||t[55]!==J?(te=(0,$.jsxs)(R,{type:`button`,variant:`secondary`,className:`h-10 min-h-[44px] gap-2 rounded-md sm:min-h-10`,onClick:d,children:[q,n.filtersMore,J]}),t[53]=n.filtersMore,t[54]=d,t[55]=J,t[56]=te):te=t[56];let Y;t[57]!==n.clear||t[58]!==p||t[59]!==m?(Y=p?(0,$.jsxs)(R,{type:`button`,variant:`ghost`,className:`h-10 min-h-[44px] gap-1 sm:min-h-10`,onClick:m,children:[(0,$.jsx)(ee,{className:`size-4`,strokeWidth:1.75}),n.clear]}):null,t[57]=n.clear,t[58]=p,t[59]=m,t[60]=Y):Y=t[60];let ne;t[61]!==te||t[62]!==Y?(ne=(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center gap-2`,children:[te,Y]}),t[61]=te,t[62]=Y,t[63]=ne):ne=t[63];let X;t[64]!==L||t[65]!==K||t[66]!==ne?(X=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center`,children:[L,K,ne]}),t[64]=L,t[65]=K,t[66]=ne,t[67]=X):X=t[67];let Z;t[68]!==n.liveHint||t[69]!==h?(Z=h?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:n.liveHint}):null,t[68]=n.liveHint,t[69]=h,t[70]=Z):Z=t[70];let re;return t[71]!==n.filters||t[72]!==X||t[73]!==Z||t[74]!==D?(re=(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,"aria-label":_,children:[D,X,Z]}),t[71]=n.filters,t[72]=X,t[73]=Z,t[74]=D,t[75]=re):re=t[75],re}function Xe(e){return(0,$.jsx)(g,{value:e,children:e},e)}function Ze(e){let t=(0,G.c)(20),{L:n,logs:r,loading:i,hasMore:o,onSelectLog:s,onLoadMore:c,onRefreshAll:l,onFilterByRequestId:u}=e,d;t[0]!==i||t[1]!==r.length?(d=i&&r.length===0?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel shadow-surface`,"aria-busy":`true`,children:Array.from({length:8}).map(Qe)}):null,t[0]=i,t[1]=r.length,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==i||t[5]!==r.length||t[6]!==l?(f=!i&&r.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-xl bg-surface-base py-16 text-center`,children:[(0,$.jsx)(H,{className:`size-12 text-fg-subtle`,strokeWidth:1.5,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n.noLogs}),(0,$.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-fg-muted`,children:n.noLogsDescription}),(0,$.jsxs)(R,{type:`button`,variant:`secondary`,className:`mt-4 gap-2`,onClick:l,children:[(0,$.jsx)(B,{className:`size-4`,strokeWidth:1.75}),n.refresh]})]}):null,t[3]=n,t[4]=i,t[5]=r.length,t[6]=l,t[7]=f):f=t[7];let p;t[8]!==n||t[9]!==o||t[10]!==i||t[11]!==r||t[12]!==u||t[13]!==c||t[14]!==s?(p=r.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:[ye(n.showingCount,{count:String(r.length)}),o?(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[` · `,n.moreAvailable]}):null]}),(0,$.jsx)(`ul`,{className:`overflow-hidden rounded-xl bg-surface-panel font-mono text-sm leading-6 shadow-surface`,children:r.map(e=>{let t=e.level??`info`,r=typeof e.requestId==`string`?e.requestId.trim():``,i=De(e),o=t===`error`||t===`fatal`;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:a(`flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,o&&`border-l-2 border-l-red-500/70`),children:[(0,$.jsx)(`span`,{className:`w-[5.25rem] shrink-0 tabular-nums text-fg-subtle`,children:Se(e.timestamp)}),(0,$.jsx)(`span`,{className:a(`w-[4.5rem] shrink-0 truncate`,o?`font-medium text-red-600 dark:text-red-400`:`text-fg-muted`),title:t,children:Ee(t)}),(0,$.jsx)(`span`,{className:`w-[4.5rem] shrink-0 truncate sm:w-[5.25rem]`,children:r?u?(0,$.jsx)(`span`,{role:`link`,tabIndex:0,className:`cursor-pointer text-accent hover:underline`,title:`${n.requestId}: ${r}`,onClick:e=>{e.stopPropagation(),u(r)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),u(r))},children:Te(r)}):(0,$.jsx)(`span`,{className:`text-fg-subtle`,title:`${n.requestId}: ${r}`,children:Te(r)}):(0,$.jsx)(`span`,{className:`text-fg-subtle`,children:`—`})}),(0,$.jsx)(`span`,{className:`hidden max-w-[6rem] shrink-0 truncate text-fg-subtle xl:inline`,title:i===`—`?void 0:i,children:i===`—`?`—`:i}),(0,$.jsx)(`span`,{className:`hidden max-w-[7rem] shrink-0 truncate text-fg-muted lg:inline`,title:be(e),children:be(e)}),(0,$.jsx)(`span`,{className:a(`min-w-0 flex-1 truncate`,`text-fg`),children:xe(e)})]})},Oe(e))})}),o?(0,$.jsx)(`div`,{className:`flex justify-center pt-1`,children:(0,$.jsxs)(R,{type:`button`,variant:`secondary`,className:`gap-2`,disabled:i,onClick:c,children:[i?(0,$.jsx)(B,{className:`size-4 animate-spin motion-reduce:animate-none`,strokeWidth:1.75}):(0,$.jsx)(A,{className:`size-4`,strokeWidth:1.75}),n.loadMore]})}):null]}):null,t[8]=n,t[9]=o,t[10]=i,t[11]=r,t[12]=u,t[13]=c,t[14]=s,t[15]=p):p=t[15];let m;return t[16]!==d||t[17]!==f||t[18]!==p?(m=(0,$.jsxs)($.Fragment,{children:[d,f,p]}),t[16]=d,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function Qe(e,t){return(0,$.jsxs)(`div`,{className:`flex gap-3 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`h-4 w-16 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 w-12 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 w-20 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 min-w-0 flex-1 bg-surface-hover motion-reduce:animate-none animate-pulse`})]},t)}function $e(e){let t=(0,G.c)(8),{L:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(y,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=r):r=t[0];let i;t[1]===n.title?i=t[2]:(i=(0,$.jsx)(`h1`,{className:`text-base font-semibold tracking-tight text-fg`,children:n.title}),t[1]=n.title,t[2]=i);let a;t[3]===n.needToken?a=t[4]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.needToken}),t[3]=n.needToken,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,$.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-10 sm:px-5 xl:px-6`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[r,(0,$.jsxs)(`div`,{children:[i,a]})]})}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function et(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function tt(e){let t=[`timestamp`,`level`,`module`,`phase`,`requestId`,`sessionId`,`message`],n=e.map(e=>{let t=String(e.module||``),n=String(e.phase??e.meta?.phase??``);return[e.timestamp,e.level,t,n,e.requestId??``,e.sessionId??``,e.message??``].map(e=>et(String(e))).join(`,`)});return[t.join(`,`),...n].join(`
7
- `)}function nt(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}function rt(e,t){let n=new Date().toISOString().replace(/[:.]/g,`-`);if(t===`json`){nt(JSON.stringify(e,null,2),`xopc-logs-${n}.json`,`application/json`);return}nt(tt(e),`xopc-logs-${n}.csv`,`text/csv;charset=utf-8`)}function it(e){let t=(0,G.c)(32),{L:n,logs:r,disabled:i}=e,o=i||r.length===0,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[0]=s):s=t[0];let c;t[1]===n.exportLogs?c=t[2]:(c=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:n.exportLogs}),t[1]=n.exportLogs,t[2]=c);let l;t[3]!==n.exportLogs||t[4]!==o||t[5]!==c?(l=(0,$.jsx)(V,{asChild:!0,children:(0,$.jsxs)(R,{type:`button`,variant:`secondary`,className:`h-9 gap-2 px-3 text-xs`,disabled:o,title:n.exportLogs,children:[s,c]})}),t[3]=n.exportLogs,t[4]=o,t[5]=c,t[6]=l):l=t[6];let u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(`w-52 rounded-xl border border-edge bg-surface-panel p-2 shadow-popover outline-none`,E,`dark:border-edge`),t[7]=u):u=t[7];let d;t[8]===n.exportLogs?d=t[9]:(d=(0,$.jsx)(`p`,{className:`px-2 py-1 text-xs font-medium text-fg`,children:n.exportLogs}),t[8]=n.exportLogs,t[9]=d);let m;t[10]===n.exportHint?m=t[11]:(m=(0,$.jsx)(`p`,{className:`px-2 pb-2 text-xs leading-5 text-fg-muted`,children:n.exportHint}),t[10]=n.exportHint,t[11]=m);let h;t[12]===r?h=t[13]:(h=()=>rt(r,`json`),t[12]=r,t[13]=h);let g;t[14]!==n.exportJson||t[15]!==h?(g=(0,$.jsx)(R,{type:`button`,variant:`ghost`,className:`h-8 justify-start px-2 text-xs`,onClick:h,children:n.exportJson}),t[14]=n.exportJson,t[15]=h,t[16]=g):g=t[16];let _;t[17]===r?_=t[18]:(_=()=>rt(r,`csv`),t[17]=r,t[18]=_);let v;t[19]!==n.exportCsv||t[20]!==_?(v=(0,$.jsx)(R,{type:`button`,variant:`ghost`,className:`h-8 justify-start px-2 text-xs`,onClick:_,children:n.exportCsv}),t[19]=n.exportCsv,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==g?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[g,v]}),t[22]=v,t[23]=g,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==d||t[27]!==m?(b=(0,$.jsx)(f,{children:(0,$.jsxs)(S,{side:`bottom`,align:`end`,sideOffset:6,className:u,children:[d,m,y]})}),t[25]=y,t[26]=d,t[27]=m,t[28]=b):b=t[28];let x;return t[29]!==b||t[30]!==l?(x=(0,$.jsxs)(k,{children:[l,b]}),t[29]=b,t[30]=l,t[31]=x):x=t[31],x}function at(e){let t=(0,G.c)(38),{L:n}=e,[r,i]=(0,W.useState)(!1),[o,s]=(0,W.useState)(`info`),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(null),p,m;t[0]!==n.logLevelLoadError||t[1]!==r?(p=()=>{if(!r)return;let e=!1;return X().then(t=>{e||s(t)}).catch(t=>{e||d(t instanceof Error?t.message:n.logLevelLoadError)}),()=>{e=!0}},m=[r,n.logLevelLoadError],t[0]=n.logLevelLoadError,t[1]=r,t[2]=p,t[3]=m):(p=t[2],m=t[3]),(0,W.useEffect)(p,m);let h;t[4]===n.logLevelSaveError?h=t[5]:(h=e=>{l(!0),d(null),Z(e).then(e=>{s(e.current),i(!1)}).catch(e=>{d(e instanceof Error?e.message:n.logLevelSaveError)}).finally(()=>l(!1))},t[4]=n.logLevelSaveError,t[5]=h);let g=h,_;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(L,{className:`size-4`,strokeWidth:1.75}),t[6]=_):_=t[6];let v;t[7]===n.logLevelTitle?v=t[8]:(v=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:n.logLevelTitle}),t[7]=n.logLevelTitle,t[8]=v);let y;t[9]===o?y=t[10]:(y=(0,$.jsx)(`span`,{className:`tabular-nums text-fg-muted`,children:o}),t[9]=o,t[10]=y);let b;t[11]!==n.logLevelTitle||t[12]!==v||t[13]!==y?(b=(0,$.jsx)(V,{asChild:!0,children:(0,$.jsxs)(R,{type:`button`,variant:`secondary`,className:`h-9 gap-2 px-3 text-xs`,title:n.logLevelTitle,children:[_,v,y]})}),t[11]=n.logLevelTitle,t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=a(`w-56 rounded-xl border border-edge bg-surface-panel p-3 shadow-popover outline-none`,E,`dark:border-edge`),t[15]=x):x=t[15];let C;t[16]===n.logLevelTitle?C=t[17]:(C=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.logLevelTitle}),t[16]=n.logLevelTitle,t[17]=C);let w;t[18]===n.logLevelHint?w=t[19]:(w=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.logLevelHint}),t[18]=n.logLevelHint,t[19]=w);let T;t[20]!==n.levelNames||t[21]!==g||t[22]!==o||t[23]!==c?(T=Q.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>g(e),className:a(`flex w-full items-center justify-between rounded-md px-2 py-1.5 text-left text-xs transition-colors`,o===e?`bg-accent/10 font-medium text-accent`:`text-fg hover:bg-surface-hover`),children:[(0,$.jsx)(`span`,{children:n.levelNames[e]}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] uppercase text-fg-subtle`,children:e})]})},e)),t[20]=n.levelNames,t[21]=g,t[22]=o,t[23]=c,t[24]=T):T=t[24];let D;t[25]===T?D=t[26]:(D=(0,$.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1`,children:T}),t[25]=T,t[26]=D);let O;t[27]===u?O=t[28]:(O=u?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:u}):null,t[27]=u,t[28]=O);let A;t[29]!==w||t[30]!==D||t[31]!==O||t[32]!==C?(A=(0,$.jsx)(f,{children:(0,$.jsxs)(S,{side:`bottom`,align:`end`,sideOffset:6,className:x,children:[C,w,D,O]})}),t[29]=w,t[30]=D,t[31]=O,t[32]=C,t[33]=A):A=t[33];let j;return t[34]!==r||t[35]!==A||t[36]!==b?(j=(0,$.jsxs)(k,{open:r,onOpenChange:i,children:[b,A]}),t[34]=r,t[35]=A,t[36]=b,t[37]=j):j=t[37],j}function ot(e){let t=(0,G.c)(49),{L:n,autoRefresh:r,onAutoRefreshChange:i,fileCount:a,onOpenFiles:o,loading:s,onRefreshAll:c,logs:l}=e,u;t[0]===n.title?u=t[1]:(u=(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),t[0]=n.title,t[1]=u);let d;t[2]===n.subtitle?d=t[3]:(d=(0,$.jsx)(`p`,{className:`mt-0.5 text-sm leading-relaxed text-fg-muted`,children:n.subtitle}),t[2]=n.subtitle,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p=r?`live`:`paused`,m;t[7]===i?m=t[8]:(m=e=>i(e===`live`),t[7]=i,t[8]=m);let h;t[9]===n.refreshManual?h=t[10]:(h={value:`paused`,label:n.refreshManual},t[9]=n.refreshManual,t[10]=h);let g;t[11]===n.refreshLive?g=t[12]:(g={value:`live`,label:n.refreshLive},t[11]=n.refreshLive,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=[h,g],t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]!==n.refreshModeAria||t[17]!==p||t[18]!==m||t[19]!==_?(v=(0,$.jsx)(`div`,{className:`w-full sm:w-48`,children:(0,$.jsx)(Je,{"aria-label":n.refreshModeAria,value:p,onChange:m,options:_,buttonClassName:`h-8`})}),t[16]=n.refreshModeAria,t[17]=p,t[18]=m,t[19]=_,t[20]=v):v=t[20];let y;t[21]===n?y=t[22]:(y=(0,$.jsx)(at,{L:n}),t[21]=n,t[22]=y);let b;t[23]!==n||t[24]!==s||t[25]!==l?(b=(0,$.jsx)(it,{L:n,logs:l,disabled:s}),t[23]=n,t[24]=s,t[25]=l,t[26]=b):b=t[26];let x;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(N,{className:`size-4`,strokeWidth:1.75}),t[27]=x):x=t[27];let S;t[28]===a?S=t[29]:(S=a>0?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-1.5 text-xs text-fg-muted`,children:a}):null,t[28]=a,t[29]=S);let C;t[30]!==n.logFiles||t[31]!==o||t[32]!==S?(C=(0,$.jsxs)(R,{type:`button`,variant:`ghost`,className:`h-9 min-h-[44px] min-w-[44px] px-2 sm:min-h-9 sm:min-w-0`,title:n.logFiles,"aria-label":n.logFiles,onClick:o,children:[x,S]}),t[30]=n.logFiles,t[31]=o,t[32]=S,t[33]=C):C=t[33];let w;t[34]!==n.refresh||t[35]!==s||t[36]!==c?(w=(0,$.jsx)(z,{className:`h-9 min-h-[44px] min-w-[44px] px-2 sm:min-h-9 sm:min-w-0`,loading:s,label:n.refresh,onClick:c}),t[34]=n.refresh,t[35]=s,t[36]=c,t[37]=w):w=t[37];let T;t[38]!==y||t[39]!==b||t[40]!==C||t[41]!==w?(T=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 self-end sm:self-center`,children:[y,b,C,w]}),t[38]=y,t[39]=b,t[40]=C,t[41]=w,t[42]=T):T=t[42];let E;t[43]!==T||t[44]!==v?(E=(0,$.jsxs)(`div`,{className:`flex w-full shrink-0 flex-col gap-2 sm:w-auto sm:max-w-md sm:flex-row sm:items-center sm:justify-end`,children:[v,T]}),t[43]=T,t[44]=v,t[45]=E):E=t[45];let D;return t[46]!==E||t[47]!==f?(D=(0,$.jsxs)(`header`,{className:`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:[f,E]}),t[46]=E,t[47]=f,t[48]=D):D=t[48],D}function st(e){let t=(0,G.c)(33),{L:n,stats:r}=e,i;t[0]===r.byLevel?i=t[1]:(i=r.byLevel??{},t[0]=r.byLevel,t[1]=i);let o;t[2]!==n.levelNames||t[3]!==i?(o=je(i,n.levelNames),t[2]=n.levelNames,t[3]=i,t[4]=o):o=t[4];let s=o,c=r.runtime?.errorsLast24h;if(!s&&c==null)return null;let l;t[5]===n.statsRegion?l=t[6]:(l=(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.statsRegion}),t[5]=n.statsRegion,t[6]=l);let u;t[7]===s?u=t[8]:(u=s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mx-1.5 text-fg-subtle`,children:`·`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:s})]}):null,t[7]=s,t[8]=u);let d;t[9]!==n.runtimeErrors||t[10]!==c?(d=c!=null&&c>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mx-1.5 text-fg-subtle`,children:`·`}),(0,$.jsxs)(`span`,{className:`tabular-nums text-red-600 dark:text-red-400`,children:[n.runtimeErrors,` `,c]})]}):null,t[9]=n.runtimeErrors,t[10]=c,t[11]=d):d=t[11];let p;t[12]!==l||t[13]!==u||t[14]!==d?(p=(0,$.jsx)(V,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded-lg border border-transparent px-1 py-0.5 text-left text-xs leading-5 text-fg-subtle transition-colors duration-150 ease-out hover:border-edge-subtle hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel dark:hover:border-edge`,children:[l,u,d]})}),t[12]=l,t[13]=u,t[14]=d,t[15]=p):p=t[15];let m;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(m=a(`w-[min(calc(100vw-2rem),20rem)] rounded-xl border border-edge bg-surface-panel p-3 shadow-popover outline-none`,E,`dark:border-edge`),t[16]=m):m=t[16];let h;t[17]===n.statsDetailTitle?h=t[18]:(h=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.statsDetailTitle}),t[17]=n.statsDetailTitle,t[18]=h);let g;t[19]===n.statsHint?g=t[20]:(g=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.statsHint}),t[19]=n.statsHint,t[20]=g);let _;t[21]!==n.levelNames||t[22]!==r.byLevel?(_=Q.map(e=>{let t=r.byLevel?.[e]??0;return t===0?null:(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs dark:border-edge`,children:[(0,$.jsx)(`span`,{className:`font-medium capitalize text-fg`,children:n.levelNames[e]}),(0,$.jsx)(`span`,{className:`tabular-nums text-fg-muted`,children:t})]},e)}),t[21]=n.levelNames,t[22]=r.byLevel,t[23]=_):_=t[23];let v;t[24]===_?v=t[25]:(v=(0,$.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1.5`,children:_}),t[24]=_,t[25]=v);let y;t[26]!==v||t[27]!==h||t[28]!==g?(y=(0,$.jsx)(f,{children:(0,$.jsxs)(S,{side:`bottom`,align:`start`,sideOffset:6,className:m,children:[h,g,v]})}),t[26]=v,t[27]=h,t[28]=g,t[29]=y):y=t[29];let b;return t[30]!==y||t[31]!==p?(b=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(k,{children:[p,y]})}),t[30]=y,t[31]=p,t[32]=b):b=t[32],b}function ct(){let e=(0,G.c)(89),{L:t,hasToken:n,logs:r,loading:i,error:a,hasMore:o,searchInput:s,setSearchInput:c,selectedLevels:l,moduleFilter:d,setModuleFilter:f,dateFrom:p,setDateFrom:m,dateTo:h,setDateTo:g,modules:_,files:v,stats:y,selectedLog:b,setSelectedLog:x,filesOpen:S,setFilesOpen:C,filtersOpen:w,setFiltersOpen:T,logDir:E,autoRefresh:D,setAutoRefresh:O,copiedDetail:k,setCopiedDetail:A,hasActiveFilters:j,activeFilterCount:M,clearFilters:N,toggleDialogLevel:P,handleLoadMore:F,refreshAll:I,levelSegment:L,handleLevelSegment:R,filterByRequestId:z,filterBySessionId:B,filterByErrorSummary:V,openChatForSession:ee,errorSummary:H,errorSummaryLoading:U}=Fe(u(lt));if(!n){let n;return e[0]===t?n=e[1]:(n=(0,$.jsx)($e,{L:t}),e[0]=t,e[1]=n),n}let W;e[2]===C?W=e[3]:(W=()=>C(!0),e[2]=C,e[3]=W);let K;e[4]!==t||e[5]!==D||e[6]!==v.length||e[7]!==i||e[8]!==r||e[9]!==I||e[10]!==O||e[11]!==W?(K=(0,$.jsx)(ot,{L:t,autoRefresh:D,onAutoRefreshChange:O,fileCount:v.length,onOpenFiles:W,loading:i,onRefreshAll:I,logs:r}),e[4]=t,e[5]=D,e[6]=v.length,e[7]=i,e[8]=r,e[9]=I,e[10]=O,e[11]=W,e[12]=K):K=e[12];let q;e[13]===a?q=e[14]:(q=a?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg dark:border-edge`,role:`alert`,children:a}):null,e[13]=a,e[14]=q);let J;e[15]!==t||e[16]!==y?(J=y?(0,$.jsx)(st,{L:t,stats:y}):null,e[15]=t,e[16]=y,e[17]=J):J=e[17];let te;e[18]!==t||e[19]!==H||e[20]!==U||e[21]!==V?(te=(0,$.jsx)(Ie,{L:t,items:H,loading:U,onSelectItem:V}),e[18]=t,e[19]=H,e[20]=U,e[21]=V,e[22]=te):te=e[22];let Y;e[23]===T?Y=e[24]:(Y=()=>T(!0),e[23]=T,e[24]=Y);let ne;e[25]!==t||e[26]!==M||e[27]!==D||e[28]!==N||e[29]!==R||e[30]!==j||e[31]!==L||e[32]!==d||e[33]!==_||e[34]!==s||e[35]!==f||e[36]!==c||e[37]!==Y?(ne=(0,$.jsx)(Ye,{L:t,levelSegment:L,onLevelSegment:R,searchInput:s,onSearchInputChange:c,moduleFilter:d,onModuleFilterChange:f,modules:_,onOpenFilters:Y,activeFilterCount:M,hasActiveFilters:j,onClearFilters:N,autoRefresh:D}),e[25]=t,e[26]=M,e[27]=D,e[28]=N,e[29]=R,e[30]=j,e[31]=L,e[32]=d,e[33]=_,e[34]=s,e[35]=f,e[36]=c,e[37]=Y,e[38]=ne):ne=e[38];let X;e[39]!==t||e[40]!==z||e[41]!==F||e[42]!==o||e[43]!==i||e[44]!==r||e[45]!==I||e[46]!==x?(X=(0,$.jsx)(Ze,{L:t,logs:r,loading:i,hasMore:o,onSelectLog:x,onLoadMore:F,onRefreshAll:I,onFilterByRequestId:z}),e[39]=t,e[40]=z,e[41]=F,e[42]=o,e[43]=i,e[44]=r,e[45]=I,e[46]=x,e[47]=X):X=e[47];let Z;e[48]!==t||e[49]!==p||e[50]!==h||e[51]!==w||e[52]!==l||e[53]!==m||e[54]!==g||e[55]!==T||e[56]!==P?(Z=(0,$.jsx)(Ue,{L:t,open:w,onOpenChange:T,dateFrom:p,onDateFromChange:m,dateTo:h,onDateToChange:g,selectedLevels:l,onToggleLevel:P}),e[48]=t,e[49]=p,e[50]=h,e[51]=w,e[52]=l,e[53]=m,e[54]=g,e[55]=T,e[56]=P,e[57]=Z):Z=e[57];let re;e[58]===x?re=e[59]:(re=()=>x(null),e[58]=x,e[59]=re);let ie,ae;e[60]===A?(ie=e[61],ae=e[62]):(ie=()=>A(`message`),ae=()=>A(`json`),e[60]=A,e[61]=ie,e[62]=ae);let oe;e[63]!==t||e[64]!==k||e[65]!==z||e[66]!==B||e[67]!==ee||e[68]!==b||e[69]!==ie||e[70]!==ae||e[71]!==re?(oe=(0,$.jsx)(Be,{L:t,log:b,onClose:re,copiedDetail:k,onCopiedMessage:ie,onCopiedJson:ae,onFilterByRequestId:z,onFilterBySessionId:B,onOpenChat:ee}),e[63]=t,e[64]=k,e[65]=z,e[66]=B,e[67]=ee,e[68]=b,e[69]=ie,e[70]=ae,e[71]=re,e[72]=oe):oe=e[72];let Q;e[73]!==t||e[74]!==v||e[75]!==S||e[76]!==E||e[77]!==C?(Q=(0,$.jsx)(Ve,{L:t,open:S,onOpenChange:C,files:v,logDir:E}),e[73]=t,e[74]=v,e[75]=S,e[76]=E,e[77]=C,e[78]=Q):Q=e[78];let se;return e[79]!==K||e[80]!==oe||e[81]!==Q||e[82]!==q||e[83]!==J||e[84]!==te||e[85]!==ne||e[86]!==X||e[87]!==Z?(se=(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[K,q,J,te,ne,X,Z,oe,Q]}),e[79]=K,e[80]=oe,e[81]=Q,e[82]=q,e[83]=J,e[84]=te,e[85]=ne,e[86]=X,e[87]=Z,e[88]=se):se=e[88],se}function lt(e){return e.language}export{ct as LogsPage};
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./messages-CQGpD-dC.js";import{d as c,i as l,n as u,o as d,r as f}from"./locale-store-Bp8joZck.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{An as m,Ao as h,As as g,Bn as _,Dl as v,Dn as y,Dt as b,En as x,Fn as S,Gn as C,Gt as w,Hn as T,Ic as E,In as D,Ir as O,Jn as k,Jo as A,Kn as j,Ko as M,Kt as N,Ln as P,Mn as F,Mo as I,Nn as L,No as R,On as z,Oo as B,Ot as V,Pn as ee,Po as te,Ql as ne,Qs as re,Rc as H,Rn as ie,Ss as ae,Tn as oe,Un as se,Uo as ce,Ur as le,Ut as ue,Vs as de,Wn as fe,Wo as U,Wt as pe,Xl as me,Xn as he,Yn as ge,Yo as _e,Zs as ve,as as ye,bc as be,cs as W,ds as xe,ec as Se,er as Ce,fl as we,fs as Te,fu as Ee,gc as De,hc as Oe,io as G,jc as ke,jn as Ae,kn as je,ko as Me,kt as Ne,mc as K,ms as q,no as Pe,ns as Fe,ps as J,qn as Ie,qt as Le,rl as Re,ro as ze,rs as Be,so as Ve,ss as He,vs as Ue,zn as We,zo as Ge}from"./index-CxkNzw3e.js";import{n as Ke,t as qe}from"./settings-page-layout-DaFwstQw.js";import{r as Je}from"./settings-loading-skeleton-B79dq-XY.js";import{c as Ye,d as Xe,f as Ze,h as Qe,i as $e,l as et,m as tt,n as nt,o as rt,p as it,r as at,s as ot,t as st,u as ct}from"./voice-api-key-field-b-YZtvUu.js";import{t as lt}from"./settings-advanced-gate-BHGmH6YS.js";import{t as ut}from"./settings-collapsible-section-CUTExnlK.js";import{n as dt,t as ft}from"./settings-form-section-CmnDhsf0.js";import{t as pt}from"./page-tabs-DKB6RDre.js";import{n as mt,t as ht}from"./save-bar-controls-BgIE9BBh.js";var Y=n(),X=e(t(),1),Z=r(),gt=()=>c(Qe),_t=e=>{let t=e?.trim();return c(t?`/api/image/capabilities?agentId=${encodeURIComponent(t)}`:`/api/image/capabilities`)},vt=()=>c(`/api/global-defaults`),yt=()=>`image-models-agents`,bt={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function xt(e){let t=await l(e);if(!t.payload)throw Error(`Invalid image capabilities response`);return t.payload}function St(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function Ct(e){return e.map(e=>e.trim()).filter(Boolean)}function wt(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=Ct(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=Ct(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function Tt(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function Et(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,n),e)}function Dt(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var Ot={saving:!1,savedFlash:!1,error:void 0};function kt(e){let t=(0,Y.c)(40),{current:n,agentId:r,agentOptions:i,t:a,onAgentIdChange:o}=e,s=n?.effectiveImageModel??null,c=n?.imageModelSource??`none`,l=n?.imageModelRoleId??n?.imageModelRoleDescription??``,u;t[0]!==l||t[1]!==c||t[2]!==a.runtimeUnderstandingAutoProvider||t[3]!==a.runtimeUnderstandingAutoRole||t[4]!==a.runtimeUnderstandingExplicit||t[5]!==a.runtimeUnderstandingNone?(u=c===`explicit`?a.runtimeUnderstandingExplicit:c===`auto-role`?Et(a.runtimeUnderstandingAutoRole,{role:l||`unknown`}):c===`auto-provider`?a.runtimeUnderstandingAutoProvider:a.runtimeUnderstandingNone,t[0]=l,t[1]=c,t[2]=a.runtimeUnderstandingAutoProvider,t[3]=a.runtimeUnderstandingAutoRole,t[4]=a.runtimeUnderstandingExplicit,t[5]=a.runtimeUnderstandingNone,t[6]=u):u=t[6];let d=u,f;t[7]!==n||t[8]!==a.runtimeUnderstandingFallbacks||t[9]!==a.runtimeUnderstandingNoFallbacks?(f=n?.effectiveImageModelFallbacks?.length?Et(a.runtimeUnderstandingFallbacks,{models:n.effectiveImageModelFallbacks.join(`, `)}):a.runtimeUnderstandingNoFallbacks,t[7]=n,t[8]=a.runtimeUnderstandingFallbacks,t[9]=a.runtimeUnderstandingNoFallbacks,t[10]=f):f=t[10];let p=f,m;t[11]===a.runtimeUnderstandingTitle?m=t[12]:(m=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.runtimeUnderstandingTitle}),t[11]=a.runtimeUnderstandingTitle,t[12]=m);let h;t[13]===d?h=t[14]:(h=(0,Z.jsx)(`p`,{className:`mt-1 max-w-[72ch] text-xs leading-relaxed text-fg-muted`,children:d}),t[13]=d,t[14]=h);let g;t[15]!==m||t[16]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[15]=m,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==r||t[19]!==i||t[20]!==o||t[21]!==a.runtimeAgentLabel?(_=i.length>0?(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs font-medium text-fg-muted sm:w-56`,children:[a.runtimeAgentLabel,(0,Z.jsx)(ce,{value:r,options:i,placeholder:a.runtimeAgentLabel,allowEmpty:!1,triggerClassName:`bg-surface-panel`,onChange:o})]}):null,t[18]=r,t[19]=i,t[20]=o,t[21]=a.runtimeAgentLabel,t[22]=_):_=t[22];let v;t[23]!==g||t[24]!==_?(v=(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[g,_]}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y=s??a.noModelSelected,b;t[26]===y?b=t[27]:(b=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:y}),t[26]=y,t[27]=b);let x;t[28]===p?x=t[29]:(x=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:p}),t[28]=p,t[29]=x);let S;t[30]!==x||t[31]!==b?(S=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-subtle px-3 py-2 shadow-surface`,children:[b,x]}),t[30]=x,t[31]=b,t[32]=S):S=t[32];let C;t[33]!==i.length||t[34]!==a.runtimeAgentHint?(C=i.length>0?(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:a.runtimeAgentHint}):null,t[33]=i.length,t[34]=a.runtimeAgentHint,t[35]=C):C=t[35];let w;return t[36]!==S||t[37]!==C||t[38]!==v?(w=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[v,S,C]}),t[36]=S,t[37]=C,t[38]=v,t[39]=w):w=t[39],w}function At(e){let t=(0,Y.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,p;t[0]!==c||t[1]!==s?(p=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==m||t[5]!==s?(h=s?l.find(e=>!m.has(e.value))?.value??``:``,t[3]=l,t[4]=m,t[5]=s,t[6]=h):h=t[6];let _=h,v;t[7]!==c||t[8]!==_||t[9]!==f?(v=()=>{_&&f([...c,_])},t[7]=c,t[8]=_,t[9]=f,t[10]=v):v=t[10];let y=v,b;t[11]!==c||t[12]!==f?(b=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=b):b=t[13];let x=b,S;t[14]!==c||t[15]!==f?(S=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=S):S=t[16];let C=S,w;t[17]===n?w=t[18]:(w=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=w);let T;t[19]===r?T=t[20]:(T=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,Z.jsxs)(`div`,{className:`mb-3`,children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]===c?D=t[25]:(D=new Set(c),t[24]=c,t[25]=D);let O;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==D||t[30]!==s?(O=(0,Z.jsx)(ce,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:D,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=D,t[30]=s,t[31]=O):O=t[31];let k;t[32]!==i||t[33]!==O?(k=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,O]}),t[32]=i,t[33]=O,t[34]=k):k=t[34];let A;t[35]===a?A=t[36]:(A=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=A);let j;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==C||t[43]!==m||t[44]!==x?(j=c.length===0?(0,Z.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg bg-surface-subtle px-3 text-sm font-normal text-fg-subtle shadow-surface`,children:o}):c.map((e,t)=>(0,Z.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,Z.jsx)(ce,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:m,onChange:e=>x(t,e)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,Z.jsx)(g,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=C,t[43]=m,t[44]=x,t[45]=j):j=t[45];let M=!_,N;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(K,{className:`size-4`,"aria-hidden":`true`}),t[46]=N):N=t[46];let P;t[47]!==y||t[48]!==a||t[49]!==M?(P=(0,Z.jsxs)(`button`,{type:`button`,onClick:y,disabled:M,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[N,a]}),t[47]=y,t[48]=a,t[49]=M,t[50]=P):P=t[50];let F;t[51]!==j||t[52]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[j,P]}),t[51]=j,t[52]=P,t[53]=F):F=t[53];let I;t[54]!==A||t[55]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,F]}),t[54]=A,t[55]=F,t[56]=I):I=t[56];let L;t[57]!==k||t[58]!==I?(L=(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[k,I]}),t[57]=k,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==L||t[61]!==E?(R=(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[E,L]}),t[60]=L,t[61]=E,t[62]=R):R=t[62],R}function jt(){let e=(0,Y.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Array.from({length:2}).map(Mt),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(G,{className:`h-4 w-36`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[t,(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[n,(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,Z.jsx)(G,{className:`h-10 rounded-lg`}),(0,Z.jsx)(G,{className:`h-16 rounded-lg`})]})]})]}),e[2]=r):r=e[2],r}function Mt(e,t){return(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Z.jsx)(G,{className:`h-4 w-40`}),(0,Z.jsx)(G,{className:`mt-2 h-3 w-72 max-w-full`}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,Z.jsx)(G,{className:`h-10 rounded-lg`}),(0,Z.jsx)(G,{className:`h-10 rounded-lg`}),(0,Z.jsx)(G,{className:`h-9 w-36 rounded-lg`})]})]},t)}function Nt(){let e=u(e=>e.language),t=s(e),n=t.imageModelsSettings,r=!!d(e=>e.token),[i,a]=(0,X.useReducer)(Ne,Ot),{saving:o,error:c}=i,l=Ve(),f=(0,X.useMemo)(()=>new Set(l.map(e=>e.id)),[l]),{data:m=[],isLoading:h}=p(r?gt():null,tt,{revalidateOnFocus:!1}),{data:g,isLoading:_}=p(r?yt():null,le,{revalidateOnFocus:!1}),[v,y]=(0,X.useState)(``);(0,X.useEffect)(()=>{g&&y(e=>e&&g.agents.some(t=>t.id===e)?e:g.defaultId||g.agents[0]?.id||``)},[g]);let{data:b,isLoading:x,mutate:S}=p(r?_t(v):null,xt,{revalidateOnFocus:!1}),{data:C,isLoading:w,mutate:T}=p(r?vt():null,N,{revalidateOnFocus:!1}),E=m.some(e=>e.configured),D=Ze(m),[k,A]=(0,X.useState)(bt),[j,M]=(0,X.useState)(bt);(0,X.useEffect)(()=>{if(!C?.models)return;let e=St(C.models);A(e),M(e)},[C?.models]);let P=JSON.stringify(k)!==JSON.stringify(j),F=D.credDirty||P;(0,X.useEffect)(()=>{if(!F)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[F]),mt({id:`image-models`,dirty:F,saving:o,save:(0,X.useCallback)(async()=>{a({type:`patch`,patch:{saving:!0,error:void 0}});try{if(P){if(!C?.models)throw Error(n.loadError);let e=await Le(wt(C.models,k));await T(e,!1),await S();let t=St(e.models);A(t),M(t)}D.credDirty&&(await D.saveCredentials(n.credentialsSaveError),await S()),a({type:`patch`,patch:{savedFlash:!0}})}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{saving:!1}})}},[D,C?.models,P,k,T,S,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,X.useCallback)(()=>{D.credDirty&&D.onDiscardCredentials(),P&&A(j),a({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[D,j,P])});let I=(0,X.useMemo)(()=>Dt(n),[n]),L=(0,X.useMemo)(()=>Tt(b?.imageUnderstanding.providers??[]),[b?.imageUnderstanding.providers]),R=(0,X.useMemo)(()=>Tt(b?.imageGeneration.providers??[]),[b?.imageGeneration.providers]),z=(0,X.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]),B=(0,X.useMemo)(()=>(g?.agents??[]).map(e=>({value:e.id,label:O(e,t.agentsSettings)})),[g?.agents,t.agentsSettings]);return r?h||x||w||_?(0,Z.jsx)(jt,{}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:c}):null,(0,Z.jsx)(kt,{current:b?.current,agentId:v,agentOptions:B,t:n,onAgentIdChange:y}),(0,Z.jsx)(At,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:k.imageModel,fallbackValues:k.imageModelFallbacks,options:L,emptyLabel:n.noModelSelected,onValueChange:e=>A(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>A(t=>({...t,imageModelFallbacks:e}))}),(0,Z.jsx)(At,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:k.imageGenerationModel,fallbackValues:k.imageGenerationModelFallbacks,options:R,emptyLabel:n.noModelSelected,onValueChange:e=>A(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>A(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,Z.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,Z.jsx)(`input`,{type:`number`,min:1,value:k.imageGenerationModelTimeoutMs,onChange:e=>A(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,Z.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:k.imageGenerationModelAutoProviderFallback,onChange:e=>A(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,Z.jsx)(ut,{icon:re,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:E,children:m.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,Z.jsx)(it,{summaries:m,credDraft:D.credDraft,credBaseline:D.credBaseline,credDirty:D.credDirty,credSaving:D.credSaving,credError:D.credError,credSavedFlash:D.credSavedFlash,credNoopFlash:D.credNoopFlash,updateCredRow:D.updateCredRow,onDiscardCredentials:D.onDiscardCredentials,onSaveCredentials:()=>void D.saveCredentials(n.credentialsSaveError),extensionIds:f,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:z,messages:I})})]}):(0,Z.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Pt=xe;function Ft(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function It(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Lt(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,J,`dark:border-edge`)}function Q(){return o(Te,xe)}function Rt(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function zt(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var Bt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Vt=[{id:`whisper-1`,name:`Whisper-1`}],Ht=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Ut=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Wt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Gt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Kt=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],qt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Jt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Yt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],Xt=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Zt(e,t){switch(e){case`xopc-local`:return t.stt.localProvider;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Qt(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function $t(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function en(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function tn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function nn(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function rn(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function an(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function on(){let e=u(e=>e.language),t=s(e).voiceSettings,n=!!d(e=>e.token),[r,i]=(0,X.useReducer)(an,{form:null,baseline:null}),a=r.form,o=r.baseline,[l,f]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(null),v=(0,X.useRef)(!1),y=(0,X.useRef)({parsed:null,models:void 0}),{data:b,error:x,isLoading:S,mutate:C}=ze(n),{data:w,error:T,isLoading:E,mutate:D}=p(n?c(`/api/voice/models`):null,at,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=p(n?c(`/api/voice/providers`):null,$e,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=p(n?c(`/api/voice/stt-providers`):null,rt,{revalidateOnFocus:!1}),P=(0,X.useMemo)(()=>O?.providers??[],[O]),F=(0,X.useMemo)(()=>j?.providers??[],[j]),I=(0,X.useMemo)(()=>b?.payload?.config===void 0?null:Ye(b.payload.config),[b]),L=(0,X.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);n?I!==null&&w!==void 0&&!v.current&&(y.current.parsed!==I||y.current.models!==w)&&(y.current={parsed:I,models:w},i({type:`sync`,value:I}),f(w)):(y.current.parsed!==null||y.current.models!==void 0)&&(y.current={parsed:null,models:void 0},i({type:`reset`}),f(null),v.current=!1);let R=!!(n&&(I===null||w===void 0||O===void 0||j===void 0)&&(S||E||A||N)),z=x instanceof Error?x.message:x?String(x):T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):M instanceof Error?M.message:M?String(M):null,B=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),V=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),ee=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),te=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[`xopc-local`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ne=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),re=(0,X.useCallback)(t=>{v.current=!0,i({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),H=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ie=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),ae=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),oe=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,voice:e.voice!==void 0||e.lang!==void 0?{...t.voice,languageMode:`manual`}:t.voice,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),se=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ce=(0,X.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(mt({id:`voice`,dirty:L,saving:m,save:(0,X.useCallback)(async()=>{if(!(!a||m)){h(!0),_(null);try{await et(a),i({type:`saved`,value:a}),v.current=!1}catch(e){_(e instanceof Error?e.message:t.saveError)}finally{h(!1)}}},[a,m,t.saveError]),discard:(0,X.useCallback)(()=>{o&&(v.current=!1,i({type:`discard`}),_(null))},[o])}),!n)return(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(R)return(0,Z.jsx)(Je,{rows:4});if(!a||l===null)return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g??z??t.loadError}),(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>{C(),D()},children:t.retry})]});let le=a.stt,ue=a.tts,de=a.voice.input.refinement,fe=tn(t);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(sn,{v:t,voice:a.voice,updateLanguageMode:re}),(0,Z.jsx)(cn,{v:t,stt:le,tts:ue}),(0,Z.jsx)(un,{v:t,apiKeyLabels:fe,stt:le,models:l,sttProviders:F,refinement:de,updateStt:B,updateSttAlibaba:V,updateSttOpenai:ee,updateSttFallback:te,updateRefinement:ne}),(0,Z.jsx)(vn,{v:t,apiKeyLabels:fe,tts:ue,models:l,ttsProviders:P,updateTts:H,updateTtsAlibaba:ie,updateTtsOpenai:ae,updateTtsEdge:oe,updateTtsMinimax:se,updateTtsLocalCli:ce})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Z.jsx)(`strong`,{className:`text-accent`,children:t.notes.title}),` `,t.notes.duration]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.notes.envVars})]})]})}function sn(e){let t=(0,Y.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,Z.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=Q(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let d;t[10]===n.language.auto?d=t[11]:(d=(0,Z.jsx)(M,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=d);let f;t[12]===n.language.manual?f=t[13]:(f=(0,Z.jsx)(M,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=f);let p;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==r.languageMode?(p=(0,Z.jsxs)(U,{className:l,value:r.languageMode,onChange:u,children:[d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=r.languageMode,t[18]=p):p=t[18];let m;return t[19]!==c||t[20]!==p?(m=(0,Z.jsx)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,p]})}),t[19]=c,t[20]=p,t[21]=m):m=t[21],m}function cn(e){let t=(0,Y.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Zt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,Z.jsx)(ln,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?$t(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,Z.jsx)(ln,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Qt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,Z.jsx)(ln,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function ln(e){let t=(0,Y.c)(10),{label:n,value:r,ready:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=a);let s=i?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=o(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Z.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==a||t[8]!==l?(u=(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[a,l]}),t[7]=a,t[8]=l,t[9]=u):u=t[9],u}function un(e){let t=(0,Y.c)(49),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:s,refinement:c,updateStt:l,updateSttAlibaba:u,updateSttOpenai:d,updateSttFallback:f,updateRefinement:p}=e,m=a?.stt?.alibaba?.length?a.stt.alibaba:Bt,h=a?.stt?.openai?.length?a.stt.openai:Vt,g;if(t[0]!==s){let e=new Set;g=[];for(let t of s)e.has(t.id)||(e.add(t.id),g.push(t));t[0]=s,t[1]=g}else g=t[1];let _=g,v,y,b,x,S;if(t[2]!==m||t[3]!==r||t[4]!==a?.stt||t[5]!==h||t[6]!==_||t[7]!==c||t[8]!==i||t[9]!==p||t[10]!==l||t[11]!==u||t[12]!==f||t[13]!==d||t[14]!==n){let e=_.find(e=>e.id===i.provider),s=i.providers?.[i.provider],g=typeof s?.apiKey==`string`?s.apiKey:``,C=typeof s?.model==`string`?s.model:``,w={...i.provider===`alibaba`?i.alibaba??{}:{},...i.provider===`openai`?i.openai??{}:{},...s??{}},T=(e?.fields??[]).filter(hn),E;t[20]!==i.provider||t[21]!==i.providers||t[22]!==l?(E=e=>{l({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[20]=i.provider,t[21]=i.providers,t[22]=l,t[23]=E):E=t[23];let D=E;x=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(ke,{className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=O):O=t[24];let k;t[25]===n.stt.title?k=t[26]:(k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[O,n.stt.title]}),t[25]=n.stt.title,t[26]=k);let A;t[27]===n.stt.description?A=t[28]:(A=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[27]=n.stt.description,t[28]=A),t[29]!==k||t[30]!==A?(S=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[k,A]}),t[29]=k,t[30]=A,t[31]=S):S=t[31],v=`space-y-4`;let j;t[32]===l?j=t[33]:(j=e=>l({enabled:e}),t[32]=l,t[33]=j),t[34]!==i.enabled||t[35]!==j||t[36]!==n.overview.off||t[37]!==n.overview.ready||t[38]!==n.stt.enable||t[39]!==n.stt.enableDesc?(y=(0,Z.jsx)(yn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:j}),t[34]=i.enabled,t[35]=j,t[36]=n.overview.off,t[37]=n.overview.ready,t[38]=n.stt.enable,t[39]=n.stt.enableDesc,t[40]=y):y=t[40],b=i.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:n.stt.provider}),(0,Z.jsx)(U,{className:Q(),value:i.provider,onChange:e=>l({provider:e.target.value}),children:_.map(e=>(0,Z.jsxs)(M,{value:e.id,children:[Zt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:n.stt.model}),i.provider===`xopc-local`?(0,Z.jsx)(U,{className:Q(),value:C||`sensevoice-small`,onChange:e=>D({model:e.target.value}),children:(a?.stt?.[`xopc-local`]??[]).map(mn)}):i.provider===`alibaba`?(0,Z.jsx)(U,{className:Q(),value:i.alibaba?.model??``,onChange:e=>u({model:e.target.value}),children:m.map(pn)}):i.provider===`openai`?(0,Z.jsx)(U,{className:Q(),value:i.openai?.model??``,onChange:e=>d({model:e.target.value}),children:h.map(fn)}):i.provider===`groq`?(0,Z.jsx)(U,{className:Q(),value:C||Ht[0].id,onChange:e=>D({model:e.target.value}),children:Ht.map(dn)}):(0,Z.jsx)(`input`,{className:Lt(),value:C,onChange:e=>D({model:e.target.value}),placeholder:i.provider})]}),e?.diagnostics.requiresApiKey===!1?null:(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:n.stt.apiKey}),(0,Z.jsx)(st,{kind:`stt`,providerId:i.provider,fieldId:`voice-stt-${i.provider}-api-key`,value:i.provider===`alibaba`?i.alibaba?.apiKey??``:i.provider===`openai`?i.openai?.apiKey??``:g,onChange:e=>{i.provider===`alibaba`?u({apiKey:e}):i.provider===`openai`?d({apiKey:e}):D({apiKey:e})},labels:r,placeholder:i.provider===`groq`?`gsk_...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Ft(i.provider)?` ${Ft(i.provider)}`:``]})]})]}),T.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:T.map(e=>(0,Z.jsx)(bn,{field:e,value:nn(w,e),onChange:t=>D({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Pt},e.key))}):null,i.provider===`xopc-local`?(0,Z.jsx)(_n,{v:n}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>f({enabled:e.target.checked})})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.refinement}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.refinementDesc})]}),(0,Z.jsxs)(U,{className:Q(),value:c.mode,onChange:e=>p({mode:e.target.value}),children:[(0,Z.jsx)(M,{value:`off`,children:n.stt.refinementOff}),(0,Z.jsx)(M,{value:`punctuation`,children:n.stt.refinementPunctuation}),(0,Z.jsx)(M,{value:`light`,children:n.stt.refinementLight})]})]})]}):null,t[2]=m,t[3]=r,t[4]=a?.stt,t[5]=h,t[6]=_,t[7]=c,t[8]=i,t[9]=p,t[10]=l,t[11]=u,t[12]=f,t[13]=d,t[14]=n,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S}else v=t[15],y=t[16],b=t[17],x=t[18],S=t[19];let C;t[41]!==v||t[42]!==y||t[43]!==b?(C=(0,Z.jsxs)(`div`,{className:v,children:[y,b]}),t[41]=v,t[42]=y,t[43]=b,t[44]=C):C=t[44];let w;return t[45]!==x||t[46]!==S||t[47]!==C?(w=(0,Z.jsxs)(`section`,{className:x,children:[S,C]}),t[45]=x,t[46]=S,t[47]=C,t[48]=w):w=t[48],w}function dn(e){return(0,Z.jsx)(M,{value:e.id,children:e.name},e.id)}function fn(e){return(0,Z.jsx)(M,{value:e.id,children:e.name},e.id)}function pn(e){return(0,Z.jsx)(M,{value:e.id,children:e.name},e.id)}function mn(e){return(0,Z.jsx)(M,{value:e.id,children:e.name},e.id)}function hn(e){return e.key!==`apiKey`&&e.key!==`model`}function gn(e){return`${Math.round(e/1024/1024)} MB`}function _n({v:e}){let{data:t,error:n,mutate:r}=p(c(`/api/voice/local/status`),nt,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,X.useState)(null),[s,l]=(0,X.useState)(null),u=(0,X.useCallback)(async(e,t)=>{a(e.id),l(null);try{t===`install`?await ot(e.id):await ct(e.id),await r()}catch(e){l(e instanceof Error?e.message:String(e))}finally{a(null)}},[r]);return(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel/60 p-3`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.localModels}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.localModelsDesc}),n?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:String(n)}):null,s?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:s}):null,(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:(t?.models??[]).map(t=>{let n=i===t.id||t.state===`downloading`;return(0,Z.jsxs)(`div`,{className:o(`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2.5`,t.recommended?`ring-1 ring-accent/40`:``),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-fg`,children:[t.name,t.recommended?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent`,children:e.stt.localRecommended}):null]}),(0,Z.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[gn(t.approximateBytes),` · `,t.description]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:[t.engine,` · `,t.languages.join(` / `)]}),t.state===`downloading`?(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-accent`,children:[e.stt.localDownloading,` `,Math.round((t.progress??0)*100),`%`]}):t.state===`error`?(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:t.error}):null]}),(0,Z.jsx)(q,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void u(t,t.state===`ready`?`remove`:`install`),children:n?(0,Z.jsx)(H,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function vn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:Ut,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Wt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Gt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Kt,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:qt,_=r?.tts?.minimax?.length?r.tts.minimax:Jt,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:Yt,[y,b]=(0,X.useState)(e.tts.test.sampleText),[x,S]=(0,X.useState)({status:`idle`}),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useCallback)(()=>{C.current?.pause(),C.current=null,w.current&&=(URL.revokeObjectURL(w.current),null)},[]),E=(0,X.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),D=E.find(e=>e.id===n.provider),O=n.providers?.[n.provider],k={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...O??{}},A=(D?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),j=!!D?.diagnostics.requiresApiKey,N=!!D?.configured||!j,P=n.enabled?N?`ready`:`action`:`muted`,F=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,I=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,X.useEffect)(()=>()=>T(),[T]);let L=(0,X.useCallback)(e=>{a({provider:e}),S({status:`idle`})},[a]),R=(0,X.useCallback)(async()=>{let t=y.trim();if(!t){S({status:`error`,message:e.tts.test.emptyText});return}T(),S({status:`loading`});try{let r=await Xe({text:t,provider:n.provider,providerConfig:k,...F?{model:F}:{},...I?{voice:I}:{}}),i=zt(r.audio,r.mimeType);w.current=i;let a=new Audio(i);C.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Rt(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>S({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>S({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),S({status:`playing`,summary:o})}catch(e){T(),S({status:`error`,message:e instanceof Error?e.message:String(e)})}},[F,I,k,T,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),z=(0,X.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]),B=(0,X.useCallback)((e,t)=>{let r={[e.key]:t};z(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,z,l,u,c]);return(0,Z.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ae,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(yn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>a({enabled:e})}),(0,Z.jsxs)(`div`,{className:o(`rounded-xl border px-3 py-2.5 text-sm`,P===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:P===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?N?`${e.tts.statusReady} ${Qt(n.provider,e)}${I?` · ${I}`:``}`:`${e.tts.statusNeedsSetup} ${Qt(n.provider,e)} · ${D?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:e.tts.trigger}),(0,Z.jsxs)(U,{className:Q(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,Z.jsx)(M,{value:`off`,children:e.tts.triggerOff}),(0,Z.jsx)(M,{value:`inbound`,children:e.tts.triggerInbound}),(0,Z.jsx)(M,{value:`tagged`,children:e.tts.triggerTagged}),(0,Z.jsx)(M,{value:`always`,children:e.tts.triggerAlways})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:e.tts.provider}),(0,Z.jsx)(U,{className:Q(),value:n.provider,onChange:e=>L(e.target.value),children:E.map(t=>(0,Z.jsx)(M,{value:t.id,children:Qt(t.id,e)},t.id))}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[D?.configured?e.tts.configured:D?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${D.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,D?.description??en(n.provider,e)]})]})]}),(0,Z.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!N||n.provider===`tts-local-cli`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:e.stt.apiKey}),(0,Z.jsx)(st,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,It(n.provider)?` ${It(n.provider)}`:``]})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:e.stt.model}),(0,Z.jsx)(U,{className:Q(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,Z.jsx)(M,{value:e.id,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(U,{className:Q(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,Z.jsx)(M,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,Pt),children:[(0,Z.jsx)($,{children:e.tts.voice}),(0,Z.jsx)(U,{className:Q(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Z.jsx)(M,{value:e.id,children:e.name},e.id))}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.preset}),(0,Z.jsxs)(U,{className:Q(),value:``,onChange:e=>{let t=Xt.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Z.jsx)(M,{value:``,children:e.tts.localCli.presetPlaceholder}),Xt.map(e=>(0,Z.jsx)(M,{value:e.id,children:e.id},e.id))]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.command}),(0,Z.jsx)(`input`,{className:o(Lt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.cwd}),(0,Z.jsx)(`input`,{className:o(Lt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Z.jsxs)(U,{className:Q(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Z.jsx)(M,{value:`wav`,children:`wav`}),(0,Z.jsx)(M,{value:`mp3`,children:`mp3`}),(0,Z.jsx)(M,{value:`opus`,children:`opus`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Z.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Z.jsx)(`input`,{className:Lt(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,A.length>0?(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:A.map(e=>(0,Z.jsx)(bn,{field:e,value:nn(k,e),onChange:t=>B(e,t),className:e.type===`textarea`?`sm:col-span-2`:Pt},e.key))}):null]})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsxs)(q,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,Z.jsx)(H,{className:`size-4 animate-spin`}):(0,Z.jsx)(De,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,onClick:()=>{T(),S(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:x.status!==`playing`,className:`h-9`,children:[(0,Z.jsx)(de,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Z.jsx)(`textarea`,{className:o(Lt(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(e.target.value),maxLength:1e3}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Z.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),x.status===`playing`||x.status===`done`?(0,Z.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[x.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,x.summary]}):null,x.status===`error`?(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function yn(e){let t=(0,Y.c)(33),{checked:n,title:r,description:i,onLabel:a,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=o(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,J,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?a:s,h;t[7]!==p||t[8]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===i?_=t[14]:(_=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[13]=i,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let C;t[22]===S?C=t[23]:(C=(0,Z.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,Z.jsx)(`span`,{className:b,"aria-hidden":!0,children:C}),t[24]=b,t[25]=C,t[26]=w):w=t[26];let T;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==w||t[31]!==d?(T=(0,Z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,w]}),t[27]=n,t[28]=l,t[29]=v,t[30]=w,t[31]=d,t[32]=T):T=t[32],T}function bn(e){let t=(0,Y.c)(36),{field:n,value:r,onChange:i,className:a}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=o(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,Z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,Z.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==i?(f=e=>i(rn(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===a?u=t[20]:(u=o(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,Z.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==i?(f=n.type===`select`?(0,Z.jsx)(U,{id:s,className:Q(),value:l,required:n.required,onChange:e=>i(rn(n,e.target.value)),children:(n.options??[]).map(xn)}):n.type===`textarea`?(0,Z.jsx)(`textarea`,{id:s,className:o(Lt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>i(rn(n,e.target.value))}):n.type===`password`?(0,Z.jsx)(ye,{id:s,className:a,value:l,onChange:e=>i(rn(n,e)),placeholder:n.placeholder,labels:Fe}):(0,Z.jsx)(`input`,{id:s,className:Lt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>i(rn(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=l,t[26]=s,t[27]=i,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,Z.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function xn(e){return(0,Z.jsx)(M,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function Sn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Cn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Pe()}async function wn(e){let t=await l(c(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Tn(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function En(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,J,`dark:border-edge`)}function Dn(){return o(Te,xe)}var On=[`brave`,`tavily`,`bing`,`searxng`];function kn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var An=b();function jn(){let e=s(u(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!d(e=>e.token),[i,a]=(0,X.useReducer)(An,{form:null,baseline:null}),c=i.form,l=i.baseline,[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=(0,X.useRef)(!1),_=(0,X.useRef)(null),{data:v,error:y,isLoading:b,mutate:x}=ze(r);V({enabled:r,parsed:(0,X.useMemo)(()=>v?.payload?.config===void 0?null:Sn(v.payload.config),[v]),dirty:g.current,trackedParsedRef:_,dispatch:a,onResetDirty:()=>{g.current=!1}});let S=!!(r&&b&&v===void 0&&!y),C=y instanceof Error?y.message:y?String(y):null,w=(0,X.useMemo)(()=>!c||!l?!1:JSON.stringify(c)!==JSON.stringify(l),[c,l]),T=(0,X.useCallback)(e=>{g.current=!0,a({type:`patch`,patch:e})},[]);return mt({id:`search`,dirty:w,saving:f,save:(0,X.useCallback)(async()=>{if(!(!c||f)){p(!0),h(null);try{await Cn(c),g.current=!1,a({type:`saved`,value:c})}catch(e){h(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[c,f,t.saveError]),discard:(0,X.useCallback)(()=>{l&&(g.current=!1,a({type:`discard`}),h(null))},[l])}),r?S?(0,Z.jsx)(Je,{rows:3}):c?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Z.jsxs)(ft,{children:[(0,Z.jsx)(dt,{icon:Se,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,Z.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Z.jsx)(Tn,{label:t.regionLabel,description:t.regionDesc,children:(0,Z.jsxs)(U,{className:Dn(),value:c.regionMode,onChange:e=>T({regionMode:e.target.value}),children:[(0,Z.jsx)(M,{value:`auto`,children:t.regionAuto}),(0,Z.jsx)(M,{value:`cn`,children:t.regionCn}),(0,Z.jsx)(M,{value:`global`,children:t.regionGlobal})]})})})]}),(0,Z.jsx)(lt,{children:(0,Z.jsxs)(ft,{children:[(0,Z.jsx)(dt,{icon:Ee,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.blocklistEnabled,onChange:e=>T({blocklistEnabled:e.target.checked})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,Z.jsx)(Tn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,Z.jsx)(`textarea`,{className:o(En(),`min-h-[6rem] font-mono text-xs`),value:c.blocklistDomains.join(`
2
- `),placeholder:t.blocklistDomainsPlaceholder,disabled:!c.blocklistEnabled,onChange:e=>{T({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,Z.jsxs)(ft,{children:[(0,Z.jsx)(dt,{icon:Se,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,Z.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Z.jsx)(Tn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,Z.jsx)(`input`,{type:`number`,min:1,max:50,className:En(),value:c.maxResults,onChange:e=>T({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),c.providers.map((n,r)=>(0,Z.jsx)(Mn,{row:n,providerIndex:r,labels:t,secretLabels:Be(e.providersSettings),onChange:e=>{let t=[...c.providers];t[r]=e,T({providers:t})},onRemove:()=>{T({providers:c.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>T({providers:[...c.providers,kn()]}),children:[(0,Z.jsx)(K,{className:`size-4`}),t.addProvider]})]})]})]}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??C??t.loadError}),(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void x(),children:n.refresh})]}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function Mn(e){let t=(0,Y.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>wn(r).then(Nn),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(Dn(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==s||t[4]!==n?(p=e=>s({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=s,t[4]=n,t[5]=p):p=t[5];let m;t[6]===i.providerTypes?m=t[7]:(m=On.map(e=>(0,Z.jsx)(M,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,Z.jsx)(U,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let _;t[12]!==s||t[13]!==n?(_=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=_):_=t[14];let v;t[15]!==n.disabled||t[16]!==_?(v=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==i.disabled||t[19]!==v?(y=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[v,i.disabled]}),t[18]=i.disabled,t[19]=v,t[20]=y):y=t[20];let b;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(g,{className:`size-4`}),t[21]=b):b=t[21];let x;t[22]===c?x=t[23]:(x=(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:c,children:b}),t[22]=c,t[23]=x);let S;t[24]!==x||t[25]!==y?(S=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,x]}),t[24]=x,t[25]=y,t[26]=S):S=t[26];let C;t[27]!==S||t[28]!==h?(C=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,S]}),t[27]=S,t[28]=h,t[29]=C):C=t[29];let w;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==s||t[33]!==n?(w=n.type===`searxng`?(0,Z.jsx)(Tn,{label:i.urlLabel,description:i.urlDesc,children:(0,Z.jsx)(`input`,{type:`url`,className:En(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>s({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=s,t[33]=n,t[34]=w):w=t[34];let T;t[35]!==s||t[36]!==n?(T=e=>s({...n,apiKey:e}),t[35]=s,t[36]=n,t[37]=T):T=t[37];let E;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==a||t[44]!==T?(E=(0,Z.jsx)(ye,{value:n.apiKey,onChange:T,placeholder:i.keyPlaceholder,labels:a,reveal:u,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=u,t[42]=n.apiKey,t[43]=a,t[44]=T,t[45]=E):E=t[45];let D;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==E?(D=(0,Z.jsx)(Tn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:E}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=E,t[49]=D):D=t[49];let O;return t[50]!==C||t[51]!==w||t[52]!==D?(O=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[C,w,D]}),t[50]=C,t[51]=w,t[52]=D,t[53]=O):O=t[53],O}function Nn(e){return e.apiKey??null}function Pn(){let e=(0,Y.c)(31),t=d(zn),n=!!t,{data:r,isLoading:i}=ze(n),a;e[0]===n?a=e[1]:(a=n?c(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let{data:l,isLoading:u}=p(a,o,s),f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},e[5]=f):f=e[5];let{data:m,isLoading:h}=p(n?ge:null,Rn,f),g;e[6]===m?g=e[7]:(g=m===void 0?[]:m,e[6]=m,e[7]=g);let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=p(n?Ie:null,Ln,v),b;bb0:{if(!l||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==l||e[12]!==_?(t=se(l,C(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=l,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=je(y.config),e[14]=y.config,e[15]=t),S=t}let w=S,T;if(e[16]!==x||e[17]!==w||e[18]!==l||e[19]!==_){T=[];let t=new Set((l??[]).filter(In).map(Fn)),n;e[21]===w?n=e[22]:(n=new Set(w?Object.keys(w.providers):[]),e[21]=w,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?w.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;T.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(w){let t;e[23]===w.providers?t=e[24]:(t=Object.entries(w.providers),e[23]=w.providers,e[24]=t);for(let[e,n]of t)T.some(t=>t.id===e)||T.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=w,e[18]=l,e[19]=_,e[20]=T}else T=e[20];let E=T,D=i||u||h,O;return e[25]!==x||e[26]!==E||e[27]!==w||e[28]!==D||e[29]!==_?(O={cards:E,loading:D,builtinRows:x,customConfig:w,allModels:_},e[25]=x,e[26]=E,e[27]=w,e[28]=D,e[29]=_,e[30]=O):O=e[30],O}function Fn(e){return e.id}function In(e){return e.configured}function Ln(){return z()}function Rn(){return he()}function zn(e){return e.token}function Bn(e){let t=(0,Y.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=Pn();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(G,{className:`h-6 w-48 max-w-full`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(Hn)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(Vn),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(K,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,Z.jsx)(K,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,Z.jsx)(Un,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function Vn(e){return e.configured}function Hn(e){return(0,Z.jsx)(G,{className:`h-32 rounded-2xl`},e)}function Un(e){let t=(0,Y.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=o(`group relative flex flex-col justify-between rounded-2xl bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,W.pressCard),t[0]=a):a=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,Z.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=s);let c;t[3]!==n.isCustom||t[4]!==r.custom?(c=n.isCustom?(0,Z.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=c):c=t[5];let l;t[6]!==s||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(me,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(ve,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==p?(g=(0,Z.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==i||t[25]!==g||t[26]!==d?(_=(0,Z.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[d,g]}),t[24]=i,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}async function Wn(e){let t=await f(c(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function Gn(e){let t=await f(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function Kn(e,t){let n=await f(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function qn(e){let t=await f(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Jn(e){let t=await f(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function Yn(e){let t=await f(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var Xn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function Zn(e){let t=new Map;for(let e of Xn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function Qn(e){let t=(0,Y.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,X.useState)(u),[p,m]=(0,X.useState)(``),g;t[1]===r?g=t[2]:(g=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=g);let _=g,v;t[3]!==_||t[4]!==l?(v=()=>{l(),_(!1)},t[3]=_,t[4]=l,t[5]=v):v=t[5];let y=v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(I,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,_e)}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=o(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,A),t[7]=x):x=t[7];let S;t[8]!==i||t[9]!==a||t[10]!==y||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(S=(0,Z.jsxs)(R,{children:[b,(0,Z.jsx)(h,{className:x,children:d.type===`pick`?(0,Z.jsx)(er,{builtinRows:i,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>{let t=D(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,Z.jsx)(tr,{providerId:d.providerId,builtinRows:i,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y}):(0,Z.jsx)(ir,{initialPresetKey:d.presetKey,customConfig:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y})})]}),t[8]=i,t[9]=a,t[10]=y,t[11]=s,t[12]=c,t[13]=p,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=S):S=t[17];let C;return t[18]!==_||t[19]!==n||t[20]!==S?(C=(0,Z.jsx)(B,{open:n,onOpenChange:_,children:S}),t[18]=_,t[19]=n,t[20]=S,t[21]=C):C=t[21],C}function $n(e){let t=(0,Y.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,W.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Ue,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,Z.jsx)(Me,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function er(e){let t=(0,Y.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:s,onPickCustom:c}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=ue[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,p;t[7]===f?p=t[8]:(p=Zn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===a.step1Title?h=t[10]:(h=(0,Z.jsx)(te,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:a.step1Title}),t[9]=a.step1Title,t[10]=h);let g;t[11]===a.close?g=t[12]:(g=(0,Z.jsx)($n,{label:a.close}),t[11]=a.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Se,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]===i?y=t[18]:(y=e=>i(e.target.value),t[17]=i,t[18]=y);let b=a.searchPlaceholder,x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=o(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,J),t[19]=x):x=t[19];let S;t[20]!==a.searchPlaceholder||t[21]!==r||t[22]!==y?(S=(0,Z.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[v,(0,Z.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:b,autoComplete:`off`,autoFocus:!0,className:x})]})}),t[20]=a.searchPlaceholder,t[21]=r,t[22]=y,t[23]=S):S=t[23];let C;t[24]!==a.addCustom||t[25]!==a.customDescription||t[26]!==c||t[27]!==u?(C=u?null:(0,Z.jsxs)(`button`,{type:`button`,onClick:c,className:o(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,W.press),children:[(0,Z.jsx)(we,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.addCustom}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.customDescription})]}),(0,Z.jsx)(ne,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=a.addCustom,t[25]=a.customDescription,t[26]=c,t[27]=u,t[28]=C):C=t[28];let w;t[29]!==f.length||t[30]!==m||t[31]!==a.categories||t[32]!==a.noResults||t[33]!==s?(w=f.length===0?(0,Z.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:Xn.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.categories[e]??e}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:o(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,W.press),children:[(0,Z.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,Z.jsx)(me,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=a.categories,t[32]=a.noResults,t[33]=s,t[34]=w):w=t[34];let T;t[35]!==C||t[36]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[C,w]}),t[35]=C,t[36]=w,t[37]=T):T=t[37];let E;return t[38]!==S||t[39]!==T||t[40]!==_?(E=(0,Z.jsxs)(Z.Fragment,{children:[_,S,T]}),t[38]=S,t[39]=T,t[40]=_,t[41]=E):E=t[41],E}function tr({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let c=t.find(t=>t.id===e),l=ue[e],[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),v=(0,X.useRef)(null),y=s(r).providersSettings,b=Be(y),x=(0,X.useMemo)(()=>pe(e,r),[e,r]),S=c?.supportsApiKey!==!1,C=c?.supportsOAuth===!0,[T,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(`idle`),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(``),L=k===`waiting`||k===`waiting_code`;(0,X.useEffect)(()=>{if(!T||!L)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Gn(T);t.status===`waiting_auth`||t.status===`waiting_code`?(A(t.status===`waiting_code`?`waiting_code`:`waiting`),O(t.message??null),M(t.authUrl??null),P(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),A(`success`),O(t.message??y.saved),window.setTimeout(a,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),A(`error`),O(t.error??t.message??y.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[T,L,a,y.revokeFailed,y.saved]),(0,X.useEffect)(()=>()=>{T&&Jn(T).catch(()=>{})},[T]);let R=async()=>{A(`waiting`),O(y.oauthStarting),h(null);try{E((await Wn(e)).sessionId)}catch(e){A(`error`),O(e instanceof Error?e.message:y.revokeFailed)}},z=async()=>{if(T){try{await qn(T)}catch{}A(`idle`),O(null),E(null),M(null),P(null)}},B=async()=>{if(!(!T||!F.trim()))try{await Kn(T,F.trim()),I(``),O(y.oauthProcessingCode)}catch(e){A(`error`),O(e instanceof Error?e.message:y.revokeFailed)}},V=async()=>{let t=u.trim();if(!(!t||!S)){p(!0),h(null);try{await fe({[e]:t}),_(!0),window.setTimeout(a,600)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{p(!1)}}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,W.press),"aria-label":n.back,children:(0,Z.jsx)(ne,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(te,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,Z.jsx)($n,{label:n.close})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,S?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Z.jsx)(ye,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:b,inputRef:v,onKeyDown:e=>{e.key===`Enter`&&V()}})]}):null,C?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:y.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:y.oauthHint})]}),(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:L,onClick:()=>void R(),children:[L?(0,Z.jsx)(H,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,y.oauth]})]}),D?(0,Z.jsx)(`p`,{className:o(`text-xs`,k===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:D}):null,k===`waiting`||k===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[j?(0,Z.jsxs)(`a`,{href:j,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[y.openAuthPage,(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void z(),children:y.cancelOAuth})]}):null,N?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:N}):null,k===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:e=>e.key===`Enter`&&void B(),placeholder:y.pasteRedirectUrl,className:o(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,J)}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,onClick:()=>void B(),children:y.submitCode})]}):null]}):null,x.length>0&&S?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:x.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[w(e,n),(0,Z.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,m?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),S?(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!u.trim()||f||g,onClick:()=>void V(),children:g?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(me,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(H,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function nr(e=`custom`){if(e!==`custom`&&F[e]){let t=F[e].config;return{preset:e,providerId:ie(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function rr(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:F[t.key]?nr(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function ir({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[c,l]=(0,X.useReducer)(rr,void 0,()=>nr(e)),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),h=Be(s(r).providersSettings),{preset:g,providerId:_,baseUrl:v,api:b,apiKey:x,modelIds:S,error:C}=c,w=async()=>{let e=_.trim(),r=v.trim();if(!e){l({type:`setError`,value:n.providerIdRequired});return}if(!r){l({type:`setError`,value:n.baseUrlRequired});return}let i=S.map(e=>e.trim()).filter(Boolean);d(!0),l({type:`setError`,value:null});try{let n=t?.providers??{},o=g===`custom`?void 0:F[g]?.config,s={...o??{},baseUrl:r,api:b,apiKey:x.trim()||void 0,models:i.map(e=>o?.models?.find(t=>t.id===e)??{id:e})};await m({providers:{...n,[e]:s}}),a()}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},T=async()=>{let e=_.trim()||ie(g)||`custom`,t=v.trim();if(!t){l({type:`setError`,value:n.baseUrlRequired});return}p(!0),l({type:`setError`,value:null});try{let r=g===`custom`?void 0:F[g]?.config,i=(await y({providerId:e,baseUrl:t,apiKey:x.trim()||void 0,api:b,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));l({type:`setModelIds`,values:i}),i.length===0&&l({type:`setError`,value:n.discoverModelsHint})}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},E=_.trim()&&v.trim(),D=(b===`openai-completions`||b===`openai-responses`)&&v.trim();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,W.press),"aria-label":n.back,children:(0,Z.jsx)(ne,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Z.jsx)(te,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,Z.jsx)($n,{label:n.close})]}),(0,Z.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,Z.jsxs)(U,{id:`custom-preset`,value:g,onChange:e=>l({type:`applyPreset`,key:e.target.value}),className:We(),children:[(0,Z.jsx)(M,{value:`custom`,children:n.presetCustom}),L.map(e=>(0,Z.jsx)(M,{value:e.key,children:e.label},e.key))]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,Z.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:_,onChange:e=>l({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:o(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,J)})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:v,onChange:e=>l({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:o(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,J)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,Z.jsx)(U,{id:`custom-api-type`,value:b,onChange:e=>l({type:`setApi`,value:e.target.value}),className:We(),children:oe.map(e=>(0,Z.jsx)(M,{value:e.value,children:e.label},e.value))})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Z.jsx)(ye,{id:`custom-api-key`,value:x,onChange:e=>l({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:h})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!D||f,onClick:()=>void T(),children:[f?(0,Z.jsx)(H,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),S.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>l({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:o(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,J)}),S.length>1?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>l({type:`removeModelSlot`,index:t}),className:o(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,W.press),children:(0,Z.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>l({type:`addModelSlot`}),children:[(0,Z.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),C?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!E||u,onClick:()=>void w(),children:u?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(H,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function ar(e){let t=(0,Y.c)(156),{model:n,isNew:r,providerId:i,onSave:a,onClose:s,m:c}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:x(``),t[0]=n,t[1]=l);let[u,d]=(0,X.useState)(l),[f,p]=(0,X.useState)(or),m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=m):m=t[2];let h=m,g;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(g=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,c.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,c.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,c.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=c.modelIdRequired,t[7]=c.mustBePositive,t[8]=g):g=t[8];let _=g,v;t[9]!==u||t[10]!==s||t[11]!==a||t[12]!==_?(v=()=>{if(!_())return;let e=(u.id||``).trim();a({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),s()},t[9]=u,t[10]=s,t[11]=a,t[12]=_,t[13]=v):v=t[13];let y=v,b=u,C;t[14]===b?C=t[15]:(C=P(b),t[14]=b,t[15]=C);let w=C,T=r?c.addModelTitle:c.editModelTitle,E;t[16]===T?E=t[17]:(E=(0,Z.jsx)(te,{className:`text-base font-semibold text-fg`,children:T}),t[16]=T,t[17]=E);let D;t[18]!==c.modelProviderLabel||t[19]!==i?(D=i?(0,Z.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[c.modelProviderLabel,`: `,i]}):null,t[18]=c.modelProviderLabel,t[19]=i,t[20]=D):D=t[20];let O;t[21]!==E||t[22]!==D?(O=(0,Z.jsxs)(`div`,{children:[E,D]}),t[21]=E,t[22]=D,t[23]=O):O=t[23];let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=o(He,`p-1.5 hover:bg-surface-base`),t[24]=k):k=t[24];let A;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Ue,{className:`size-4`}),t[25]=A):A=t[25];let j;t[26]===c.close?j=t[27]:(j=(0,Z.jsx)(Me,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:k,"aria-label":c.close,children:A})}),t[26]=c.close,t[27]=j);let N;t[28]!==O||t[29]!==j?(N=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[O,j]}),t[28]=O,t[29]=j,t[30]=N):N=t[30];let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=F):F=t[31];let I;t[32]===c.modelId?I=t[33]:(I=(0,Z.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,F]}),t[32]=c.modelId,t[33]=I);let L;t[34]===f?L=t[35]:(L=o(ee(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=L);let R=u.id||``,z;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>h(`id`,e.target.value),t[36]=z):z=t[36];let B=!r,V;t[37]!==L||t[38]!==R||t[39]!==B?(V=(0,Z.jsx)(`input`,{className:L,value:R,onChange:z,placeholder:`e.g. llama3.1:8b`,disabled:B}),t[37]=L,t[38]=R,t[39]=B,t[40]=V):V=t[40];let ne;t[41]===f?ne=t[42]:(ne=f.has(`id`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=ne);let re;t[43]!==I||t[44]!==V||t[45]!==ne?(re=(0,Z.jsxs)(`div`,{children:[I,V,ne]}),t[43]=I,t[44]=V,t[45]=ne,t[46]=re):re=t[46];let H;t[47]===c.displayName?H=t[48]:(H=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=H);let ie;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ie=ee(),t[49]=ie):ie=t[49];let ae=u.name||``,oe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>h(`name`,e.target.value),t[50]=oe):oe=t[50];let se;t[51]===ae?se=t[52]:(se=(0,Z.jsx)(`input`,{className:ie,value:ae,onChange:oe}),t[51]=ae,t[52]=se);let ce;t[53]!==H||t[54]!==se?(ce=(0,Z.jsxs)(`div`,{children:[H,se]}),t[53]=H,t[54]=se,t[55]=ce):ce=t[55];let le;t[56]===c.inputTypes?le=t[57]:(le=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=le);let ue;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ue=We(),t[58]=ue):ue=t[58];let de;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>h(`input`,S(e.target.value)),t[59]=de):de=t[59];let fe;t[60]===c?fe=t[61]:(fe=Ae.map(e=>(0,Z.jsx)(M,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=fe);let pe;t[62]!==w||t[63]!==fe?(pe=(0,Z.jsx)(U,{className:ue,value:w,onChange:de,children:fe}),t[62]=w,t[63]=fe,t[64]=pe):pe=t[64];let me;t[65]!==le||t[66]!==pe?(me=(0,Z.jsxs)(`div`,{children:[le,pe]}),t[65]=le,t[66]=pe,t[67]=me):me=t[67];let he=u.reasoning||!1,ge;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>h(`reasoning`,e.target.checked),t[68]=ge):ge=t[68];let _e;t[69]===he?_e=t[70]:(_e=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:he,onChange:ge}),t[69]=he,t[70]=_e);let ve;t[71]!==c.reasoning||t[72]!==_e?(ve=(0,Z.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[_e,c.reasoning]}),t[71]=c.reasoning,t[72]=_e,t[73]=ve):ve=t[73];let ye;t[74]!==me||t[75]!==ve?(ye=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[me,ve]}),t[74]=me,t[75]=ve,t[76]=ye):ye=t[76];let be;t[77]===c.contextWindow?be=t[78]:(be=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=be);let W;t[79]===f?W=t[80]:(W=o(ee(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=W);let xe=u.contextWindow??128e3,Se;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Se=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=Se):Se=t[81];let Ce;t[82]!==W||t[83]!==xe?(Ce=(0,Z.jsx)(`input`,{type:`number`,min:1,className:W,value:xe,onChange:Se}),t[82]=W,t[83]=xe,t[84]=Ce):Ce=t[84];let we;t[85]===f?we=t[86]:(we=f.has(`contextWindow`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=we);let Te;t[87]!==be||t[88]!==Ce||t[89]!==we?(Te=(0,Z.jsxs)(`div`,{children:[be,Ce,we]}),t[87]=be,t[88]=Ce,t[89]=we,t[90]=Te):Te=t[90];let Ee;t[91]===c.maxOutputTokens?Ee=t[92]:(Ee=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=Ee);let De;t[93]===f?De=t[94]:(De=o(ee(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=De);let Oe=u.maxTokens??16384,G;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=G):G=t[95];let ke;t[96]!==De||t[97]!==Oe?(ke=(0,Z.jsx)(`input`,{type:`number`,min:1,className:De,value:Oe,onChange:G}),t[96]=De,t[97]=Oe,t[98]=ke):ke=t[98];let je;t[99]===f?je=t[100]:(je=f.has(`maxTokens`)?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=je);let Ne;t[101]!==Ee||t[102]!==ke||t[103]!==je?(Ne=(0,Z.jsxs)(`div`,{children:[Ee,ke,je]}),t[101]=Ee,t[102]=ke,t[103]=je,t[104]=Ne):Ne=t[104];let K;t[105]!==Te||t[106]!==Ne?(K=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Te,Ne]}),t[105]=Te,t[106]=Ne,t[107]=K):K=t[107];let Pe;t[108]===c.costSection?Pe=t[109]:(Pe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Pe);let Fe;t[110]===c.costInput?Fe=t[111]:(Fe=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=Fe);let J;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(J=ee(),t[112]=J):J=t[112];let Ie=u.cost?.input??0,Le;t[113]===u.cost?Le=t[114]:(Le=e=>h(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[113]=u.cost,t[114]=Le);let Re;t[115]!==Ie||t[116]!==Le?(Re=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:J,value:Ie,onChange:Le}),t[115]=Ie,t[116]=Le,t[117]=Re):Re=t[117];let ze;t[118]!==Fe||t[119]!==Re?(ze=(0,Z.jsxs)(`div`,{children:[Fe,Re]}),t[118]=Fe,t[119]=Re,t[120]=ze):ze=t[120];let Be;t[121]===c.costOutput?Be=t[122]:(Be=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Be);let Ve;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=ee(),t[123]=Ve):Ve=t[123];let Ge=u.cost?.output??0,Ke;t[124]===u.cost?Ke=t[125]:(Ke=e=>h(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[124]=u.cost,t[125]=Ke);let qe;t[126]!==Ge||t[127]!==Ke?(qe=(0,Z.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ve,value:Ge,onChange:Ke}),t[126]=Ge,t[127]=Ke,t[128]=qe):qe=t[128];let Je;t[129]!==Be||t[130]!==qe?(Je=(0,Z.jsxs)(`div`,{children:[Be,qe]}),t[129]=Be,t[130]=qe,t[131]=Je):Je=t[131];let Ye;t[132]!==ze||t[133]!==Je?(Ye=(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[ze,Je]}),t[132]=ze,t[133]=Je,t[134]=Ye):Ye=t[134];let Xe;t[135]!==Pe||t[136]!==Ye?(Xe=(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Pe,Ye]}),t[135]=Pe,t[136]=Ye,t[137]=Xe):Xe=t[137];let Ze;t[138]!==re||t[139]!==ce||t[140]!==ye||t[141]!==K||t[142]!==Xe?(Ze=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[re,ce,ye,K,Xe]}),t[138]=re,t[139]=ce,t[140]=ye,t[141]=K,t[142]=Xe,t[143]=Ze):Ze=t[143];let Qe;t[144]===c.cancel?Qe=t[145]:(Qe=(0,Z.jsx)(Me,{asChild:!0,children:(0,Z.jsx)(q,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=Qe);let $e=r?c.addModelConfirm:c.saveModelConfirm,et;t[146]!==y||t[147]!==$e?(et=(0,Z.jsx)(q,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:y,children:$e}),t[146]=y,t[147]=$e,t[148]=et):et=t[148];let tt;t[149]!==Qe||t[150]!==et?(tt=(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Qe,et]}),t[149]=Qe,t[150]=et,t[151]=tt):tt=t[151];let nt;return t[152]!==N||t[153]!==Ze||t[154]!==tt?(nt=(0,Z.jsxs)(Z.Fragment,{children:[N,Ze,tt]}),t[152]=N,t[153]=Ze,t[154]=tt,t[155]=nt):nt=t[155],nt}function or(){return new Map}function sr(e){let t=(0,Y.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:s,onSave:c,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(I,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,_e)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,A,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==s||t[3]!==l||t[4]!==a||t[5]!==r||t[6]!==c||t[7]!==n||t[8]!==i?(f=n?(0,Z.jsx)(ar,{model:a,isNew:s,providerId:i,onSave:c,onClose:()=>r(!1),m:l},`${i??`none`}-${a?.id??`new`}`):null,t[2]=s,t[3]=l,t[4]=a,t[5]=r,t[6]=c,t[7]=n,t[8]=i,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,Z.jsxs)(R,{children:[u,(0,Z.jsx)(h,{className:d,onOpenAutoFocus:cr,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,Z.jsx)(B,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function cr(e){return e.preventDefault()}function lr(e){let t=(0,Y.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>j(n).then(ur),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,Z.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,Z.jsx)(ye,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function ur(e){return e.apiKey??null}function dr(e){let t=(0,Y.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:s,customConfig:c,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(I,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,_e)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=o(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,A),t[1]=m):m=t[1];let g;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==a||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==i?(g=(0,Z.jsxs)(R,{children:[p,(0,Z.jsx)(h,{className:m,children:a?(0,Z.jsx)(pr,{providerId:i,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,Z.jsx)(fr,{providerId:i,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=a,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=i,t[11]=g):g=t[11];let _;return t[12]!==r||t[13]!==n||t[14]!==g?(_=(0,Z.jsx)(B,{open:n,onOpenChange:r,children:g}),t[12]=r,t[13]=n,t[14]=g,t[15]=_):_=t[15],_}function fr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:c,onSaved:l}){let u=t.find(t=>t.id===e),d=ue[e],f=n.filter(t=>t.provider===e),[p,m]=(0,X.useState)(u?.apiKey??``),[h,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),[D,O]=(0,X.useState)(!1),k=s(i).providersSettings,A=u?.supportsApiKey!==!1,j=u?.supportsOAuth===!0,M=u?.authMode===`oauth`&&u.authStatus===`connected`,N=u?.configured===!0&&u.activeKeySource!==`env`&&u.activeKeySource!==`extension`&&u.activeKeySource!==`models_json`,[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[R,z]=(0,X.useState)(`idle`),[B,V]=(0,X.useState)(null),[ee,ne]=(0,X.useState)(null),[re,ie]=(0,X.useState)(``),ae=R===`waiting`||R===`waiting_code`,oe=(0,X.useMemo)(()=>pe(e,i),[e,i]),se=p!==(u?.apiKey??``),ce=async()=>{let t=p.trim();if(!(!t||!A||T(t))){y(!0),C(null);try{await fe({[e]:t}),x(!0),window.setTimeout(()=>{l(),c()},600)}catch(e){C(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}};(0,X.useEffect)(()=>{if(!P||!ae)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Gn(P);t.status===`waiting_auth`||t.status===`waiting_code`?(z(t.status===`waiting_code`?`waiting_code`:`waiting`),L(t.message??null),V(t.authUrl??null),ne(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),z(`success`),L(t.message??k.saved),window.setTimeout(()=>{l(),c()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),z(`error`),L(t.error??t.message??k.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,ae,c,l,k.revokeFailed,k.saved]),(0,X.useEffect)(()=>()=>{P&&Jn(P).catch(()=>{})},[P]);let le=async()=>{try{await _(e),l(),c()}catch{}},de=async()=>{z(`waiting`),L(k.oauthStarting),C(null);try{F((await Wn(e)).sessionId)}catch(e){z(`error`),L(e instanceof Error?e.message:k.revokeFailed)}},U=async()=>{if(P){try{await qn(P)}catch{}z(`idle`),L(null),F(null),V(null),ne(null)}},he=async()=>{if(!(!P||!re.trim()))try{await Kn(P,re.trim()),ie(``),L(k.oauthProcessingCode)}catch(e){z(`error`),L(e instanceof Error?e.message:k.revokeFailed)}},ge=async()=>{try{await Yn(e),l(),c()}catch(e){C(e instanceof Error?e.message:k.revokeFailed)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsx)(te,{className:`text-base font-semibold text-fg`,children:u?.name??e}),(0,Z.jsx)(Me,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,W.press),children:(0,Z.jsx)(Ue,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[d?.description?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.description}):null,u?.baseUrl?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,Z.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:u.baseUrl})]}):u?.category===`extension`?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,A?(0,Z.jsx)(lr,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{m(e),x(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):u?.category===`extension`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:r.extensionKeyHint}),u?.extensionId?(0,Z.jsxs)(a,{to:`/settings/ext/${encodeURIComponent(u.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:c,children:[r.openExtensionSettings,(0,Z.jsx)(v,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,j?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:k.oauth}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:M?k.sourceOauth:k.oauthHint})]}),M?(0,Z.jsx)(q,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void ge(),children:k.revoke}):(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ae,onClick:()=>void de(),children:[ae?(0,Z.jsx)(H,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),k.oauth]})]}),I?(0,Z.jsx)(`p`,{className:o(`text-xs`,R===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:I}):null,R===`waiting`||R===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[B?(0,Z.jsxs)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0}),k.openAuthPage]}):null,(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>void U(),children:k.cancelOAuth})]}):null,ee?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ee}):null,R===`waiting_code`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`input`,{type:`text`,value:re,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&void he(),placeholder:k.pasteRedirectUrl,className:o(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,J)}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,onClick:()=>void he(),children:k.submitCode})]}):null]}):null,oe.length>0&&A?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:oe.map(({kind:e,href:t})=>(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[w(e,r),(0,Z.jsx)(v,{className:`size-3`,"aria-hidden":!0})]},e))}):null,f.length>0?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,f.length,`)`]}),(0,Z.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,Z.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),S?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>O(!0),children:[(0,Z.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,Z.jsx)(`span`,{}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:A&&se&&!T(p.trim())?(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:!p.trim()||h||b,onClick:()=>void ce(),children:b?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(me,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):h?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(H,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,Z.jsx)(Ce,{open:D,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,u?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void le(),onCancel:()=>O(!1)})]})}function pr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let c=s(r).modelsSettings,l=t?.providers[e],[u,d]=(0,X.useState)(l?.baseUrl??``),[f,p]=(0,X.useState)(l?.apiKey??``),[h,_]=(0,X.useState)(l?.models??[]),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),[w,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(null),j=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:T(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},M=async()=>{let e=j({models:h});if(e){y(!0),x(null);try{await m(e),a(),i()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{y(!1)}}},N=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await m({providers:r}),a(),i()}catch{}},P=(e,t)=>{A({model:e,isNew:t}),O(!0)},F=async e=>{if(!k)return;let t=k.isNew?[...h,e]:h.map(t=>t.id===e.id?e:t);_(t);let r=j({models:t});if(r)try{await m(r),a()}catch(e){x(e instanceof Error?e.message:n.saveError)}},I=async e=>{let t=h.filter(t=>t.id!==e);_(t),E(null);let r=j({models:t});if(r)try{await m(r),a()}catch(e){x(e instanceof Error?e.message:n.saveError)}};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(te,{className:`text-base font-semibold text-fg`,children:e}),(0,Z.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,Z.jsx)(Me,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,W.press),children:(0,Z.jsx)(Ue,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Z.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),className:o(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,J)})]}),(0,Z.jsx)(lr,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:p,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,Z.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,h.length>0?` (${h.length})`:``]}),(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>P(null,!0),children:[(0,Z.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),h.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,Z.jsx)(`ul`,{className:`space-y-2`,children:h.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,Z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,W.press),onClick:()=>P(e,!1),"aria-label":c.editModel,children:(0,Z.jsx)(be,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,W.press),onClick:()=>E(e.id),"aria-label":c.removeModel,children:(0,Z.jsx)(g,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),b?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>C(!0),children:[(0,Z.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(q,{type:`button`,variant:`primary`,disabled:v,onClick:()=>void M(),children:v?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(H,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,Z.jsx)(Ce,{open:S,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void N(),onCancel:()=>C(!1)}),(0,Z.jsx)(Ce,{open:w!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,w??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{w&&I(w)},onCancel:()=>E(null)}),(0,Z.jsx)(sr,{open:D,onOpenChange:e=>{O(e),e||A(null)},providerId:e,model:k?.model??null,isNew:k?.isNew??!1,onSave:e=>void F(e),m:c})]})}var mr=[`services`,`image-models`,`voice`,`search`];function hr(e){let t=(e??``).trim();return t===`providers`||t===`catalog`?`services`:mr.includes(t)?t:`services`}function gr(){let e=(0,Y.c)(59),t=u(vr),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,a=r.modelsHub,[o,c]=i(),l;e[2]===o?l=e[3]:(l=hr(o.get(`tab`)),e[2]=o,e[3]=l);let d=l,[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),g=Pn(),_;e[4]!==a.servicesHint||e[5]!==a.tabs.services?(_={id:`services`,icon:Oe,label:a.tabs.services,hint:a.servicesHint},e[4]=a.servicesHint,e[5]=a.tabs.services,e[6]=_):_=e[6];let v;e[7]!==a.imageModelsHint||e[8]!==a.tabs.imageModels?(v={id:`image-models`,icon:Re,label:a.tabs.imageModels,hint:a.imageModelsHint},e[7]=a.imageModelsHint,e[8]=a.tabs.imageModels,e[9]=v):v=e[9];let y;e[10]!==a.tabs.voice||e[11]!==a.voiceHint?(y={id:`voice`,icon:ke,label:a.tabs.voice,hint:a.voiceHint},e[10]=a.tabs.voice,e[11]=a.voiceHint,e[12]=y):y=e[12];let b;e[13]!==a.searchHint||e[14]!==a.tabs.search?(b={id:`search`,icon:Se,label:a.tabs.search,hint:a.searchHint},e[13]=a.searchHint,e[14]=a.tabs.search,e[15]=b):b=e[15];let x;e[16]!==_||e[17]!==v||e[18]!==y||e[19]!==b?(x=[_,v,y,b],e[16]=_,e[17]=v,e[18]=y,e[19]=b,e[20]=x):x=e[20];let S=x,C;e[21]===c?C=e[22]:(C=e=>{c(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=c,e[22]=C);let w=C,T=_r,E=r.settingsSections.credentials,D=a.subtitle,O;e[23]===t?O=e[24]:(O=Ge(t,`configuration`),e[23]=t,e[24]=O);let k;e[25]!==a.docsLink||e[26]!==a.subtitle||e[27]!==r.settingsSections.credentials||e[28]!==O?(k=(0,Z.jsx)(Ke,{title:E,subtitle:D,docsLink:O,docsLabel:a.docsLink}),e[25]=a.docsLink,e[26]=a.subtitle,e[27]=r.settingsSections.credentials,e[28]=O,e[29]=k):k=e[29];let A;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(ht,{}),e[30]=A):A=e[30];let j;e[31]!==d||e[32]!==a.tabsAria||e[33]!==w||e[34]!==S?(j=(0,Z.jsx)(pt,{items:S,activeTab:d,onChange:w,ariaLabel:a.tabsAria,tabIdPrefix:`hub-tab`,panelIdPrefix:`hub-panel`}),e[31]=d,e[32]=a.tabsAria,e[33]=w,e[34]=S,e[35]=j):j=e[35];let M;e[36]!==d||e[37]!==a.connectedProviders||e[38]!==S?(M=S.map(e=>(0,Z.jsx)(br,{id:e.id,activeTab:d,hint:e.hint,children:e.id===`services`?(0,Z.jsx)(Bn,{labels:a.connectedProviders,onAdd:()=>p(!0),onManage:(e,t)=>h({providerId:e,isCustom:t})}):(0,Z.jsx)(yr,{tab:e.id})},e.id)),e[36]=d,e[37]=a.connectedProviders,e[38]=S,e[39]=M):M=e[39];let N;e[40]!==f||e[41]!==a.addProviderDialog||e[42]!==t||e[43]!==g.builtinRows||e[44]!==g.customConfig?(N=(0,Z.jsx)(Qn,{open:f,onOpenChange:p,builtinRows:g.builtinRows,customConfig:g.customConfig,labels:a.addProviderDialog,language:t,onSaved:T}),e[40]=f,e[41]=a.addProviderDialog,e[42]=t,e[43]=g.builtinRows,e[44]=g.customConfig,e[45]=N):N=e[45];let P;e[46]!==a.manageProviderDialog||e[47]!==t||e[48]!==m||e[49]!==g.allModels||e[50]!==g.builtinRows||e[51]!==g.customConfig?(P=m?(0,Z.jsx)(dr,{open:!0,onOpenChange:e=>{e||h(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:g.builtinRows,customConfig:g.customConfig,allModels:g.allModels,labels:a.manageProviderDialog,language:t,onSaved:T}):null,e[46]=a.manageProviderDialog,e[47]=t,e[48]=m,e[49]=g.allModels,e[50]=g.builtinRows,e[51]=g.customConfig,e[52]=P):P=e[52];let F;return e[53]!==k||e[54]!==j||e[55]!==M||e[56]!==N||e[57]!==P?(F=(0,Z.jsxs)(qe,{children:[k,A,j,M,N,P]}),e[53]=k,e[54]=j,e[55]=M,e[56]=N,e[57]=P,e[58]=F):F=e[58],F}function _r(){k()}function vr(e){return e.language}function yr(e){let t=(0,Y.c)(3),{tab:n}=e;switch(n){case`services`:return null;case`image-models`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Nt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(on,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(jn,{}),t[2]=e):e=t[2],e}}}function br({id:e,activeTab:t,hint:n,children:r}){let i=e===t,a=(0,X.useRef)(i);return i&&(a.current=!0),a.current?(0,Z.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!i,className:o(`min-w-0 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,i?`flex flex-col gap-3`:void 0),children:[i?(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{gr as ModelsHubPanel};