pisper 0.6.3 → 0.6.4

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 (146) hide show
  1. package/README.en.md +0 -6
  2. package/README.md +0 -6
  3. package/bin/pisper.mjs +7 -15
  4. package/lib/install.mjs +9 -49
  5. package/lib/npm-platform.mjs +0 -12
  6. package/package.json +8 -9
  7. package/web/.vite/manifest.json +713 -737
  8. package/web/assets/AppDialog-BOGrPFbo.js +1 -0
  9. package/web/assets/{AppOverlays-CR5iJcP5.js → AppOverlays-D1vfPPIC.js} +1 -1
  10. package/web/assets/AppSelect-BCexz4Ty.js +1 -0
  11. package/web/assets/{AppShortcuts-BachmLQ3.js → AppShortcuts-Dd4gu7qz.js} +1 -1
  12. package/web/assets/{AssetsPage-BltehMID.js → AssetsPage-BPhPo5eU.js} +1 -1
  13. package/web/assets/ChannelsPage-Cu4v-GU2.js +1 -0
  14. package/web/assets/ChatAppearancePage-BLRQ7aH6.js +2 -0
  15. package/web/assets/ChatHistoryPage-BYqJFbY5.js +1 -0
  16. package/web/assets/ChatPage-tqAIj2Go.js +554 -0
  17. package/web/assets/ConfigPage-Z-BQwP2X.js +1 -0
  18. package/web/assets/{DecisionsPage-DOhLbIaD.js → DecisionsPage-Db6MIGD2.js} +1 -1
  19. package/web/assets/{DesktopWindowControls-KmgemDO8.js → DesktopWindowControls-CBYGv94u.js} +1 -1
  20. package/web/assets/{FloatingWidgets-Bs7ec6lW.js → FloatingWidgets-dzsQIxAO.js} +1 -1
  21. package/web/assets/{GitDiffViewer-xm2LnN9r.js → GitDiffViewer-m5aLB7Li.js} +1 -1
  22. package/web/assets/MarkdownMessage-CA9ODRKk.js +2 -0
  23. package/web/assets/McpPage-rerFxjYZ.js +1 -0
  24. package/web/assets/MemoryPage-cukfU824.js +1 -0
  25. package/web/assets/MobileContextScreen-W8V4H3Xv.js +2 -0
  26. package/web/assets/MobileNavigation-CEVgs1Ke.js +1 -0
  27. package/web/assets/MobileShellContext-D8qX-BlM.js +1 -0
  28. package/web/assets/{PageHeader-C_bfu8Ir.js → PageHeader-DIs9bESb.js} +1 -1
  29. package/web/assets/{PluginsPage-BPx5ERHL.js → PluginsPage-09Um3mY4.js} +1 -1
  30. package/web/assets/QueryClientProvider-CHJtxoX1.js +1 -0
  31. package/web/assets/{QuickPromptIdeas-Bs-udcSZ.js → QuickPromptIdeas-DGIL0nN7.js} +1 -1
  32. package/web/assets/SchedulesPage-C75QUeB5.js +1 -0
  33. package/web/assets/SessionContextPanel-oaKXyi7k.js +1 -0
  34. package/web/assets/{SessionFilesPane-BIRQ_hHi.js → SessionFilesPane-DPijesqH.js} +2 -2
  35. package/web/assets/{SidebarMoreTools-BDqt5VTG.js → SidebarMoreTools-D1nDS3i0.js} +1 -1
  36. package/web/assets/SidebarRecentSessions-a7z2ZvDv.js +2 -0
  37. package/web/assets/{SidebarSettingsButton-B4_vEBS5.js → SidebarSettingsButton-CRdV0Vft.js} +1 -1
  38. package/web/assets/{SidebarUpdateStatus-DD8f4Fxv.js → SidebarUpdateStatus-DgNJBwgT.js} +1 -1
  39. package/web/assets/SkillsPage-DLirgTyX.js +1 -0
  40. package/web/assets/TerminalPanel-CJPy4Qhs.js +18 -0
  41. package/web/assets/{ThemeToggleButton-CXXbLtcY.js → ThemeToggleButton-C5QA5Kf2.js} +1 -1
  42. package/web/assets/{WebDesktopPet-DWFspeZE.js → WebDesktopPet-DgyHLE9y.js} +1 -1
  43. package/web/assets/{WorkbenchSidebarToggle-AgjfcT29.js → WorkbenchSidebarToggle-CcO1Al5A.js} +1 -1
  44. package/web/assets/WorkflowsPage-DrKHzJvb.js +1 -0
  45. package/web/assets/WorkspacePicker-B3liZkwe.js +1 -0
  46. package/web/assets/{api-Dzobr-o_.js → api-YI8_cHpR.js} +1 -1
  47. package/web/assets/{app-primitives-BBXY6U2S.js → app-primitives-SxfoFmHc.js} +1 -1
  48. package/web/assets/app-update-Bg6w1SOW.js +32 -0
  49. package/web/assets/arrow-up-DST6-qVQ.js +1 -0
  50. package/web/assets/catalog-BPCnu3F8.js +1 -0
  51. package/web/assets/channels-messages-DgWnmzUo.js +1 -0
  52. package/web/assets/chat-api-CqF-FICX.js +1 -0
  53. package/web/assets/{client-store-DPMvgPNS.js → client-store-BP_3-plw.js} +1 -1
  54. package/web/assets/{component-api-Nwo2yGZI.js → component-api-CN9Tcn5p.js} +1 -1
  55. package/web/assets/config-search-DOIJENN1.js +1 -0
  56. package/web/assets/dist-B7rNRXig.js +1 -0
  57. package/web/assets/dist-C3P9WH0T.js +1 -0
  58. package/web/assets/dist-CXiO_DNx.js +1 -0
  59. package/web/assets/dist-D8Wfxh48.js +1 -0
  60. package/web/assets/{dropdown-menu-DmL4pJTo.js → dropdown-menu-pKRdLJUe.js} +1 -1
  61. package/web/assets/{events-Bwv6HmwM.js → events-KqdUtjsm.js} +1 -1
  62. package/web/assets/{floating-widgets-store-DIy4GSy4.js → floating-widgets-store-Pjm1AdvO.js} +2 -2
  63. package/web/assets/folder-DPM8D8cf.js +1 -0
  64. package/web/assets/house-BNrzTkx9.js +1 -0
  65. package/web/assets/{http-DphgzWtw.js → http-Be2GB6DH.js} +1 -1
  66. package/web/assets/i18n-8nTnthu6.js +1 -0
  67. package/web/assets/{index-iBrSU61i.js → index-AF29hfx9.js} +2 -2
  68. package/web/assets/index-BAmsg90v.css +2 -0
  69. package/web/assets/monitor-ORxecA9m.js +1 -0
  70. package/web/assets/mount-app-WW5hteuX.js +9 -0
  71. package/web/assets/panels-top-left-BlZftvhg.js +1 -0
  72. package/web/assets/pick-system-directory-BnIFt85A.js +1 -0
  73. package/web/assets/{popover-BBuzaBfd.js → popover-CQqAaq-c.js} +1 -1
  74. package/web/assets/public-c36e4881.js +1 -0
  75. package/web/assets/public-components-C4ndcOCF.js +1 -0
  76. package/web/assets/{runtime-capabilities-store-DaWPY5y-.js → runtime-capabilities-store-CiL3ZPEo.js} +1 -1
  77. package/web/assets/scale-D0LcHVmf.js +1 -0
  78. package/web/assets/{session-change-summary-api-DFgTzTci.js → session-change-summary-api--7cl4LDn.js} +1 -1
  79. package/web/assets/session-context-store-DJnHgWwb.js +1 -0
  80. package/web/assets/session-list-DkNhT87s.js +1 -0
  81. package/web/assets/settings-navigation-CI7Yt4Or.js +1 -0
  82. package/web/assets/{shortcuts-BO-h6OmP.js → shortcuts-C_Cph88H.js} +1 -1
  83. package/web/assets/side-chat-context-Dn8w9ut8.js +3 -0
  84. package/web/assets/{sidebar-CfWEKOIK.js → sidebar-C3YJQV72.js} +1 -1
  85. package/web/assets/{speech-session-DKjw0mV_.js → speech-session-CoUr4n9Q.js} +1 -1
  86. package/web/assets/{startup-queries-CAQZvUIR.js → startup-queries-ByepQfGF.js} +1 -1
  87. package/web/assets/tabs-B60r4YwO.js +1 -0
  88. package/web/assets/{ui-store-2wpnH8Kf.js → ui-store-BGs-dEVz.js} +1 -1
  89. package/web/assets/{use-i18n-BSZKFkMb.js → use-i18n-a84Zp9dV.js} +1 -1
  90. package/web/assets/{useCustomUiComponents-BH86kuaq.js → useCustomUiComponents-BaQ_fwbr.js} +1 -1
  91. package/web/assets/useQuery-D3P5wO_Z.js +1 -0
  92. package/web/assets/web-preview-B7L-G6kp.js +1 -0
  93. package/web/assets/web-preview-events-C4AW4-It.js +1 -0
  94. package/web/index.html +2 -2
  95. package/web/assets/AppSelect-D149YYg1.js +0 -1
  96. package/web/assets/ChannelsPage-Tuw_qicj.js +0 -1
  97. package/web/assets/ChatAppearancePage-DME3PgDr.js +0 -2
  98. package/web/assets/ChatDockView-DoGtrBpY.js +0 -2
  99. package/web/assets/ChatHistoryPage-DTXS6i3n.js +0 -1
  100. package/web/assets/ChatPage-ibc_7olm.js +0 -4
  101. package/web/assets/ConfigPage-CI6one5Y.js +0 -1
  102. package/web/assets/MarkdownMessage-H1336cMr.js +0 -2
  103. package/web/assets/McpPage-Ck-7aLuZ.js +0 -1
  104. package/web/assets/MemoryPage-BEdNJ3ot.js +0 -1
  105. package/web/assets/MobileContextScreen-Dasny2J9.js +0 -2
  106. package/web/assets/MobileThreePane-DEKMHPfN.js +0 -1
  107. package/web/assets/SchedulesPage-W4Mg7frl.js +0 -1
  108. package/web/assets/SessionContextPanel-lu9F9AJg.js +0 -1
  109. package/web/assets/SidebarRecentSessions-1G_huYu9.js +0 -1
  110. package/web/assets/SkillsPage-CpRRosmo.js +0 -1
  111. package/web/assets/TerminalPanel-DVKC4htc.js +0 -18
  112. package/web/assets/Threads-B8ij_QtI.js +0 -1
  113. package/web/assets/WorkflowsPage-bhQlHSzS.js +0 -1
  114. package/web/assets/app-update-DppJNspd.js +0 -32
  115. package/web/assets/arrow-right-DqLOhpA2.js +0 -1
  116. package/web/assets/catalog-D4eaIju4.js +0 -1
  117. package/web/assets/channels-messages-CeRKS_DE.js +0 -1
  118. package/web/assets/chat-api-DfnvubiW.js +0 -1
  119. package/web/assets/chevron-left-BAtyp3_6.js +0 -1
  120. package/web/assets/config-search-CwVhh2uc.js +0 -1
  121. package/web/assets/dist-DAs5KRGl.js +0 -1
  122. package/web/assets/dist-swnK7PHk.js +0 -1
  123. package/web/assets/i18n-7QvbQzOQ.js +0 -1
  124. package/web/assets/index-CdASiNlI.css +0 -2
  125. package/web/assets/local-path-reveal-DWhkyox-.js +0 -1
  126. package/web/assets/mobile-shell-layout-CMpTmYRX.js +0 -1
  127. package/web/assets/mount-app-n_05p6iW.js +0 -9
  128. package/web/assets/panel-left-C_lYsiIA.js +0 -1
  129. package/web/assets/panel-right-BSUtqUd8.js +0 -1
  130. package/web/assets/pick-system-directory-R1F5WyaB.js +0 -1
  131. package/web/assets/pin-Dc2zE4cS.js +0 -1
  132. package/web/assets/public-BcTP7F3I.js +0 -1
  133. package/web/assets/public-components-Ck5BYo6M.js +0 -1
  134. package/web/assets/session-list-CMaoK_ZX.js +0 -1
  135. package/web/assets/session-streaming-state-llCTupbI.js +0 -3
  136. package/web/assets/side-chat-context-Dr2QLUJA.js +0 -1
  137. package/web/assets/tabs-DQYVDdOp.js +0 -1
  138. package/web/assets/use-animation-visibility-_Xe7jeUy.js +0 -1
  139. package/web/assets/useQuery-DdcpUQhO.js +0 -1
  140. package/web/assets/vendor-dockview-Bf3Gg83W.js +0 -1
  141. package/web/assets/vendor-dockview-D5adAaCg.css +0 -1
  142. package/web/assets/web-preview-BPNd1LUd.js +0 -1
  143. package/web/assets/web-preview-CQbpHjt1.js +0 -1
  144. package/web/assets/web-preview-events-o845ErdA.js +0 -1
  145. package/web/assets/web-preview-panel-DVQxVfig.js +0 -552
  146. package/web/assets/workflow-Bg94dy8I.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{s as t}from"./vendor-router-CZg2bCPV.js";import{t as n}from"./index-AF29hfx9.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{n as a,s as o,u as s}from"./i18n-8nTnthu6.js";import{t as c}from"./use-i18n-a84Zp9dV.js";import{t as l}from"./storage-BpAqa-YY.js";import{i as u}from"./dist-Cfh4kzCK.js";import{c as d,i as f,o as p,s as m}from"./dist-B_a0oV4U.js";import{i as h}from"./dist-B7rNRXig.js";import{n as g,r as _,t as v}from"./collapsible-C__hRcbA.js";import{t as y}from"./dist-C3P9WH0T.js";import{t as b}from"./dist-TksYpDID.js";import{a as x,n as S,r as C,t as w}from"./dropdown-menu-pKRdLJUe.js";import{t as T}from"./label-BzlNatZM.js";import{n as E,t as D}from"./AppSelect-BCexz4Ty.js";import{t as O}from"./dist-D8Wfxh48.js";import{t as k}from"./separator-BDICnhEL.js";import{n as A}from"./switch-Ci_hmu39.js";import{t as j}from"./utils-C8uzG5AZ.js";import{t as M}from"./createLucideIcon-Cd-3GVxJ.js";import{t as N}from"./arrow-left-B8oVrQ2S.js";import{a as P,i as F,t as ee}from"./config-search-DOIJENN1.js";import{i as te,n as ne,r as re,t as ie}from"./zap-3wDb3GcJ.js";import{t as I}from"./bell-BjONAtgH.js";import{t as ae}from"./bot-B3TaBp_T.js";import{i as oe,n as L,r as se,t as ce}from"./scale-D0LcHVmf.js";import{t as R}from"./check-2vYc6QaP.js";import{t as le}from"./chevron-down-CxtxIjiP.js";import{t as ue}from"./circle-alert-DCChabnT.js";import{t as de}from"./circle-check-iEdCm3Pw.js";import{t as fe}from"./clock-3-CBHGbD_G.js";import{t as pe}from"./code-xml-BrUXrBax.js";import{t as me}from"./copy-DHmIFc52.js";import{t as he}from"./download-BCfIiuaL.js";import{t as ge}from"./earth-Ddy13fHh.js";import{t as _e}from"./ellipsis-CfGKfbq6.js";import{t as ve}from"./external-link-CEQqPcqc.js";import{t as ye}from"./flask-conical-DhW5v7Zz.js";import{t as be}from"./image-BY_c3FYU.js";import{t as xe}from"./loader-circle-BOwQzHB-.js";import{t as Se}from"./message-square-SKjZyY3v.js";import{n as Ce,r as we,t as Te}from"./sun-DBWBo3We.js";import{t as Ee}from"./plus-fQbSqB1n.js";import{t as z}from"./refresh-cw-TbWxTY4K.js";import{t as De}from"./rocket-BgLSjoHY.js";import{t as Oe}from"./rotate-ccw-C0v8V77_.js";import{t as ke}from"./save-CHBB52P8.js";import{t as Ae}from"./search-D0mqDaf_.js";import{t as je}from"./send-Cj-W03w_.js";import{t as B}from"./server-BgNvmqwJ.js";import{t as Me}from"./shield-check-Gvek4RJ7.js";import{t as Ne}from"./sliders-horizontal-Dryf1XyC.js";import{t as Pe}from"./sparkles-S_eeuqn9.js";import{t as Fe}from"./square-terminal-BVG6cUT1.js";import{t as Ie}from"./trash-2-CNrPOoPR.js";import{t as V}from"./triangle-alert-CE1q54ci.js";import{t as Le}from"./wand-sparkles-DdQneChm.js";import{t as Re}from"./wrench-6pg6_bqI.js";import{t as ze}from"./x-07u4-129.js";import{t as H}from"./api-YI8_cHpR.js";import{t as U}from"./button-CQA36izu.js";import{a as Be,i as Ve,o as He,r as Ue,s as We,t as Ge}from"./dialog-D-ER2p-D.js";import{t as Ke}from"./input-CvjGYteF.js";import{t as W}from"./field-3bN8nouy.js";import{r as qe}from"./format-BRFKAYMT.js";import{a as Je,i as Ye,l as Xe,n as Ze,o as Qe,r as $e,s as et,t as tt}from"./app-primitives-SxfoFmHc.js";import{a as nt,c as rt,d as it,l as at,s as ot,t as st,u as ct}from"./shortcuts-C_Cph88H.js";import{r as G,t as lt}from"./ui-store-BGs-dEVz.js";import{t as ut}from"./usePagePrimaryAction-CWPC0C_f.js";import{t as dt}from"./MarkdownMessage-CA9ODRKk.js";import{t as ft}from"./brand-DIEc3fK8.js";import{a as pt,c as mt,i as ht,o as gt,r as _t}from"./app-update-Bg6w1SOW.js";import{i as vt,n as yt,r as bt,t as xt}from"./browser-notifications-DBS0oXqN.js";var K=e(r(),1),q=i(),St=Object.defineProperty,J=(e,t)=>St(e,`name`,{value:t,configurable:!0}),Ct=[`PageUp`,`PageDown`],wt=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Tt={"from-left":[`Home`,`PageDown`,`ArrowDown`,`ArrowLeft`],"from-right":[`Home`,`PageDown`,`ArrowDown`,`ArrowRight`],"from-bottom":[`Home`,`PageDown`,`ArrowDown`,`ArrowLeft`],"from-top":[`Home`,`PageDown`,`ArrowUp`,`ArrowLeft`]},Et=`Slider`,[Dt,Ot,kt]=h(Et),[At,jt]=m(Et,[kt]),[Mt,Nt]=At(Et),Pt=K.forwardRef(J(function(e,t){let{name:n,min:r=0,max:i=100,step:a=1,orientation:o=`horizontal`,disabled:s=!1,minStepsBetweenThumbs:c=0,defaultValue:l=[r],value:d,onValueChange:m=J(()=>{},`onValueChange`),onValueCommit:h=J(()=>{},`onValueCommit`),inverted:g=!1,form:_,...v}=e,y=K.useRef(new Set),b=K.useRef(0),x=K.useRef(!1),S=o===`horizontal`?Lt:Rt,[C,w]=K.useState(null),T=u(t,w),[E=[],D]=f({prop:d,defaultProp:l,onChange:J(e=>{[...y.current][b.current]?.focus({preventScroll:!0,focusVisible:x.current}),x.current=!1,m(e)},`onChange`)}),k=K.useRef(E),A=K.useRef(E);K.useEffect(()=>{let e=_?C?.ownerDocument.getElementById(_):C?.closest(`form`);if(e instanceof HTMLFormElement){let t=J(()=>D(A.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[C,_,D]);function j(e){P(e,nn(E,e))}J(j,`handleSlideStart`);function M(e){P(e,b.current)}J(M,`handleSlideMove`);function N(){String(E)!==String(k.current)&&h(E)}J(N,`handleSlideEnd`);function P(e,t,{commit:n}={commit:!1}){let o=cn(a),s=ln(Math.round((e-r)/a)*a+r,o),l=O(s,[r,i]);D((e=[])=>{let r=$t(e,l,t);if(on(r,c*a)){b.current=r.indexOf(l);let t=String(r)!==String(e);return t&&n&&h(r),t?r:e}return e})}return J(P,`updateValues`),(0,q.jsx)(Mt,{scope:e.__scopeSlider,name:n,disabled:s,min:r,max:i,valueIndexToChangeRef:b,thumbs:y.current,values:E,orientation:o,form:_,children:(0,q.jsx)(Dt.Provider,{scope:e.__scopeSlider,children:(0,q.jsx)(Dt.Slot,{scope:e.__scopeSlider,children:(0,q.jsx)(S,{"aria-disabled":s,"data-disabled":s?``:void 0,...v,ref:T,onPointerDown:p(v.onPointerDown,()=>{s||(k.current=E,x.current=!1)}),min:r,max:i,inverted:g,onSlideStart:s?void 0:j,onSlideMove:s?void 0:M,onSlideEnd:s?void 0:N,onHomeKeyDown:()=>{s||(x.current=!0,P(r,0,{commit:!0}))},onEndKeyDown:()=>{s||(x.current=!0,P(i,E.length-1,{commit:!0}))},onStepKeyDown:({event:e,direction:t})=>{if(!s){x.current=!0;let n=Ct.includes(e.key)||e.shiftKey&&wt.includes(e.key)?10:1,i=b.current,o=E[i];P(un(o,{min:r,step:a,direction:t,multiplier:n}),i,{commit:!0})}}})})})})},`Slider`)),[Ft,It]=At(Et,{startEdge:`left`,endEdge:`right`,size:`width`,direction:1}),Lt=K.forwardRef(J(function(e,t){let{min:n,max:r,dir:i,inverted:a,onSlideStart:o,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...d}=e,[f,p]=K.useState(null),m=u(t,p),h=K.useRef(void 0),g=y(i),_=g===`ltr`,v=_&&!a||!_&&a;function b(e){let t=h.current||f.getBoundingClientRect(),i=sn([0,t.width],v?[n,r]:[r,n]);return h.current=t,i(e-t.left)}return J(b,`getValueFromPointer`),(0,q.jsx)(Ft,{scope:e.__scopeSlider,startEdge:v?`left`:`right`,endEdge:v?`right`:`left`,direction:v?1:-1,size:`width`,children:(0,q.jsx)(zt,{dir:g,"data-orientation":`horizontal`,...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":`translateX(-50%)`},onSlideStart:e=>{let t=b(e.clientX);o?.(t)},onSlideMove:e=>{let t=b(e.clientX);s?.(t)},onSlideEnd:()=>{h.current=void 0,c?.()},onStepKeyDown:e=>{let t=Tt[v?`from-left`:`from-right`].includes(e.key);l?.({event:e,direction:t?-1:1})}})})},`SliderHorizontal`)),Rt=K.forwardRef(J(function(e,t){let{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:s,onStepKeyDown:c,...l}=e,d=K.useRef(null),f=u(t,d),p=K.useRef(void 0),m=!i;function h(e){let t=p.current||d.current.getBoundingClientRect(),i=sn([0,t.height],m?[r,n]:[n,r]);return p.current=t,i(e-t.top)}return J(h,`getValueFromPointer`),(0,q.jsx)(Ft,{scope:e.__scopeSlider,startEdge:m?`bottom`:`top`,endEdge:m?`top`:`bottom`,size:`height`,direction:m?1:-1,children:(0,q.jsx)(zt,{"data-orientation":`vertical`,...l,ref:f,style:{...l.style,"--radix-slider-thumb-transform":`translateY(50%)`},onSlideStart:e=>{let t=h(e.clientY);a?.(t)},onSlideMove:e=>{let t=h(e.clientY);o?.(t)},onSlideEnd:()=>{p.current=void 0,s?.()},onStepKeyDown:e=>{let t=Tt[m?`from-bottom`:`from-top`].includes(e.key);c?.({event:e,direction:t?-1:1})}})})},`SliderVertical`)),zt=K.forwardRef(J(function(e,t){let{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:s,onStepKeyDown:c,...l}=e,u=Nt(Et,n);return(0,q.jsx)(d.span,{...l,ref:t,onKeyDown:p(e.onKeyDown,e=>{e.key===`Home`?(o(e),e.preventDefault()):e.key===`End`?(s(e),e.preventDefault()):Ct.concat(wt).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:p(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),u.thumbs.has(t)?t.focus({preventScroll:!0,focusVisible:!1}):r(e)}),onPointerMove:p(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:p(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),a(e))})})},`SliderImpl`)),Bt=`SliderTrack`,Vt=K.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=Nt(Bt,n);return(0,q.jsx)(d.span,{"data-disabled":i.disabled?``:void 0,"data-orientation":i.orientation,...r,ref:t})},`SliderTrack`)),Ht=`SliderRange`,Ut=K.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=Nt(Ht,n),a=It(Ht,n),o=K.useRef(null),s=u(t,o),c=i.values.length,l=i.values.map(e=>en(e,i.min,i.max)),f=c>1?Math.min(...l):0,p=100-Math.max(...l);return(0,q.jsx)(d.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?``:void 0,...r,ref:s,style:{...e.style,[a.startEdge]:f+`%`,[a.endEdge]:p+`%`}})},`SliderRange`)),[Wt,Gt]=At(`SliderThumb`),Kt=`SliderThumbProvider`;function qt(e){let{__scopeSlider:t,name:n,children:r,internal_do_not_use_render:i}=e,a=Nt(Kt,t),o=Ot(t),[s,c]=K.useState(null),l=K.useMemo(()=>s?o().findIndex(e=>e.ref.current===s):-1,[o,s]),u=b(s),d=!s||!!a.form||!!s.closest(`form`),f=a.values[l],p=n??(a.name?a.name+(a.values.length>1?`[]`:``):void 0),m=f===void 0?0:en(f,a.min,a.max);K.useEffect(()=>{if(s)return a.thumbs.add(s),()=>{a.thumbs.delete(s)}},[s,a.thumbs]);let h={value:f,name:p,form:a.form,isFormControl:d,index:l,thumb:s,onThumbChange:c,percent:m,size:u};return(0,q.jsx)(Wt,{scope:t,...h,children:dn(i)?i(h):r})}J(qt,`SliderThumbProvider`);var Jt=`SliderThumbTrigger`,Yt=K.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=Nt(Jt,n),a=It(Jt,n),{index:o,value:s,percent:c,size:l,onThumbChange:f}=Gt(Jt,n),m=u(t,f),h=tn(o,i.values.length),g=l?.[a.size],_=g?rn(g,c,a.direction):0;return(0,q.jsx)(`span`,{style:{transform:`var(--radix-slider-thumb-transform)`,position:`absolute`,[a.startEdge]:`calc(${c}% + ${_}px)`},children:(0,q.jsx)(Dt.ItemSlot,{scope:n,children:(0,q.jsx)(d.span,{role:`slider`,"aria-label":e[`aria-label`]||h,"aria-valuemin":i.min,"aria-valuenow":s,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?``:void 0,tabIndex:i.disabled?void 0:0,...r,ref:m,style:s===void 0?{display:`none`}:e.style,onFocus:p(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})})})},`SliderThumbTrigger`)),Xt=K.forwardRef(J(function(e,t){let{__scopeSlider:n,name:r,...i}=e;return(0,q.jsx)(qt,{__scopeSlider:n,name:r,internal_do_not_use_render:({index:e,isFormControl:r})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Yt,{...i,ref:t,__scopeSlider:n}),r?(0,q.jsx)(Qt,{__scopeSlider:n},e):null]})})},`SliderThumb`)),Zt=`SliderBubbleInput`,Qt=K.forwardRef(J(function({__scopeSlider:e,...t},n){let{value:r,name:i,form:a}=Gt(Zt,e),o=K.useRef(null),s=u(o,n),c=E(r);return K.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(c!==r&&n){let t=new Event(`input`,{bubbles:!0});n.call(e,r),e.dispatchEvent(t)}},[c,r]),(0,q.jsx)(d.input,{style:{display:`none`},name:i,form:a,...t,ref:s,defaultValue:r})},`SliderBubbleInput`));function $t(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}J($t,`getNextSortedValues`);function en(e,t,n){let r=100/(n-t)*(e-t);return O(r,[0,100])}J(en,`convertValueToPercentage`);function tn(e,t){if(t>2)return`Value ${e+1} of ${t}`;if(t===2)return[`Minimum`,`Maximum`][e]}J(tn,`getLabel`);function nn(e,t){if(e.length===1)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}J(nn,`getClosestValueIndex`);function rn(e,t,n){let r=e/2;return(r-sn([0,50],[0,r])(t)*n)*n}J(rn,`getThumbInBoundsOffset`);function an(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}J(an,`getStepsBetweenValues`);function on(e,t){if(t>0){let n=an(e);return Math.min(...n)>=t}return!0}J(on,`hasMinStepsBetweenValues`);function sn(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}J(sn,`linearScale`);function cn(e){if(!Number.isFinite(e))return 0;let t=e.toString();if(t.includes(`e`)){let[e,n]=t.split(`e`),r=e.split(`.`)[1]||``,i=Number(n);return Math.max(0,r.length-i)}let n=t.split(`.`)[1];return n?n.length:0}J(cn,`getDecimalCount`);function ln(e,t){let n=10**t;return Math.round(e*n)/n}J(ln,`roundValue`);function un(e,{min:t,step:n,direction:r,multiplier:i}){let a=cn(n),o=(e-t)/n,s=Math.round(o),c=ln(s*n+t,a)===ln(e,a),l;return l=c?s+i*r:r>0?Math.ceil(o):Math.floor(o),ln(l*n+t,a)}J(un,`getNextStepValue`);function dn(e){return typeof e==`function`}J(dn,`isFunction`);var fn=M(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),pn=M(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),mn=M(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),hn=M(`cat`,[[`path`,{d:`M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z`,key:`x6xyqk`}],[`path`,{d:`M8 14v.5`,key:`1nzgdb`}],[`path`,{d:`M16 14v.5`,key:`1lajdz`}],[`path`,{d:`M11.25 16.25h1.5L12 17l-.75-.75Z`,key:`12kq1m`}]]),gn=M(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),_n=M(`fold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3-3-3 3`,key:`e37ymu`}],[`path`,{d:`m15 5-3 3-3-3`,key:`19d6lf`}]]),vn=M(`handshake`,[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]),yn=M(`languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),bn=M(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),xn=M(`package-check`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m16 17 2 2 4-4`,key:`uh5qu3`}],[`path`,{d:`M21 11.127V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.32-.753`,key:`kpkbpo`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),Sn=M(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Cn=M(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),wn=M(`radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),Tn=M(`scan-line`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]),En=M(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Dn=M(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),On=M(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),kn=M(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),An=M(`unfold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m15 5-3-3-3 3`,key:`itvq4r`}]]);function jn(e,t){if(typeof window>`u`||!window.__PISPER_MOBILE_APP__)return null;e.preventDefault();let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(`mobile_open_external_url`,{url:t}):Promise.reject(Error(`移动端原生桥不可用。`))}var Y=tt,Mn=Qe,X=Xe;function Nn(e){return(0,q.jsx)(et,{density:`compact`,...e})}var Pn=`0.5.62`,Fn=`https://ling-kong-ran.github.io/pisper/`,In=`https://github.com/ling-kong-ran/pisper`,Ln=`${In}/blob/release/LICENSE`;function Rn({href:e,icon:t,label:n,value:r,onClick:i}){return(0,q.jsxs)(`a`,{className:`group grid min-h-14 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 py-3 text-left no-underline`,href:e,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,q.jsx)(`span`,{className:`grid size-8 place-items-center rounded-[var(--r-xs)] bg-[var(--surface-muted)] text-[var(--text-muted)] transition-colors group-hover:text-[var(--star-strong)]`,children:(0,q.jsx)(t,{size:16})}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`strong`,{className:`block text-[13px] text-[var(--text)]`,children:n}),(0,q.jsx)(`small`,{className:`mt-0.5 block truncate text-[12px] text-[var(--text-muted)]`,children:r})]}),(0,q.jsx)(ve,{className:`text-[var(--text-muted)] transition-colors group-hover:text-[var(--star-strong)]`,size:14})]})}function zn({update:e,notify:t}){let{t:n}=c(),r=e.info?.version||Pn,i=e=>{jn(e,e.currentTarget.href)?.catch(()=>t(n(`config:aboutSettings.openLinkFailed`),`error`))};return(0,q.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-4 px-1 py-3`,children:[(0,q.jsx)(`img`,{className:`size-16 shrink-0 rounded-[14px] shadow-[0_10px_28px_-14px_var(--shadow)]`,src:`/favicon.svg`,alt:`Pisper`}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h1`,{className:`text-[22px] font-bold tracking-[0]`,children:`Pisper`}),(0,q.jsxs)(X,{tone:`gray`,children:[`v`,r]})]}),(0,q.jsx)(`p`,{className:`mt-1 text-[13px] leading-5 text-[var(--text-muted)]`,children:n(`config:aboutSettings.description`)})]})]}),(0,q.jsxs)(Y,{className:`p-5`,"data-config-card":`about-project`,children:[(0,q.jsx)(Mn,{title:n(`config:aboutSettings.projectInformation`)}),(0,q.jsxs)(`div`,{className:`mt-3 divide-y divide-[var(--stroke-soft)] border-y border-[var(--stroke-soft)]`,children:[(0,q.jsx)(Rn,{href:Fn,icon:ge,label:n(`config:aboutSettings.website`),value:`ling-kong-ran.github.io/pisper`,onClick:i}),(0,q.jsx)(Rn,{href:In,icon:pe,label:n(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`,onClick:i}),(0,q.jsx)(Rn,{href:Ln,icon:ce,label:n(`config:aboutSettings.license`),value:`MIT License`,onClick:i})]})]}),(0,q.jsx)(Y,{className:`p-5`,"data-config-card":`about-support`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(Mn,{title:n(`config:aboutSettings.supportPisper`)}),(0,q.jsx)(`p`,{className:`mt-1 max-w-[520px] text-[13px] leading-5 text-[var(--text-muted)]`,children:n(`config:aboutSettings.supportDescription`)})]}),(0,q.jsx)(U,{asChild:!0,size:`lg`,className:`max-[540px]:w-full`,children:(0,q.jsxs)(`a`,{href:In,target:`_blank`,rel:`noopener noreferrer`,"data-web-preview":`external`,onClick:i,children:[(0,q.jsx)(Dn,{size:15}),n(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,q.jsx)(`p`,{className:`px-1 py-2 text-center text-[12px] text-[var(--text-muted)]`,children:n(`config:aboutSettings.copyright`)})]})}function Bn({className:e,defaultValue:t,value:n,min:r=0,max:i=100,...a}){let o=K.useMemo(()=>Array.isArray(n)?n:Array.isArray(t)?t:[r,i],[n,t,r,i]);return(0,q.jsxs)(Pt,{"data-slot":`slider`,defaultValue:t,value:n,min:r,max:i,className:j(`relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col`,e),...a,children:[(0,q.jsx)(Vt,{"data-slot":`slider-track`,className:`relative grow overflow-hidden rounded-full bg-muted data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1`,children:(0,q.jsx)(Ut,{"data-slot":`slider-range`,className:`absolute bg-primary select-none data-horizontal:h-full data-vertical:w-full`})}),Array.from({length:o.length},(e,t)=>(0,q.jsx)(Xt,{"data-slot":`slider-thumb`,className:`relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50`},t))]})}function Vn(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function Hn({notify:e,requestConfirm:t}){let{t:n}=c(),r=window.pisperDesktop,i=(0,K.useMemo)(()=>r?.getPetStatus?{getStatus:()=>r.getPetStatus(),setEnabled:e=>r.setPetEnabled(e),setOpacity:e=>r.setPetOpacity(e),search:e=>r.searchPets(e),install:e=>r.installPet(e),select:e=>r.selectPet(e),remove:e=>r.removePet(e),openCatalog:()=>void r.openPetdex?.()}:{getStatus:()=>H(`/api/desktop-pet`),setEnabled:e=>H(`/api/desktop-pet/enabled`,{method:`POST`,body:{enabled:e}}),setOpacity:e=>H(`/api/desktop-pet/opacity`,{method:`POST`,body:{opacity:e}}),search:e=>H(`/api/desktop-pet/catalog?query=${encodeURIComponent(e)}`),install:e=>H(`/api/desktop-pet/install`,{method:`POST`,body:{slug:e}}),select:e=>H(`/api/desktop-pet/select`,{method:`POST`,body:{slug:e}}),remove:e=>H(`/api/desktop-pet/${encodeURIComponent(e)}`,{method:`DELETE`}),openCatalog:()=>window.open(`https://petdex.dev`,`_blank`,`noopener,noreferrer`)},[r]),[a,o]=(0,K.useState)(null),[s,l]=(0,K.useState)(``),[u,d]=(0,K.useState)([]),[f,p]=(0,K.useState)(100),[m,h]=(0,K.useState)(``),[g,_]=(0,K.useState)(``),v=(0,K.useCallback)(e=>{o(e),p(Math.round((e.opacity??1)*100))},[]),y=(0,K.useCallback)(async()=>{try{_(``),v(await i.getStatus())}catch(e){_(e instanceof Error?e.message:String(e))}},[v,i]),b=(0,K.useCallback)(async()=>{h(`search`);try{_(``),d(await i.search(s))}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(``)}},[i,s]);(0,K.useEffect)(()=>{y(),i.search(``).then(d).catch(()=>{})},[i,y]);let x=async t=>{let r=a;o(e=>e&&{...e,enabled:t,running:!!(t&&e.installed.length)}),h(`toggle`);try{_(``);let r=await i.setEnabled(t);v(r),Vn(r),e(n(t?`config:desktopPetSettings.petEnabled`:`config:desktopPetSettings.petDisabled`))}catch(e){o(r),_(e instanceof Error?e.message:String(e))}finally{h(``)}},S=async e=>{h(`opacity`);try{_(``);let t=await i.setOpacity(e);v(t),Vn(t)}catch(e){p(Math.round((a?.opacity??1)*100)),_(e instanceof Error?e.message:String(e))}finally{h(``)}},C=async(t=s)=>{if(t.trim()){h(`install`);try{_(``);let r=await i.install(t);v(r),Vn(r),e(n(`config:desktopPetSettings.petInstalled`,{name:r.selectedName||t}))}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(``)}}},w=async t=>{if(t!==a?.selectedSlug){h(`select:${t}`);try{_(``);let r=await i.select(t);v(r),Vn(r),e(n(`config:desktopPetSettings.petSelected`,{name:r.selectedName||t}))}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(``)}}},T=async r=>{if(await t({title:n(`config:desktopPetSettings.deleteTitle`),message:n(`config:desktopPetSettings.deleteConfirm`,{name:r.name}),confirmLabel:n(`config:desktopPetSettings.delete`),tone:`danger`})){h(`remove:${r.slug}`);try{_(``);let t=await i.remove(r.slug);v(t),Vn(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(``)}}};return(0,q.jsxs)(`div`,{className:`flex flex-col gap-[12px] desktop-pet-settings`,children:[(0,q.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-settings`,children:[(0,q.jsxs)(`div`,{className:`language-settings-heading flex items-start gap-[11px] [&_h2]:text-[16px] [&_p]:mt-[4px] [&_p]:text-[var(--text-muted)] [&_p]:text-[13px] [&_p]:leading-[1.55]`,children:[(0,q.jsx)(`span`,{className:`grid w-[38px] h-[38px] [flex:0_0_auto] place-items-center rounded-[11px] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(hn,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{children:n(`config:desktopPetSettings.title`)}),(0,q.jsx)(`p`,{children:n(`config:desktopPetSettings.description`)})]})]}),a?(0,q.jsxs)(`div`,{className:`max-w-1/2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center snotification-option [&_>_div]:flex [&_>_div]:min-w-0 [&_>_div]:flex-col [&_>_div]:gap-1 gap-2.75 mt-4`,children:[(0,q.jsx)(hn,{size:18}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`font-bold`,children:n(`config:desktopPetSettings.showOnDesktop`)}),` `,(0,q.jsx)(X,{tone:a.running?`green`:`gray`,children:a.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)})]}),(0,q.jsx)(`span`,{className:`text-xs`,children:a.selectedName?n(`config:desktopPetSettings.currentPet`,{name:a.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`)})]}),(0,q.jsx)(Nn,{value:a.enabled,disabled:!!m||!a.installed.length,onChange:x,ariaLabel:n(`config:desktopPetSettings.showOnDesktop`),className:`ml-4`})]}),a&&(0,q.jsxs)(`div`,{className:`flex items-center snotification-option gap-2.75 mt-4`,children:[(0,q.jsx)(mn,{size:18}),(0,q.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,q.jsx)(`span`,{className:`font-bold`,children:n(`config:desktopPetSettings.opacity`)}),(0,q.jsxs)(`span`,{className:`text-xs`,children:[f,`%`]})]}),(0,q.jsx)(Bn,{value:[f],min:20,max:100,step:5,disabled:m===`opacity`,onValueChange:([e])=>p(e),onValueCommit:([e])=>void S(e/100),"aria-label":n(`config:desktopPetSettings.opacity`),className:`flex-1 w-auto ml-4`})]})]}):(0,q.jsxs)(Je,{className:`[margin-top:15px]`,children:[(0,q.jsx)(z,{className:`animate-spin`,size:16}),(0,q.jsx)(`span`,{children:n(`config:desktopPetSettings.loading`)})]}),g&&(0,q.jsx)(`div`,{className:`text-[var(--danger)] text-[13px] mt-3`,children:g})]}),(0,q.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-install`,children:[(0,q.jsxs)(`div`,{className:`language-settings-heading flex items-start gap-[11px] [&_h2]:text-[16px] [&_p]:mt-[4px] [&_p]:text-[var(--text-muted)] [&_p]:text-[13px] [&_p]:leading-[1.55]`,children:[(0,q.jsx)(`span`,{className:`grid w-[38px] h-[38px] [flex:0_0_auto] place-items-center rounded-[11px] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(he,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{children:n(`config:desktopPetSettings.installTitle`)}),(0,q.jsx)(`p`,{children:n(`config:desktopPetSettings.installDescription`)})]})]}),(0,q.jsxs)(`div`,{className:`workspace-path-form grid h-[39px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] mt-[16px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] p-[3px_3px_3px_10px] text-[var(--text-muted)] [&_input]:min-w-0 [&_input]:border-0 [&_input]:[outline:0] [&_input]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_input]:text-[12px] dark:[&_input]:bg-[var(--solid)] dark:[&_input]:text-[var(--text)] desktop-pet-search !grid-cols-[minmax(0,1fr)_auto] mt-4`,children:[(0,q.jsx)(`input`,{value:s,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},placeholder:n(`config:desktopPetSettings.searchPlaceholder`),"aria-label":n(`config:desktopPetSettings.petSlug`)}),(0,q.jsxs)(U,{size:`lg`,className:`min-w-[104px]`,disabled:m===`search`,onClick:b,children:[m===`search`?(0,q.jsx)(z,{className:`animate-spin`,size:14}):(0,q.jsx)(Ae,{size:14}),n(`config:desktopPetSettings.search`)]})]}),u.length>0&&(0,q.jsx)(`div`,{className:`language-choice-grid grid grid-cols-4 max-[650px]:grid-cols-1 max-[1300px]:grid-cols-2 gap-2.25 mt-4`,children:u.map(e=>{let t=a?.installed.some(t=>t.slug===e.slug);return(0,q.jsxs)(`button`,{type:`button`,className:`language-choice hover:border-[var(--star)] hover:bg-[var(--accent-soft)] hover:[transform:translateY(-1px)] [&.selected]:border-[var(--star)] [&.selected]:bg-[var(--star-soft)] [&.selected]:shadow-[0_0_0_3px_var(--accent-ring)] grid min-h-[80px] grid-cols-[auto_minmax(0,_1fr)_auto] items-center gap-[10px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:11px] text-[var(--text)] text-left [transition:border-color_var(--d1)_var(--ease-out),_background_var(--d1)_var(--ease-out),_box-shadow_var(--d1)_var(--ease-out),_transform_var(--d1)_var(--ease-out)]`,disabled:!!m,onClick:()=>t?w(e.slug):C(e.slug),children:[(0,q.jsx)(`span`,{className:`language-choice-mark grid w-[34px] h-[34px] place-items-center rounded-[9px] bg-[var(--solid)] text-[var(--star-strong)] text-[12px] font-[800] tracking-[.03em]`,children:(0,q.jsx)(hn,{size:16})}),(0,q.jsxs)(`span`,{className:`language-choice-copy [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] flex min-w-0 flex-col gap-[3px]`,children:[(0,q.jsx)(`strong`,{children:e.displayName}),(0,q.jsx)(`small`,{children:e.slug})]}),(0,q.jsx)(X,{tone:t?`green`:`blue`,children:n(t?`config:desktopPetSettings.installed`:`config:desktopPetSettings.install`)})]},e.slug)})}),(0,q.jsx)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:(0,q.jsxs)(U,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:i.openCatalog,children:[(0,q.jsx)(ve,{size:14}),n(`config:desktopPetSettings.browsePetdex`)]})})]}),a&&a.installed.length>0&&(0,q.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-installed`,children:[(0,q.jsxs)(`div`,{className:`language-settings-heading flex items-start gap-[11px] [&_h2]:text-[16px] [&_p]:mt-[4px] [&_p]:text-[var(--text-muted)] [&_p]:text-[13px] [&_p]:leading-[1.55]`,children:[(0,q.jsx)(`span`,{className:`grid w-[38px] h-[38px] [flex:0_0_auto] place-items-center rounded-[11px] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(hn,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{children:n(`config:desktopPetSettings.installedTitle`)}),(0,q.jsx)(`p`,{children:n(`config:desktopPetSettings.installedDescription`)})]})]}),(0,q.jsx)(`div`,{className:`language-choice-grid max-[650px]:grid-cols-[1fr] grid grid-cols-[repeat(2,_minmax(0,_1fr))] gap-[9px] [margin-top:18px] mt-4`,role:`radiogroup`,children:a.installed.map(e=>{let t=e.slug===a.selectedSlug;return(0,q.jsxs)(`div`,{className:`language-choice hover:border-[var(--star)] hover:bg-[var(--accent-soft)] [&.selected]:border-[var(--star)] [&.selected]:bg-[var(--star-soft)] [&.selected]:shadow-[0_0_0_3px_var(--accent-ring)] grid min-h-[80px] grid-cols-[minmax(0,_1fr)_auto] items-center gap-[4px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:4px] text-[var(--text)] [transition:border-color_var(--d1)_var(--ease-out),_background_var(--d1)_var(--ease-out),_box-shadow_var(--d1)_var(--ease-out)] ${t?`selected`:``}`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`grid min-h-[70px] grid-cols-[auto_minmax(0,_1fr)_auto] items-center gap-[10px] rounded-[calc(var(--r-sm)-2px)] [padding:7px] text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--star)] disabled:pointer-events-none disabled:opacity-50 ${e.source===`pisper`?``:`col-span-2`}`,role:`radio`,"aria-checked":t,disabled:!!m,onClick:()=>w(e.slug),children:[(0,q.jsx)(`span`,{className:`language-choice-mark grid w-[34px] h-[34px] place-items-center rounded-[9px] bg-[var(--solid)] text-[var(--star-strong)] text-[12px] font-[800] tracking-[.03em]`,children:(0,q.jsx)(hn,{size:16})}),(0,q.jsxs)(`span`,{className:`language-choice-copy [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] flex min-w-0 flex-col gap-[3px]`,children:[(0,q.jsx)(`strong`,{children:e.name}),(0,q.jsx)(`small`,{children:e.slug})]}),(0,q.jsx)(X,{tone:e.source===`pisper`?`blue`:`gray`,children:e.source===`pisper`?`Pisper`:`Petdex`})]}),e.source===`pisper`&&(0,q.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`text-content-muted hover:text-destructive`,disabled:!!m,onClick:()=>void T(e),"aria-label":n(`config:desktopPetSettings.delete`),title:n(`config:desktopPetSettings.delete`),children:m===`remove:${e.slug}`?(0,q.jsx)(z,{className:`animate-spin`,size:14}):(0,q.jsx)(Ie,{size:14})})]},`${e.source}:${e.slug}`)})})]})]})}function Un(e,t){return t(e===`en-US`?`config:languageSettings.english`:`config:languageSettings.simplifiedChinese`)}function Wn({notify:e}){let{language:t,setLanguage:n,t:r}=c(),i=r=>{r!==t&&(n(r),e(s(r===`en-US`?`config:languageSettings.displayLanguageChangedToEnglish`:`config:languageSettings.displayLanguageChangedToSimplifiedChinese`,r)))};return(0,q.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-language`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-[11px] [&_h2]:text-[16px] [&_p]:mt-1 [&_p]:text-[13px] [&_p]:leading-[1.55] [&_p]:text-[var(--text-muted)]`,children:[(0,q.jsx)(`span`,{className:`grid size-[38px] flex-none place-items-center rounded-[var(--r-sm)] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(yn,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{children:r(`config:languageSettings.displayLanguage`)}),(0,q.jsx)(`p`,{children:r(`config:languageSettings.chooseTheLanguageUsedByPisperChangesApplyImmediatelyAndAreSavedForYourNextVisit`)})]})]}),(0,q.jsx)(`div`,{className:`mt-[18px] grid grid-cols-2 gap-[9px] max-[650px]:grid-cols-1`,role:`radiogroup`,"aria-label":r(`config:languageSettings.displayLanguage`),children:a.map(e=>{let n=e.value===t;return(0,q.jsxs)(`button`,{type:`button`,className:`grid min-h-[80px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 rounded-[var(--r-sm)] border bg-[var(--surface-subtle)] p-[11px] text-left text-[var(--text)] transition hover:-translate-y-px hover:border-[var(--star)] hover:bg-[var(--accent-soft)] ${n?`border-[var(--star)] bg-[var(--star-soft)] shadow-[0_0_0_3px_var(--accent-ring)]`:`border-[var(--stroke)]`}`,role:`radio`,"aria-checked":n,onClick:()=>i(e.value),children:[(0,q.jsx)(`span`,{className:`grid size-[34px] place-items-center rounded-[var(--r-xs)] text-[12px] font-extrabold ${e.value===`en-US`?`bg-[var(--brand-blue-soft)] text-[var(--brand-blue-strong)]`:`bg-[var(--solid)] text-[var(--star-strong)]`}`,children:e.shortName}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[3px] [&_small]:text-[var(--text-muted)] [&_strong]:text-[13px]`,children:[(0,q.jsx)(`strong`,{children:Un(e.value,r)}),(0,q.jsx)(`small`,{children:e.value===`zh-CN`?r(`config:languageSettings.chineseInterface`):r(`config:languageSettings.englishInterface`)})]}),n&&(0,q.jsx)(`span`,{className:`grid size-[21px] place-items-center rounded-full bg-[var(--star)] text-[var(--on-accent)]`,children:(0,q.jsx)(R,{size:15})})]},e.value)})}),(0,q.jsxs)(Je,{className:`mt-[15px]`,children:[(0,q.jsx)(yn,{size:16}),(0,q.jsxs)(`span`,{children:[(0,q.jsxs)(`strong`,{children:[r(`config:languageSettings.currentLanguage`),` · `,Un(t,r)]}),(0,q.jsx)(`small`,{children:r(`config:languageSettings.thisSettingChangesInterfaceTextOnlyItDoesNotControlTheLanguageOfAgentResponses`)})]})]})]})}function Gn({icon:e,title:t,description:n}){return(0,q.jsxs)(`div`,{className:`flex items-start gap-[11px] [&_h2]:text-[16px] [&_p]:mt-1 [&_p]:text-[13px] [&_p]:leading-[1.55] [&_p]:text-[var(--text-muted)]`,children:[(0,q.jsx)(`span`,{className:`grid size-[38px] flex-none place-items-center rounded-[var(--r-sm)] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(e,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{children:t}),(0,q.jsx)(`p`,{children:n})]})]})}function Kn({label:e,options:t,value:n,onChange:r,className:i}){return(0,q.jsx)(`div`,{className:j(`mt-4 grid grid-cols-4 gap-2 max-[650px]:grid-cols-1 max-[1300px]:grid-cols-2`,i),role:`radiogroup`,"aria-label":e,children:t.map(e=>{let t=e.value===n,i=e.icon;return(0,q.jsxs)(`button`,{type:`button`,className:`grid min-h-[72px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 rounded-[var(--r-sm)] border p-2.5 text-left transition hover:-translate-y-px hover:border-[var(--star)] hover:bg-[var(--accent-soft)] ${t?`border-[var(--star)] bg-[var(--star-soft)] shadow-[0_0_0_3px_var(--accent-ring)]`:`border-[var(--stroke)] bg-[var(--surface-subtle)]`}`,role:`radio`,"aria-checked":t,onClick:()=>r(e.value),children:[(0,q.jsx)(`span`,{className:`grid size-8 place-items-center rounded-[var(--r-xs)] bg-[var(--solid)] text-[var(--star-strong)]`,children:(0,q.jsx)(i,{size:16})}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,q.jsx)(`strong`,{className:`text-[13px]`,children:e.label}),(0,q.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:e.description})]}),t&&(0,q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-[var(--star)] text-[var(--on-accent)]`,children:(0,q.jsx)(R,{size:13})})]},e.value)})})}function qn({label:e,options:t,value:n,onChange:r}){return(0,q.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-1`,role:`radiogroup`,"aria-label":e,children:t.map(e=>(0,q.jsx)(`button`,{type:`button`,className:`min-h-8 rounded-[var(--r-xs)] px-2 text-[12px] font-semibold transition ${e.value===n?`bg-[var(--solid)] text-[var(--text)] shadow-sm`:`text-[var(--text-muted)] hover:text-[var(--text)]`}`,role:`radio`,"aria-checked":e.value===n,onClick:()=>r(e.value),children:e.label},e.value))})}var Jn={neutral:`#18181b`,blue:`#1677e8`,teal:`#0f766e`,violet:`#7557c8`,coral:`#c94f5d`,custom:`#1677e8`};function Yn({notify:e}){let{t}=c(),n=G(e=>e.theme),r=G(e=>e.density),i=G(e=>e.accent),a=G(e=>e.customAccent),o=G(e=>e.fontScale),s=G(e=>e.radius),l=G(e=>e.motion),u=G(e=>e.setTheme),d=G(e=>e.setDensity),f=G(e=>e.setAccent),p=G(e=>e.setCustomAccent),m=G(e=>e.setFontScale),h=G(e=>e.setRadius),g=G(e=>e.setMotion),_=G(e=>e.resetAppearance),v=n!==lt.theme||r!==lt.density||i!==lt.accent||a!==lt.customAccent||o!==lt.fontScale||s!==lt.radius||l!==lt.motion,[y,b]=(0,K.useState)(a);(0,K.useEffect)(()=>b(a),[a]);let x=mt(y),S=!!y.trim()&&!x,C=e=>{b(e);let t=mt(e);t&&T(p)(t)},w=()=>e(t(`config:interfaceSettings.preferencesUpdated`)),T=e=>t=>{e(t),w()},E=[{value:`system`,label:t(`config:interfaceSettings.followSystem`),description:t(`config:interfaceSettings.followSystemDescription`),icon:we},{value:`scheduled`,label:t(`config:interfaceSettings.automaticByTime`),description:t(`config:interfaceSettings.automaticByTimeDescription`),icon:fe},{value:`light`,label:t(`config:interfaceSettings.light`),description:t(`config:interfaceSettings.lightDescription`),icon:Te},{value:`dark`,label:t(`config:interfaceSettings.dark`),description:t(`config:interfaceSettings.darkDescription`),icon:Ce}],D=[{value:`comfortable`,label:t(`config:interfaceSettings.comfortable`),description:t(`config:interfaceSettings.comfortableDescription`),icon:An},{value:`compact`,label:t(`config:interfaceSettings.compact`),description:t(`config:interfaceSettings.compactDescription`),icon:_n}],O=[{value:`system`,label:t(`config:interfaceSettings.motionSystem`),description:t(`config:interfaceSettings.motionSystemDescription`),icon:we},{value:`full`,label:t(`config:interfaceSettings.motionFull`),description:t(`config:interfaceSettings.motionFullDescription`),icon:Pe},{value:`reduced`,label:t(`config:interfaceSettings.motionReduced`),description:t(`config:interfaceSettings.motionReducedDescription`),icon:fn}],k=[{value:`neutral`,label:t(`config:interfaceSettings.accentNeutral`)},{value:`blue`,label:t(`config:interfaceSettings.accentBlue`)},{value:`teal`,label:t(`config:interfaceSettings.accentTeal`)},{value:`violet`,label:t(`config:interfaceSettings.accentViolet`)},{value:`coral`,label:t(`config:interfaceSettings.accentCoral`)},{value:`custom`,label:t(`config:interfaceSettings.accentCustom`)}],A=[{value:`small`,label:t(`config:interfaceSettings.small`)},{value:`default`,label:t(`config:interfaceSettings.standard`)},{value:`large`,label:t(`config:interfaceSettings.large`)}],j=[{value:`sharp`,label:t(`config:interfaceSettings.sharp`)},{value:`default`,label:t(`config:interfaceSettings.standard`)},{value:`soft`,label:t(`config:interfaceSettings.soft`)}];return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-appearance`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 max-[650px]:flex-col`,children:[(0,q.jsx)(Gn,{icon:Sn,title:t(`config:interfaceSettings.appearance`),description:t(`config:interfaceSettings.appearanceDescription`)}),(0,q.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,disabled:!v,onClick:()=>{_(),e(t(`config:interfaceSettings.defaultsRestored`))},children:[(0,q.jsx)(Oe,{size:14}),t(`config:interfaceSettings.restoreDefaults`)]})]}),(0,q.jsx)(Kn,{label:t(`config:interfaceSettings.colorMode`),options:E,value:n,onChange:T(u)}),(0,q.jsxs)(`div`,{className:`mt-5 border-t border-[var(--stroke-soft)] pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-bold text-[var(--text-soft)]`,children:[(0,q.jsx)(Sn,{size:15}),t(`config:interfaceSettings.accentColor`)]}),(0,q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":t(`config:interfaceSettings.accentColor`),children:k.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:`flex min-h-9 items-center gap-2 rounded-[var(--r-sm)] border px-2.5 text-[12px] font-semibold transition hover:border-[var(--star)] ${i===e.value?`border-[var(--star)] bg-[var(--star-soft)] text-[var(--star-strong)] shadow-[0_0_0_3px_var(--accent-ring)]`:`border-[var(--stroke)] bg-[var(--surface-subtle)] text-[var(--text-soft)]`}`,role:`radio`,"aria-checked":i===e.value,onClick:()=>T(f)(e.value),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full border border-black/10 shadow-sm`,style:{backgroundColor:e.value===`custom`?a:Jn[e.value]}}),e.label,i===e.value&&(0,q.jsx)(R,{size:13})]},e.value))}),i===`custom`&&(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 rounded-[var(--r-sm)] border border-[var(--stroke)] bg-[var(--surface-subtle)] p-3`,children:[(0,q.jsx)(`input`,{type:`color`,value:mt(a)||`#1677e8`,onChange:e=>T(p)(e.target.value),"aria-label":t(`config:interfaceSettings.customAccentColor`),className:`h-9 w-14 cursor-pointer rounded-[var(--r-xs)] border border-[var(--stroke)] bg-[var(--solid)] p-1`}),(0,q.jsx)(`input`,{type:`text`,value:y,onChange:e=>C(e.target.value),spellCheck:!1,"aria-label":t(`config:interfaceSettings.customAccentHex`),className:`h-9 w-[116px] rounded-[var(--r-xs)] border bg-[var(--solid)] px-2.5 font-mono text-[12.5px] text-[var(--text)] ${S?`border-[var(--danger)]`:`border-[var(--stroke)]`}`}),(0,q.jsx)(`span`,{className:`text-[12px] ${S?`text-[var(--danger)]`:`text-[var(--text-muted)]`}`,children:t(S?`config:interfaceSettings.invalidAccentColor`:`config:interfaceSettings.customAccentHint`)})]})]}),(0,q.jsxs)(`div`,{className:`mt-5 grid grid-cols-[minmax(0,1fr)_minmax(260px,.72fr)] gap-4 border-t border-[var(--stroke-soft)] pt-4 max-[720px]:grid-cols-1`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-bold text-[var(--text-soft)]`,children:[(0,q.jsx)(kn,{size:15}),t(`config:interfaceSettings.interfaceStyle`)]}),(0,q.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 max-[470px]:grid-cols-1`,children:[(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:interfaceSettings.fontSize`)}),(0,q.jsx)(qn,{label:t(`config:interfaceSettings.fontSize`),options:A,value:o,onChange:T(m)}),(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t(`config:interfaceSettings.fontScaleHint`)})]}),(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:interfaceSettings.cornerStyle`)}),(0,q.jsx)(qn,{label:t(`config:interfaceSettings.cornerStyle`),options:j,value:s,onChange:T(h)})]})]})]}),(0,q.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--r-md)] border border-[var(--stroke)] bg-[var(--main-surface-bg)] shadow-[var(--sh-surface)]`,"aria-label":t(`config:interfaceSettings.livePreview`),children:[(0,q.jsxs)(`div`,{className:`flex h-8 items-center gap-1.5 border-b border-[var(--stroke)] bg-[var(--surface-subtle)] px-3`,children:[(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--brand-blue)]`}),(0,q.jsx)(`span`,{className:`text-[11px] font-bold text-[var(--text-muted)]`,children:t(`config:interfaceSettings.livePreview`)})]}),(0,q.jsxs)(`div`,{className:`grid gap-2.5 p-3`,children:[(0,q.jsx)(`div`,{className:`mr-7 rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-2 text-[var(--app-font-size)] text-[var(--text-soft)]`,children:t(`config:interfaceSettings.previewAgentMessage`)}),(0,q.jsx)(`div`,{className:`ml-7 rounded-[var(--r-sm)] bg-[var(--star)] p-2 text-[var(--app-font-size)] text-[var(--on-accent)]`,children:t(`config:interfaceSettings.previewUserMessage`)}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,q.jsx)(`span`,{className:`block h-full w-2/3 rounded-full bg-[var(--brand-blue)]`})}),(0,q.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:`67%`})]})]})]})]})]}),(0,q.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-motion`,children:[(0,q.jsx)(Gn,{icon:fn,title:t(`config:interfaceSettings.displayAndMotion`),description:t(`config:interfaceSettings.displayAndMotionDescription`)}),(0,q.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-5 max-[720px]:grid-cols-1`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-[13px] font-bold text-[var(--text-soft)]`,children:t(`config:interfaceSettings.interfaceDensity`)}),(0,q.jsx)(Kn,{label:t(`config:interfaceSettings.interfaceDensity`),options:D,value:r,onChange:T(d),className:`grid-cols-2`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-[13px] font-bold text-[var(--text-soft)]`,children:t(`config:interfaceSettings.motion`)}),(0,q.jsx)(Kn,{label:t(`config:interfaceSettings.motion`),options:O,value:l,onChange:T(g),className:`grid-cols-2`})]})]})]}),(0,q.jsx)(Wn,{notify:e})]})}var Xn=[`voiceInput`,`sendMessage`,`commandPalette`,`primaryAction`],Zn=at.filter(e=>!Xn.includes(e));function Qn({requestConfirm:e}){let{t}=c(),n=ot(e=>e.bindings),r=ot(e=>e.setBinding),i=ot(e=>e.resetBindings),[a,o]=(0,K.useState)(null),[s,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(!1),f={commandPalette:t(`config:shortcuts.commandPalette`),primaryAction:t(`config:shortcuts.primaryAction`),focusSearch:t(`config:shortcuts.focusSearch`),toggleSidebar:t(`config:shortcuts.toggleSidebar`),toggleTerminal:t(`config:shortcuts.toggleTerminal`),openSettings:t(`config:shortcuts.openSettings`),focusComposer:t(`config:shortcuts.focusComposer`),sendMessage:t(`config:shortcuts.sendMessage`),voiceInput:t(`config:shortcuts.voiceInput`)},p=(e,i)=>{d(!1);let a=ct(n,e,i);if(a){l({action:e,message:t(`config:shortcuts.conflict`,{action:f[a]})});return}try{it({...n,[e]:i})}catch{l({action:e,message:t(`config:shortcuts.invalid`)});return}try{r(e,i),o(null),l(null),d(!0)}catch{l({action:e,message:t(`config:shortcuts.saveFailed`)})}},m=(e,n)=>{if(a!==n)return;if(e.key===`Tab`){o(null);return}let r=nt(e.nativeEvent);if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(null),l(null);return}r?p(n,r):!e.nativeEvent.isComposing&&e.keyCode!==229&&!e.repeat&&![`Control`,`Meta`,`Alt`,`Shift`,`AltGraph`,`Dead`,`Process`].includes(e.key)&&l({action:n,message:t(`config:shortcuts.invalid`)})},h=async()=>{if(o(null),await e({title:t(`config:shortcuts.resetAll`),message:t(`config:shortcuts.resetConfirm`),confirmLabel:t(`config:shortcuts.resetAll`)}))try{i(),l(null),d(!0)}catch{l({action:null,message:t(`config:shortcuts.saveFailed`)})}},g=at.some(e=>n[e]!==rt[e]),_=e=>(0,q.jsxs)(`div`,{className:`py-3`,"data-shortcut-action":e,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-${e}`,className:`min-w-0 text-sm font-medium`,children:f[e]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-1`,children:[(0,q.jsx)(U,{id:`shortcut-${e}`,"data-shortcut-recorder":!0,variant:`outline`,className:`h-9 w-44 min-w-0 justify-center gap-2 px-2.5 text-xs max-[400px]:w-40`,"aria-label":t(`config:shortcuts.edit`,{action:f[e]}),"aria-pressed":a===e,"aria-describedby":s?.action===e?`shortcut-error-${e}`:void 0,onClick:()=>{o(e),l(null),d(!1)},onBlur:()=>o(t=>t===e?null:t),onKeyDown:t=>m(t,e),children:(0,q.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words text-left`,children:a===e?t(`config:shortcuts.recording`):st(n[e])||t(`config:shortcuts.disabled`)})}),(0,q.jsxs)(w,{children:[(0,q.jsx)(x,{asChild:!0,children:(0,q.jsx)(U,{variant:`ghost`,size:`icon`,title:t(`config:shortcuts.options`,{action:f[e]}),"aria-label":t(`config:shortcuts.options`,{action:f[e]}),children:(0,q.jsx)(_e,{className:`size-4`})})}),(0,q.jsxs)(S,{align:`end`,className:`w-40`,onCloseAutoFocus:e=>{document.activeElement?.hasAttribute(`data-shortcut-recorder`)&&e.preventDefault()},children:[(0,q.jsxs)(C,{disabled:n[e]===null,onSelect:()=>p(e,null),children:[(0,q.jsx)(ze,{className:`size-4`}),t(`config:shortcuts.disableKey`)]}),(0,q.jsxs)(C,{disabled:n[e]===rt[e],onSelect:()=>p(e,rt[e]),children:[(0,q.jsx)(Oe,{className:`size-4`}),t(`config:shortcuts.resetAll`)]})]})]})]})]}),s?.action===e&&(0,q.jsx)(`p`,{id:`shortcut-error-${e}`,role:`alert`,className:`mt-2 text-sm text-destructive`,children:s.message})]},e);return(0,q.jsxs)(`section`,{className:`w-full min-w-0`,"data-config-card":`shortcuts-bindings`,children:[(0,q.jsxs)(`div`,{className:`mb-5 flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(se,{className:`size-5 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`config:configPage.shortcuts`)})]}),(0,q.jsx)(U,{variant:`ghost`,size:`icon`,disabled:!g,title:t(`config:shortcuts.resetAll`),"aria-label":t(`config:shortcuts.resetAll`),onClick:()=>void h(),children:(0,q.jsx)(Oe,{className:`size-4`})})]}),(0,q.jsx)(`div`,{className:`divide-y divide-border border-y border-border`,children:Xn.map(_)}),(0,q.jsxs)(`details`,{className:`group mt-3`,onToggle:()=>o(null),children:[(0,q.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 py-2 text-sm text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(le,{className:`size-4 transition-transform group-open:rotate-180`}),t(`config:shortcuts.more`)]}),(0,q.jsx)(`div`,{className:`divide-y divide-border border-b border-border`,children:Zn.map(_)})]}),(0,q.jsx)(`div`,{className:`mt-3 min-h-5 text-xs text-muted-foreground`,role:`status`,"aria-live":`polite`,children:s?.action===null?(0,q.jsx)(`span`,{className:`text-destructive`,children:s.message}):t(u?`config:shortcuts.saved`:`config:shortcuts.deviceScope`)})]})}o.addResourceBundle(`zh-CN`,`providers`,{"modelEditor.edit":`编辑模型`,"modelEditor.add":`添加模型`,"modelEditor.description":`能力与思考强度`,"modelEditor.id":`模型 ID`,"modelEditor.capabilities":`模型能力`,"modelEditor.chat":`对话`,"modelEditor.image":`图像生成`,"modelEditor.video":`视频生成`,"modelEditor.capabilitiesHint":`可单选或多选。仅选图像生成时,复用此连接的密钥,不会出现在对话模型中。`,"modelEditor.chatCapabilities":`对话能力`,"modelEditor.vision":`图片理解`,"modelEditor.reasoning":`深度思考`,"modelEditor.contextWindow":`上下文窗口(Token)`,"modelEditor.maxTokens":`最大输出(Token)`,"modelEditor.editNamed":`编辑模型 {name}`,"modelEditor.optionsNamed":`模型能力:{name}`,"modelEditor.delete":`删除模型`,"modelEditor.deleteNamed":`删除模型 {name}`,"modelEditor.deleteConfirmation":`删除“{name}”?供应商连接和密钥会保留。若它是默认模型,将选用其他可用模型,没有可用模型时清空默认值;已有会话的模型不会自动替换。之后可以重新添加此模型。`,"modelEditor.deleted":`模型已删除`}),o.addResourceBundle(`en-US`,`providers`,{"modelEditor.edit":`Edit model`,"modelEditor.add":`Add model`,"modelEditor.description":`Capabilities and reasoning levels`,"modelEditor.id":`Model ID`,"modelEditor.capabilities":`Model capabilities`,"modelEditor.chat":`Chat`,"modelEditor.image":`Image generation`,"modelEditor.video":`Video generation`,"modelEditor.capabilitiesHint":`Choose one or more. Image-only models reuse this connection’s key and stay out of the chat model picker.`,"modelEditor.chatCapabilities":`Chat capabilities`,"modelEditor.vision":`Image understanding`,"modelEditor.reasoning":`Reasoning`,"modelEditor.contextWindow":`Context window (tokens)`,"modelEditor.maxTokens":`Maximum output (tokens)`,"modelEditor.editNamed":`Edit model {name}`,"modelEditor.optionsNamed":`Model capabilities: {name}`,"modelEditor.delete":`Delete model`,"modelEditor.deleteNamed":`Delete model {name}`,"modelEditor.deleteConfirmation":`Delete “{name}”? The provider connection and credentials will remain. If this is the default model, another available model will be selected, or the default will be cleared if none is available. Existing conversations will keep their model bindings. You can add this model again later.`,"modelEditor.deleted":`Model deleted`});var $n=[[`openai-responses`,`OpenAI Responses`],[`openai-completions`,`OpenAI Chat Completions`],[`anthropic-messages`,`Anthropic Messages`],[`google-generative-ai`,`Google Generative AI`]],er={openai:ae,"openai-codex":ae,anthropic:oe,google:Pe,deepseek:pe,xai:ie,openrouter:re,"kimi-coding":Pe,"zai-coding-cn":oe},tr={deleteModel(e,t){return H(`/api/providers/`+encodeURIComponent(e)+`/models`,{method:`DELETE`,body:JSON.stringify({modelId:t})})},saveModel(e,t,n=!1){return H(`/api/providers/`+encodeURIComponent(e)+`/models`+(n?``:`/options`),{method:n?`POST`:`PUT`,body:JSON.stringify(n?{...t,id:t.modelId,kind:t.capabilities[0]}:t)})},saveConnection(e,t){return H(`/api/providers/`+encodeURIComponent(e)+`/connection`,{method:`PUT`,body:JSON.stringify(t)})},importLocal(){return H(`/api/providers/import-local`,{method:`POST`,body:`{}`})}};function nr({provider:e,onSave:t,draft:n,onDraftChange:r,onSavingChange:i}){let{t:a}=c(),[o,s]=(0,K.useState)(!1),[l,u]=(0,K.useState)(``),d=n.name!==e.name||n.api!==e.api||n.baseUrl!==(e.baseUrl||``)||!!n.apiKey,f=async a=>{if(a.preventDefault(),!o){s(!0),i(!0),u(``);try{t(await tr.saveConnection(e.id,{...n,apiKey:n.apiKey.trim()||void 0})),r(void 0)}catch(e){u(e instanceof Error?e.message:String(e))}finally{s(!1),i(!1)}}};return(0,q.jsxs)(`form`,{onSubmit:e=>void f(e),className:`space-y-4`,"data-provider-connection-editor":!0,children:[(0,q.jsxs)(`fieldset`,{disabled:o,className:`grid gap-4`,children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a(`config:configPage.displayName`),(0,q.jsx)(Ke,{required:!0,value:n.name,onChange:e=>r({...n,name:e.target.value})})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a(`config:configPage.apiKey`),(0,q.jsx)(Ke,{type:`password`,autoComplete:`new-password`,value:n.apiKey,placeholder:e.configured?a(`config:configPage.leaveBlankToKeepExistingKey`):a(`config:configPage.enterTheProviderAPIKey`),onChange:e=>r({...n,apiKey:e.target.value})})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.8fr)]`,children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a(`config:configPage.apiProtocol`),(0,q.jsx)(D,{value:n.api,onChange:e=>r({...n,api:e.target.value}),children:$n.map(([e,t])=>(0,q.jsx)(`option`,{value:e,children:t},e))})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Base URL`,(0,q.jsx)(Ke,{required:!0,type:`url`,value:n.baseUrl,onChange:e=>r({...n,baseUrl:e.target.value})})]})]})]}),l&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:l}),d&&(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsxs)(U,{type:`submit`,size:`sm`,disabled:o,children:[o&&(0,q.jsx)(xe,{size:14,className:`animate-spin`}),a(o?`config:configPage.saving`:`config:configPage.saveChanges`)]})})]})}var rr=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ir({label:e,checked:t,disabled:n,onChange:r}){return(0,q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t,disabled:n,onClick:r,className:j(`inline-flex h-9 items-center gap-2 rounded-lg border px-3 text-sm transition-colors disabled:opacity-50`,t?`border-foreground/30 bg-muted text-foreground`:`border-border hover:bg-muted/60`),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:j(`grid size-3.5 place-items-center rounded-[3px] border`,t&&`border-primary bg-primary text-primary-foreground`),children:t&&(0,q.jsx)(R,{size:11})}),e]})}function ar({provider:e,model:t,onSave:n,onClose:r}){let{t:i}=c(),[a,o]=(0,K.useState)(()=>({modelId:t?.id||``,name:t?.name||``,capabilities:t?.capabilities||[t?.kind===`image`?`image`:t?.kind===`video`?`video`:`chat`],input:t?.input||[`text`],reasoning:t?.reasoning??!0,contextWindow:t?.contextWindow||2e5,maxTokens:t?.maxTokens||8192})),[s,l]=(0,K.useState)(t?.thinkingLevels||[`off`,`low`,`medium`,`high`]),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``),g=a.capabilities.includes(`chat`),_=async i=>{if(i.preventDefault(),!f){p(!0),h(``);try{n(await tr.saveModel(e.id,{...a,modelId:a.modelId.trim(),thinkingLevels:u||!t?s:void 0},!t)),r()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,q.jsx)(Ge,{open:!0,onOpenChange:e=>{!e&&!f&&r()},children:(0,q.jsxs)(Ue,{className:`sm:max-w-[540px] p-5`,showCloseButton:!f,onEscapeKeyDown:e=>{f&&e.preventDefault()},onInteractOutside:e=>e.preventDefault(),children:[(0,q.jsxs)(He,{children:[(0,q.jsx)(We,{children:i(t?`providers:modelEditor.edit`:`providers:modelEditor.add`)}),(0,q.jsxs)(Ve,{children:[e.name,` · `,i(`providers:modelEditor.description`)]})]}),(0,q.jsxs)(`form`,{onSubmit:e=>void _(e),className:`space-y-5`,children:[(0,q.jsxs)(`fieldset`,{disabled:f,className:`space-y-5`,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`providers:modelEditor.id`),(0,q.jsx)(Ke,{required:!0,disabled:!!t,value:a.modelId,onChange:e=>o({...a,modelId:e.target.value})})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(`config:configPage.modelName`),(0,q.jsx)(Ke,{value:a.name,onChange:e=>o({...a,name:e.target.value})})]})]}),(0,q.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,q.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.capabilities`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`chat`,`image`,`video`].map(e=>(0,q.jsx)(ir,{label:i(e===`chat`?`providers:modelEditor.chat`:e===`image`?`providers:modelEditor.image`:`providers:modelEditor.video`),checked:a.capabilities.includes(e),onChange:()=>o({...a,capabilities:a.capabilities.includes(e)?a.capabilities.filter(t=>t!==e):[...a.capabilities,e]})},e))}),(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`providers:modelEditor.capabilitiesHint`)})]}),g&&(0,q.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,q.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`providers:modelEditor.chatCapabilities`)}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(ir,{label:i(`providers:modelEditor.vision`),checked:a.input.includes(`image`),onChange:()=>o({...a,input:a.input.includes(`image`)?[`text`]:[`text`,`image`]})}),(0,q.jsx)(ir,{label:i(`providers:modelEditor.reasoning`),checked:a.reasoning,onChange:()=>o({...a,reasoning:!a.reasoning})})]})]}),g&&a.reasoning&&(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{className:`mb-2 text-sm font-medium`,children:i(`config:configPage.modelThinkingLevels`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:rr.map(e=>(0,q.jsx)(ir,{label:e,checked:e===`off`||s.includes(e),disabled:e===`off`,onChange:()=>{d(!0),l(s.includes(e)?s.filter(t=>t!==e):[...s,e])}},e))})]}),g&&(0,q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`contextWindow`,`maxTokens`].map(e=>(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[i(e===`contextWindow`?`providers:modelEditor.contextWindow`:`providers:modelEditor.maxTokens`),(0,q.jsx)(Ke,{required:!0,type:`number`,min:1,max:1e8,step:1,value:a[e],onChange:t=>o({...a,[e]:Number(t.target.value)})})]},e))})]}),m&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:m}),(0,q.jsxs)(Be,{children:[(0,q.jsx)(U,{type:`button`,variant:`ghost`,disabled:f,onClick:r,children:i(`config:configPage.cancel`)}),(0,q.jsxs)(U,{type:`submit`,disabled:f||!a.capabilities.length||!a.modelId.trim(),children:[f&&(0,q.jsx)(xe,{className:`animate-spin`,size:14}),` `,i(f?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})]})})}function or(e,t){let n=e.providers.filter(e=>e.configured||e.custom),r=e.defaultProvider||e.provider;return{providers:n,selected:n.find(e=>e.id===t)??n.find(e=>e.id===r)??n[0],defaultId:r}}function sr(e){let{t}=c(),n=(0,K.useId)(),{providers:r,selected:i,defaultId:a}=or(e.config,e.selectedProviderId),[o,s]=(0,K.useState)({}),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(null),p=i&&er[i.id]||B,m=r.length>0,h=!!(l||e.settingDefault||e.settingModel||e.toggling||e.deletingModel);return(0,q.jsxs)(`section`,{"data-config-card":`models-connections`,className:`overflow-hidden rounded-xl border border-border bg-card`,children:[(0,q.jsxs)(`div`,{"data-model-provider-split-panel":!0,className:j(`grid grid-cols-1 content-start`,m&&`min-h-[36rem] md:grid-cols-[224px_minmax(0,1fr)]`),children:[m&&(0,q.jsxs)(`nav`,{"aria-label":t(`config:configPage.connections`),className:`min-w-0 border-b border-border p-3 md:border-r md:border-b-0`,children:[(0,q.jsx)(`p`,{className:`mb-2 px-2 text-xs text-muted-foreground`,children:t(`config:configPage.connections`)}),(0,q.jsx)(`div`,{className:`flex gap-1 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:pb-0`,children:r.map(r=>{let o=er[r.id]||B,s=r.id===a;return(0,q.jsxs)(`button`,{type:`button`,title:r.name,"aria-label":r.name,"aria-describedby":s?n:void 0,"aria-current":i?.id===r.id?`true`:void 0,disabled:h,onClick:()=>e.onSelectProvider(r.id),className:j(`flex min-h-11 max-w-64 shrink-0 items-center gap-2.5 rounded-lg border px-3 text-left text-sm md:min-h-10 md:w-full md:px-2`,i?.id===r.id?`border-border bg-muted text-foreground`:`border-transparent text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[(0,q.jsx)(o,{size:17,className:`shrink-0`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.name}),s&&(0,q.jsx)(A,{id:n,variant:`secondary`,className:`px-1.5`,children:t(`config:providerWorkbench.default`)}),(0,q.jsx)(`span`,{className:j(`size-1.5 shrink-0 rounded-full`,r.configured&&r.enabled?`bg-emerald-500`:`bg-muted-foreground/25`)})]},r.id)})})]}),(0,q.jsx)(`div`,{className:`min-w-0 p-4 sm:p-6`,children:i?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`mb-6 flex min-w-0 items-center gap-3`,children:[(0,q.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-xl border border-border`,children:(0,q.jsx)(p,{size:23})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,q.jsx)(`h2`,{className:`max-w-full truncate text-lg font-semibold`,children:i.name}),i.id===a&&(0,q.jsx)(A,{variant:`secondary`,children:t(`config:providerWorkbench.defaultProvider`)})]}),(0,q.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:i.id})]}),(0,q.jsx)(Nn,{value:i.configured&&i.enabled,disabled:!i.configured||h,onChange:()=>void e.onToggle(i,!i.enabled),ariaLabel:t(`config:configPage.providerEnabled`,{name:i.name})}),(0,q.jsxs)(w,{children:[(0,q.jsx)(x,{asChild:!0,children:(0,q.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":t(`config:providerWorkbench.actions`),children:(0,q.jsx)(_e,{size:16})})}),(0,q.jsxs)(S,{align:`end`,children:[(0,q.jsxs)(C,{disabled:i.id===a||!i.configured||!i.enabled||!i.defaultModel||h,onSelect:()=>void e.onSetDefault(i),children:[(0,q.jsx)(Dn,{size:14}),t(`config:configPage.setAsDefaultProvider`)]}),(0,q.jsxs)(C,{disabled:h,onSelect:()=>e.onClone(i),children:[(0,q.jsx)(me,{size:14}),t(`config:configPage.cloneProvider`)]}),i.custom&&(0,q.jsxs)(C,{className:`text-destructive`,disabled:h,onSelect:()=>void e.onDelete(i),children:[(0,q.jsx)(Ie,{size:14}),t(`config:configPage.deleteProvider`)]})]})]})]}),(0,q.jsx)(nr,{provider:i,draft:o[i.id]??{name:i.name,api:i.api,baseUrl:i.baseUrl||``,apiKey:``},onDraftChange:e=>s(t=>({...t,[i.id]:e})),onSavingChange:u,onSave:e.onSave},i.id),(0,q.jsxs)(`div`,{className:`mt-6 border-t border-border pt-5`,children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`h3`,{className:`text-sm font-medium`,children:[t(`config:providerWorkbench.models`),` `,(0,q.jsx)(`span`,{className:`ml-1 font-normal text-muted-foreground`,children:i.models.length})]}),(0,q.jsxs)(U,{variant:`ghost`,size:`sm`,disabled:h,onClick:()=>f({provider:i}),children:[(0,q.jsx)(Ee,{size:14}),t(`providers:modelEditor.add`)]})]}),(0,q.jsx)(`div`,{className:`space-y-1.5`,children:i.models.map(n=>{let r=n.capabilities||[n.kind];return(0,q.jsxs)(`div`,{"data-provider-model":n.id,className:`flex min-w-0 items-center gap-2 rounded-lg border border-border/70 px-3 py-2.5`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>f({provider:i,model:n}),disabled:h,className:`min-w-0 flex-1 text-left`,"aria-label":t(`providers:modelEditor.editNamed`,{name:n.name||n.id}),children:[(0,q.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:n.name||n.id}),(0,q.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:n.id}),r.includes(`chat`)&&(0,q.jsx)(Se,{size:12}),` `,r.includes(`image`)&&(0,q.jsx)(be,{size:12}),` `,r.includes(`video`)&&(0,q.jsx)(ne,{size:12}),` `,n.reasoning&&r.includes(`chat`)&&(0,q.jsx)(oe,{size:12})]})]}),n.kind===`chat`&&(0,q.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":t(`config:configPage.providerDefaultModel`)+`: `+n.id,title:t(`config:configPage.providerDefaultModel`),"aria-pressed":i.defaultModel===n.id,disabled:h||!i.configured||i.defaultModel===n.id,onClick:()=>void e.onSetDefaultModel(i,n.id),children:i.defaultModel===n.id?(0,q.jsx)(R,{size:15}):(0,q.jsx)(Dn,{size:15})}),(0,q.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":t(`providers:modelEditor.optionsNamed`,{name:n.id}),disabled:h,onClick:()=>f({provider:i,model:n}),children:(0,q.jsx)(Ne,{size:14})}),(0,q.jsx)(U,{variant:`ghost`,size:`icon-sm`,disabled:h,"aria-label":t(`providers:modelEditor.deleteNamed`,{name:n.name||n.id}),title:t(`providers:modelEditor.delete`),onClick:()=>void e.onDeleteModel(i,n),children:(0,q.jsx)(Ie,{size:14})})]},n.id)})})]})]}):(0,q.jsxs)(`div`,{className:`grid min-h-80 place-content-center gap-4 text-center`,children:[(0,q.jsx)(B,{size:28,className:`mx-auto text-muted-foreground`}),(0,q.jsx)(`p`,{className:`text-sm font-medium`,children:t(`config:providerWorkbench.noConnections`)}),(0,q.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:t(`config:providerWorkbench.addConnectionHint`)})]})})]}),d&&(0,q.jsx)(ar,{provider:d.provider,model:d.model,onSave:e.onSave,onClose:()=>f(null)})]})}function cr(){let e=globalThis.crypto.getRandomValues(new Uint32Array(4));return`custom-${Array.from(e,e=>e.toString(16).padStart(8,`0`)).join(``)}`}function lr({value:e,onChange:t,configured:n=!1,cloning:r=!1}){let{t:i}=c();return(0,q.jsxs)(W,{variant:`control`,children:[i(`config:configPage.apiKey`),(0,q.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:e,onChange:e=>t(e.target.value),placeholder:i(r?`config:configPage.leaveBlankToCopySourceKey`:n?`config:configPage.leaveBlankToKeepExistingKey`:`config:configPage.enterTheProviderAPIKey`)})]})}function ur({ids:e,onChange:t,placeholder:n,primaryId:r=``}){let{t:i}=c(),[a,o]=(0,K.useState)(``),s=()=>{let n=a.trim();!n||n===r.trim()||e.includes(n)||(t([...e,n]),o(``))};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(W,{variant:`control`,children:[i(`config:configPage.manualModelIds`),(0,q.jsxs)(`div`,{className:`flex items-stretch gap-[6px]`,children:[(0,q.jsx)(`input`,{"aria-label":i(`config:configPage.manualModelIds`),value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:n}),(0,q.jsx)(U,{type:`button`,size:`icon`,className:`h-[31px] w-[31px] flex-none`,"aria-label":i(`config:configPage.manualModelIds`),disabled:!a.trim(),onClick:s,children:(0,q.jsx)(Ee,{size:14})})]})]}),e.length>0&&(0,q.jsx)(`div`,{className:`flex flex-col gap-[6px]`,children:e.map(n=>(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-[6px_10px]`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:n}),(0,q.jsx)(`button`,{type:`button`,"aria-label":i(`config:configPage.delete`),className:`grid w-[20px] h-[20px] flex-none cursor-pointer place-items-center rounded-full border-0 bg-transparent p-0 text-[var(--text-muted)] hover:bg-[var(--surface-highlight)] hover:text-[var(--text)]`,onClick:()=>t(e.filter(e=>e!==n)),children:(0,q.jsx)(ze,{size:12})})]},n))}),(0,q.jsx)(`p`,{className:`[margin:0] text-[11px] text-[var(--text-tertiary)]`,children:i(`config:configPage.manualModelIdsHint`)})]})}function dr(e,t){return e?.models.find(t=>t.id===e.defaultModel)||(t===`visual`?e?.models.find(e=>e.kind===`image`||e.kind===`video`):e?.models.find(e=>e.kind===`chat`)||e?.models[0])}function fr({onClose:e,onCreated:t,onConfigChanged:n,initialProviderType:r=`chat`,initialProvider:i,cloneProvider:a,embedded:o=!1}){let{t:s}=c(),l=i||a,u=!!a,d=l?.type||r,f=dr(l,d),[p,m]=(0,K.useState)(``),h=!!(i||p),[g,_]=(0,K.useState)(()=>({name:a?s(`config:configPage.clonedProviderName`,{name:a.name}):i?.name||``,id:a?cr():i?.id||``,providerType:d,api:i?.api||`openai-responses`,baseUrl:i?.baseUrl||``,model:f?.id||``,modelName:f?.name||``,modelKind:f?.kind===`image`||f?.kind===`video`?f.kind:d===`visual`?`image`:`chat`,reasoning:f?.reasoning!==!1,thinkingLevels:f?.thinkingLevels||[],enabled:i?.enabled??!0})),v=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[y,b]=(0,K.useState)(!1),x=e=>{b(!0),_(t=>({...t,thinkingLevels:t.thinkingLevels.includes(e)?t.thinkingLevels.filter(t=>t!==e):[...t.thinkingLevels,e]}))},[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(``),[E,O]=(0,K.useState)(``),k=E.trim()||void 0,[A,M]=(0,K.useState)([]),N=e=>_(t=>({...t,name:e,id:t.id||e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}));return(0,K.useEffect)(()=>{if(o||S)return;let t=t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[o,e,S]),(0,q.jsx)(`div`,{className:o?`provider-config-inline`:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [backdrop-filter:blur(3px)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:t=>!o&&!S&&t.target===t.currentTarget&&e(),children:(0,q.jsxs)(`form`,{role:o?void 0:`dialog`,"aria-modal":!o||void 0,className:o?`provider-config-form grid gap-3 text-sm [&_label]:!mt-0 [&_label]:!text-sm [&_label]:font-medium [&_input]:!h-9 [&_input]:!min-h-9 [&_input]:rounded-lg [&_input]:!text-sm [&_select]:!h-9 [&_select]:!min-h-9 [&_select]:rounded-lg [&_select]:!text-sm [&_summary]:text-sm`:`modal !w-[min(430px,100%)] max-h-[calc(100dvh_-_40px)] overflow-y-auto [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)] provider-config-modal !w-[min(620px,100%)]`,onSubmit:async e=>{if(e.preventDefault(),!S){if(!u&&!k&&!i?.configured&&!p){T(s(`config:configPage.enterTheAPIKeyForThisConnection`));return}C(!0),T(``);try{if(a){t(await H(`/api/providers/${encodeURIComponent(a.id)}/clone`,{method:`POST`,body:JSON.stringify({name:g.name,id:g.id,apiKey:k})}));return}let e=h?await H(`/api/config`,{method:`PUT`,body:JSON.stringify({...g,apiKey:k,thinkingLevels:y?g.thinkingLevels:void 0,provider:p||g.id,providerName:g.name,setAsDefault:!1})}):await H(`/api/providers`,{method:`POST`,body:JSON.stringify({...g,apiKey:k,thinkingLevels:y?g.thinkingLevels:void 0})}),r=e.createdProviderId||p||g.id;i||(m(r),_(e=>({...e,id:r})),n?.(e));let o=new Set((i?.models||[]).map(e=>e.id)),s=A.filter(e=>e!==g.model.trim()&&!o.has(e));if(s.length)try{e=await H(`/api/providers/${encodeURIComponent(r)}/models/batch`,{method:`POST`,body:JSON.stringify({models:s.map(e=>({id:e,kind:g.providerType===`visual`?g.modelKind:`chat`}))})})}catch(e){T(e instanceof Error?e.message:String(e));return}t(e)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}}},children:[!o&&(0,q.jsxs)(Ze,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{children:s(u?`config:configPage.cloneProvider`:h?`config:configPage.editProviderConnection`:`config:configPage.addProviderConnection`)}),!u&&(0,q.jsx)(`p`,{children:s(h?`config:configPage.updateProviderKeyURLAndModelSettings`:`config:configPage.youCanCreateMultipleConnectionsUsingTheSameProtocolEachWithItsOwnKeyAndBaseURL`)})]}),(0,q.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`config:configPage.closeDialog`),disabled:S,onClick:t=>{t.preventDefault(),t.stopPropagation(),e()},children:(0,q.jsx)(ze,{size:17})})]}),(0,q.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(W,{variant:`control`,children:[s(`config:configPage.displayName`),(0,q.jsx)(`input`,{value:g.name,onChange:e=>N(e.target.value),placeholder:s(`config:configPage.forExampleOpenAIOfficial`)})]}),(0,q.jsxs)(W,{variant:`control`,children:[`Provider ID`,(0,q.jsx)(`input`,{value:g.id,disabled:h,onChange:e=>_({...g,id:e.target.value}),placeholder:`openai-official`})]})]}),(0,q.jsx)(lr,{value:E,onChange:O,configured:i?.configured,cloning:u}),!u&&(0,q.jsxs)(q.Fragment,{children:[!o&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-[8px] [margin-top:10px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-[8px_10px]`,children:[(0,q.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:s(`config:configPage.providerPurpose`)}),(0,q.jsx)(`strong`,{className:`text-[12px]`,children:g.providerType===`visual`?s(`config:configPage.visualProvider`):s(`config:configPage.chatProvider`)})]}),(0,q.jsxs)(W,{variant:`control`,children:[s(`config:configPage.apiProtocol`),(0,q.jsx)(D,{value:g.api,onChange:e=>_({...g,api:e.target.value}),children:$n.map(([e,t])=>(0,q.jsx)(`option`,{value:e,children:t},e))})]}),(0,q.jsxs)(W,{variant:`control`,children:[`Base URL`,(0,q.jsx)(`input`,{value:g.baseUrl,onChange:e=>_({...g,baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})]}),(0,q.jsxs)(`div`,{className:`form-grid grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(W,{variant:`control`,children:[s(h?`config:configPage.providerDefaultModel`:`config:configPage.initialModelID`),(0,q.jsx)(`input`,{value:g.model,onChange:e=>_({...g,model:e.target.value}),placeholder:g.providerType===`visual`?`gpt-image-2 or grok-imagine-video`:`gpt-5.4 or gpt-image-1`})]}),(0,q.jsxs)(W,{variant:`control`,children:[s(`config:configPage.modelName`),(0,q.jsx)(`input`,{value:g.modelName,onChange:e=>_({...g,modelName:e.target.value}),placeholder:s(`config:configPage.leaveBlankToUseTheModelID`)})]})]}),(0,q.jsxs)(`details`,{open:!o||void 0,className:`group rounded-lg border border-border px-3 py-2 [&[open]]:space-y-3`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer text-[13px] text-muted-foreground`,children:s(`config:providerWorkbench.modelOptions`)}),(0,q.jsxs)(W,{variant:`control`,children:[s(`config:configPage.modelType`),(0,q.jsxs)(D,{value:g.modelKind,onChange:e=>_({...g,modelKind:e.target.value,providerType:e.target.value===`chat`?`chat`:`visual`}),children:[(0,q.jsx)(`option`,{value:`chat`,children:s(`providers:modelEditor.chat`)}),(0,q.jsx)(`option`,{value:`image`,children:s(`providers:modelEditor.image`)}),(0,q.jsx)(`option`,{value:`video`,children:s(`providers:modelEditor.video`)})]})]}),(0,q.jsx)(`div`,{className:`grid gap-[9px]`,children:(0,q.jsx)(ur,{ids:A,onChange:M,primaryId:g.model,placeholder:g.providerType===`visual`?`gpt-image-1`:`gpt-5.5`})}),g.modelKind===`chat`&&(0,q.jsxs)(W,{variant:`control`,children:[s(`config:configPage.modelThinkingLevels`),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:v.map(e=>{let t=e===`off`,n=t||g.thinkingLevels.includes(e),r=t||!g.reasoning&&e!==`off`;return(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r,onClick:()=>!t&&x(e),className:j(`inline-flex h-[27px] cursor-pointer items-center gap-[4px] rounded-full border px-[10px] text-[12px] font-medium transition-colors`,n?`border-[var(--control-selected-border)] bg-[var(--control-selected-bg)] text-[var(--control-selected-text)]`:`border-[var(--stroke)] bg-[var(--surface-subtle)] text-[var(--text)] hover:bg-[var(--surface-highlight)]`,t?`cursor-default`:r&&`cursor-not-allowed opacity-40`),children:[n&&(0,q.jsx)(R,{size:12}),e]},e)})}),(0,q.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:s(`config:configPage.modelThinkingLevelsHint`)})]})]}),!o&&(0,q.jsxs)(`div`,{className:`mt-2.5 flex min-h-11 items-center justify-between gap-3 rounded-sm border border-[var(--stroke-soft)] bg-[var(--surface-subtle)] px-2.5 py-2`,children:[(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,q.jsx)(`strong`,{className:`text-[13px]`,children:h?s(`config:configPage.providerEnabled`,{name:g.name}):s(`config:configPage.enableAfterCreation`)}),g.providerType===`visual`&&(0,q.jsx)(`small`,{className:`text-[13px] text-muted-foreground`,children:s(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]}),(0,q.jsx)(Nn,{value:g.enabled,onChange:e=>_({...g,enabled:e})})]})]}),w&&(0,q.jsxs)(Ye,{children:[(0,q.jsx)(V,{size:13}),w]}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,q.jsx)(U,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:S,onClick:e,children:s(`config:configPage.cancel`)}),(0,q.jsxs)(U,{size:`lg`,disabled:S,children:[S?(0,q.jsx)(z,{className:`animate-spin`,size:14}):h?(0,q.jsx)(R,{size:14}):(0,q.jsx)(Ee,{size:14}),s(S?`config:configPage.saving`:u?`config:configPage.cloneProvider`:h?`config:configPage.saveChanges`:`config:configPage.createConnection`)]})]})]})})}function pr(e){return(e.providers||[]).filter(e=>e.importable&&!e.imported&&!e.conflict).length}function mr(e){return pr(e)>0}function hr(e,t){return!t&&!mr(e)}function gr(e,t,n){let r=e.providers||[],i=e.errors||[],a=mr(e),o=!!(n||i.length||r.some(e=>e.conflict||!e.imported&&!e.importable||e.warnings?.some(e=>e.code!==`login_auth_not_imported`)));return t||a||o}function _r(e){return e.source===`codex-config`?`Codex config.toml`:e.source===`claude-config`?`Claude settings.json`:e.source===`codex-auth`?`Codex login`:`Claude login`}function vr(e,t){return e.authType===`environment`?t(`config:configPage.keyVariableName`,{name:e.authVariable}):e.authType===`bearer`||e.authType===`api_key`?t(`config:configPage.authenticationIncludedInConfiguration`):e.authType===`oauth`?t(`config:configPage.loginStateFileDetected`):e.authType===`external-login`?t(`config:configPage.authenticationRequired`):t(`config:configPage.noAuthenticationInConfiguration`)}function yr(e,t){return t(e===`multiple_auth_values`?`config:configPage.multipleAuthenticationFieldsWereDetectedTheAuthorizationFieldTakesPrecedence`:e===`invalid_url`?`config:configPage.theProviderEndpointIsInvalid`:e===`unsupported_api`?`config:configPage.theAPIProtocolInThisConfigurationIsNotSupportedYet`:e===`invalid_env_name`?`config:configPage.theKeyEnvironmentVariableNameIsInvalid`:`config:configPage.someConfigurationFieldsCannotBeImported`)}function br({discovery:e,discovering:t,error:n,importing:r,forceVisible:i=!1,onRefresh:a,onImport:o}){let{t:s}=c(),[l,u]=(0,K.useState)(null),d=e.providers||[],f=e.errors||[];if(!i&&!gr(e,t,n))return null;let p=l??(!i&&hr(e,t)),m=()=>(u(null),a()),h=e=>(u(null),o(e)),g=e=>[`invalid_json`,`invalid_toml`].includes(e.code)?s(`config:configPage.invalidConfigurationFileFormat`):e.code===`unsupported_config`?s(`config:configPage.noImportableProviderConfigurationWasFound`):e.code===`invalid_login_state`?s(`config:configPage.incompleteLoginState`):e.code===`file_too_large`?s(`config:configPage.configurationFileIsTooLarge`):s(`config:configPage.unableToReadTheConfigurationFile`);return(0,q.jsxs)(Y,{className:`[margin-bottom:12px] [padding:12px_14px]`,children:[(0,q.jsxs)(`div`,{className:`[&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] max-[650px]:flex-wrap flex items-center gap-[10px]`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`max-[650px]:basis-full [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-1 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[3px] flex min-w-0 flex-1 items-center gap-[10px] border-0 bg-transparent p-0 text-inherit text-left cursor-pointer`,"aria-expanded":!p,onClick:()=>u(!p),children:[(0,q.jsx)(`span`,{className:`grid w-[38px] h-[38px] [flex:0_0_auto] place-items-center rounded-[11px] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(B,{size:18})}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:s(`config:configPage.localProviderConfiguration`)}),(0,q.jsx)(`small`,{children:s(`config:configPage.readProviderEndpointModelAndAuthenticationFieldsFromCodexConfigTomlAndClaudeSettingsJson`)})]}),(0,q.jsx)(le,{size:15,className:`provider-discovery-caret [&.open]:[transform:rotate(180deg)] flex-none text-[var(--text-muted)] [transition:transform_var(--d1)_var(--ease-out)] ${p?``:`open`}`})]}),(0,q.jsxs)(U,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:t||!!r,onClick:m,children:[t?(0,q.jsx)(z,{className:`animate-spin`,size:13}):(0,q.jsx)(z,{size:13}),s(`config:configPage.rescan`)]})]}),!p&&(0,q.jsxs)(q.Fragment,{children:[t&&!d.length?(0,q.jsxs)(`div`,{className:`flex min-h-[48px] items-center justify-center gap-[7px] [margin-top:9px] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] text-[var(--text-muted)] text-[12px]`,children:[(0,q.jsx)(z,{className:`animate-spin`,size:15}),s(`config:configPage.scanningProviderConfigurationFiles`)]}):d.length?(0,q.jsx)(`div`,{className:`provider-discovery-list max-[650px]:grid-cols-[1fr] grid grid-cols-[repeat(2,minmax(0,1fr))] gap-[8px] [margin-top:11px]`,children:d.map(e=>{let t=_r(e),n=r===e.id,i=e.source.startsWith(`claude-`)?oe:ae,a=e.kind===`authentication`?s(`config:configPage.officialProviderAuthenticationOnly`):e.models?.length?e.models.map(e=>e.id).join(`, `):s(`config:configPage.noModelSpecified`);return(0,q.jsxs)(`div`,{className:`provider-discovery-card grid min-w-0 min-h-[68px] grid-cols-[auto_minmax(0,1fr)_auto] max-[650px]:grid-cols-[auto_minmax(0,1fr)] items-center gap-[9px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:8px_9px] ${e.imported?`configured [.provider-discovery-card&]:border-[var(--success-border)] [.provider-discovery-card&]:bg-[var(--success-soft)]`:``}`,children:[(0,q.jsx)(`span`,{className:`provider-discovery-icon [&.source-claude-config]:bg-[var(--brand-blue-soft)] [&.source-claude-config]:text-[var(--brand-blue-strong)] grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] bg-[var(--star-soft)] text-[var(--star-strong)] source-${e.source}`,children:(0,q.jsx)(i,{size:17})}),(0,q.jsxs)(`span`,{className:`provider-discovery-copy [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[12px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] flex min-w-0 flex-col gap-[3px]`,children:[(0,q.jsxs)(`strong`,{children:[t,` · `,e.providerName]}),(0,q.jsxs)(`small`,{children:[e.api,` · `,a]}),(0,q.jsxs)(`small`,{children:[e.kind===`authentication`?s(`config:configPage.officialEndpointOnly`):e.baseUrl||s(`config:configPage.noBaseURLSpecified`),` `,`· `,vr(e,s),` · `,e.location]})]}),(0,q.jsx)(`span`,{className:`flex min-w-0 flex-none items-center max-[650px]:col-start-2`,children:e.imported?(0,q.jsx)(X,{tone:`green`,children:s(`config:configPage.loaded`)}):e.conflict?(0,q.jsx)(X,{tone:`amber`,children:s(`config:configPage.conflictDetected`)}):e.importable?(0,q.jsxs)(U,{type:`button`,disabled:n||!!r,onClick:()=>h(e),children:[n?(0,q.jsx)(z,{className:`animate-spin`,size:12}):(0,q.jsx)(he,{size:12}),n?s(`config:configPage.loading`):e.kind===`authentication`?s(`config:configPage.loadLoginState`):s(`config:configPage.loadConfiguration`)]}):(0,q.jsx)(X,{tone:`gray`,children:s(`config:configPage.cannotLoad`)})})]},e.id)})}):(0,q.jsxs)(`div`,{className:`flex min-h-[48px] items-center justify-center gap-[7px] [margin-top:9px] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] text-[var(--text-muted)] text-[12px]`,children:[(0,q.jsx)(B,{size:15}),s(`config:configPage.noImportableCodexOrClaudeProviderConfigurationWasDetected`)]}),(n||f.length>0||d.some(e=>e.warnings?.some(e=>e.code!==`login_auth_not_imported`)))&&(0,q.jsxs)(`div`,{className:`provider-discovery-errors [&_span]:flex [&_span]:items-center [&_span]:gap-[5px] flex flex-col gap-[4px] [margin-top:8px] text-[var(--danger)] text-[11px]`,"aria-live":`polite`,children:[n&&(0,q.jsxs)(`span`,{children:[(0,q.jsx)(V,{size:13}),n]}),f.map((e,t)=>(0,q.jsxs)(`span`,{children:[(0,q.jsx)(V,{size:13}),_r(e),` · `,g(e)]},`${e.source}-${e.code}-${t}`)),d.flatMap(e=>(e.warnings||[]).filter(e=>e.code!==`login_auth_not_imported`).map((t,n)=>(0,q.jsxs)(`span`,{children:[(0,q.jsx)(V,{size:13}),_r(e),` · `,yr(t.code,s)]},`${e.id}-${t.code}-${n}`)))]})]})]})}function xr(e){try{return{name:new URL(e).hostname.replace(/^www\./i,``)||`Custom Provider`}}catch{return{name:`Custom Provider`}}}function Sr({config:e,providerType:t=`chat`,initialProviderId:n,onClose:r,onConfigChanged:i,onCompleted:a}){let{t:o}=c(),s=n&&e.providers.find(e=>e.id===n)||null,[l,u]=(0,K.useState)(1),[d,f]=(0,K.useState)(s),[p]=(0,K.useState)(cr),[m,h]=(0,K.useState)(``),g=(0,K.useRef)(null),_=(0,K.useRef)(null),[v,y]=(0,K.useState)(s?.baseUrl||``),[b,x]=(0,K.useState)(s?.api||`openai-responses`),[S,C]=(0,K.useState)(``),w=S.trim()||void 0,[T,E]=(0,K.useState)(s?.organization||``),[O,k]=(0,K.useState)(s?.name||``),[A,M]=(0,K.useState)(s?.models||[]),[F,ee]=(0,K.useState)(s?.defaultModel||``),[te,ne]=(0,K.useState)([]),[re,ie]=(0,K.useState)(s?.models.find(e=>e.id===s.defaultModel)?.kind||(t===`visual`?`image`:`chat`)),[I,ae]=(0,K.useState)(!1),[oe,L]=(0,K.useState)(``),[se,ce]=(0,K.useState)(``),le=xr(v),ue=o(t===`visual`?`config:configPage.visualProvider`:`config:configPage.chatProvider`),de=o(l===1?`config:configPage.quickSetupStepBaseUrl`:l===2?`config:configPage.quickSetupStepProtocol`:`config:configPage.quickSetupStepModel`),fe=A.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`),pe=()=>{let e=v.trim();try{let t=new URL(e);if(![`http:`,`https:`].includes(t.protocol))throw Error()}catch{L(o(`config:configPage.providerBaseURLMustBeHTTPOrHTTPS`));return}L(``),O.trim()||k(le.name),u(2)},me=()=>{if(!b){L(o(`config:configPage.selectAPIProtocol`));return}L(``),u(3)},he=async()=>{if(I)return;let e=d;if(!w&&!e?.configured&&!m){L(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}ae(!0),L(``),ce(``);try{let n=((await H(`/api/providers/models/discover-connection`,{method:`POST`,body:JSON.stringify({providerId:e?.id||m,providerType:t,api:b,baseUrl:v,organization:T,apiKey:w})})).models||[]).filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`);if(!n.length){L(o(t===`visual`?`config:configPage.fetchOrAddAVisualModel`:`config:configPage.fetchOrAddAChatModel`));return}M(n);let r=n.find(e=>e.id===F)||n[0];ee(r.id),ie(t===`visual`?r.kind:`chat`)}catch(n){let r=n instanceof Error?n.message:String(n),i=e?.models.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`)||[];if(!/\(401\)|\(403\)|鉴权|认证|密钥|API Key/i.test(r)&&i.length){M(i);let e=i.find(e=>e.id===F)||i[0];ee(e.id),ie(t===`visual`?e.kind:`chat`),ce(r)}else L(r)}finally{ae(!1)}},ge=async()=>{if(I)return;let e=F.trim()||te[0]||``;if(!e){L(o(`config:configPage.selectModelToFinish`));return}if(!w&&!d?.configured&&!m){L(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}let n=new Set((d?.models||[]).map(e=>e.id)),r=te.filter(t=>t!==e&&!n.has(t));ae(!0),L(``);try{let n=d?.id||m,o=n?await H(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:n,providerType:t,api:b,baseUrl:v,organization:T,model:e,modelKind:t===`visual`?re:`chat`,apiKey:w,setAsDefault:!1,enabled:!0})}):await H(`/api/providers`,{method:`POST`,body:JSON.stringify({id:p,name:O.trim()||le.name,providerType:t,api:b,baseUrl:v,organization:T,apiKey:w,model:e,modelKind:t===`visual`?re:`chat`,enabled:!0})}),c=n||o.createdProviderId||p,l=s?``:c;l&&h(l);let u=o.providers.find(e=>e.id===c);if(u&&f(u),i?.(l?{...o,createdProviderId:l}:o),r.length){let e=t===`visual`?re:`chat`;try{o=await H(`/api/providers/${encodeURIComponent(c)}/models/batch`,{method:`POST`,body:JSON.stringify({models:r.map(t=>({id:t,kind:e}))})})}catch(e){L(e instanceof Error?e.message:String(e));return}}a(l?{...o,createdProviderId:l}:o)}catch(e){L(e instanceof Error?e.message:String(e))}finally{ae(!1)}};return(0,q.jsx)(Ge,{open:!0,onOpenChange:e=>{!e&&!I&&r()},children:(0,q.jsxs)(Ue,{showCloseButton:!1,className:`modal z-[80] block max-h-[calc(100dvh_-_40px)] w-[calc(100%_-_40px)] max-w-lg overflow-y-auto [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] sm:max-w-lg max-[650px]:max-h-[calc(100dvh_-_16px)] max-[650px]:w-[calc(100%_-_16px)]`,overlayClassName:`z-[70] bg-[var(--modal-overlay)] [backdrop-filter:blur(3px)]`,"aria-busy":I,onEscapeKeyDown:e=>{I&&e.preventDefault()},onInteractOutside:e=>{I&&e.preventDefault()},onOpenAutoFocus:e=>{e.preventDefault(),g.current=document.activeElement instanceof HTMLElement?document.activeElement:null,_.current?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),g.current?.focus()},children:[(0,q.jsxs)(Ze,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(We,{asChild:!0,children:(0,q.jsx)(`h2`,{children:o(t===`visual`?`config:configPage.visualQuickSetupTitle`:`config:configPage.quickSetupTitle`)})}),(0,q.jsx)(Ve,{asChild:!0,children:(0,q.jsxs)(`p`,{children:[o(`config:configPage.stepIndicator`,{current:l,total:3}),` · `,de]})})]}),(0,q.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":o(`config:configPage.closeDialog`),disabled:I,onClick:r,children:(0,q.jsx)(ze,{size:17})})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-[8px] [margin-top:12px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-[9px_10px]`,children:[(0,q.jsx)(`span`,{className:`grid w-[30px] h-[30px] flex-none place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(B,{size:16})}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,q.jsx)(`strong`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:O||le.name}),(0,q.jsx)(`small`,{className:`text-[11px] text-[var(--text-muted)]`,children:ue})]}),(0,q.jsx)(X,{tone:`gray`,children:ue})]}),l===1&&(0,q.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,q.jsxs)(W,{variant:`control`,children:[`Base URL`,(0,q.jsx)(`input`,{ref:_,value:v,onChange:e=>y(e.target.value),placeholder:`https://api.example.com/v1`,inputMode:`url`})]}),(0,q.jsx)(`p`,{className:`[margin:8px_0_0] text-[12px] leading-[1.5] text-[var(--text-muted)]`,children:o(`config:configPage.quickSetupBaseUrlHint`)})]}),l===2&&(0,q.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,q.jsxs)(W,{variant:`control`,children:[o(`config:configPage.apiProtocol`),(0,q.jsx)(D,{value:b,onChange:e=>x(e.target.value),children:$n.map(([e,t])=>(0,q.jsx)(`option`,{value:e,children:t},e))})]}),(0,q.jsxs)(W,{variant:`control`,children:[`Organization`,(0,q.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),placeholder:o(`config:configPage.optionalUsedOnlyForOpenAIOrganization`)})]})]}),l===3&&(0,q.jsxs)(`div`,{className:`[margin-top:14px]`,children:[!d&&(0,q.jsxs)(W,{variant:`control`,children:[o(`config:configPage.displayName`),(0,q.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:le.name})]}),(0,q.jsx)(lr,{value:S,onChange:C,configured:d?.configured}),(0,q.jsxs)(U,{type:`button`,size:`lg`,className:`[margin-top:10px] w-full`,disabled:I,onClick:()=>void he(),children:[I?(0,q.jsx)(z,{className:`animate-spin`,size:14}):(0,q.jsx)(z,{size:14}),o(I?`config:configPage.fetchingModels`:`config:configPage.fetchModels`)]}),se&&(0,q.jsxs)(Je,{className:`[margin-top:10px]`,children:[(0,q.jsx)(V,{size:15}),(0,q.jsx)(`small`,{children:o(`config:configPage.discoverFailedUsingExisting`,{message:se})})]}),fe.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`[margin:14px_0_8px] text-[12px] leading-[1.5] text-[var(--text-muted)]`,children:o(t===`visual`?`config:configPage.selectVisualModelToFinish`:`config:configPage.selectModelToFinish`)}),(0,q.jsx)(`div`,{className:`flex max-h-[260px] flex-col gap-[6px] overflow-y-auto`,children:fe.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:j(`flex min-w-0 cursor-pointer items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-[8px_10px] text-left hover:border-[var(--accent-border)]`,F===e.id&&`[border-color:var(--accent-border)] bg-[var(--accent-soft)]`),onClick:()=>{ee(e.id),ie(t===`visual`?e.kind:`chat`)},children:[(0,q.jsx)(`span`,{className:j(`grid w-[16px] h-[16px] flex-none place-items-center rounded-full [border:1px_solid_var(--stroke)] text-transparent`,F===e.id&&`[border-color:var(--brand-blue)] bg-[var(--brand-blue)] text-white`),children:(0,q.jsx)(R,{size:11})}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:e.name}),t===`visual`&&(0,q.jsx)(X,{tone:`gray`,children:e.kind===`video`?o(`config:configPage.visualVideoModel`):o(`config:configPage.visualImageModel`)})]},`${e.id}-${e.kind}`))})]}),(0,q.jsxs)(`div`,{className:`[margin-top:14px] grid gap-[9px]`,children:[(0,q.jsxs)(W,{variant:`control`,children:[o(`config:configPage.manualModelId`),(0,q.jsx)(`input`,{value:F,onChange:e=>ee(e.target.value),placeholder:t===`visual`?`gpt-image-1`:`gpt-5.4`})]}),(0,q.jsx)(`p`,{className:`[margin:0] text-[11px] text-[var(--text-tertiary)]`,children:o(`config:configPage.manualModelIdHint`)}),t===`visual`&&(0,q.jsxs)(W,{variant:`control`,children:[o(`config:configPage.modelType`),(0,q.jsxs)(D,{value:re,onChange:e=>ie(e.target.value),children:[(0,q.jsx)(`option`,{value:`image`,children:o(`config:configPage.imageGenerationAndEditing`)}),(0,q.jsx)(`option`,{value:`video`,children:o(`config:configPage.videoGeneration`)})]})]}),(0,q.jsx)(ur,{ids:te,onChange:ne,primaryId:F,placeholder:t===`visual`?`gpt-image-1`:`gpt-5.5`})]})]}),oe&&(0,q.jsxs)(Ye,{children:[(0,q.jsx)(V,{size:13}),oe]}),(0,q.jsxs)(`div`,{className:`flex justify-between gap-[8px] [margin-top:18px]`,children:[(0,q.jsxs)(U,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:I||l===1,onClick:()=>{L(``),u(l-1)},children:[(0,q.jsx)(N,{size:14}),o(`config:configPage.previousStep`)]}),l===1?(0,q.jsxs)(U,{type:`button`,size:`lg`,disabled:I||!v.trim(),onClick:pe,children:[(0,q.jsx)(P,{size:14}),o(`config:configPage.nextStep`)]}):l===2?(0,q.jsxs)(U,{type:`button`,size:`lg`,disabled:I,onClick:me,children:[(0,q.jsx)(P,{size:14}),o(`config:configPage.nextStep`)]}):(0,q.jsxs)(U,{type:`button`,size:`lg`,disabled:I||!F.trim()&&te.length===0,onClick:()=>void ge(),children:[I?(0,q.jsx)(z,{className:`animate-spin`,size:14}):(0,q.jsx)(R,{size:14}),o(I?`config:configPage.saving`:`config:configPage.saveChanges`)]})]})]})})}function Cr({config:e,notify:t,onConfigChanged:n}){let{t:r}=c(),[i,a]=(0,K.useState)(e.thinkingLevel),[o,s]=(0,K.useState)(e.toolMode),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(``);(0,K.useEffect)(()=>{a(e.thinkingLevel),s(e.toolMode)},[e.thinkingLevel,e.toolMode]);let p=e.defaultProvider||e.provider,m=e.defaultModel||e.model,h=e.providers.find(e=>e.id===p),g=!!(h?.configured&&m),_=i!==e.thinkingLevel||o!==e.toolMode,v=async()=>{if(!(!h||!m)){u(!0),f(``);try{n(await H(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:h.id,providerType:h.type,api:h.api,baseUrl:h.baseUrl||``,organization:h.organization||``,model:m,thinkingLevel:i,toolMode:o,setAsDefault:!1})})),t(r(`config:configPage.runtimePolicySaved`))}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}};return(0,q.jsxs)(Y,{children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-[8px]`,children:[(0,q.jsx)(Mn,{title:r(`config:configPage.agentRuntimePolicy`)}),(0,q.jsxs)(U,{size:`sm`,className:`h-[27px] px-[10px] text-[12px]`,disabled:l||!_||!g,onClick:()=>void v(),children:[l?(0,q.jsx)(z,{className:`animate-spin`,size:13}):(0,q.jsx)(ke,{size:13}),r(l?`config:configPage.saving`:`config:configPage.saveSettings`)]})]}),(0,q.jsxs)(W,{variant:`control`,children:[r(`config:configPage.thinkingLevel`),(0,q.jsx)(D,{value:i,onChange:e=>a(e.target.value),children:[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`].map(e=>(0,q.jsx)(`option`,{children:e},e))})]}),(0,q.jsxs)(W,{variant:`control`,children:[r(`config:configPage.availableTools`),(0,q.jsxs)(D,{value:o,onChange:e=>s(e.target.value),children:[(0,q.jsx)(`option`,{value:`full`,children:r(`config:configPage.fullToolAccess`)}),(0,q.jsx)(`option`,{value:`custom`,children:r(`config:configPage.customManageEachToolOnThePluginsPage`)})]})]}),(0,q.jsxs)(Je,{children:[(0,q.jsx)(Me,{size:16}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:r(`config:configPage.permissionsAreEnforcedByTheRuntime`)}),(0,q.jsx)(`small`,{children:r(`config:configPage.afterSavingExistingRuntimesAreReleasedAndNewChatsUseTheLatestPolicy`)})]})]}),d&&(0,q.jsxs)(Ye,{children:[(0,q.jsx)(V,{size:13}),d]})]})}function wr(e){return e instanceof Error?e.message:String(e)}function Tr({notify:e,requestConfirm:t,t:n}){let[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(!0),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(``),_=(0,K.useRef)(0),v=(0,K.useRef)(!1);(0,K.useEffect)(()=>{let e=!0;v.current=!0;let t=_.current;return H(`/api/config`).then(n=>{if(e)return _.current===t&&i(n),o(!1),H(`/api/providers/models/refresh`,{method:`POST`,body:`{}`})}).then(n=>{!e||_.current!==t||!n?.config||i(n.config)}).catch(n=>{!e||_.current!==t||(c(wr(n)),o(!1))}),()=>{e=!1,v.current=!1,_.current+=1}},[]);let y=(0,K.useCallback)(e=>{_.current+=1,i(e),o(!1),c(``)},[]),b=(0,K.useCallback)(async()=>{let e=_.current,t=await H(`/api/config`);v.current&&_.current===e&&y(t)},[y]),x=(0,K.useCallback)(async(t,r)=>{u(t.id),c(``);try{let i=await H(`/api/providers/${encodeURIComponent(t.id)}/enabled`,{method:`PUT`,body:JSON.stringify({enabled:r})});y(i),e(n(`config:configPage.nameState`,{name:t.name,state:n(r?`config:configPage.enabled`:`config:configPage.disabled`)}))}catch(e){c(wr(e))}finally{u(``)}},[y,e,n]),S=(0,K.useCallback)(async t=>{f(t.id),c(``);try{let r=await H(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,setAsDefault:!0})});y(r),e(n(`config:configPage.defaultProviderUpdated`,{name:t.name}))}catch(e){c(wr(e))}finally{f(``)}},[y,e,n]),C=(0,K.useCallback)(async(t,r)=>{m(t.id),c(``);try{let i=await H(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:t.id,model:r,setAsDefault:!1})});y(i),e(n(`config:configPage.providerConnectionUpdated`))}catch(e){c(wr(e))}finally{m(``)}},[y,e,n]),w=(0,K.useCallback)(async(r,i)=>{if(await t({title:n(`providers:modelEditor.delete`),message:n(`providers:modelEditor.deleteConfirmation`,{name:i.name||i.id}),confirmLabel:n(`config:configPage.delete`)})){g(`${r.id}/${i.id}`),c(``);try{y(await tr.deleteModel(r.id,i.id)),e(n(`providers:modelEditor.deleted`))}catch(e){c(wr(e))}finally{g(``)}}},[y,e,t,n]);return{config:r,loading:a,error:s,toggling:l,settingDefault:d,settingModel:p,deletingModel:h,applyConfig:y,refreshConfig:b,setDefaultProvider:S,setProviderDefaultModel:C,toggleProvider:x,deleteProvider:(0,K.useCallback)(async r=>{if(await t({title:n(`config:configPage.deleteProviderConnection`),message:n(`config:configPage.deleteNameItsModelSettingsAndAuthenticationDetailsWillAlsoBeRemoved`,{name:r.name}),confirmLabel:n(`config:configPage.delete`)})){c(``);try{let t=await H(`/api/providers/${encodeURIComponent(r.id)}`,{method:`DELETE`});y(t),e(n(`config:configPage.providerConnectionDeleted`))}catch(e){c(wr(e))}}},[y,e,t,n]),deleteModel:w}}function Er({requestConfirm:e,onImported:t,onAutoImported:n,t:r}){let[i,a]=(0,K.useState)({providers:[],errors:[]}),[o,s]=(0,K.useState)(!0),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)({imported:0,skipped:0}),g=(0,K.useRef)(0),_=(0,K.useRef)(n);_.current=n;let v=(0,K.useCallback)(async()=>{let e=++g.current;s(!0),l(``);try{let t=await tr.importLocal();if(e!==g.current)return;a(t.discovery),h({imported:t.imported.length,skipped:t.skipped.length}),t.imported.length&&await _.current()}catch(t){e===g.current&&l(wr(t))}finally{e===g.current&&s(!1)}},[]);return(0,K.useEffect)(()=>(v(),()=>{g.current+=1}),[v]),{discovery:i,autoImport:m,discovering:o,error:c,operationError:u,importing:f,refresh:v,importProvider:(0,K.useCallback)(async n=>{let i=n.source===`codex-config`?`Codex config.toml`:n.source===`claude-config`?`Claude settings.json`:n.source===`codex-auth`?`Codex login`:`Claude login`,o=n.kind===`authentication`;if(await e({title:r(o?`config:configPage.loadLoginState`:`config:configPage.loadProviderConfiguration`),message:r(o?`config:configPage.loadOfficialProviderLoginStateFromSource`:`config:configPage.loadThisProviderConfigurationFromSource`,{source:i}),confirmLabel:r(o?`config:configPage.loadLoginState`:`config:configPage.loadConfiguration`)})){p(n.id),d(``);try{let e=await H(`/api/providers/${encodeURIComponent(n.id)}/import`,{method:`POST`,body:`{}`});a(e.discovery),t(e)}catch(e){d(wr(e))}finally{p(``)}}},[t,e,r])}}function Dr({providers:e,defaultProviderId:t=``,toggling:n,settingDefault:r=``,settingModel:i=``,onConfigure:a,onClone:o,onSetDefault:s,onSetDefaultModel:l,onToggle:u,onDelete:d}){let{t:f}=c(),p=e.filter(e=>e.configured||e.custom);return(0,q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:p.map(e=>{let c=er[e.id]||B,p=e.id===t,m=e.configured?e.enabled?f(`config:configPage.authenticationReady`):f(`config:configPage.disabled2`):e.id===`openai-codex`?f(`config:configPage.codexCLILoginRequired`):f(`config:configPage.apiKeyRequired`);return(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border border-[var(--stroke-soft)] rounded-sm bg-[var(--surface-subtle)] px-3 py-2.5`,children:[(0,q.jsxs)(`button`,{type:`button`,title:f(`config:configPage.configure`),className:`flex min-w-0 cursor-pointer items-center gap-2 rounded-sm border-0 bg-transparent p-0 text-left hover:text-[var(--brand-blue)] focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,onClick:()=>a(e),children:[(0,q.jsx)(`span`,{className:`grid w-[30px] h-[30px] flex-none place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(c,{size:16})}),(0,q.jsx)(`strong`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:e.name}),p&&(0,q.jsx)(X,{tone:`green`,children:f(`config:configPage.defaultBadge`)})]}),l&&e.models.some(e=>e.kind===`chat`)?(0,q.jsxs)(`label`,{className:`grid min-w-0 gap-1 text-[12px] text-[var(--text-muted)]`,children:[f(`config:configPage.providerDefaultModel`),(0,q.jsxs)(D,{"aria-label":`${f(`config:configPage.providerDefaultModel`)}: ${e.name}`,value:e.defaultModel||``,disabled:!!(i||r),onChange:t=>void l(e,t.target.value),children:[!e.models.some(t=>t.kind===`chat`&&t.id===e.defaultModel)&&(0,q.jsx)(`option`,{value:e.defaultModel||``,disabled:!0,children:e.defaultModel||f(`config:configPage.selectModel`)}),e.models.filter(e=>e.kind===`chat`).map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):e.defaultModel?(0,q.jsxs)(`small`,{className:`truncate text-[12px] text-[var(--text-muted)]`,title:e.defaultModel,children:[f(`config:configPage.providerDefaultModel`),`: `,e.defaultModel]}):null,(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-[8px]`,children:[(0,q.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:m}),(0,q.jsxs)(`div`,{className:`flex flex-none items-center gap-[6px]`,children:[s&&(0,q.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`h-[26px] w-[26px]`,title:f(`config:configPage.setAsDefaultProvider`),"aria-label":f(`config:configPage.setAsDefaultProvider`),"aria-pressed":p,disabled:p||!e.configured||!e.enabled||!e.defaultModel||!!(r||i),onClick:()=>void s(e),children:(0,q.jsx)(Dn,{size:13})}),(0,q.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`h-[26px] w-[26px]`,title:f(`config:configPage.cloneProvider`),"aria-label":f(`config:configPage.cloneProvider`),onClick:()=>o(e),children:(0,q.jsx)(me,{size:13})}),(0,q.jsx)(Nn,{ariaLabel:f(`config:configPage.providerEnabled`,{name:e.name}),value:e.configured&&e.enabled,disabled:!e.configured||n===e.id,onChange:t=>u(e,t)}),e.custom&&(0,q.jsx)(U,{type:`button`,variant:`destructive`,size:`icon`,className:`h-[26px] w-[26px]`,title:f(`config:configPage.deleteProvider`),"aria-label":f(`config:configPage.deleteProvider`),onClick:()=>void d(e),children:(0,q.jsx)(Ie,{size:13})})]})]})]},e.id)})})}var Or=`pisper.config.visualConnectionsOpen`,Z={running:null,result:null,error:``};function kr(){return n.getItem(Or)===`1`}function Ar({config:e,notify:t,toggling:r,onToggleProvider:i,onDeleteProvider:a,onCloneProvider:o,onQuickSetup:s,onEditVisualProvider:l}){let{t:u}=c(),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(!0),[h,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(null),[w,T]=(0,K.useState)(``),[E,O]=(0,K.useState)(kr),k=(0,K.useCallback)(async()=>{try{f(await H(`/api/visual/models`)),T(``)}catch(e){T(e instanceof Error?e.message:String(e))}finally{m(!1)}},[]);(0,K.useEffect)(()=>{k()},[k,e]),(0,K.useEffect)(()=>{Z.result&&C(Z.result),Z.error&&T(Z.error);let e=Z.running;if(!e)return;x(!0);let t=!0;return e.then(e=>{t&&C(e)}).catch(()=>{t&&T(Z.error)}).finally(()=>{t&&x(!1)}),()=>{t=!1}},[]);let A=async(e,n)=>{y(e),T(``);try{f(await H(`/api/visual/models/${e}`,{method:`PUT`,body:JSON.stringify({model:n})})),t(u(`config:configPage.visualModelUpdated`))}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(``)}},j=async()=>{if(Z.running)return;x(!0),T(``),C(null),Z.result=null,Z.error=``;let e=H(`/api/visual/test`,{method:`POST`,body:`{}`,timeout:21e4});Z.running=e;try{let n=await e;Z.result=n,C(n),t(u(`config:configPage.testSucceeded`))}catch(e){let n=e instanceof Error?e.message:String(e);Z.error=n,T(n),t(n)}finally{Z.running=null,x(!1)}},M=e=>{O(e),n.setItem(Or,e?`1`:`0`)},N=e.providers.filter(e=>e.type===`visual`),P=N.filter(e=>e.configured||e.custom),F=d?.imageModels||[],ee=d?.videoModels||[];return(0,q.jsxs)(`section`,{className:`[margin-top:12px]`,children:[(0,q.jsxs)(Y,{className:`[margin-bottom:12px]`,"data-config-card":`models-visual`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,q.jsx)(`span`,{className:`grid size-10 flex-none place-items-center rounded-lg bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(Pe,{size:19})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,q.jsx)(`span`,{className:`text-[12px] font-[600] text-[var(--text-muted)]`,children:u(`config:configPage.currentVisualModel`)}),p?(0,q.jsxs)(`span`,{className:`flex items-center gap-[7px] text-[12px] text-[var(--text-muted)]`,children:[(0,q.jsx)(z,{className:`animate-spin`,size:13}),u(`config:configPage.loadingVisualStatus`)]}):d?.image?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-[7px]`,children:[(0,q.jsxs)(`strong`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[15px]`,children:[d.image.providerName,` / `,d.image.name]}),(0,q.jsxs)(X,{tone:`green`,children:[(0,q.jsx)(de,{size:11,className:`mr-[3px] inline`}),u(`config:configPage.authenticationReady`)]})]}),d.video&&(0,q.jsxs)(`small`,{className:`text-[12px] text-[var(--text-muted)] [overflow-wrap:anywhere]`,children:[u(`config:configPage.visualVideoModel`),`:`,d.video.providerName,` /`,` `,d.video.name]})]}):(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,q.jsxs)(`strong`,{className:`flex items-center gap-[6px] text-[14px] text-[var(--warning-strong)]`,children:[(0,q.jsx)(ue,{size:15}),u(`config:configPage.visualNoneConfigured`)]}),(0,q.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:u(`config:configPage.visualEmptyHint`)})]})]}),(0,q.jsxs)(`div`,{className:`flex w-full min-w-0 max-w-full flex-none flex-wrap items-center gap-[7px] sm:w-auto`,children:[d?.image&&(0,q.jsxs)(U,{variant:`outline`,className:`bg-surface-subtle`,disabled:b,onClick:()=>void j(),children:[b?(0,q.jsx)(z,{className:`animate-spin`,size:13}):(0,q.jsx)(ye,{size:13}),u(b?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,q.jsxs)(U,{onClick:s,children:[(0,q.jsx)(Le,{size:13}),u(`config:configPage.visualQuickSetup`)]})]})]}),S&&(0,q.jsxs)(`div`,{className:`flex items-center gap-[10px] [margin-top:10px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-[8px_10px]`,children:[S.previewDataUrl?(0,q.jsx)(`img`,{src:S.previewDataUrl,alt:S.modelName,className:`h-[44px] w-[44px] flex-none rounded-[var(--r-xs)] object-cover`}):(0,q.jsx)(R,{size:16,className:`flex-none text-[var(--success)]`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[1px] text-[12px]`,children:[(0,q.jsx)(`strong`,{className:`text-[var(--success-strong)]`,children:u(`config:configPage.testSucceeded`)}),(0,q.jsxs)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[var(--text-muted)]`,children:[S.providerName,` / `,S.modelName,` · `,S.path]})]})]})]}),(0,q.jsxs)(v,{open:E,onOpenChange:M,children:[(0,q.jsx)(_,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`group flex w-full cursor-pointer items-center gap-[7px] border-0 bg-transparent p-[4px_2px] text-left`,children:[(0,q.jsx)(le,{size:15,className:`flex-none text-[var(--text-muted)] transition-transform group-data-[state=closed]:-rotate-90`}),(0,q.jsx)(`span`,{className:`shrink-0 text-[13px] font-[700] text-[var(--text-secondary)]`,children:u(`config:configPage.visualConnections`)}),(0,q.jsx)(`span`,{className:`min-w-0 text-[12px] text-[var(--text-tertiary)]`,children:u(`config:configPage.visualConnectionsHint`)})]})}),(0,q.jsx)(g,{children:(0,q.jsxs)(Y,{children:[(0,q.jsx)(Dr,{providers:N,toggling:r,onClone:o,onConfigure:e=>l(e.id),onToggle:i,onDelete:a}),P.length===0&&(0,q.jsx)(`p`,{className:`[margin:2px_0_0] text-[12px] text-[var(--text-muted)]`,children:u(`config:configPage.visualEmptyHint`)}),(F.length>0||ee.length>0)&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-[8px] [border-top:1px_solid_var(--stroke-soft)] [margin-top:10px] pt-[10px]`,children:[F.length>0&&(0,q.jsxs)(`div`,{className:`flex items-center gap-[8px]`,children:[(0,q.jsx)(`span`,{className:`w-[64px] flex-none text-[12px] text-[var(--text-muted)]`,children:u(`config:configPage.visualImageModel`)}),(0,q.jsxs)(D,{className:`min-w-0 flex-1`,value:d?.imageSelection||``,disabled:h===`image`,"aria-label":u(`config:configPage.visualImageModel`),onChange:e=>void A(`image`,e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),F.map(e=>(0,q.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),ee.length>0&&(0,q.jsxs)(`div`,{className:`flex items-center gap-[8px]`,children:[(0,q.jsx)(`span`,{className:`w-[64px] flex-none text-[12px] text-[var(--text-muted)]`,children:u(`config:configPage.visualVideoModel`)}),(0,q.jsxs)(D,{className:`min-w-0 flex-1`,value:d?.videoSelection||``,disabled:h===`video`,"aria-label":u(`config:configPage.visualVideoModel`),onChange:e=>void A(`video`,e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:u(`config:configPage.visualAutoSelected`)}),ee.map(e=>(0,q.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,q.jsx)(`small`,{className:`text-[11px] text-[var(--text-tertiary)]`,children:u(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),w&&(0,q.jsx)(`div`,{className:`[margin-top:10px]`,children:(0,q.jsxs)(Ye,{children:[(0,q.jsx)(V,{size:13}),w]})})]})}var jr=`pisper.config.manageConnectionsOpen`;function Mr(){let e=n.getItem(jr);return e===`1`||e!==`0`&&null}function Nr({notify:e,registerPrimaryAction:r,requestConfirm:i}){let{t:a}=c(),o=t(),s=new URLSearchParams(o.search).get(`import`)===`1`,[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),[h,y]=(0,K.useState)(()=>s?!0:Mr());(0,K.useEffect)(()=>{s&&y(!0)},[s]);let b=Tr({notify:e,requestConfirm:i,t:a}),{config:x}=b,S=Er({requestConfirm:i,onAutoImported:b.refreshConfig,onImported:t=>{b.applyConfig(t.config);let n=t.config.providers.find(e=>e.id===t.providerId);e(t.kind===`authentication`?a(`config:configPage.nameLoginStateHasBeenLoadedIntoPisper`,{name:n?.name||t.providerId}):a(`config:configPage.nameConfigurationHasBeenLoadedIntoPisper`,{name:n?.name||t.providerId}))},t:a});if(ut(r,()=>f({providerType:`chat`})),!x)return(0,q.jsxs)($e,{children:[(0,q.jsx)(z,{className:`animate-spin`,size:24}),(0,q.jsx)(`h2`,{children:a(`config:configPage.loadingModelCatalog`)}),(0,q.jsx)(`p`,{children:a(`config:configPage.readingProvidersAndAuthenticationStatus`)}),b.error&&(0,q.jsx)(Ye,{children:b.error})]});let C=x.defaultProvider||x.provider,w=x.providers.find(e=>e.id===C&&e.configured),T=x.defaultModel||x.model,E=h??!1,D=pr(S.discovery),O=e=>{y(e),n.setItem(jr,e?`1`:`0`)},k=e=>m(e);return(0,q.jsxs)(q.Fragment,{children:[w&&T&&(0,q.jsx)(`div`,{className:`mb-4 text-sm`,children:(0,q.jsxs)(`p`,{className:`min-w-0 truncate text-muted-foreground`,children:[a(`config:configPage.currentChatModel`),` ·`,` `,(0,q.jsxs)(`span`,{className:`text-foreground`,children:[w.name,` / `,T]})]})}),(0,q.jsxs)(`p`,{className:`mb-4 flex items-center gap-2 text-xs text-muted-foreground`,role:`status`,children:[S.discovering&&(0,q.jsx)(z,{size:12,className:`animate-spin`}),S.discovering?a(`config:providerWorkbench.scanningLocal`):a(`config:providerWorkbench.localImportStatus`,{imported:S.autoImport.imported,skipped:S.autoImport.skipped})]}),(0,q.jsx)(sr,{config:x,selectedProviderId:l,onSelectProvider:u,toggling:b.toggling,settingDefault:b.settingDefault,settingModel:b.settingModel,onSave:t=>{b.applyConfig(t),e(a(`config:configPage.providerConnectionUpdated`))},onClone:k,onDelete:b.deleteProvider,deletingModel:b.deletingModel,onDeleteModel:b.deleteModel,onToggle:b.toggleProvider,onSetDefault:b.setDefaultProvider,onSetDefaultModel:b.setProviderDefaultModel}),b.error&&(0,q.jsx)(Ye,{children:b.error}),D>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0 text-[length:var(--app-small-size)] text-[var(--text-muted)]`,children:[(0,q.jsx)(`span`,{children:a(`config:configPage.localProviderImportHint`,{count:D})}),(0,q.jsx)(U,{type:`button`,variant:`link`,size:`sm`,className:`h-auto min-h-11 shrink-0 px-1 py-0 font-normal text-[var(--text-secondary)] sm:min-h-8`,"aria-expanded":E,"aria-controls":`model-connection-management`,onClick:()=>O(!0),children:a(`config:configPage.reviewLocalProviders`)})]}),(0,q.jsxs)(v,{open:E,onOpenChange:O,"data-config-card":`models-advanced`,children:[(0,q.jsx)(_,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`group flex w-full cursor-pointer items-center gap-[7px] [margin:2px_0_10px] border-0 bg-transparent p-[4px_2px] text-left`,children:[(0,q.jsx)(le,{size:15,className:`shrink-0 text-[var(--text-muted)] transition-transform group-data-[state=closed]:-rotate-90`}),(0,q.jsx)(`span`,{className:`shrink-0 text-[13px] font-[700] text-[var(--text-secondary)]`,children:a(`config:providerWorkbench.advanced`)}),(0,q.jsx)(`span`,{className:`min-w-0 text-[12px] text-[var(--text-tertiary)]`,children:a(`config:providerWorkbench.advancedHint`)})]})}),(0,q.jsxs)(g,{id:`model-connection-management`,children:[(0,q.jsx)(br,{discovery:S.discovery,discovering:S.discovering,error:S.error||S.operationError,importing:S.importing,forceVisible:s,onRefresh:S.refresh,onImport:S.importProvider}),(0,q.jsx)(`div`,{className:`[margin-top:12px]`,children:(0,q.jsx)(Cr,{config:x,notify:e,onConfigChanged:b.applyConfig})}),(0,q.jsx)(Ar,{config:x,notify:e,toggling:b.toggling,onToggleProvider:b.toggleProvider,onCloneProvider:k,onDeleteProvider:b.deleteProvider,onQuickSetup:()=>f({providerType:`visual`}),onEditVisualProvider:e=>{let t=x.providers.find(t=>t.id===e);t&&(u(t.id),document.querySelector(`[data-model-provider-split-panel]`)?.scrollIntoView({block:`start`,behavior:`smooth`}))}})]})]}),d&&(0,q.jsx)(Sr,{config:x,providerType:d.providerType||`chat`,initialProviderId:d.providerId,onConfigChanged:e=>{b.applyConfig(e),e.createdProviderId&&u(e.createdProviderId)},onClose:()=>f(null),onCompleted:t=>{b.applyConfig(t),t.createdProviderId&&u(t.createdProviderId),e(a(`config:configPage.setupComplete`)),f(null)}}),p&&(0,q.jsx)(fr,{initialProviderType:p.type,cloneProvider:p,onClose:()=>m(null),onCreated:t=>{b.applyConfig(t),t.createdProviderId&&u(t.createdProviderId),e(a(`config:configPage.providerConnectionCreated`)),m(null)}})]})}function Q(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function Pr(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var Fr,$,Ir,Lr,Rr=`__TAURI_TO_IPC_KEY__`;function zr(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var Br=class{constructor(e){Fr.set(this,void 0),$.set(this,0),Ir.set(this,[]),Lr.set(this,void 0),Pr(this,Fr,e||(()=>{}),`f`),this.id=zr(e=>{let t=e.index;if(`end`in e){t==Q(this,$,`f`)?this.cleanupCallback():Pr(this,Lr,t,`f`);return}let n=e.message;if(t==Q(this,$,`f`)){for(Q(this,Fr,`f`).call(this,n),Pr(this,$,Q(this,$,`f`)+1,`f`);Q(this,$,`f`)in Q(this,Ir,`f`);){let e=Q(this,Ir,`f`)[Q(this,$,`f`)];Q(this,Fr,`f`).call(this,e),delete Q(this,Ir,`f`)[Q(this,$,`f`)],Pr(this,$,Q(this,$,`f`)+1,`f`)}Q(this,$,`f`)===Q(this,Lr,`f`)&&this.cleanupCallback()}else Q(this,Ir,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){Pr(this,Fr,e,`f`)}get onmessage(){return Q(this,Fr,`f`)}[(Fr=new WeakMap,$=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,Rr)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[Rr]()}};function Vr(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function Hr(e,t){return Vr(`plugin:barcode-scanner|${e}`,t)}function Ur(e){return e instanceof Error?e.message:String(e)}function Wr(e){return/cancel(?:led|ed)/i.test(Ur(e))}function Gr(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Kr(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function qr(e){if(!e.isActive||!e.port)return null;let t=Kr(e.txt.fp);if(!/^SHA256:[0-9A-F]{64}$/i.test(t))return null;let n=e.addresses.find(e=>/^\d{1,3}(?:\.\d{1,3}){3}$/.test(e))||e.addresses.find(e=>e.includes(`:`));if(!n)return null;let r=n.includes(`:`)?`[${n}]`:n,i=Kr(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function Jr(e){return new Promise(t=>window.setTimeout(t,e))}function Yr({open:e,onOpenChange:t}){let{t:n}=c(),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(!1),[s,l]=(0,K.useState)([]),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(``),[g,_]=(0,K.useState)(``),v=(0,K.useRef)(!1),y=(0,K.useRef)(!1),b=(0,K.useRef)(!1),x=(0,K.useRef)(0),S=(0,K.useRef)(``),C=(0,K.useCallback)(e=>{v.current=e,o(e)},[]),w=(0,K.useCallback)(async()=>{y.current=!0,v.current&&await Hr(`cancel`).catch(()=>void 0),C(!1),i(null)},[C]);(0,K.useEffect)(()=>{if(!a)return;let e=document.getElementById(`root`),t=[],n=(e,n,r)=>{e&&(t.push({element:e,property:n,value:e.style.getPropertyValue(n),priority:e.style.getPropertyPriority(n)}),e.style.setProperty(n,r,`important`))};return n(document.documentElement,`background`,`transparent`),n(document.body,`background`,`transparent`),n(e,`background`,`transparent`),n(e,`visibility`,`hidden`),()=>{for(let{element:e,property:n,value:r,priority:i}of t.reverse())r?e.style.setProperty(n,r,i):e.style.removeProperty(n)}},[a]),(0,K.useEffect)(()=>{if(!a)return;let e=`pisper-scanner-${Date.now()}`;window.history.pushState({...window.history.state,pisperScanner:e},``);let t=()=>void w();return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),!b.current&&window.history.state?.pisperScanner===e&&window.history.back()}},[w,a]);let T=e=>{if(!e.proxyUrl)throw Error(n(`config:mobileServer.pairFailed`));window.location.replace(e.proxyUrl)},E=(0,K.useCallback)(async()=>{let e=++x.current;d(!0),p(``),l([]);let t=new Br;t.onmessage=t=>{if(x.current!==e)return;if(t.reason===`permission-denied`){p(n(`config:mobileServer.localNetworkDenied`));return}if(t.reason?.startsWith(`error:`)){p(n(`config:mobileServer.discoveryFailed`));return}if(!t.service)return;if(!t.service.isActive){l(e=>e.filter(e=>!e.id.startsWith(`${t.service?.fullName}:`)));return}let r=qr(t.service);r&&l(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await Vr(`mobile_ensure_local_network_permission`),r=(await Vr(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await Jr(4300)}catch(t){x.current===e&&p(Ur(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await Vr(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),x.current===e&&d(!1)}},[n]);(0,K.useEffect)(()=>{if(!(!e||a))return E(),()=>{x.current+=1}},[E,e,a]);let D=(0,K.useCallback)(async()=>{let e=S.current;S.current=``,e&&await Vr(`mobile_cancel_lan_pairing`,{operationId:e}).catch(()=>void 0),i(null),h(``)},[]),O=async e=>{let t=globalThis.crypto?.randomUUID?.()||`lan-${Date.now()}-${Math.random().toString(16).slice(2)}`;S.current=t,i(`lan:${e.id}`),_(``),h(n(`config:mobileServer.awaitingApproval`,{name:e.name}));try{let n=await Vr(`mobile_pair_lan`,{operationId:t,name:e.name,url:e.url,fingerprint:e.fingerprint,deviceName:null});if(S.current!==t)return;T(n)}catch(e){S.current===t&&_(Ur(e))}finally{S.current===t&&(S.current=``,i(null),h(``))}},A=async()=>{y.current=!1,b.current=!1,i(`scan`),_(``);try{let e=await Hr(`check_permissions`);if(e.camera!==`granted`&&(e=await Hr(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(y.current||(C(!0),await Gr(),y.current))return;let t=await Hr(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));b.current=!0,T(await Vr(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!y.current&&!Wr(e)&&_(Ur(e))}finally{C(!1),i(null),y.current=!1}};return(0,q.jsx)(Ge,{open:e,onOpenChange:e=>{if(!e&&a){w();return}if(!e&&r?.startsWith(`lan:`)){D(),t(!1);return}r||(e||_(``),t(e))},children:(0,q.jsx)(Ue,{showCloseButton:!a,overlayClassName:a?`bg-transparent supports-backdrop-filter:backdrop-blur-none`:void 0,className:a?`inset-0 top-0 left-0 h-dvh max-h-none w-screen max-w-none translate-x-0 translate-y-0 gap-0 overflow-hidden rounded-none bg-transparent p-0 text-white ring-0 sm:max-w-none`:`sm:max-w-md`,onPointerDownOutside:a?e=>e.preventDefault():void 0,children:a?(0,q.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,q.jsxs)(He,{className:`sr-only`,children:[(0,q.jsx)(We,{children:n(`config:mobileServer.scanTitle`)}),(0,q.jsx)(Ve,{children:n(`config:mobileServer.scanHint`)})]}),(0,q.jsxs)(`header`,{className:`flex min-h-16 items-center justify-between gap-3 bg-black/60 px-4 pb-3`,style:{paddingTop:`max(env(safe-area-inset-top), 0.75rem)`},children:[(0,q.jsxs)(U,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void w(),children:[(0,q.jsx)(N,{}),n(`config:mobileServer.cancelScan`)]}),(0,q.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,q.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,q.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,q.jsx)(`div`,{className:`relative aspect-square w-[min(72vw,20rem)] rounded-md border-2 border-white/90 shadow-[0_0_0_9999px_rgba(0,0,0,0.18)]`,children:(0,q.jsx)(Tn,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,q.jsxs)(`footer`,{className:`flex flex-col items-center gap-3 bg-black/60 px-5 pt-4 text-center`,style:{paddingBottom:`max(env(safe-area-inset-bottom), 1rem)`},children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,q.jsx)(U,{variant:`outline`,className:`w-full max-w-sm border-white/50 bg-black/30 text-white hover:bg-black/60 hover:text-white`,onClick:()=>void w(),children:n(`config:mobileServer.cancelScan`)})]})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(He,{children:[(0,q.jsx)(We,{children:n(`config:mobileServer.addServer`)}),(0,q.jsx)(Ve,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,q.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,q.jsx)(wn,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,q.jsx)(U,{size:`icon-sm`,variant:`ghost`,disabled:u||r!==null,"aria-label":n(`config:mobileServer.rediscover`),onClick:()=>void E(),children:(0,q.jsx)(z,{className:u?`animate-spin`:void 0})})]}),s.length?(0,q.jsx)(`ul`,{className:`grid max-h-44 gap-1.5 overflow-y-auto`,children:s.map(e=>{let t=r===`lan:${e.id}`;return(0,q.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(B,{className:`size-4 flex-none text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,q.jsxs)(U,{size:`sm`,disabled:r!==null,onClick:()=>void O(e),children:[t?(0,q.jsx)(xe,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(u?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),f?(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-destructive`,children:f}):null,m?(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md bg-muted px-3 py-2`,children:[(0,q.jsx)(`p`,{className:`text-xs leading-relaxed`,children:m}),(0,q.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void D(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,q.jsxs)(`div`,{className:`relative py-1`,children:[(0,q.jsx)(k,{}),(0,q.jsx)(`span`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-popover px-2 text-xs text-muted-foreground`,children:n(`config:mobileServer.otherMethods`)})]}),(0,q.jsxs)(U,{className:`w-full`,disabled:r!==null,onClick:()=>void A(),children:[r===`scan`?(0,q.jsx)(xe,{className:`animate-spin`}):(0,q.jsx)(Cn,{}),n(`config:mobileServer.scan`)]}),g?(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-destructive`,children:g}):null]})})})}function Xr(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function Zr({requestConfirm:e}){let{t}=c(),[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(``),[l,u]=(0,K.useState)(!1),d=(0,K.useCallback)(async()=>{try{r(await Xr(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,K.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{s(n||e);try{r(await Xr(e,t)),a(``)}catch(e){a(String(e))}finally{s(``)}},p=async n=>{o||await e({title:t(`config:mobileServer.forget`),message:t(`config:mobileServer.forgetConfirm`),confirmLabel:t(`config:mobileServer.forget`),tone:`danger`})&&await f(`mobile_forget_server`,{id:n.id},n.id)},m=async e=>{s(e);try{let t=await Xr(`mobile_select_server`,{id:e});r(t),a(``),t.proxyUrl&&window.location.replace(t.proxyUrl)}catch(e){a(String(e))}finally{s(``)}},h=n?.mode===`local`,g=n?.mode===`remote`&&!!n.activeId,_=h||g,v=t(h?`config:mobileServer.currentLocal`:g?`config:mobileServer.current`:`config:mobileServer.empty`);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 rounded-[var(--r-sm)] border px-3 py-2 text-[12px] ${_?`border-[var(--success)] bg-[var(--success-soft)] text-[var(--success-strong)]`:`border-[var(--stroke)] bg-[var(--surface-subtle)] text-[var(--text-muted)]`}`,role:`status`,"aria-live":`polite`,children:[(0,q.jsx)(_?de:ue,{size:15,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),n?.activeTransport?(0,q.jsx)(`span`,{className:`flex-none text-[11px] opacity-80`,children:n.activeTransport===`iroh`?t(`config:mobileServer.transportP2p`):t(`config:mobileServer.transportLan`)}):null]}),(0,q.jsx)(Yr,{open:l,onOpenChange:u}),(0,q.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`mobile-server-main`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-[11px]`,children:[(0,q.jsx)(`span`,{className:`grid size-[38px] flex-none place-items-center rounded-[var(--r-sm)] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(L,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-[16px]`,children:t(`config:mobileServer.title`)}),(0,q.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:mobileServer.description`)})]})]}),(0,q.jsxs)(U,{size:`sm`,className:`max-[650px]:h-10 max-[650px]:px-3`,onClick:()=>u(!0),children:[(0,q.jsx)(Ee,{size:14}),t(`config:mobileServer.addServer`)]})]}),i?(0,q.jsx)(`p`,{className:`text-[12px] text-[var(--danger)]`,children:i}):null]}),(0,q.jsx)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`mobile-server-local`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-48 items-start gap-[11px]`,children:[(0,q.jsx)(`span`,{className:`grid size-[38px] flex-none place-items-center rounded-[var(--r-sm)] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(En,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`h2`,{className:`flex flex-wrap items-center gap-2 text-[16px]`,children:[t(`config:mobileServer.localTitle`),h?(0,q.jsx)(`span`,{className:`text-[11px] text-[var(--star-strong)]`,children:t(`config:mobileServer.currentLocal`)}):null]}),(0,q.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:mobileServer.localDescription`)})]})]}),(0,q.jsx)(U,{size:`sm`,variant:`outline`,className:`flex-none max-[650px]:h-10 max-[650px]:px-3`,disabled:h||!!o,onClick:()=>void(async()=>{s(`mobile_enter_local`);try{let e=await Xr(`mobile_enter_local`);e.onDevice.url&&window.location.replace(e.onDevice.url)}catch(e){a(String(e))}finally{s(``)}})(),children:t(h?`config:mobileServer.currentLocal`:`config:mobileServer.enterLocal`)})]})}),(0,q.jsx)(Y,{className:`flex flex-col gap-3 p-4`,children:n?.servers?.length?(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:n.servers.map(e=>{let r=n.mode===`remote`&&e.id===n.activeId,i=e.endpoints.find(e=>e.url),a=e.endpoints.find(e=>e.t===`iroh`),s=i?.url||(a?.nodeId?`Iroh ${a.nodeId.slice(0,12)}`:`Iroh`);return(0,q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-sm)] border border-[var(--border)] px-3 py-2 max-[650px]:items-start max-[650px]:flex-wrap`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(B,{size:15,className:`flex-none text-[var(--text-muted)]`}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`truncate text-[13px]`,children:[e.name,r?(0,q.jsx)(`span`,{className:`ml-2 text-[11px] text-[var(--star-strong)]`,children:t(`config:mobileServer.current`)}):null]}),(0,q.jsxs)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:[s,(0,q.jsx)(`span`,{className:`ml-2`,children:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`)})]}),r&&n.activeTransport?(0,q.jsx)(`div`,{className:`text-[11px] text-[var(--star-strong)]`,children:t(`config:mobileServer.activeTransport`,{transport:n.activeTransport===`iroh`?t(`config:mobileServer.transportP2p`):t(`config:mobileServer.transportLan`)})}):null]})]}),(0,q.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[r?null:(0,q.jsx)(U,{size:`sm`,variant:`ghost`,className:`max-[650px]:h-10 max-[650px]:px-3`,disabled:o===e.id,onClick:()=>void m(e.id),children:t(`config:mobileServer.connect`)}),(0,q.jsx)(U,{size:`sm`,variant:`ghost`,className:`max-[650px]:size-10`,"aria-label":t(`config:mobileServer.forget`),title:t(`config:mobileServer.forget`),disabled:!!o,onClick:()=>void p(e),children:(0,q.jsx)(Ie,{size:14})})]})]},e.id)})}):(0,q.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:mobileServer.empty`)})})]})}var Qr={feishu:{tone:`blue`},weixin:{tone:`green`},qq:{tone:`blue`},telegram:{tone:`blue`},browser:{tone:`blue`}};function $r(e,t){return t(e===`feishu`?`config:notificationSettings.feishu`:e===`weixin`?`config:notificationSettings.weChat`:e===`qq`?`config:notificationSettings.qq`:e===`telegram`?`config:notificationSettings.telegram`:`config:notificationSettings.browserNotification`)}function ei(e,t,n){return e===`chat.completed`?n(`config:notificationSettings.chatCompleted`):e===`chat.waiting`?n(`config:notificationSettings.chatWaiting`):e===`schedule.completed`?n(`config:notificationSettings.scheduleCompleted`):e===`schedule.failed`?n(`config:notificationSettings.scheduleFailed`):e===`workflow.completed`?n(`config:notificationSettings.workflowCompleted`):e===`workflow.failed`?n(`config:notificationSettings.workflowFailed`):t}function ti(e,t,n){return e===`chat.completed`?n(`config:notificationSettings.chatCompletedDescription`):e===`chat.waiting`?n(`config:notificationSettings.chatWaitingDescription`):e===`schedule.completed`?n(`config:notificationSettings.scheduleCompletedDescription`):e===`schedule.failed`?n(`config:notificationSettings.scheduleFailedDescription`):e===`workflow.completed`?n(`config:notificationSettings.workflowCompletedDescription`):e===`workflow.failed`?n(`config:notificationSettings.workflowFailedDescription`):t}function ni(e,t){let n={"chat.title":t(`config:notificationSettings.fixChannelNotification`),"chat.summary":t(`config:notificationSettings.implementationIsCompleteTestsAndBuildHavePassed`),"chat.tool":`bash`,"chat.reason":t(`config:notificationSettings.confirmationIsRequired`),"chat.model":`openai/gpt-5.4`,"task.name":t(`config:notificationSettings.dailyCodeReview`),"task.summary":t(`config:notificationSettings.found2IssuesToAddressTheReportHasBeenArchived`),"task.duration":t(`config:notificationSettings.message2Min18Sec`),"task.nextRun":t(`config:notificationSettings.tomorrow0900`),"task.error":t(`config:notificationSettings.testProcessTimedOut`),"workflow.name":t(`config:notificationSettings.preReleaseChecks`),"workflow.summary":t(`config:notificationSettings.testsBuildAndSecurityChecksHaveAllPassed`),"workflow.duration":t(`config:notificationSettings.message6Min42Sec`),"workflow.runId":`run_20260718_001`,"workflow.node":t(`config:notificationSettings.endToEndTests`),"workflow.error":t(`config:notificationSettings.browserFailedToStart`)};return String(e||``).replace(/\{\{\s*([\w.]+)\s*\}\}/g,(e,t)=>n[t]||`{{${t}}}`)}function ri(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&_t()?`checking`:xt()}function ii(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function ai(e){return e instanceof Error?e.message:String(e)}function oi({notify:e,onBrowserNotificationChange:t}){let{t:n}=c(),[r,i]=(0,K.useState)({browser:{enabled:!1},connections:{},scopes:[],templates:[]}),[a,o]=(0,K.useState)(!0),[s,l]=(0,K.useState)(``),u=!!window.pisperDesktop?.showNotification,d=_t(),[f,p]=(0,K.useState)(ri),[m,h]=(0,K.useState)(!1),g=(0,K.useCallback)(async()=>{if(!u)return;let e=window.pisperDesktop?.getNotificationStatus;if(!e){p(`granted`);return}try{let t=await e(),n=t?.permission;p(n==="default"||n===`denied`||n===`granted`||n===`checking`||n===`unsupported`?n:t?.supported===!1?`unsupported`:`granted`)}catch{p(`unsupported`)}},[u]),_=(0,K.useCallback)(async()=>{try{l(``);let e=await H(`/api/settings/notifications`);i(e),t?.(e)}catch(e){l(ai(e))}finally{o(!1)}},[t]);(0,K.useEffect)(()=>{_()},[_]),(0,K.useEffect)(()=>{if(!u)return;g();let e=()=>{g()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[u,g]);let v=(0,K.useCallback)(async()=>{if(!(u||!d))try{let e=await ht();p(e===!0?`granted`:e===!1?`denied`:`default`)}catch{p(`unsupported`)}},[u,d]);(0,K.useEffect)(()=>{if(u||!d)return;v();let e=()=>void v();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[u,d,v]);let y=async r=>{let a=``;if(r){if(u&&f!==`granted`)a=ii(`system-disabled`,n);else if(!u&&d){let e=`denied`;try{let t=await ht()===!0?`granted`:await gt();e=t===`granted`?`granted`:t===`denied`?`denied`:`default`}catch{e=`unsupported`}p(e),e!==`granted`&&(a=n(`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`))}else if(!u){let e=await bt();if(p(e),e!==`granted`)a=n(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await yt()}catch{a=n(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}h(!0);try{let o=await H(`/api/settings/notifications/browser`,{method:`PATCH`,body:JSON.stringify({enabled:r})});i(o),t?.(o),a?e(n(`config:notificationSettings.savedButLocalDeliveryUnavailable`,{reason:a}),`info`):e(n(r?`config:notificationSettings.notificationsEnabled`:`config:notificationSettings.notificationsDisabled`))}catch(t){e(ai(t),`error`)}finally{h(!1)}},b=(0,K.useCallback)(async(e,t,r=`pisper-browser-test`)=>{if(u){let r=window.pisperDesktop?.showNotification;if(!r)throw Error(n(`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`));let i=await r({title:e,body:t});if(i&&typeof i==`object`&&i.shown===!1)throw p(i.permission??`denied`),Error(ii(i.reason,n));return i}return d?(await pt(e,t),{shown:!0,transport:`tauri`}):vt({title:e,body:t,tag:r,url:window.location.href})},[u,d,n]),x=async()=>{if(f!==`granted`){e(f===`unsupported`?ii(`unsupported`,n):u?ii(`system-disabled`,n):n(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await b(n(`config:notificationSettings.appNotificationTest`,{app:ft}),n(`config:notificationSettings.notificationsAreWorking`)),e(n(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(ai(t)||n(`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`),`error`)}},S=async()=>{try{await window.pisperDesktop?.openNotificationSettings?.()||e(n(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}catch{e(n(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}};if(a)return(0,q.jsxs)($e,{children:[(0,q.jsx)(z,{className:`animate-spin`,size:23}),(0,q.jsx)(`h2`,{children:n(`config:notificationSettings.loadingNotificationSettings`)})]});let C=n(f===`granted`?`config:notificationSettings.permissionGranted`:f===`denied`?u?`config:notificationSettings.systemNotificationsAreOff`:`config:notificationSettings.browserNotificationsAreBlocked`:f===`unsupported`?`config:notificationSettings.notSupported`:f===`checking`?`config:notificationSettings.checking`:`config:notificationSettings.waitingForPermission`),w=f===`granted`?`green`:f==="default"||f===`checking`?`amber`:`red`;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-[12px]`,children:[s&&(0,q.jsxs)(Ye,{children:[(0,q.jsx)(V,{size:13}),s]}),(0,q.jsxs)(Y,{className:`browser-notification-card`,"data-config-card":`notifications-browser`,children:[(0,q.jsxs)(`div`,{className:`notification-option [&_>_div]:flex [&_>_div]:min-w-0 [&_>_div]:flex-col [&_>_div]:gap-[4px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] grid grid-cols-[auto_minmax(0,1fr)_auto_auto] items-center gap-[11px]`,children:[(0,q.jsx)(`span`,{className:`provider-icon [&_svg]:w-[19px] [&.green]:bg-[var(--success-soft)] [&.green]:text-[var(--success)] [&.blue]:bg-[var(--brand-blue-soft)] [&.blue]:text-[var(--brand-blue-strong)] [.notification-option_&:not(.blue)]:bg-[var(--surface-muted)] [.notification-option_&:not(.blue)]:text-[var(--text-muted)] grid w-[38px] h-[38px] place-items-center rounded-[var(--r-md)] ${r.browser.enabled?`blue`:``}`,children:r.browser.enabled?(0,q.jsx)(I,{size:18}):(0,q.jsx)(pn,{size:18})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`strong`,{children:n(`config:notificationSettings.notification`)}),(0,q.jsx)(`small`,{children:n(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,q.jsx)(X,{tone:w,children:C}),(0,q.jsx)(Nn,{value:r.browser.enabled,disabled:m||f===`checking`,onChange:y})]}),(0,q.jsxs)(Je,{children:[(0,q.jsx)(Me,{size:15}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:n(u?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,q.jsx)(`small`,{children:n(u?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,q.jsxs)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:[u&&f===`denied`&&(0,q.jsxs)(U,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:S,children:[(0,q.jsx)(Me,{size:14}),n(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,q.jsxs)(U,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:!r.browser.enabled||f!==`granted`,onClick:x,children:[(0,q.jsx)(I,{size:14}),n(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,q.jsx)(si,{data:r,setData:i,notify:e,permission:f,onBrowserTest:b,onSettingsChange:t})]})}function si({data:e,setData:t,notify:n,permission:r,onBrowserTest:i,onSettingsChange:a}){let{t:o}=c(),[s,l]=(0,K.useState)(e.templates[0]?.id||``),[u,d]=(0,K.useState)(`feishu`),f=e.templates.find(e=>e.id===s)||e.templates[0],p=f?.channels?.[u],[m,h]=(0,K.useState)(p?.content||``),[g,_]=(0,K.useState)(!1),v=e.scopes.find(e=>e.platform===u),y=u===`browser`?e.browser.enabled&&r===`granted`:!!v,b=Qr;return(0,K.useEffect)(()=>{h(p?.content||``)},[s,u,p?.content]),f?(0,q.jsxs)(`div`,{className:`two-one-grid max-[900px]:grid-cols-[1fr] grid grid-cols-[minmax(0,2fr)_minmax(260px,1fr)] gap-[12px] [margin-top:0]`,children:[(0,q.jsxs)(Y,{"data-config-card":`notifications-templates`,children:[(0,q.jsxs)(`div`,{className:`channel-section-head [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[13px] flex items-center justify-between gap-[8px] [margin-bottom:8px]`,children:[(0,q.jsx)(Mn,{title:o(`config:notificationSettings.notificationTemplates`)}),(0,q.jsx)(`span`,{children:o(`config:notificationSettings.sharedByChatsScheduledTasksAndWorkflows`)})]}),e.templates.map(e=>(0,q.jsxs)(`button`,{className:`channel-template-row hover:rounded-[var(--r-sm)] hover:bg-[var(--accent-soft)] [&.selected]:rounded-[var(--r-sm)] [&.selected]:bg-[var(--accent-soft)] [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[4px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] grid w-full min-h-[58px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[9px] border-0 [border-top:1px_solid_var(--stroke-soft)] bg-transparent [padding:8px_6px] text-left ${e.id===f.id?`selected`:``}`,onClick:()=>l(e.id),children:[(0,q.jsx)(`span`,{className:`route-icon grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(je,{size:14})}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:ei(e.id,e.name,o)}),(0,q.jsx)(`small`,{children:ti(e.id,e.description,o)})]}),(0,q.jsx)(X,{tone:e.enabled?`green`:`gray`,children:e.enabled?o(`config:notificationSettings.enabled`):o(`config:notificationSettings.disabled`)})]},e.id))]}),(0,q.jsxs)(Y,{className:`channel-template-editor [&_textarea]:min-h-[118px] [&_textarea]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_textarea]:leading-[1.55]`,children:[(0,q.jsxs)(Ze,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{children:ei(f.id,f.name,o)}),(0,q.jsx)(`p`,{children:ti(f.id,f.description,o)})]}),(0,q.jsx)(Nn,{value:f.enabled,onChange:e=>t(t=>({...t,templates:t.templates.map(t=>t.id===f.id?{...t,enabled:e}:t)}))})]}),(0,q.jsx)(`div`,{className:`channel-template-platforms [&_>_button]:relative [&_>_button]:flex [&_>_button]:min-h-9 [&_>_button]:items-center [&_>_button]:justify-center [&_>_button]:gap-[7px] [&_>_button]:[border:1px_solid_var(--stroke)] [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-[var(--surface-subtle)] [&_>_button]:p-[0_9px] [&_>_button]:text-[12px] [&_>_button]:font-[700] [&_>_button.active]:border-[var(--focus)] [&_>_button.active]:bg-[var(--accent-soft)] [&_>_button.active]:text-[var(--star-strong)] max-[650px]:grid-cols-[1fr] grid grid-cols-[repeat(5,minmax(0,1fr))] gap-[7px] [margin-top:13px]`,children:Object.entries(b).map(([t,n])=>{let r=t===`browser`?e.browser.enabled:e.connections?.[t];return(0,q.jsxs)(`button`,{className:u===t?`active`:``,onClick:()=>d(t),children:[$r(t,o),(0,q.jsx)(X,{tone:r?n.tone:`red`,className:` absolute -top-2.5 -right-1.5`,children:o(r?t===`browser`?`config:notificationSettings.enabled2`:`config:notificationSettings.connected`:t===`browser`?`config:notificationSettings.notEnabled`:`config:notificationSettings.notConnected`)})]},t)})}),(0,q.jsxs)(W,{variant:`control`,children:[o(`config:notificationSettings.messageContent`),(0,q.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`channel-template-vars [&_>_span]:mr-[3px] [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[13px] [&_code]:rounded-[var(--r-xs)] [&_code]:bg-[var(--template-code-bg)] [&_code]:text-[var(--template-code-text)] [&_code]:p-[3px_5px] [&_code]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_code]:text-[13px] flex flex-wrap items-center gap-[5px] [margin-top:10px]`,children:[(0,q.jsx)(`span`,{children:o(`config:notificationSettings.availableVariables`)}),f.variables.map(e=>(0,q.jsx)(`code`,{children:`{{${e}}}`},e))]}),(0,q.jsxs)(`div`,{className:`channel-template-preview [&_>_small]:text-[var(--text-muted)] [&_>_small]:text-[13px] [&_pre]:m-[7px_0_0] [&_pre]:overflow-auto [&_pre]:text-[var(--text-soft)] [&_pre]:font-[inherit] [&_pre]:text-[12px] [&_pre]:leading-[1.55] [&_pre]:whitespace-pre-wrap [margin-top:10px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:9px]`,children:[(0,q.jsx)(`small`,{children:o(`config:notificationSettings.preview`)}),(0,q.jsx)(`pre`,{children:ni(m,o)})]}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,q.jsxs)(U,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:g||!y,onClick:async()=>{_(!0);try{let e=await H(`/api/settings/notifications/templates/${encodeURIComponent(f.id)}/${u}/test`,{method:`POST`,body:`{}`});u===`browser`&&await i?.(e.title||ei(f.id,f.name,o),e.body||e.preview||``,`pisper-template-${f.id}`),n(o(u===`browser`?`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`:`config:notificationSettings.testNotificationSentToCountChats`,{count:e.sent}))}catch(e){n(ai(e),`error`)}finally{_(!1)}},children:[(0,q.jsx)(je,{size:14}),o(`config:notificationSettings.sendTest`)]}),(0,q.jsxs)(U,{size:`lg`,disabled:g||!m.trim(),onClick:async()=>{_(!0);try{let e=await H(`/api/settings/notifications/templates/${encodeURIComponent(f.id)}/${u}`,{method:`PUT`,body:JSON.stringify({enabled:f.enabled,content:m})});t(e),a?.(e),n(o(`config:notificationSettings.notificationTemplateSaved`))}catch(e){n(ai(e),`error`)}finally{_(!1)}},children:[g?(0,q.jsx)(z,{className:`animate-spin`,size:14}):(0,q.jsx)(ke,{size:14}),o(`config:notificationSettings.saveTemplate`)]})]})]})]}):null}o.addResourceBundle(`zh-CN`,`remote-workspace`,{description:`使用本机的 Pisper 界面,在另一台 Linux 上运行会话、读写文件和执行任务。`,instructions:`先在 Linux 上运行 Pisper,在「设置 → 远程访问」启用连接,然后复制 HTTPS 地址、证书指纹和配对码。请通过可信渠道核对指纹。`,isolation:`每个工作区在独立窗口中打开。会话、文件、模型配置与任务属于远程机器,不会复制本机密钥;关闭窗口不会停止远程正在执行的任务。本机终端与桌面控制不会在远程窗口中启用。`,refresh:`刷新远程工作区`,name:`工作区名称(可选)`,address:`Linux HTTPS 地址`,fingerprint:`证书指纹`,code:`配对码`,pair:`配对并打开`,open:`连接`,show:`显示窗口`,forget:`移除 {name}`,forgetDescription:`这会关闭该工作区的本机窗口并移除保存的连接,不删除远程文件或会话,也不会停止远程任务。如需吊销设备授权,请在 Linux 的远程访问页操作。`,activeTitle:`当前为远程工作区`,activeDescription:`这里的会话、文件和模型设置属于远程 Linux。连接管理请回到本机主窗口;如需修改远程访问服务,请在 Linux 本机操作。`,manualConnection:`手动连接所需信息`,serverAddress:`HTTPS 服务器地址`}),o.addResourceBundle(`en-US`,`remote-workspace`,{description:`Use the local Pisper interface to run conversations, work with files, and execute tasks on another Linux machine.`,instructions:`Run Pisper on Linux and enable Settings → Remote access. Copy its HTTPS address, certificate fingerprint, and pairing code. Verify the fingerprint through a trusted channel.`,isolation:`Each workspace opens in a separate window. Sessions, files, model settings, and tasks belong to the remote machine; local credentials are not copied. Closing the window does not stop remote tasks. Local terminals and desktop controls are not enabled in remote windows.`,refresh:`Refresh remote workspaces`,name:`Workspace name (optional)`,address:`Linux HTTPS address`,fingerprint:`Certificate fingerprint`,code:`Pairing code`,pair:`Pair and open`,open:`Connect`,show:`Show window`,forget:`Remove {name}`,forgetDescription:`Close this workspace’s local windows and forget the saved connection. Remote files, sessions, and running tasks are not deleted or stopped. To revoke the device authorization, use Remote access on Linux.`,activeTitle:`Remote workspace`,activeDescription:`Sessions, files and model settings in this window belong to the remote Linux machine. Manage connections in your local main window; change remote access service settings directly on Linux.`,manualConnection:`Manual connection details`,serverAddress:`HTTPS server address`});function ci({notify:e}){let{t,language:n}=c(),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(null),[s,l]=(0,K.useState)([]),[u,d]=(0,K.useState)([]),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),[v,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(``),w=(0,K.useCallback)(async()=>{try{let[e,t,n,r]=await Promise.all([H(`/api/remote/status`),H(`/api/remote/devices`),H(`/api/remote/pairing-requests`).catch(()=>({requests:[]})),H(`/api/remote/firewall`).catch(e=>{if(e&&typeof e==`object`&&`status`in e&&e.status===403)return null;throw e})]);i(e),o(r),l(t.devices.filter(e=>!e.revokedAt)),d(n.requests),C(``)}catch{C(t(`config:remoteAccess.loadFailed`))}},[t]);(0,K.useEffect)(()=>{w()},[w]),(0,K.useEffect)(()=>{if(!r?.listening)return;let e=window.setInterval(()=>void w(),2e3);return()=>window.clearInterval(e)},[w,r?.listening]);let T=async n=>{x(!0);try{await H(`/api/remote/enabled`,{method:`PUT`,body:{enabled:n,configureFirewall:a!==null},timeout:15e4});let e=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;e&&await e(`desktop_iroh_set_enabled`,{enabled:n}).catch(()=>void 0),n||(p(null),h(!1),_(``)),await w()}catch(n){e(t(`config:remoteAccess.toggleFailed`,{message:String(n)}),`error`)}finally{x(!1)}},E=async()=>{x(!0);try{await H(`/api/remote/firewall/retry`,{method:`POST`,body:{},timeout:15e4}),await w()}catch(n){e(t(`config:remoteAccess.firewallRetryFailed`,{message:String(n)}),`error`)}finally{x(!1)}},D={disabled:t(`config:remoteAccess.firewallDisabled`),configured:t(`config:remoteAccess.firewallConfigured`),not_needed:t(`config:remoteAccess.firewallNotNeeded`),needs_authorization:t(`config:remoteAccess.firewallNeedsAuthorization`),unsupported:t(`config:remoteAccess.firewallUnsupported`),cancelled:t(`config:remoteAccess.firewallCancelled`),error:t(`config:remoteAccess.firewallError`),cleanup_pending:t(`config:remoteAccess.firewallCleanupPending`)},O={packaged_app_required:t(`config:remoteAccess.firewallPackagedApp`),unsupported_firewall:t(`config:remoteAccess.firewallUnsupportedBackend`),unsupported_platform:t(`config:remoteAccess.firewallUnsupportedBackend`),permission_denied:t(`config:remoteAccess.firewallPermissionDenied`),cancelled:t(`config:remoteAccess.firewallCancelled`),timeout:t(`config:remoteAccess.firewallTimeout`),block_all:t(`config:remoteAccess.firewallBlockAll`),rule_changed:t(`config:remoteAccess.firewallRuleChanged`),inspection_failed:t(`config:remoteAccess.firewallVerificationFailed`),verification_failed:t(`config:remoteAccess.firewallVerificationFailed`),operation_failed:t(`config:remoteAccess.firewallVerificationFailed`),unsupported:t(`config:remoteAccess.firewallUnsupportedBackend`)},k=async()=>{x(!0),_(``);try{let e=await H(`/api/remote/pairing-code`,{method:`POST`});if(!e?.code||!e?.expiresAt)throw Error(t(`config:remoteAccess.qrUnavailable`));e.connectionInfo=await H(`/api/remote/connection-info`).catch(()=>void 0),p(e),h(!0),e.qrDataUrl||_(t(`config:remoteAccess.qrUnavailable`))}catch(n){let r=t(`config:remoteAccess.pairingFailed`,{message:String(n)});_(r),e(r,`error`)}finally{x(!1)}},A=async(n,r)=>{y(n.id);try{await H(`/api/remote/pairing-requests/${encodeURIComponent(n.id)}/decision`,{method:`POST`,body:{approved:r}}),await w()}catch(n){e(t(`config:remoteAccess.approvalFailed`,{message:String(n)}),`error`)}finally{y(``)}},j=async n=>{if(window.confirm(t(`config:remoteAccess.revokeConfirm`,{name:n.name})))try{await H(`/api/remote/devices/${encodeURIComponent(n.id)}/revoke`,{method:`POST`}),await w()}catch(n){e(t(`config:remoteAccess.revokeFailed`,{message:String(n)}),`error`)}};return S?(0,q.jsx)(Y,{className:`p-4 text-[13px] text-[var(--text-muted)]`,children:S}):r?(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(Ge,{open:m&&f!==null,onOpenChange:h,children:(0,q.jsxs)(Ue,{className:`sm:max-w-md`,children:[(0,q.jsxs)(He,{children:[(0,q.jsx)(We,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,q.jsx)(Ve,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[f?.qrDataUrl?(0,q.jsx)(`img`,{src:f.qrDataUrl,alt:t(`config:remoteAccess.qrAlt`),className:`size-64 max-w-full rounded-[var(--r-sm)] bg-white p-2`}):null,g?(0,q.jsx)(`p`,{className:`text-center text-[12px] leading-relaxed text-[var(--danger)]`,children:g}):null,f?(0,q.jsxs)(`div`,{className:`text-center`,children:[(0,q.jsx)(`div`,{className:`font-mono text-[20px] tracking-[0.2em]`,children:f.code}),(0,q.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.codeExpiresAt`,{time:qe(f.expiresAt,n)})})]}):null]}),f?.connectionInfo&&(0,q.jsxs)(`details`,{className:`min-w-0 rounded-md border px-3 py-2 text-sm`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer`,children:t(`remote-workspace:manualConnection`)}),(0,q.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs`,children:[(0,q.jsx)(`div`,{children:t(`remote-workspace:serverAddress`)}),f.connectionInfo.endpoints.map(e=>(0,q.jsx)(`code`,{className:`block select-all break-all`,children:e.url},e.url)),(0,q.jsx)(`div`,{children:t(`remote-workspace:fingerprint`)}),(0,q.jsx)(`code`,{className:`block select-all break-all`,children:f.connectionInfo.fingerprint})]})]}),(0,q.jsx)(Be,{children:(0,q.jsxs)(U,{disabled:b,onClick:()=>void k(),children:[b?(0,q.jsx)(xe,{className:`animate-spin`}):(0,q.jsx)(z,{}),t(b?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),(0,q.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-main`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-[11px]`,children:[(0,q.jsx)(`span`,{className:`grid size-[38px] flex-none place-items-center rounded-[var(--r-sm)] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(L,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-[16px]`,children:t(`config:remoteAccess.title`)}),(0,q.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:remoteAccess.description`)})]})]}),(0,q.jsx)(Nn,{value:r.enabled,disabled:b,onChange:e=>void T(e),ariaLabel:t(`config:remoteAccess.title`)})]}),r.error?(0,q.jsx)(`p`,{className:`rounded-[var(--r-sm)] bg-[var(--danger-soft)] px-3 py-2 text-[12px] text-[var(--danger)]`,children:t(`config:remoteAccess.listenFailed`,{message:r.error})}):null]}),a?(0,q.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"aria-live":`polite`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`h3`,{className:`text-[14px]`,children:t(`config:remoteAccess.firewallTitle`)}),r.enabled||a.state===`cleanup_pending`?(0,q.jsxs)(U,{size:`sm`,disabled:b||a.busy,onClick:()=>void E(),children:[b||a.busy?(0,q.jsx)(xe,{className:`animate-spin`}):(0,q.jsx)(z,{}),r.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):null]}),(0,q.jsx)(`p`,{className:`text-[13px]`,children:a.busy?t(`config:remoteAccess.firewallWorking`):D[a.state]}),a.reason&&O[a.reason]?(0,q.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:O[a.reason]}):null,r.enabled?(0,q.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:a.scope===`application`?t(`config:remoteAccess.firewallApplicationScope`):a.scope===`program_port`?t(`config:remoteAccess.firewallProgramPortScope`,{port:a.port??`—`}):t(`config:remoteAccess.firewallPortScope`,{port:a.port??`—`})}):null,(0,q.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:t(`config:remoteAccess.firewallReachability`)}),a.checkedAt?(0,q.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:qe(a.checkedAt,n)})}):null]}):null,r.listening&&u.length?(0,q.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"aria-live":`polite`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,q.jsx)(En,{size:16}),t(`config:remoteAccess.pendingApprovals`)]}),(0,q.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:t(`config:remoteAccess.pendingApprovalsDescription`)}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-sm)] border border-[var(--border)] px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-[13px]`,children:e.deviceName}),(0,q.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.requestedAt`,{time:qe(e.requestedAt,n)})}),(0,q.jsx)(`code`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})})]}),(0,q.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[(0,q.jsxs)(U,{size:`sm`,variant:`ghost`,disabled:v===e.id,onClick:()=>void A(e,!1),children:[(0,q.jsx)(ze,{}),t(`config:remoteAccess.reject`)]}),(0,q.jsxs)(U,{size:`sm`,disabled:v===e.id,onClick:()=>void A(e,!0),children:[v===e.id?(0,q.jsx)(xe,{className:`animate-spin`}):(0,q.jsx)(R,{}),t(`config:remoteAccess.approve`)]})]})]},e.id))})]}):null,r.listening?(0,q.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-pairing`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,q.jsx)(Cn,{size:16}),t(`config:remoteAccess.pairing`)]}),(0,q.jsxs)(U,{size:`sm`,disabled:b,onClick:()=>void k(),children:[b?(0,q.jsx)(xe,{className:`animate-spin`}):(0,q.jsx)(Cn,{}),t(b?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]})]}),(0,q.jsx)(`p`,{className:`text-[12px] leading-[1.6] text-[var(--text-muted)]`,children:t(`config:remoteAccess.pairingDescription`)}),g&&!m?(0,q.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--danger)]`,"aria-live":`polite`,children:g}):null]}):null,(0,q.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-devices`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,q.jsx)(En,{size:16}),t(`config:remoteAccess.devices`)]}),(0,q.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void w(),"aria-label":t(`config:remoteAccess.refresh`),children:(0,q.jsx)(z,{size:14})})]}),s.length===0?(0,q.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.noDevices`)}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:s.map(e=>(0,q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-sm)] border border-[var(--border)] px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`truncate text-[13px]`,children:[e.name,e.current?(0,q.jsx)(`span`,{className:`ml-2 text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.currentDevice`)}):null]}),(0,q.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.lastSeen`,{time:qe(e.lastSeenAt,n)})})]}),(0,q.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>void j(e),children:t(`config:remoteAccess.revoke`)})]},e.id))})]})]}):null}function li({requestConfirm:e}){let{t}=c(),n=window.pisperDesktop?.remoteWorkspaces,[r,i]=(0,K.useState)([]),[a,o]=(0,K.useState)(``),[s,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),v=(0,K.useCallback)(async()=>{n&&i(await n.list())},[n]);(0,K.useEffect)(()=>{v().catch(e=>_(String(e)))},[v]);let y=async e=>{if(!m){h(!0),_(``);try{await e()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return window.__PISPER_REMOTE_WORKSPACE__?(0,q.jsxs)(Y,{"data-config-card":`remote-workspaces`,className:`space-y-3`,children:[(0,q.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold`,children:[(0,q.jsx)(B,{className:`size-4`}),t(`remote-workspace:activeTitle`)]}),(0,q.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:t(`remote-workspace:activeDescription`)}),(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t(`remote-workspace:isolation`)})]}):n?(0,q.jsxs)(Y,{"data-config-card":`remote-workspaces`,className:`space-y-4`,children:[(0,q.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold`,children:[(0,q.jsx)(B,{className:`size-4`}),t(`config:remoteWorkspace.title`)]}),(0,q.jsx)(`p`,{className:`max-w-[64ch] text-sm leading-relaxed text-muted-foreground`,children:t(`remote-workspace:description`)})]}),(0,q.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:m,"aria-label":t(`remote-workspace:refresh`),onClick:()=>void y(v),children:(0,q.jsx)(z,{className:`size-3.5`})})]}),(0,q.jsx)(`p`,{className:`rounded-md bg-muted/50 px-3 py-2 text-sm leading-relaxed text-muted-foreground`,children:t(`remote-workspace:instructions`)}),r.length>0&&(0,q.jsx)(`ul`,{className:`divide-y rounded-lg border`,children:r.map(r=>(0,q.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,q.jsx)(B,{className:`size-4 shrink-0 text-muted-foreground`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-medium`,children:r.name}),(0,q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:r.address})]}),(0,q.jsxs)(U,{type:`button`,size:`sm`,variant:`secondary`,disabled:m,onClick:()=>void y(async()=>{await n.open(r.id),await v()}),children:[r.connected?t(`remote-workspace:show`):t(`remote-workspace:open`),(0,q.jsx)(te,{className:`size-3.5`})]}),(0,q.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:m,"aria-label":t(`remote-workspace:forget`,{name:r.name}),onClick:()=>void y(async()=>{await e({title:t(`remote-workspace:forget`,{name:r.name}),message:t(`remote-workspace:forgetDescription`)})&&(await n.forget(r.id),await v())}),children:(0,q.jsx)(Ie,{className:`size-3.5`})})]},r.id))}),(0,q.jsxs)(`form`,{className:`grid gap-3 sm:grid-cols-2`,onSubmit:e=>{e.preventDefault(),y(async()=>{let e=await n.pair({name:a,address:s,fingerprint:u,code:f});p(``),await v(),await n.open(e),await v()})},children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(T,{htmlFor:`remote-workspace-name`,children:t(`remote-workspace:name`)}),(0,q.jsx)(Ke,{id:`remote-workspace-name`,value:a,maxLength:160,disabled:m,placeholder:`Linux`,onChange:e=>o(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(T,{htmlFor:`remote-workspace-address`,children:t(`remote-workspace:address`)}),(0,q.jsx)(Ke,{id:`remote-workspace-address`,type:`url`,value:s,required:!0,disabled:m,placeholder:`https://192.168.1.10:5174`,autoComplete:`off`,spellCheck:!1,onChange:e=>l(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5 sm:col-span-2`,children:[(0,q.jsx)(T,{htmlFor:`remote-workspace-fingerprint`,children:t(`remote-workspace:fingerprint`)}),(0,q.jsx)(Ke,{id:`remote-workspace-fingerprint`,value:u,required:!0,disabled:m,placeholder:`SHA256:…`,autoComplete:`off`,spellCheck:!1,className:`font-mono text-xs`,onChange:e=>d(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(T,{htmlFor:`remote-workspace-code`,children:t(`remote-workspace:code`)}),(0,q.jsx)(Ke,{id:`remote-workspace-code`,value:f,required:!0,maxLength:64,disabled:m,placeholder:`ABCD-EFGH`,autoComplete:`off`,spellCheck:!1,onChange:e=>p(e.target.value)})]}),(0,q.jsx)(`div`,{className:`flex items-end sm:justify-end`,children:(0,q.jsxs)(U,{type:`submit`,size:`sm`,disabled:m,children:[m?(0,q.jsx)(xe,{className:`size-3.5 animate-spin`}):(0,q.jsx)(te,{className:`size-3.5`}),t(`remote-workspace:pair`)]})})]}),g&&(0,q.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-destructive`,children:g}),(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:t(`remote-workspace:isolation`)})]}):null}function ui({notify:e}){let{t}=c(),n=window.pisperDesktop,[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(``),[s,l]=(0,K.useState)(``);(0,K.useEffect)(()=>{if(!n?.getCliStatus)return;let e=!0;return n.getCliStatus().then(t=>e&&i(t)).catch(t=>e&&l(t instanceof Error?t.message:String(t))),()=>{e=!1}},[n]);let u=!!(n?.getCliStatus&&n.installCli&&n.uninstallCli),d=async()=>{if(n?.installCli){o(`install`),l(``);try{let r=await n.installCli();i(r),e(t(`config:cliSettings.installedNotification`))}catch(e){l(e instanceof Error?e.message:String(e))}finally{o(``)}}},f=async()=>{if(n?.uninstallCli){o(`uninstall`),l(``);try{let r=await n.uninstallCli();i(r),e(t(`config:cliSettings.uninstalledNotification`))}catch(e){l(e instanceof Error?e.message:String(e))}finally{o(``)}}},p=u&&!r,m=u?p?t(`config:cliSettings.checking`):r?.supported?r.needsRepair?t(`config:cliSettings.needsRepair`):r.installed?t(`config:cliSettings.installed`):t(`config:cliSettings.notInstalled`):t(`config:cliSettings.unavailable`):t(`config:cliSettings.unavailable`);return(0,q.jsxs)(Y,{className:`[padding:18px] cli-settings-card`,"data-config-card":`updates-cli`,children:[(0,q.jsxs)(`div`,{className:`language-settings-heading flex items-start gap-[11px] [&_h2]:text-[16px] [&_p]:mt-[4px] [&_p]:text-[var(--text-muted)] [&_p]:text-[13px] [&_p]:leading-[1.55] cli-settings-heading !grid grid-cols-[auto_minmax(0,1fr)_auto]`,children:[(0,q.jsx)(`span`,{className:`grid w-[38px] h-[38px] [flex:0_0_auto] place-items-center rounded-[11px] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(On,{size:19})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{children:t(`config:cliSettings.title`)}),(0,q.jsx)(`p`,{children:t(`config:cliSettings.description`)})]}),(0,q.jsx)(X,{tone:r?.installed&&!r.needsRepair?`green`:r?.needsRepair?`blue`:`gray`,children:m})]}),r&&(0,q.jsxs)(Je,{className:`[margin-top:15px] cli-settings-status [&_small]:[overflow-wrap:anywhere]`,children:[r.installed&&!r.needsRepair?(0,q.jsx)(de,{size:16}):(0,q.jsx)(On,{size:16}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:r.installed?t(`config:cliSettings.commandReady`,{command:r.command}):t(`config:cliSettings.commandNotInstalled`,{command:r.command})}),(0,q.jsx)(`small`,{children:r.installPath}),r.installed&&(0,q.jsx)(`small`,{children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),s&&(0,q.jsx)(Ye,{children:s}),u&&(0,q.jsxs)(`div`,{className:`mt-3.5 flex justify-end gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,q.jsxs)(U,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,q.jsx)(z,{className:`animate-spin`,size:14}):(0,q.jsx)(Ie,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,q.jsxs)(U,{type:`button`,size:`lg`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,q.jsx)(z,{className:`animate-spin`,size:14}):r?.needsRepair?(0,q.jsx)(Re,{size:14}):(0,q.jsx)(he,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),u&&(0,q.jsx)(`small`,{className:`block [margin:9px_1px_0] text-[var(--text-muted)] text-[12px]`,children:t(`config:cliSettings.restartTerminal`)})]})}var di=`0.5.62`,fi=9e5,pi=2592e6;function mi(){try{let e=JSON.parse(n.getItem(l.sponsorDismissals)||`{}`);return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`number`&&e[1]>Date.now()))}catch{return{}}}function hi(e,t){return!e.desktop&&!e.mobile?t(`config:updateSettings.browserMode`):`${{win32:`Windows`,darwin:`macOS`,linux:`Linux`,android:`Android`,ios:`iOS`}[e.platform]||e.platform} · ${e.arch}`}function gi(e,t){let n=Number(e)||0;if(!n)return`0 B`;let r=[`B`,`KB`,`MB`,`GB`],i=Math.min(r.length-1,Math.floor(Math.log(n)/Math.log(1024)));return`${(n/1024**i).toLocaleString(t,{maximumFractionDigits:1})} ${r[i]}`}function _i({notify:e,update:t}){let{t:r,language:i}=c(),a=t?.info||{desktop:!1,packaged:!1,version:di,platform:`browser`,arch:``},o=t?.status||{state:`idle`},s=!!a.desktop,u=!!a.mobile,d=s||u,[f,p]=(0,K.useState)({version:di,date:``,notes:``}),[m,h]=(0,K.useState)([]),[g,_]=(0,K.useState)(``),[v,y]=(0,K.useState)(mi);(0,K.useEffect)(()=>{let e=!0;return fetch(`/release-notes.json`,{cache:`no-store`}).then(e=>e.ok?e.json():null).then(t=>{e&&t&&p(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,K.useEffect)(()=>{let e=!0,t=(t=!1)=>H(`/api/sponsors/settings-updates?locale=${encodeURIComponent(i)}${t?`&refresh=1`:``}`).then(t=>{e&&h(Array.isArray(t.campaigns)?t.campaigns:[])}).catch(()=>{e&&!t&&h([])});t();let n=window.setInterval(()=>void t(!0),fi);return()=>{e=!1,window.clearInterval(n)}},[i]);let b=e=>{let t={...v,[e]:Date.now()+pi};y(t);try{n.setItem(l.sponsorDismissals,JSON.stringify(t))}catch{}},x=async()=>{if(t){_(`check`);try{await t.check()}finally{_(``)}}},S=()=>t?.openReleases(),C=()=>t?.openUpdateLog?.(),w=t=>{jn(t,t.currentTarget.href)?.catch(()=>e(r(`config:aboutSettings.openLinkFailed`),`error`))},T=async()=>{_(s?`install`:``);try{s?await t?.installComponents():await t?.download()}catch(t){e(t instanceof Error?t.message:String(t),`error`)}finally{_(``)}},E=()=>t?.install(),D=f.version===a.version?f:null,O=o.notes||(d?D?.notes||r(`config:updateSettings.noReleaseNotesAreAvailableForThisVersion`):o.state===`current`?r(`config:updateSettings.theCurrentWebSourceIsSyncedWithBranch`,{branch:o.branch||`release`}):r(`config:updateSettings.commitsThatHaveNotBeenSyncedWillAppearHereAfterTheCheck`)),k=o.state===`available`,A=o.state===`error`&&o.canResume&&o.canDownload,j=o.state===`downloaded`,M=o.state===`checking`||g===`check`,N=o.state===`downloading`||g===`install`,F=M?`checking`:N?`downloading`:o.state,ee=d?`v${a.version}`:`v${a.version}${o.currentCommit?` · ${o.currentCommit.slice(0,7)}`:``}`,te=d?`v${o.availableVersion||D?.version||a.version}`:o.availableCommit?.slice(0,7)||o.currentCommit?.slice(0,7)||f.version||a.version,ne=m.filter(e=>(v[e.id]||0)<=Date.now()),re=(0,K.useMemo)(()=>{let e=new Map(t.components.map(e=>[e.component,e]));return[`desktop`,`tui`,`runtime`].map(t=>e.get(t)||{component:t,state:`idle`,currentVersion:t===`desktop`?a.version:`--`,availableVersion:``,message:``,releaseUrl:``,notes:``,size:0,transferred:0,canInstall:!1,restartRequired:!1})},[a.version,t.components]),ie=(0,K.useMemo)(()=>({idle:[r(`config:updateSettings.notChecked`),`gray`],checking:[r(`config:updateSettings.checking`),`blue`],current:[r(`config:updateSettings.upToDate`),`green`],available:[r(d?`config:updateSettings.updateAvailable`:`config:updateSettings.sourceUpdatesAvailable`),`blue`],downloading:[r(`config:updateSettings.downloading`),`blue`],downloaded:[r(`config:updateSettings.readyToRestart`),`green`],installed:[r(`config:updateSettings.upToDate`),`green`],error:[r(A?`config:updateSettings.downloadPaused`:`config:updateSettings.checkFailed`),`red`]})[F]||[r(`config:updateSettings.notChecked`),`gray`],[d,F,A,r]);return(0,q.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-3`,children:[(0,q.jsxs)(Y,{className:`p-5`,"data-config-card":`updates-main`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,q.jsx)(`span`,{className:`grid w-[38px] h-[38px] [flex:0_0_auto] place-items-center rounded-[11px] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(xn,{size:19})}),(0,q.jsx)(`span`,{className:`min-w-0`,children:(0,q.jsx)(`strong`,{className:`block text-[16px]`,children:r(`config:updateSettings.pisperAppUpdates`)})})]}),(0,q.jsx)(X,{tone:ie[1],children:ie[0]})]}),(0,q.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,q.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,q.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(d?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,q.jsx)(`strong`,{className:`mt-1 block font-mono text-[14px]`,children:ee})]}),(0,q.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,q.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`config:updateSettings.platform`)}),(0,q.jsx)(`strong`,{className:`mt-1 block text-[14px]`,children:hi(a,r)})]}),(0,q.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,q.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`config:updateSettings.updateChannel`)}),(0,q.jsx)(`strong`,{className:`mt-1 block text-[14px]`,children:d?`Stable`:o.branch||`release`})]})]}),o.message&&(0,q.jsxs)(`div`,{className:`mt-4 flex items-start gap-2 rounded-[var(--r-sm)] p-3 text-[13px] ${o.state===`error`?`bg-[var(--danger-soft)] text-[var(--danger)]`:`bg-[var(--accent-soft)] text-[var(--text)]`}`,children:[o.state===`error`?(0,q.jsx)(V,{className:`mt-0.5 shrink-0`,size:15}):(0,q.jsx)(bn,{className:`mt-0.5 shrink-0`,size:15}),(0,q.jsx)(`span`,{children:o.message})]}),A&&(0,q.jsx)(`small`,{className:`mt-2 block text-[12px] text-[var(--text-muted)]`,children:r(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),N&&(0,q.jsxs)(`div`,{className:`mt-4`,children:[(0,q.jsxs)(`div`,{className:`flex justify-between text-[12px] text-[var(--text-muted)]`,children:[(0,q.jsx)(`span`,{children:r(`config:updateSettings.downloadProgress`)}),(0,q.jsxs)(`span`,{children:[Math.round(o.percent||0),`% · `,gi(o.transferred,i),` /`,` `,gi(o.total,i)]})]}),(0,q.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-[var(--progress-track)]`,children:(0,q.jsx)(`i`,{className:`block h-full bg-[var(--star)] transition-[width]`,style:{width:`${o.percent||0}%`}})})]}),(0,q.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,q.jsxs)(U,{size:`lg`,disabled:M||N||!!g,onClick:j?E:k||A?T:x,children:[M||N?(0,q.jsx)(z,{className:`animate-spin`,size:14}):j?(0,q.jsx)(De,{size:14}):k||A?o.canDownload?(0,q.jsx)(he,{size:14}):(0,q.jsx)(ve,{size:14}):(0,q.jsx)(z,{size:14}),M||N?r(N&&s?`config:updateSettings.installingUpdates`:`config:updateSettings.checking2`):j?r(`config:updateSettings.restartAndInstall`):A?r(`config:updateSettings.resumeDownload`):k?o.canDownload?r(s?`config:updateSettings.downloadAndInstallUpdates`:`config:updateSettings.downloadUpdate`):r(d?`config:updateSettings.viewRelease`:`config:updateSettings.viewSourceUpdates`):r(`config:updateSettings.checkForUpdates`)]}),(0,q.jsxs)(U,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:S,children:[(0,q.jsx)(ve,{size:14}),d?`GitHub Releases`:`GitHub Compare`]}),s&&(0,q.jsxs)(U,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:C,children:[(0,q.jsx)(ve,{size:14}),r(`config:updateSettings.viewUpdateDiagnosticLog`)]})]}),!u&&(0,q.jsxs)(`div`,{className:`mt-6 border-t border-[var(--border)] pt-5`,"data-config-card":`updates-components`,children:[(0,q.jsx)(Mn,{title:r(`config:updateSettings.appComponents`)}),(0,q.jsx)(`div`,{className:`mt-3 divide-y divide-[var(--border)]`,children:re.map(e=>{let t=e.component===`desktop`?bn:e.component===`tui`?Fe:gn,n=e.component===`desktop`?r(`config:updateSettings.desktopFrontend`):e.component===`tui`?r(`config:updateSettings.tuiClient`):r(`config:updateSettings.runtime`),a=e.state===`error`?`red`:e.state===`available`?`blue`:e.state===`installed`||e.state===`current`?`green`:`gray`,o=e.state===`checking`?r(`config:updateSettings.checking`):e.state===`downloading`?r(`config:updateSettings.downloading`):e.state===`available`?r(`config:updateSettings.updateAvailable`):e.state===`installed`?r(`config:updateSettings.installed`):e.state===`error`?r(`config:updateSettings.checkFailed`):e.state===`current`?r(`config:updateSettings.upToDate`):r(`config:updateSettings.notChecked`);return(0,q.jsxs)(`div`,{className:`grid min-h-[68px] items-center gap-3 py-3 sm:grid-cols-[minmax(0,1fr)_auto_auto]`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,q.jsx)(t,{className:`shrink-0 text-[var(--text-muted)]`,size:17}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`strong`,{className:`block text-[14px]`,children:n}),e.message&&(0,q.jsx)(`small`,{className:`mt-0.5 block text-[12px] text-[var(--text-muted)]`,children:e.message})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[12px]`,children:[(0,q.jsxs)(`span`,{children:[`v`,e.currentVersion]}),e.availableVersion&&e.availableVersion!==e.currentVersion&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(P,{size:12}),(0,q.jsxs)(`span`,{children:[`v`,e.availableVersion]})]}),e.size>0&&e.state===`available`&&(0,q.jsx)(`span`,{className:`font-sans text-[var(--text-muted)]`,children:gi(e.size,i)})]}),(0,q.jsx)(X,{tone:a,children:o})]},e.component)})})]})]}),!u&&(0,q.jsx)(ui,{notify:e}),(0,q.jsxs)(Y,{className:`p-5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(Mn,{title:r(d?k||A||j||N?`config:updateSettings.newVersionReleaseNotes`:`config:updateSettings.currentReleaseNotes`:k?`config:updateSettings.commitsToSync`:`config:updateSettings.currentSourceStatus`)}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px] text-[var(--text-muted)]`,children:[(0,q.jsx)(de,{size:13}),k||A||j||N?te:d?`v${D?.version||a.version}`:o.currentCommit?.slice(0,7)||r(`config:updateSettings.notChecked`)]})]}),(o.releaseDate||d&&D?.date)&&(0,q.jsx)(`small`,{className:`mt-2 block text-[12px] text-[var(--text-muted)]`,children:new Intl.DateTimeFormat(i,{dateStyle:`long`}).format(new Date(o.releaseDate||D?.date||``))}),(0,q.jsx)(`div`,{className:`mt-4 rounded-[var(--r-sm)] border border-[var(--stroke-soft)] bg-[var(--surface-subtle)] p-4`,children:(0,q.jsx)(dt,{children:O})})]}),ne.length>0&&(0,q.jsxs)(Y,{className:`p-5`,"data-config-card":`updates-sponsors`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,q.jsx)(`span`,{className:`grid w-[38px] h-[38px] [flex:0_0_auto] place-items-center rounded-[11px] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,q.jsx)(vn,{size:19})}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(Mn,{title:r(`config:updateSettings.sponsors`)}),(0,q.jsx)(`small`,{className:`mt-1 block text-[12px] leading-5 text-[var(--text-muted)]`,children:r(`config:updateSettings.sponsorsDescription`)})]})]}),(0,q.jsx)(`div`,{className:`mt-4 divide-y divide-[var(--stroke-soft)] border-y border-[var(--stroke-soft)]`,children:ne.map(e=>(0,q.jsxs)(`div`,{className:`grid min-h-16 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3 py-3`,children:[(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsxs)(`span`,{className:`mb-1 flex items-center gap-2`,children:[(0,q.jsx)(`strong`,{className:`truncate text-[14px]`,children:e.name}),(0,q.jsx)(X,{tone:`gray`,children:r(`config:updateSettings.sponsored`)})]}),(0,q.jsx)(`small`,{className:`block text-[12px] leading-5 text-[var(--text-muted)]`,children:e.description})]}),(0,q.jsx)(U,{asChild:!0,variant:`outline`,className:`bg-surface-subtle`,children:(0,q.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer sponsored`,"data-web-preview":`external`,onClick:w,children:[(0,q.jsx)(ve,{size:13}),r(`config:updateSettings.visitSponsor`)]})}),(0,q.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0`,"aria-label":r(`config:updateSettings.hideSponsor`),title:r(`config:updateSettings.hideSponsor`),onClick:()=>b(e.id),children:(0,q.jsx)(ze,{size:15})})]},e.id))})]})]})}function vi({notify:e,registerPrimaryAction:t,section:n,onBrowserNotificationChange:r,requestConfirm:i,update:a,renderInterfaceSettings:o}){F(n);let s;if(n===`notifications`)s=(0,q.jsx)(oi,{notify:e,onBrowserNotificationChange:r});else if(n===`interface`){let t=(0,q.jsx)(Yn,{notify:e});s=o?o(t):t}else s=n===`shortcuts`?(0,q.jsx)(Qn,{requestConfirm:i}):n===`desktop-pet`?(0,q.jsx)(Hn,{notify:e,requestConfirm:i}):n===`mobile-server`?(0,q.jsx)(Zr,{requestConfirm:i}):n===`remote-access`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(li,{requestConfirm:i}),!window.__PISPER_REMOTE_WORKSPACE__&&(0,q.jsx)(ci,{notify:e})]}):n===`updates`?(0,q.jsx)(_i,{notify:e,update:a}):n===`about`?(0,q.jsx)(zn,{update:a,notify:e}):(0,q.jsx)(Nr,{notify:e,registerPrimaryAction:t,requestConfirm:i});return(0,q.jsx)(`div`,{"data-config-card":ee,className:n===`models`?`mx-auto w-full max-w-[1040px]`:void 0,children:s})}export{vi as ConfigPage};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-BSZKFkMb.js";import{n as i,r as a,t as o}from"./collapsible-C__hRcbA.js";import{t as s}from"./label-BzlNatZM.js";import{t as c}from"./AppSelect-D149YYg1.js";import{t as l}from"./createLucideIcon-Cd-3GVxJ.js";import{t as u}from"./chevron-down-CxtxIjiP.js";import{t as d}from"./circle-check-iEdCm3Pw.js";import{t as f}from"./circle-x-Ba4QL7Ec.js";import{t as p}from"./flask-conical-DhW5v7Zz.js";import{t as m}from"./key-round-C29uZbsf.js";import{t as h}from"./loader-circle-BOwQzHB-.js";import{t as g}from"./refresh-cw-TbWxTY4K.js";import{t as _}from"./save-CHBB52P8.js";import{i as v}from"./http-DphgzWtw.js";import{t as y}from"./api-Dzobr-o_.js";import{t as b}from"./button-CQA36izu.js";import{t as x}from"./input-CvjGYteF.js";import{t as S}from"./field-3bN8nouy.js";import{l as C,n as w,o as T,s as E,t as D}from"./app-primitives-BBXY6U2S.js";var O=l(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),k=e(t(),1),A=Object.freeze({typesafe:Object.freeze({protocol:`typesafe-decisions`,endpointSuffixes:Object.freeze([`/systemone`,`/decisions`]),defaultBaseUrl:`https://api.typesafe.ai`,path:`/v1/systemone`,defaultModelId:`jev-1.13.0`}),openrouter:Object.freeze({protocol:`typesafe-decisions`,endpointSuffixes:Object.freeze([`/systemone`,`/decisions`]),defaultBaseUrl:`https://openrouter.ai/api`,path:`/alpha/decisions`,defaultModelId:`typesafe/jev-1.13`}),custom:Object.freeze({protocol:`typesafe-decisions`,endpointSuffixes:Object.freeze([`/systemone`,`/decisions`]),defaultBaseUrl:``,path:`/alpha/decisions`,defaultModelId:`typesafe/jev-1.13`})});function j(e){return typeof e==`string`&&Object.hasOwn(A,e)}var M=Object.keys(A).filter(j),N=Object.fromEntries(Object.entries(A).map(([e,t])=>[e,{baseUrl:t.defaultBaseUrl,modelId:t.defaultModelId}]));function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F(e){if(!P(e)||!P(e.config))throw v();let{remote:t,delegate:n,approval:r}=e.config;if(!P(t)||!P(n))throw v();let{provider:i,baseUrl:a,modelId:o,hasKey:s}=t;if(!j(i)||typeof a!=`string`||typeof o!=`string`||typeof s!=`boolean`||typeof n.enabled!=`boolean`||typeof n.verifyActions!=`boolean`||typeof n.allowThreshold!=`number`||!Number.isFinite(n.allowThreshold)||n.allowThreshold<.5||n.allowThreshold>1)throw v();let c;if(r!==void 0){if(!P(r)||r.status!==`ready`&&r.status!==`model_unverified`&&r.status!==`threshold_required`)throw v();c=r.status}return{config:{remote:{provider:i,baseUrl:a,modelId:o,hasKey:s},delegate:{enabled:n.enabled,verifyActions:n.verifyActions,allowThreshold:n.allowThreshold},...c?{approval:{status:c}}:{}}}}async function I(e){return F(await y(`/api/decisions/status`,{signal:e}))}async function L(e){return F(await y(`/api/decisions/config`,{method:`PUT`,body:e}))}function R(e){return y(`/api/decisions/test`,{method:`POST`,body:{},signal:e,timeout:18e4})}function z(e,t){return e instanceof Error&&e.message?e.message:t}var B=n();function V({remote:e,disabled:t,notify:n,onSaved:s}){let{t:l}=r(),[h,v]=(0,k.useState)(e.provider),[y,E]=(0,k.useState)(e.baseUrl),[A,P]=(0,k.useState)(e.modelId),[F,I]=(0,k.useState)(``),[V,H]=(0,k.useState)(!1),[U,W]=(0,k.useState)({status:`idle`}),G=(0,k.useRef)(null);(0,k.useEffect)(()=>()=>G.current?.abort(),[]),(0,k.useEffect)(()=>{v(e.provider),E(e.baseUrl),P(e.modelId),I(``)},[e.provider,e.baseUrl,e.modelId,e.hasKey]),(0,k.useEffect)(()=>{G.current?.abort(),W({status:`idle`})},[h,y,A,F,e.hasKey]);let K=h!==e.provider||y.trim()!==e.baseUrl||A.trim()!==e.modelId||!!F.trim(),q=e=>e===`custom`?l(`decisions:remote.providerCustom`):e===`typesafe`?l(`decisions:remote.providerTypesafe`):e===`openrouter`?l(`decisions:remote.providerOpenrouter`):e,J=t||V||U.status===`running`,Y=N[h],X=!Y.baseUrl,Z=e=>{v(e),E(N[e].baseUrl),P(N[e].modelId)},Q=async e=>{H(!0),W({status:`idle`});try{s((await L({remote:e??{provider:h,baseUrl:y.trim(),modelId:A.trim(),apiKey:F.trim()}})).config),e?.apiKey===null?(I(``),n(l(`decisions:remote.keyCleared`),`success`)):n(l(`decisions:remote.saved`),`success`)}catch(e){n(z(e,l(`decisions:remote.saveFailed`)),`error`)}finally{H(!1)}},$=async()=>{if(K||!e.hasKey)return;G.current?.abort();let t=new AbortController;G.current=t,W({status:`running`});try{let e=await R(t.signal);if(t.signal.aborted)return;W({status:`ok`,result:e})}catch(e){if(t.signal.aborted)return;W({status:`error`,message:z(e,l(`decisions:remote.testFailed`))})}};return(0,B.jsxs)(D,{children:[(0,B.jsxs)(w,{children:[(0,B.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:(0,B.jsx)(T,{title:l(`decisions:remote.title`)})}),(0,B.jsxs)(C,{tone:e.hasKey?`green`:`gray`,children:[(0,B.jsx)(m,{size:11,className:`mr-1 inline`}),e.hasKey?l(`decisions:remote.keyConfigured`):l(`decisions:remote.keyMissing`)]})]}),(0,B.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(S,{variant:`control`,className:`mt-0`,children:[l(`decisions:remote.provider`),(0,B.jsx)(c,{value:h,disabled:J,"aria-label":l(`decisions:remote.provider`),onChange:e=>{j(e.target.value)&&Z(e.target.value)},children:M.map(e=>(0,B.jsx)(`option`,{value:e,children:q(e)},e))})]}),(0,B.jsxs)(S,{variant:`control`,className:`mt-0`,children:[l(`decisions:remote.modelId`),(0,B.jsx)(x,{value:A,disabled:J,placeholder:l(`decisions:remote.modelIdPlaceholder`),onChange:e=>P(e.target.value)})]})]}),(X||y!==Y.baseUrl)&&(0,B.jsxs)(S,{variant:`control`,children:[l(`decisions:remote.baseUrl`),(0,B.jsx)(x,{value:y,disabled:J||!X,placeholder:`https://…`,onChange:e=>E(e.target.value)})]}),(0,B.jsxs)(S,{variant:`control`,children:[l(`decisions:remote.apiKey`),(0,B.jsx)(x,{type:`password`,autoComplete:`new-password`,value:F,disabled:J,placeholder:e.hasKey?l(`decisions:remote.apiKeyPlaceholderKeep`):l(`decisions:remote.apiKeyPlaceholderEnter`),onChange:e=>I(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(b,{size:`sm`,disabled:J||!K,onClick:()=>void Q(),children:[V?(0,B.jsx)(g,{size:13,className:`animate-spin`}):(0,B.jsx)(_,{size:13}),l(`decisions:remote.save`)]}),(0,B.jsxs)(b,{size:`sm`,variant:`outline`,disabled:J||K||!e.hasKey,onClick:()=>void $(),children:[U.status===`running`?(0,B.jsx)(g,{size:13,className:`animate-spin`}):(0,B.jsx)(p,{size:13}),U.status===`running`?l(`decisions:remote.testing`):l(`decisions:remote.test`)]}),e.hasKey&&(0,B.jsxs)(b,{size:`sm`,variant:`ghost`,disabled:J,onClick:()=>void Q({apiKey:null}),children:[(0,B.jsx)(f,{size:13}),l(`decisions:remote.clearKey`)]})]}),K&&(0,B.jsx)(`p`,{className:`mt-2 text-xs text-content-muted`,children:l(`decisions:remote.saveBeforeTest`)}),U.status===`ok`&&(0,B.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,role:`status`,children:[(0,B.jsx)(d,{size:14,className:`shrink-0`}),l(`decisions:remote.testSucceeded`,{model:U.result.model??e.modelId})]}),U.status===`error`&&(0,B.jsxs)(o,{className:`mt-3 rounded-md border border-border bg-muted/40 text-content-muted`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-3`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,role:`status`,children:[(0,B.jsx)(O,{size:14,className:`shrink-0`}),l(`decisions:remote.testFailed`)]}),(0,B.jsx)(a,{asChild:!0,children:(0,B.jsxs)(b,{variant:`ghost`,size:`sm`,className:`group shrink-0`,children:[l(`decisions:remote.details`),(0,B.jsx)(u,{className:`size-3 transition-transform group-data-[state=open]:rotate-180`})]})})]}),(0,B.jsx)(i,{children:(0,B.jsx)(`p`,{className:`max-h-40 overflow-auto border-t border-border p-3 text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:U.message})})]})]})}function H({delegate:e,hasKey:t,approvalStatus:n=`ready`,notify:i,onSaved:a}){let{t:o}=r(),[c,l]=(0,k.useState)(!1),u=async e=>{l(!0);try{a((await L({delegate:e})).config),i(o(`decisions:delegate.saved`),`success`)}catch(e){i(z(e,o(`decisions:delegate.saveFailed`)),`error`)}finally{l(!1)}},d=e=>{let t=Number(e);return Number.isFinite(t)?t:null};return(0,B.jsxs)(D,{children:[(0,B.jsx)(w,{children:(0,B.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:(0,B.jsx)(T,{title:o(`decisions:delegate.title`)})})}),(0,B.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,B.jsxs)(s,{htmlFor:`decision-delegation`,className:`flex flex-col items-start gap-1`,children:[(0,B.jsx)(`span`,{children:o(`decisions:delegate.enabled`)}),(0,B.jsx)(`span`,{className:`text-[11px] leading-normal font-normal text-content-muted`,children:o(`decisions:delegate.enabledHint`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c&&(0,B.jsx)(h,{size:13,className:`animate-spin text-content-muted`}),(0,B.jsx)(E,{id:`decision-delegation`,value:e.enabled,disabled:c,onChange:e=>void u({enabled:e}),ariaLabel:o(`decisions:delegate.enabled`)})]})]}),(0,B.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,B.jsxs)(s,{htmlFor:`decision-verification`,className:`flex flex-col items-start gap-1`,children:[(0,B.jsx)(`span`,{children:o(`decisions:delegate.verifyActions`)}),(0,B.jsx)(`span`,{className:`text-[11px] leading-normal font-normal text-content-muted`,children:o(`decisions:delegate.verifyActionsHint`)})]}),(0,B.jsx)(E,{id:`decision-verification`,value:e.verifyActions,disabled:c,onChange:e=>void u({verifyActions:e}),ariaLabel:o(`decisions:delegate.verifyActions`)})]}),e.enabled&&(0,B.jsxs)(`div`,{className:`mt-3 flex max-w-sm flex-col gap-1.5`,children:[(0,B.jsx)(s,{htmlFor:`delegate-allow`,children:o(`decisions:delegate.allowThreshold`)}),(0,B.jsx)(x,{id:`delegate-allow`,type:`number`,min:.5,max:1,step:.05,disabled:c,defaultValue:e.allowThreshold,onBlur:t=>{let n=d(t.target.value);n!==null&&n!==e.allowThreshold&&u({allowThreshold:n})}},e.allowThreshold),(0,B.jsx)(`p`,{className:`text-[11px] text-content-muted`,children:o(`decisions:delegate.allowThresholdHint`)})]}),e.enabled&&n!==`ready`&&(0,B.jsx)(`div`,{className:`mt-3 rounded-md bg-muted/40 p-3 text-xs text-content-muted`,role:`status`,children:(0,B.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,B.jsx)(`p`,{children:o(n===`model_unverified`?`decisions:delegate.modelUnverified`:`decisions:delegate.thresholdRequired`)}),n===`threshold_required`&&(0,B.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:()=>void u({allowThreshold:e.allowThreshold}),children:o(`decisions:delegate.confirmThreshold`)})]})}),(e.enabled||e.verifyActions)&&!t&&(0,B.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,role:`status`,children:o(`decisions:delegate.noKeyHint`)})]})}function U({notify:e}){let{t}=r(),[n,i]=(0,k.useState)(null),[a,o]=(0,k.useState)(``);return(0,k.useEffect)(()=>{let e=new AbortController;return I(e.signal).then(i).catch(n=>{e.signal.aborted||o(z(n,t(`decisions:page.loadFailed`)))}),()=>e.abort()},[]),a?(0,B.jsx)(`div`,{className:`mx-auto max-w-3xl p-6`,children:(0,B.jsx)(D,{className:`p-6 text-sm text-content-muted`,children:a})}):n?(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-4 p-6 pt-0`,children:[(0,B.jsx)(V,{remote:n.config.remote,disabled:!1,notify:e,onSaved:e=>i(t=>t&&{...t,config:e})}),(0,B.jsx)(H,{delegate:n.config.delegate,approvalStatus:n.config.approval?.status,hasKey:n.config.remote.hasKey,notify:e,onSaved:e=>i(t=>t&&{...t,config:e})})]}):(0,B.jsx)(`div`,{className:`flex items-center justify-center p-12 text-content-muted`,children:(0,B.jsx)(h,{className:`size-5 animate-spin`})})}export{U as DecisionsPage};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-a84Zp9dV.js";import{n as i,r as a,t as o}from"./collapsible-C__hRcbA.js";import{t as s}from"./label-BzlNatZM.js";import{t as c}from"./AppSelect-BCexz4Ty.js";import{t as l}from"./createLucideIcon-Cd-3GVxJ.js";import{t as u}from"./chevron-down-CxtxIjiP.js";import{t as d}from"./circle-check-iEdCm3Pw.js";import{t as f}from"./circle-x-Ba4QL7Ec.js";import{t as p}from"./flask-conical-DhW5v7Zz.js";import{t as m}from"./key-round-C29uZbsf.js";import{t as h}from"./loader-circle-BOwQzHB-.js";import{t as g}from"./refresh-cw-TbWxTY4K.js";import{t as _}from"./save-CHBB52P8.js";import{i as v}from"./http-Be2GB6DH.js";import{t as y}from"./api-YI8_cHpR.js";import{t as b}from"./button-CQA36izu.js";import{t as x}from"./input-CvjGYteF.js";import{t as S}from"./field-3bN8nouy.js";import{l as C,n as w,o as T,s as E,t as D}from"./app-primitives-SxfoFmHc.js";var O=l(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),k=e(t(),1),A=Object.freeze({typesafe:Object.freeze({protocol:`typesafe-decisions`,endpointSuffixes:Object.freeze([`/systemone`,`/decisions`]),defaultBaseUrl:`https://api.typesafe.ai`,path:`/v1/systemone`,defaultModelId:`jev-1.13.0`}),openrouter:Object.freeze({protocol:`typesafe-decisions`,endpointSuffixes:Object.freeze([`/systemone`,`/decisions`]),defaultBaseUrl:`https://openrouter.ai/api`,path:`/alpha/decisions`,defaultModelId:`typesafe/jev-1.13`}),custom:Object.freeze({protocol:`typesafe-decisions`,endpointSuffixes:Object.freeze([`/systemone`,`/decisions`]),defaultBaseUrl:``,path:`/alpha/decisions`,defaultModelId:`typesafe/jev-1.13`})});function j(e){return typeof e==`string`&&Object.hasOwn(A,e)}var M=Object.keys(A).filter(j),N=Object.fromEntries(Object.entries(A).map(([e,t])=>[e,{baseUrl:t.defaultBaseUrl,modelId:t.defaultModelId}]));function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F(e){if(!P(e)||!P(e.config))throw v();let{remote:t,delegate:n,approval:r}=e.config;if(!P(t)||!P(n))throw v();let{provider:i,baseUrl:a,modelId:o,hasKey:s}=t;if(!j(i)||typeof a!=`string`||typeof o!=`string`||typeof s!=`boolean`||typeof n.enabled!=`boolean`||typeof n.verifyActions!=`boolean`||typeof n.allowThreshold!=`number`||!Number.isFinite(n.allowThreshold)||n.allowThreshold<.5||n.allowThreshold>1)throw v();let c;if(r!==void 0){if(!P(r)||r.status!==`ready`&&r.status!==`model_unverified`&&r.status!==`threshold_required`)throw v();c=r.status}return{config:{remote:{provider:i,baseUrl:a,modelId:o,hasKey:s},delegate:{enabled:n.enabled,verifyActions:n.verifyActions,allowThreshold:n.allowThreshold},...c?{approval:{status:c}}:{}}}}async function I(e){return F(await y(`/api/decisions/status`,{signal:e}))}async function L(e){return F(await y(`/api/decisions/config`,{method:`PUT`,body:e}))}function R(e){return y(`/api/decisions/test`,{method:`POST`,body:{},signal:e,timeout:18e4})}function z(e,t){return e instanceof Error&&e.message?e.message:t}var B=n();function V({remote:e,disabled:t,notify:n,onSaved:s}){let{t:l}=r(),[h,v]=(0,k.useState)(e.provider),[y,E]=(0,k.useState)(e.baseUrl),[A,P]=(0,k.useState)(e.modelId),[F,I]=(0,k.useState)(``),[V,H]=(0,k.useState)(!1),[U,W]=(0,k.useState)({status:`idle`}),G=(0,k.useRef)(null);(0,k.useEffect)(()=>()=>G.current?.abort(),[]),(0,k.useEffect)(()=>{v(e.provider),E(e.baseUrl),P(e.modelId),I(``)},[e.provider,e.baseUrl,e.modelId,e.hasKey]),(0,k.useEffect)(()=>{G.current?.abort(),W({status:`idle`})},[h,y,A,F,e.hasKey]);let K=h!==e.provider||y.trim()!==e.baseUrl||A.trim()!==e.modelId||!!F.trim(),q=e=>e===`custom`?l(`decisions:remote.providerCustom`):e===`typesafe`?l(`decisions:remote.providerTypesafe`):e===`openrouter`?l(`decisions:remote.providerOpenrouter`):e,J=t||V||U.status===`running`,Y=N[h],X=!Y.baseUrl,Z=e=>{v(e),E(N[e].baseUrl),P(N[e].modelId)},Q=async e=>{H(!0),W({status:`idle`});try{s((await L({remote:e??{provider:h,baseUrl:y.trim(),modelId:A.trim(),apiKey:F.trim()}})).config),e?.apiKey===null?(I(``),n(l(`decisions:remote.keyCleared`),`success`)):n(l(`decisions:remote.saved`),`success`)}catch(e){n(z(e,l(`decisions:remote.saveFailed`)),`error`)}finally{H(!1)}},$=async()=>{if(K||!e.hasKey)return;G.current?.abort();let t=new AbortController;G.current=t,W({status:`running`});try{let e=await R(t.signal);if(t.signal.aborted)return;W({status:`ok`,result:e})}catch(e){if(t.signal.aborted)return;W({status:`error`,message:z(e,l(`decisions:remote.testFailed`))})}};return(0,B.jsxs)(D,{children:[(0,B.jsxs)(w,{children:[(0,B.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:(0,B.jsx)(T,{title:l(`decisions:remote.title`)})}),(0,B.jsxs)(C,{tone:e.hasKey?`green`:`gray`,children:[(0,B.jsx)(m,{size:11,className:`mr-1 inline`}),e.hasKey?l(`decisions:remote.keyConfigured`):l(`decisions:remote.keyMissing`)]})]}),(0,B.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(S,{variant:`control`,className:`mt-0`,children:[l(`decisions:remote.provider`),(0,B.jsx)(c,{value:h,disabled:J,"aria-label":l(`decisions:remote.provider`),onChange:e=>{j(e.target.value)&&Z(e.target.value)},children:M.map(e=>(0,B.jsx)(`option`,{value:e,children:q(e)},e))})]}),(0,B.jsxs)(S,{variant:`control`,className:`mt-0`,children:[l(`decisions:remote.modelId`),(0,B.jsx)(x,{value:A,disabled:J,placeholder:l(`decisions:remote.modelIdPlaceholder`),onChange:e=>P(e.target.value)})]})]}),(X||y!==Y.baseUrl)&&(0,B.jsxs)(S,{variant:`control`,children:[l(`decisions:remote.baseUrl`),(0,B.jsx)(x,{value:y,disabled:J||!X,placeholder:`https://…`,onChange:e=>E(e.target.value)})]}),(0,B.jsxs)(S,{variant:`control`,children:[l(`decisions:remote.apiKey`),(0,B.jsx)(x,{type:`password`,autoComplete:`new-password`,value:F,disabled:J,placeholder:e.hasKey?l(`decisions:remote.apiKeyPlaceholderKeep`):l(`decisions:remote.apiKeyPlaceholderEnter`),onChange:e=>I(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(b,{size:`sm`,disabled:J||!K,onClick:()=>void Q(),children:[V?(0,B.jsx)(g,{size:13,className:`animate-spin`}):(0,B.jsx)(_,{size:13}),l(`decisions:remote.save`)]}),(0,B.jsxs)(b,{size:`sm`,variant:`outline`,disabled:J||K||!e.hasKey,onClick:()=>void $(),children:[U.status===`running`?(0,B.jsx)(g,{size:13,className:`animate-spin`}):(0,B.jsx)(p,{size:13}),U.status===`running`?l(`decisions:remote.testing`):l(`decisions:remote.test`)]}),e.hasKey&&(0,B.jsxs)(b,{size:`sm`,variant:`ghost`,disabled:J,onClick:()=>void Q({apiKey:null}),children:[(0,B.jsx)(f,{size:13}),l(`decisions:remote.clearKey`)]})]}),K&&(0,B.jsx)(`p`,{className:`mt-2 text-xs text-content-muted`,children:l(`decisions:remote.saveBeforeTest`)}),U.status===`ok`&&(0,B.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-xs text-content-muted`,role:`status`,children:[(0,B.jsx)(d,{size:14,className:`shrink-0`}),l(`decisions:remote.testSucceeded`,{model:U.result.model??e.modelId})]}),U.status===`error`&&(0,B.jsxs)(o,{className:`mt-3 rounded-md border border-border bg-muted/40 text-content-muted`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-3`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,role:`status`,children:[(0,B.jsx)(O,{size:14,className:`shrink-0`}),l(`decisions:remote.testFailed`)]}),(0,B.jsx)(a,{asChild:!0,children:(0,B.jsxs)(b,{variant:`ghost`,size:`sm`,className:`group shrink-0`,children:[l(`decisions:remote.details`),(0,B.jsx)(u,{className:`size-3 transition-transform group-data-[state=open]:rotate-180`})]})})]}),(0,B.jsx)(i,{children:(0,B.jsx)(`p`,{className:`max-h-40 overflow-auto border-t border-border p-3 text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:U.message})})]})]})}function H({delegate:e,hasKey:t,approvalStatus:n=`ready`,notify:i,onSaved:a}){let{t:o}=r(),[c,l]=(0,k.useState)(!1),u=async e=>{l(!0);try{a((await L({delegate:e})).config),i(o(`decisions:delegate.saved`),`success`)}catch(e){i(z(e,o(`decisions:delegate.saveFailed`)),`error`)}finally{l(!1)}},d=e=>{let t=Number(e);return Number.isFinite(t)?t:null};return(0,B.jsxs)(D,{children:[(0,B.jsx)(w,{children:(0,B.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:(0,B.jsx)(T,{title:o(`decisions:delegate.title`)})})}),(0,B.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,B.jsxs)(s,{htmlFor:`decision-delegation`,className:`flex flex-col items-start gap-1`,children:[(0,B.jsx)(`span`,{children:o(`decisions:delegate.enabled`)}),(0,B.jsx)(`span`,{className:`text-[11px] leading-normal font-normal text-content-muted`,children:o(`decisions:delegate.enabledHint`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c&&(0,B.jsx)(h,{size:13,className:`animate-spin text-content-muted`}),(0,B.jsx)(E,{id:`decision-delegation`,value:e.enabled,disabled:c,onChange:e=>void u({enabled:e}),ariaLabel:o(`decisions:delegate.enabled`)})]})]}),(0,B.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,B.jsxs)(s,{htmlFor:`decision-verification`,className:`flex flex-col items-start gap-1`,children:[(0,B.jsx)(`span`,{children:o(`decisions:delegate.verifyActions`)}),(0,B.jsx)(`span`,{className:`text-[11px] leading-normal font-normal text-content-muted`,children:o(`decisions:delegate.verifyActionsHint`)})]}),(0,B.jsx)(E,{id:`decision-verification`,value:e.verifyActions,disabled:c,onChange:e=>void u({verifyActions:e}),ariaLabel:o(`decisions:delegate.verifyActions`)})]}),e.enabled&&(0,B.jsxs)(`div`,{className:`mt-3 flex max-w-sm flex-col gap-1.5`,children:[(0,B.jsx)(s,{htmlFor:`delegate-allow`,children:o(`decisions:delegate.allowThreshold`)}),(0,B.jsx)(x,{id:`delegate-allow`,type:`number`,min:.5,max:1,step:.05,disabled:c,defaultValue:e.allowThreshold,onBlur:t=>{let n=d(t.target.value);n!==null&&n!==e.allowThreshold&&u({allowThreshold:n})}},e.allowThreshold),(0,B.jsx)(`p`,{className:`text-[11px] text-content-muted`,children:o(`decisions:delegate.allowThresholdHint`)})]}),e.enabled&&n!==`ready`&&(0,B.jsx)(`div`,{className:`mt-3 rounded-md bg-muted/40 p-3 text-xs text-content-muted`,role:`status`,children:(0,B.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,B.jsx)(`p`,{children:o(n===`model_unverified`?`decisions:delegate.modelUnverified`:`decisions:delegate.thresholdRequired`)}),n===`threshold_required`&&(0,B.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:()=>void u({allowThreshold:e.allowThreshold}),children:o(`decisions:delegate.confirmThreshold`)})]})}),(e.enabled||e.verifyActions)&&!t&&(0,B.jsx)(`p`,{className:`mt-3 text-xs text-content-muted`,role:`status`,children:o(`decisions:delegate.noKeyHint`)})]})}function U({notify:e}){let{t}=r(),[n,i]=(0,k.useState)(null),[a,o]=(0,k.useState)(``);return(0,k.useEffect)(()=>{let e=new AbortController;return I(e.signal).then(i).catch(n=>{e.signal.aborted||o(z(n,t(`decisions:page.loadFailed`)))}),()=>e.abort()},[]),a?(0,B.jsx)(`div`,{className:`mx-auto max-w-3xl p-6`,children:(0,B.jsx)(D,{className:`p-6 text-sm text-content-muted`,children:a})}):n?(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-4 p-6 pt-0`,children:[(0,B.jsx)(V,{remote:n.config.remote,disabled:!1,notify:e,onSaved:e=>i(t=>t&&{...t,config:e})}),(0,B.jsx)(H,{delegate:n.config.delegate,approvalStatus:n.config.approval?.status,hasKey:n.config.remote.hasKey,notify:e,onSaved:e=>i(t=>t&&{...t,config:e})})]}):(0,B.jsx)(`div`,{className:`flex items-center justify-center p-12 text-content-muted`,children:(0,B.jsx)(h,{className:`size-5 animate-spin`})})}export{U as DecisionsPage};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-BSZKFkMb.js";import{t as i}from"./minus-BuutOHSj.js";import{t as a}from"./square-bHHVTT3G.js";import{t as o}from"./x-07u4-129.js";var s=e(t(),1),c=n();function l(){let{t:e}=r(),t={minimize:e(`navigation:window.minimize`),maximize:e(`navigation:window.maximize`),close:e(`navigation:window.close`)},n=window.pisperDesktop;return(0,s.useEffect)(()=>{if(!n?.customTitlebar||!n.windowAction)return;let e=e=>{let t=e.target instanceof Element?e.target:null;e.button!==0||!t?.closest(`[data-window-drag-region]`)||t.closest(`button, a, input, select, textarea, [role="button"], [role="tab"], [contenteditable="true"]`)||e.type===`mousedown`&&e.detail>1||n.windowAction?.(e.type===`dblclick`?`maximize`:`drag`).catch(()=>{})};return document.addEventListener(`mousedown`,e),document.addEventListener(`dblclick`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`dblclick`,e)}},[n]),!n?.customTitlebar||!n.windowAction?null:(0,c.jsx)(`div`,{className:`desktop-window-controls absolute right-0 top-0 z-40 flex h-12`,"aria-label":e(`navigation:window.controls`),children:[`minimize`,`maximize`,`close`].map(e=>{let r=e===`minimize`?i:e===`maximize`?a:o;return(0,c.jsx)(`button`,{type:`button`,title:t[e],"aria-label":t[e],className:`grid w-11 place-items-center text-muted-foreground ${e===`close`?`hover:bg-red-600 hover:text-white`:`hover:bg-foreground/10`}`,onClick:()=>void n.windowAction?.(e).catch(()=>{}),children:(0,c.jsx)(r,{size:e===`maximize`?12:15})},e)})})}export{l as DesktopWindowControls};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-a84Zp9dV.js";import{t as i}from"./minus-BuutOHSj.js";import{t as a}from"./square-bHHVTT3G.js";import{t as o}from"./x-07u4-129.js";var s=e(t(),1),c=n();function l(){let{t:e}=r(),t={minimize:e(`navigation:window.minimize`),maximize:e(`navigation:window.maximize`),close:e(`navigation:window.close`)},n=window.pisperDesktop;return(0,s.useEffect)(()=>{if(!n?.customTitlebar||!n.windowAction)return;let e=e=>{let t=e.target instanceof Element?e.target:null;e.button!==0||!t?.closest(`[data-window-drag-region]`)||t.closest(`button, a, input, select, textarea, [role="button"], [role="tab"], [contenteditable="true"]`)||e.type===`mousedown`&&e.detail>1||n.windowAction?.(e.type===`dblclick`?`maximize`:`drag`).catch(()=>{})};return document.addEventListener(`mousedown`,e),document.addEventListener(`dblclick`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`dblclick`,e)}},[n]),!n?.customTitlebar||!n.windowAction?null:(0,c.jsx)(`div`,{className:`desktop-window-controls absolute right-0 top-0 z-40 flex h-12`,"aria-label":e(`navigation:window.controls`),children:[`minimize`,`maximize`,`close`].map(e=>{let r=e===`minimize`?i:e===`maximize`?a:o;return(0,c.jsx)(`button`,{type:`button`,title:t[e],"aria-label":t[e],className:`grid w-11 place-items-center text-muted-foreground ${e===`close`?`hover:bg-red-600 hover:text-white`:`hover:bg-foreground/10`}`,onClick:()=>void n.windowAction?.(e).catch(()=>{}),children:(0,c.jsx)(r,{size:e===`maximize`?12:15})},e)})})}export{l as DesktopWindowControls};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./index-iBrSU61i.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-BSZKFkMb.js";import{a,i as o,o as s}from"./vendor-state-GkUciC5H.js";import{t as c}from"./utils-C8uzG5AZ.js";import{t as l}from"./grip-vertical-B__LYT0s.js";import{t as u}from"./rotate-ccw-C0v8V77_.js";import{t as d}from"./x-07u4-129.js";import{n as f}from"./use-mobile-YXncArOq.js";import{n as p}from"./client-store-DPMvgPNS.js";import{t as m}from"./button-CQA36izu.js";import{n as h,r as g,t as _}from"./floating-widgets-store-DIy4GSy4.js";import{t as v}from"./useCustomUiComponents-BH86kuaq.js";var y=e(n(),1),b=r();function x({componentId:e,notify:t,preview:n=!1}){let{t:r}=i(),a=v(),o=a.data?.components.find(t=>t.id===e);return o?(0,b.jsx)(g,{component:o,notify:t,preview:n},o.id):(0,b.jsxs)(`div`,{role:`status`,className:`flex h-full min-h-0 min-w-0 flex-col items-center justify-center gap-2 overflow-auto p-3 text-center text-xs text-[var(--text-muted)]`,children:[(0,b.jsx)(`p`,{className:`max-w-full break-words`,children:a.isPending?r(`custom-ui:customUiPage.loading`):a.error?r(`custom-ui:widget.catalogFailed`):r(`custom-ui:widget.missing`,{id:e})}),!a.isPending&&(0,b.jsx)(m,{variant:`outline`,size:`sm`,disabled:a.isFetching,onClick:()=>void a.refetch(),children:r(`custom-ui:widget.retry`)})]})}var S={x:.5,y:0},C=e=>Math.min(1,Math.max(0,e)),w=e=>Number.isFinite(e)?Math.max(0,e):0;function T(e,t,n,r=0){if(!n&&r===0)return S;let i=Math.max(0,w(e.width)-w(t.width)),a=Math.max(0,w(e.height)-w(t.height)),o=(n?n.x+n.width/2:e.width/2)-t.width/2,s=n?n.y+n.height/2-t.height/2:0;if(r>0){let e=Math.max(0,n?n.y+n.height+12:76),i=t.height+12,c=Math.max(0,Math.floor((a-e)/i)+1);if(r<=c)s=e+(r-1)*i;else{let e=r-c;o+=24*e,s=Math.max(0,a-(e-1)*24%Math.max(1,a))}}return{x:i?C(o/i):.5,y:a?C(s/a):0}}function E(e,t){return`${t?`mobile`:`desktop`}:${e}`}function D(e,t,n){return{x:C(e.x)*Math.max(0,w(t.width)-w(n.width)),y:C(e.y)*Math.max(0,w(t.height)-w(n.height))}}function O(e,t,n,r){let i=D(e,n,r),a=Math.max(0,w(n.width)-w(r.width)),o=Math.max(0,w(n.height)-w(r.height));return{x:C(a?(i.x+t.x)/a:e.x),y:C(o?(i.y+t.y)/o:e.y)}}function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A(e){if(!Array.isArray(e))return[];let t=new Map;for(let n of e)!k(n)||typeof n.key!=`string`||!/^(desktop|mobile):[a-zA-Z0-9][a-zA-Z0-9._:-]{0,95}$/.test(n.key)||!k(n.position)||typeof n.position.x!=`number`||!Number.isFinite(n.position.x)||typeof n.position.y!=`number`||!Number.isFinite(n.position.y)||(t.delete(n.key),t.set(n.key,{x:C(n.position.x),y:C(n.position.y)}),t.size>128&&t.delete(t.keys().next().value??``));return[...t].map(([e,t])=>({key:e,position:t}))}function j(e,t,n){return A([...e.filter(e=>e.key!==t),{key:t,position:n}])}var M=o(()=>({getItem:e=>{try{return t.getItem(e)}catch{return null}},setItem:(e,n)=>{try{t.setItem(e,n)}catch{}},removeItem:e=>{try{t.removeItem(e)}catch{}}})),N=s()(a(e=>({positions:[],setPosition:(t,n)=>e(e=>({positions:j(e.positions,t,n)})),resetPosition:t=>e(e=>({positions:e.positions.filter(e=>e.key!==t)}))}),{name:`pisper-floating-placement`,version:1,storage:M,partialize:({positions:e})=>({positions:e}),merge:(e,t)=>({...t,positions:A(e&&typeof e==`object`&&`positions`in e?e.positions:void 0)})})),P={width:0,height:0};function F({id:e,componentId:t,boundaryRef:n,anchorRef:r,notify:a,onClose:o,stackIndex:s}){let{t:m}=i(),h=f(),g=p(),_=E(e,h||g),v=N(e=>e.positions.find(e=>e.key===_)?.position),S=(0,y.useRef)(null),C=(0,y.useRef)(null),[w,k]=(0,y.useState)(null),[A,j]=(0,y.useState)({bounds:P,island:P}),M=v??T(A.bounds,A.island,A.anchor,s),F=(0,y.useId)();(0,y.useEffect)(()=>{let e=n.current,t=S.current;if(!e||!t)return;let i=null,a=new ResizeObserver(()=>s()),o=null,s=()=>{let n=r?.current;n!==i&&(i&&a.unobserve(i),i=n??null,n&&(a.observe(n),o?.disconnect(),o=null));let s=e.getBoundingClientRect(),c=n?.getBoundingClientRect(),l={bounds:{width:e.clientWidth,height:e.clientHeight},island:{width:t.offsetWidth,height:t.offsetHeight},anchor:c&&c.width>0&&c.height>0?{x:c.left-s.left,y:c.top-s.top,width:c.width,height:c.height}:void 0};j(e=>e.bounds.width===l.bounds.width&&e.bounds.height===l.bounds.height&&e.island.width===l.island.width&&e.island.height===l.island.height&&e.anchor?.x===l.anchor?.x&&e.anchor?.y===l.anchor?.y&&e.anchor?.width===l.anchor?.width&&e.anchor?.height===l.anchor?.height?e:l)};return s(),a.observe(e),a.observe(t),r&&!r.current&&(o=new MutationObserver(()=>{r.current&&s()}),o.observe(document.body,{childList:!0,subtree:!0})),window.addEventListener(`resize`,s),window.addEventListener(`scroll`,s,!0),()=>{a.disconnect(),o?.disconnect(),window.removeEventListener(`resize`,s),window.removeEventListener(`scroll`,s,!0)}},[n,r]),(0,y.useEffect)(()=>(k(null),()=>{let e=C.current;C.current=null,e?.element.hasPointerCapture(e.pointerId)&&e.element.releasePointerCapture(e.pointerId)}),[_]);let I=(e,t)=>{let n=C.current;!n||n.pointerId!==e.pointerId||(C.current=null,t&&N.getState().setPosition(_,n.latest),k(null),n.element.hasPointerCapture(n.pointerId)&&n.element.releasePointerCapture(n.pointerId))},L=()=>N.getState().resetPosition(_),R=e=>{let t=e.shiftKey?32:12,n={ArrowLeft:{x:-t,y:0},ArrowRight:{x:t,y:0},ArrowUp:{x:0,y:-t},ArrowDown:{x:0,y:t}};if(e.key===`Home`){e.preventDefault(),L();return}let r=n[e.key];r&&(e.preventDefault(),N.getState().setPosition(_,O(M,r,A.bounds,A.island)))},z=D(w??M,A.bounds,A.island);return(0,b.jsxs)(`div`,{ref:S,"data-floating-widget":e,className:c(`pointer-events-auto absolute flex w-[380px] max-w-full flex-col`,t===`pisper-island`&&`max-[650px]:w-[210px] max-[650px]:px-5`),style:{left:z.x,top:z.y,maxHeight:`100%`,visibility:A.bounds.width>0?`visible`:`hidden`},children:[(0,b.jsxs)(`div`,{className:`absolute left-0 top-1/2 z-10 flex -translate-y-1/2 flex-col items-center gap-1`,children:[(0,b.jsx)(`button`,{type:`button`,"aria-label":m(`custom-ui:floating.move`),"aria-describedby":F,title:m(`custom-ui:floating.moveHint`),className:`flex h-6 w-5 touch-none items-center justify-center rounded-full bg-background/85 text-muted-foreground shadow-sm outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,style:{cursor:w?`grabbing`:`grab`},onKeyDown:R,onPointerDown:e=>{e.button!==0||C.current||(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}),e.currentTarget.setPointerCapture(e.pointerId),C.current={pointerId:e.pointerId,element:e.currentTarget,x:e.clientX,y:e.clientY,initial:M,latest:M},k(M))},onPointerMove:e=>{let t=C.current;if(!t||t.pointerId!==e.pointerId)return;let n=O(t.initial,{x:e.clientX-t.x,y:e.clientY-t.y},A.bounds,A.island);t.latest=n,k(n)},onPointerUp:e=>I(e,!0),onPointerCancel:e=>I(e,!1),onLostPointerCapture:e=>I(e,!1),children:(0,b.jsx)(l,{className:`size-3`})}),(0,b.jsx)(`button`,{type:`button`,"aria-label":m(`custom-ui:floating.resetPosition`),title:m(`custom-ui:floating.resetPosition`),onClick:L,className:`flex size-5 items-center justify-center rounded-full bg-background/85 text-muted-foreground shadow-sm outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,b.jsx)(u,{className:`size-3`})}),(0,b.jsx)(`span`,{id:F,className:`sr-only`,children:m(`custom-ui:floating.moveHint`)})]}),o&&(0,b.jsx)(`button`,{type:`button`,"aria-label":m(`custom-ui:floating.close`),title:m(`custom-ui:floating.close`),onClick:()=>o(t),className:`absolute right-0 top-1/2 z-10 flex size-5 -translate-y-1/2 items-center justify-center rounded-full bg-background/85 text-muted-foreground shadow-sm outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,b.jsx)(d,{className:`size-3`})}),(0,b.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,style:{height:t===`pisper-island`?64:240},children:(0,b.jsx)(x,{componentId:t,notify:a})})]})}function I({widgets:e,notify:t,anchorRef:n,onClose:r}){let i=(0,y.useRef)(null),a=e.filter(e=>e.componentId!==`pisper-island`);return(0,b.jsx)(`div`,{ref:i,className:`pointer-events-none fixed inset-x-2 bottom-2 top-0 z-40 overflow-hidden`,"data-floating-custom-ui":!0,children:e.map(e=>(0,b.jsx)(F,{id:e.id,componentId:e.componentId,boundaryRef:i,notify:t,anchorRef:n,onClose:r,stackIndex:e.componentId===`pisper-island`?0:a.findIndex(t=>t.id===e.id)+1},e.id))})}function L({anchorRef:e,notify:t}){let{t:n}=i(),r=h(e=>e.prefs),a=(0,y.useMemo)(()=>_([],r).map(e=>({id:e,componentId:e})),[r]);return(0,b.jsx)(I,{widgets:a,anchorRef:e,notify:t,onClose:e=>{try{h.getState().setVisible(e,!1),h.getState().storageError&&t(n(`custom-ui:floating.storageFailed`))}catch{t(n(`custom-ui:floating.storageFailed`))}}})}export{L as FloatingWidgets};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./index-AF29hfx9.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-a84Zp9dV.js";import{a,i as o,o as s}from"./vendor-state-GkUciC5H.js";import{t as c}from"./utils-C8uzG5AZ.js";import{t as l}from"./grip-vertical-B__LYT0s.js";import{t as u}from"./rotate-ccw-C0v8V77_.js";import{t as d}from"./x-07u4-129.js";import{n as f}from"./use-mobile-YXncArOq.js";import{n as p}from"./client-store-BP_3-plw.js";import{t as m}from"./button-CQA36izu.js";import{n as h,r as g,t as _}from"./floating-widgets-store-Pjm1AdvO.js";import{t as v}from"./useCustomUiComponents-BaQ_fwbr.js";var y=e(n(),1),b=r();function x({componentId:e,notify:t,preview:n=!1}){let{t:r}=i(),a=v(),o=a.data?.components.find(t=>t.id===e);return o?(0,b.jsx)(g,{component:o,notify:t,preview:n},o.id):(0,b.jsxs)(`div`,{role:`status`,className:`flex h-full min-h-0 min-w-0 flex-col items-center justify-center gap-2 overflow-auto p-3 text-center text-xs text-[var(--text-muted)]`,children:[(0,b.jsx)(`p`,{className:`max-w-full break-words`,children:a.isPending?r(`custom-ui:customUiPage.loading`):a.error?r(`custom-ui:widget.catalogFailed`):r(`custom-ui:widget.missing`,{id:e})}),!a.isPending&&(0,b.jsx)(m,{variant:`outline`,size:`sm`,disabled:a.isFetching,onClick:()=>void a.refetch(),children:r(`custom-ui:widget.retry`)})]})}var S={x:.5,y:0},C=e=>Math.min(1,Math.max(0,e)),w=e=>Number.isFinite(e)?Math.max(0,e):0;function T(e,t,n,r=0){if(!n&&r===0)return S;let i=Math.max(0,w(e.width)-w(t.width)),a=Math.max(0,w(e.height)-w(t.height)),o=(n?n.x+n.width/2:e.width/2)-t.width/2,s=n?n.y+n.height/2-t.height/2:0;if(r>0){let e=Math.max(0,n?n.y+n.height+12:76),i=t.height+12,c=Math.max(0,Math.floor((a-e)/i)+1);if(r<=c)s=e+(r-1)*i;else{let e=r-c;o+=24*e,s=Math.max(0,a-(e-1)*24%Math.max(1,a))}}return{x:i?C(o/i):.5,y:a?C(s/a):0}}function E(e,t){return`${t?`mobile`:`desktop`}:${e}`}function D(e,t,n){return{x:C(e.x)*Math.max(0,w(t.width)-w(n.width)),y:C(e.y)*Math.max(0,w(t.height)-w(n.height))}}function O(e,t,n,r){let i=D(e,n,r),a=Math.max(0,w(n.width)-w(r.width)),o=Math.max(0,w(n.height)-w(r.height));return{x:C(a?(i.x+t.x)/a:e.x),y:C(o?(i.y+t.y)/o:e.y)}}function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A(e){if(!Array.isArray(e))return[];let t=new Map;for(let n of e)!k(n)||typeof n.key!=`string`||!/^(desktop|mobile):[a-zA-Z0-9][a-zA-Z0-9._:-]{0,95}$/.test(n.key)||!k(n.position)||typeof n.position.x!=`number`||!Number.isFinite(n.position.x)||typeof n.position.y!=`number`||!Number.isFinite(n.position.y)||(t.delete(n.key),t.set(n.key,{x:C(n.position.x),y:C(n.position.y)}),t.size>128&&t.delete(t.keys().next().value??``));return[...t].map(([e,t])=>({key:e,position:t}))}function j(e,t,n){return A([...e.filter(e=>e.key!==t),{key:t,position:n}])}var M=o(()=>({getItem:e=>{try{return t.getItem(e)}catch{return null}},setItem:(e,n)=>{try{t.setItem(e,n)}catch{}},removeItem:e=>{try{t.removeItem(e)}catch{}}})),N=s()(a(e=>({positions:[],setPosition:(t,n)=>e(e=>({positions:j(e.positions,t,n)})),resetPosition:t=>e(e=>({positions:e.positions.filter(e=>e.key!==t)}))}),{name:`pisper-floating-placement`,version:1,storage:M,partialize:({positions:e})=>({positions:e}),merge:(e,t)=>({...t,positions:A(e&&typeof e==`object`&&`positions`in e?e.positions:void 0)})})),P={width:0,height:0};function F({id:e,componentId:t,boundaryRef:n,anchorRef:r,notify:a,onClose:o,stackIndex:s}){let{t:m}=i(),h=f(),g=p(),_=E(e,h||g),v=N(e=>e.positions.find(e=>e.key===_)?.position),S=(0,y.useRef)(null),C=(0,y.useRef)(null),[w,k]=(0,y.useState)(null),[A,j]=(0,y.useState)({bounds:P,island:P}),M=v??T(A.bounds,A.island,A.anchor,s),F=(0,y.useId)();(0,y.useEffect)(()=>{let e=n.current,t=S.current;if(!e||!t)return;let i=null,a=new ResizeObserver(()=>s()),o=null,s=()=>{let n=r?.current;n!==i&&(i&&a.unobserve(i),i=n??null,n&&(a.observe(n),o?.disconnect(),o=null));let s=e.getBoundingClientRect(),c=n?.getBoundingClientRect(),l={bounds:{width:e.clientWidth,height:e.clientHeight},island:{width:t.offsetWidth,height:t.offsetHeight},anchor:c&&c.width>0&&c.height>0?{x:c.left-s.left,y:c.top-s.top,width:c.width,height:c.height}:void 0};j(e=>e.bounds.width===l.bounds.width&&e.bounds.height===l.bounds.height&&e.island.width===l.island.width&&e.island.height===l.island.height&&e.anchor?.x===l.anchor?.x&&e.anchor?.y===l.anchor?.y&&e.anchor?.width===l.anchor?.width&&e.anchor?.height===l.anchor?.height?e:l)};return s(),a.observe(e),a.observe(t),r&&!r.current&&(o=new MutationObserver(()=>{r.current&&s()}),o.observe(document.body,{childList:!0,subtree:!0})),window.addEventListener(`resize`,s),window.addEventListener(`scroll`,s,!0),()=>{a.disconnect(),o?.disconnect(),window.removeEventListener(`resize`,s),window.removeEventListener(`scroll`,s,!0)}},[n,r]),(0,y.useEffect)(()=>(k(null),()=>{let e=C.current;C.current=null,e?.element.hasPointerCapture(e.pointerId)&&e.element.releasePointerCapture(e.pointerId)}),[_]);let I=(e,t)=>{let n=C.current;!n||n.pointerId!==e.pointerId||(C.current=null,t&&N.getState().setPosition(_,n.latest),k(null),n.element.hasPointerCapture(n.pointerId)&&n.element.releasePointerCapture(n.pointerId))},L=()=>N.getState().resetPosition(_),R=e=>{let t=e.shiftKey?32:12,n={ArrowLeft:{x:-t,y:0},ArrowRight:{x:t,y:0},ArrowUp:{x:0,y:-t},ArrowDown:{x:0,y:t}};if(e.key===`Home`){e.preventDefault(),L();return}let r=n[e.key];r&&(e.preventDefault(),N.getState().setPosition(_,O(M,r,A.bounds,A.island)))},z=D(w??M,A.bounds,A.island);return(0,b.jsxs)(`div`,{ref:S,"data-floating-widget":e,className:c(`pointer-events-auto absolute flex w-[380px] max-w-full flex-col`,t===`pisper-island`&&`max-[650px]:w-[210px] max-[650px]:px-5`),style:{left:z.x,top:z.y,maxHeight:`100%`,visibility:A.bounds.width>0?`visible`:`hidden`},children:[(0,b.jsxs)(`div`,{className:`absolute left-0 top-1/2 z-10 flex -translate-y-1/2 flex-col items-center gap-1`,children:[(0,b.jsx)(`button`,{type:`button`,"aria-label":m(`custom-ui:floating.move`),"aria-describedby":F,title:m(`custom-ui:floating.moveHint`),className:`flex h-6 w-5 touch-none items-center justify-center rounded-full bg-background/85 text-muted-foreground shadow-sm outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,style:{cursor:w?`grabbing`:`grab`},onKeyDown:R,onPointerDown:e=>{e.button!==0||C.current||(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}),e.currentTarget.setPointerCapture(e.pointerId),C.current={pointerId:e.pointerId,element:e.currentTarget,x:e.clientX,y:e.clientY,initial:M,latest:M},k(M))},onPointerMove:e=>{let t=C.current;if(!t||t.pointerId!==e.pointerId)return;let n=O(t.initial,{x:e.clientX-t.x,y:e.clientY-t.y},A.bounds,A.island);t.latest=n,k(n)},onPointerUp:e=>I(e,!0),onPointerCancel:e=>I(e,!1),onLostPointerCapture:e=>I(e,!1),children:(0,b.jsx)(l,{className:`size-3`})}),(0,b.jsx)(`button`,{type:`button`,"aria-label":m(`custom-ui:floating.resetPosition`),title:m(`custom-ui:floating.resetPosition`),onClick:L,className:`flex size-5 items-center justify-center rounded-full bg-background/85 text-muted-foreground shadow-sm outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,b.jsx)(u,{className:`size-3`})}),(0,b.jsx)(`span`,{id:F,className:`sr-only`,children:m(`custom-ui:floating.moveHint`)})]}),o&&(0,b.jsx)(`button`,{type:`button`,"aria-label":m(`custom-ui:floating.close`),title:m(`custom-ui:floating.close`),onClick:()=>o(t),className:`absolute right-0 top-1/2 z-10 flex size-5 -translate-y-1/2 items-center justify-center rounded-full bg-background/85 text-muted-foreground shadow-sm outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:(0,b.jsx)(d,{className:`size-3`})}),(0,b.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,style:{height:t===`pisper-island`?64:240},children:(0,b.jsx)(x,{componentId:t,notify:a})})]})}function I({widgets:e,notify:t,anchorRef:n,onClose:r}){let i=(0,y.useRef)(null),a=e.filter(e=>e.componentId!==`pisper-island`);return(0,b.jsx)(`div`,{ref:i,className:`pointer-events-none fixed inset-x-2 bottom-2 top-0 z-40 overflow-hidden`,"data-floating-custom-ui":!0,children:e.map(e=>(0,b.jsx)(F,{id:e.id,componentId:e.componentId,boundaryRef:i,notify:t,anchorRef:n,onClose:r,stackIndex:e.componentId===`pisper-island`?0:a.findIndex(t=>t.id===e.id)+1},e.id))})}function L({anchorRef:e,notify:t}){let{t:n}=i(),r=h(e=>e.prefs),a=(0,y.useMemo)(()=>_([],r).map(e=>({id:e,componentId:e})),[r]);return(0,b.jsx)(I,{widgets:a,anchorRef:e,notify:t,onClose:e=>{try{h.getState().setVisible(e,!1),h.getState().storageError&&t(n(`custom-ui:floating.storageFailed`))}catch{t(n(`custom-ui:floating.storageFailed`))}}})}export{L as FloatingWidgets};