pisper 0.5.50 → 0.5.51

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 (47) hide show
  1. package/package.json +7 -7
  2. package/web/.vite/manifest.json +162 -159
  3. package/web/assets/{AppOverlays-DrS2NA9w.js → AppOverlays-DlB6SVT6.js} +1 -1
  4. package/web/assets/{AppSelect-CRjRgr38.js → AppSelect-kDqZkETY.js} +1 -1
  5. package/web/assets/{AssetsPage-C2GY8596.js → AssetsPage-mZkZgR9g.js} +1 -1
  6. package/web/assets/{ChannelsPage-FPSrQa1G.js → ChannelsPage-Dau7vaaV.js} +1 -1
  7. package/web/assets/{ChatDockView-BJGa8Bm8.js → ChatDockView-Cq7J6Xmn.js} +1 -1
  8. package/web/assets/{ChatHistoryPage-BBmrFY5U.js → ChatHistoryPage-BpoHAiYo.js} +1 -1
  9. package/web/assets/{ChatPage-DfQGtuLo.js → ChatPage-CCMsSvJV.js} +3 -3
  10. package/web/assets/{ConfigPage-D27UB6Ni.js → ConfigPage-BGZoCXnB.js} +1 -1
  11. package/web/assets/{MarkdownMessage-BQ_6o9-O.js → MarkdownMessage-Dbgb5XkJ.js} +1 -1
  12. package/web/assets/{MemoryPage-D46RKJLE.js → MemoryPage-BiAbcHbL.js} +1 -1
  13. package/web/assets/{PageHeader-DH1jtT2l.js → PageHeader-9ctH9v28.js} +1 -1
  14. package/web/assets/PluginsPage-D-D22LWb.js +1 -0
  15. package/web/assets/{PreviewPages-BBwzd5LJ.js → PreviewPages-DUZgwvOb.js} +1 -1
  16. package/web/assets/{SchedulesPage-AyePMsz_.js → SchedulesPage-C3sS9Ej3.js} +1 -1
  17. package/web/assets/{SkillsPage-Cb3i7xyX.js → SkillsPage-BeeTZyfc.js} +1 -1
  18. package/web/assets/{TerminalPanel-B06cwdRZ.js → TerminalPanel-a4jiIuSs.js} +1 -1
  19. package/web/assets/{WelcomeEffects-CsxWSguh.js → WelcomeEffects-Xo1Z1Nf4.js} +1 -1
  20. package/web/assets/{WorkflowsPage-Byq1cQot.js → WorkflowsPage-BCdz4ise.js} +1 -1
  21. package/web/assets/{WorkspacePicker-BNVaK0c9.js → WorkspacePicker-Ctf1A8lp.js} +1 -1
  22. package/web/assets/client-store-ohgbeJNh.js +1 -0
  23. package/web/assets/{collapsible-C4owDMcF.js → collapsible-U8Wh2f7S.js} +1 -1
  24. package/web/assets/{config-search-CsGhOXIG.js → config-search-CdRsMMUS.js} +1 -1
  25. package/web/assets/{dist-VQXpFPjV.js → dist-Dq4VqZgU.js} +1 -1
  26. package/web/assets/{dist-CyztUDRL.js → dist-cR3ayBwn.js} +1 -1
  27. package/web/assets/{es2015-BpePoPbM.js → es2015-DycjrqX-.js} +1 -1
  28. package/web/assets/{field-BAyGDYW_.js → field-t72VAR-1.js} +1 -1
  29. package/web/assets/index-Bd5A8V1V.js +40 -0
  30. package/web/assets/index-DUhopGVK.css +2 -0
  31. package/web/assets/{progress-BqaId9J2.js → progress-DQDjWjzV.js} +1 -1
  32. package/web/assets/{scroll-area-DkxdCF8r.js → scroll-area-C1DpxpHg.js} +1 -1
  33. package/web/assets/{separator-0_agp17Z.js → separator-Br2F2Mir.js} +1 -1
  34. package/web/assets/tool-labels-v0OysnpI.js +1 -0
  35. package/web/assets/{tooltip-D9uQM6ab.js → tooltip-DfGEs0yi.js} +1 -1
  36. package/web/assets/use-i18n-jYw5s_Yn.js +1 -0
  37. package/web/assets/{use-mobile-A2egKMjY.js → use-mobile-C1OVAMOm.js} +1 -1
  38. package/web/assets/web-preview-panel-uBOnhY4Z.js +556 -0
  39. package/web/assets/{welcome-brand-CYtVVlIL.js → welcome-brand-R7Xflzvb.js} +1 -1
  40. package/web/index.html +10 -10
  41. package/web/assets/PluginsPage-B4cG171E.js +0 -1
  42. package/web/assets/client-store-BSV7t02b.js +0 -1
  43. package/web/assets/index-CAWCOpxG.js +0 -40
  44. package/web/assets/index-DT-gaDrM.css +0 -2
  45. package/web/assets/tool-labels-BJhLig5u.js +0 -1
  46. package/web/assets/use-i18n-yjKc6F2w.js +0 -1
  47. package/web/assets/web-preview-panel-BOmJGqhe.js +0 -556
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{t as r}from"./api-B6CluO7V.js";import{i,n as a,o,t as s}from"./button-XhIEgIsg.js";import{d as c,g as l,h as u,m as d,p as f,r as p,s as m,t as h,u as g}from"./use-i18n-yjKc6F2w.js";import{c as _,i as v,o as y,s as b}from"./use-mobile-A2egKMjY.js";import{a as x,i as S,n as C,r as w,s as T,t as E,u as D}from"./es2015-BpePoPbM.js";import{n as O,t as k}from"./dist-CyztUDRL.js";import{a as A,c as j,i as M,n as N,o as ee,r as P,s as F,t as I}from"./collapsible-C4owDMcF.js";import{n as te,r as ne,t as L}from"./AppSelect-CRjRgr38.js";import{t as R}from"./separator-0_agp17Z.js";import{t as re}from"./utils-C8uzG5AZ.js";import{t as ie}from"./storage-BE5DCCG3.js";import{t as ae}from"./arrow-right-KWvgbo3p.js";import{t as z}from"./check-jIXqkGKr.js";import{t as oe}from"./chevron-down-DT6AXwTP.js";import{t as se}from"./code-xml-Z4K2ea1N.js";import{t as ce}from"./earth-DR_clkZ9.js";import{t as le}from"./loader-circle-72TYCcVQ.js";import{a as ue,i as de,o as fe,s as pe,t as me}from"./config-search-CsGhOXIG.js";import{n as he,t as ge}from"./zap-CFsp4Y1u.js";import{t as _e}from"./save-CVL5N6eP.js";import{t as ve}from"./send-DcLH_sg0.js";import{t as ye}from"./shield-check-BQHFfxVy.js";import{t as be}from"./square-terminal-DpCa0gzM.js";import{t as xe}from"./trash-2-mhzzyC6i.js";import{t as Se}from"./wrench-BqeVhocX.js";import{t as Ce}from"./x-bw26XDZM.js";import{A as we,At as Te,B as Ee,Bt as De,C as B,Ct as Oe,D as ke,E as Ae,Ft as je,Lt as Me,M as Ne,Mt as Pe,N as Fe,Nt as Ie,Ot as Le,P as Re,Pt as ze,Rt as Be,S as Ve,T as He,Tt as Ue,Vt as We,_t as Ge,a as Ke,b as qe,bt as V,dt as Je,gt as Ye,ht as H,i as U,j as Xe,k as Ze,kt as Qe,l as $e,n as et,o as tt,r as nt,s as rt,t as it,v as at,vt as ot,w as st,x as ct,xt as lt,y as ut,yt as dt,zt as ft}from"./index-CAWCOpxG.js";import{t as W}from"./field-BAyGDYW_.js";import{a as pt,c as mt,d as ht,l as gt,s as _t,t as vt,u as yt}from"./shortcuts-BIzphxhz.js";import{t as bt}from"./usePagePrimaryAction-Bw0OFTDZ.js";import{t as xt}from"./MarkdownMessage-BQ_6o9-O.js";import{t as St}from"./brand-DIEc3fK8.js";var G=e(t(),1),K=n(),Ct=Object.defineProperty,q=(e,t)=>Ct(e,`name`,{value:t,configurable:!0}),wt=[`Enter`,` `],Tt=[`ArrowDown`,`PageUp`,`Home`],Et=[`ArrowUp`,`PageDown`,`End`],Dt=[...Tt,...Et];[...wt],[...wt];var Ot=`Menu`,[kt,At,jt]=We(Ot),[Mt,Nt]=d(Ot,[jt,_,ft]),Pt=_(),Ft=ft(),[It,Lt]=Mt(Ot),[Rt,zt]=Mt(Ot),Bt=q(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Pt(t),[c,l]=G.useState(null),u=G.useRef(!1),d=k(a),f=De(i);return G.useEffect(()=>{let e=q(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=q(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),G.useEffect(()=>{if(!n)return;let e=q(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,K.jsx)(b,{...s,children:(0,K.jsx)(It,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,K.jsx)(Rt,{scope:t,onClose:G.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),Vt=G.forwardRef(q(function(e,t){let{__scopeMenu:n,...r}=e,i=Pt(n);return(0,K.jsx)(v,{...i,...r,ref:t})},`MenuAnchor`)),Ht=`MenuPortal`,[Ut,Wt]=Mt(Ht,{forceMount:void 0}),Gt=q(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Lt(Ht,t);return(0,K.jsx)(Ut,{scope:t,forceMount:n,children:(0,K.jsx)(D,{present:n||a.open,children:(0,K.jsx)(S,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Kt=`MenuContent`,[qt,Jt]=Mt(Kt),Yt=G.forwardRef(q(function(e,t){let n=Wt(Kt,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Lt(Kt,e.__scopeMenu),o=zt(Kt,e.__scopeMenu);return(0,K.jsx)(kt.Provider,{scope:e.__scopeMenu,children:(0,K.jsx)(D,{present:r||a.open,children:(0,K.jsx)(kt.Slot,{scope:e.__scopeMenu,children:o.modal?(0,K.jsx)(Xt,{...i,ref:t}):(0,K.jsx)(Zt,{...i,ref:t})})})})},`MenuContent`)),Xt=G.forwardRef(q(function(e,t){let n=Lt(Kt,e.__scopeMenu),r=G.useRef(null),i=o(t,r);return G.useEffect(()=>{let e=r.current;if(e)return E(e)},[]),(0,K.jsx)($t,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:f(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Zt=G.forwardRef(q(function(e,t){let n=Lt(Kt,e.__scopeMenu);return(0,K.jsx)($t,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Qt=i(`MenuContent.ScrollLock`),$t=G.forwardRef(q(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:h,disableOutsideScroll:g,..._}=e,v=Lt(Kt,n),b=zt(Kt,n),S=Pt(n),E=Ft(n),D=At(n),[O,k]=G.useState(null),A=G.useRef(null),j=o(t,A,v.onContentChange),M=G.useRef(0),N=G.useRef(``),ee=G.useRef(0),P=G.useRef(null),F=G.useRef(`right`),I=G.useRef(0),te=g?C:G.Fragment,ne=g?{as:Qt,allowPinchZoom:!0}:void 0,L=q(e=>{let t=N.current+e,n=D().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=gn(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;q((function e(t){N.current=t,window.clearTimeout(M.current),t!==``&&(M.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);G.useEffect(()=>()=>window.clearTimeout(M.current),[]),w();let R=G.useCallback(e=>F.current===P.current?.side&&vn(e,P.current?.area),[]);return(0,K.jsx)(qt,{scope:n,searchRef:N,onItemEnter:G.useCallback(e=>{R(e)&&e.preventDefault()},[R]),onItemLeave:G.useCallback(e=>{R(e)||(A.current?.focus(),k(null))},[R]),onTriggerLeave:G.useCallback(e=>{R(e)&&e.preventDefault()},[R]),pointerGraceTimerRef:ee,onPointerGraceIntentChange:G.useCallback(e=>{P.current=e},[]),children:(0,K.jsx)(te,{...ne,children:(0,K.jsx)(x,{asChild:!0,trapped:i,onMountAutoFocus:f(a,e=>{e.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:(0,K.jsx)(T,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:h,children:(0,K.jsx)(Be,{asChild:!0,...E,dir:b.dir,orientation:`vertical`,loop:r,currentTabStopId:O,onCurrentTabStopIdChange:k,onEntryFocus:f(l,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,K.jsx)(y,{role:`menu`,"aria-orientation":`vertical`,"data-state":dn(v.open),"data-radix-menu-content":``,dir:b.dir,...S,..._,ref:j,style:{outline:`none`,..._.style},onKeyDown:f(_.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&L(e.key));let i=A.current;if(e.target!==i||!Dt.includes(e.key))return;e.preventDefault();let a=D().filter(e=>!e.disabled).map(e=>e.ref.current);Et.includes(e.key)&&a.reverse(),mn(a)}),onBlur:f(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),N.current=``)}),onPointerMove:f(e.onPointerMove,yn(e=>{let t=e.target,n=I.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>I.current?`right`:`left`;F.current=t,I.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),en=`MenuItem`,tn=`menu.itemSelect`,nn=G.forwardRef(q(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=G.useRef(null),s=zt(en,e.__scopeMenu),c=Jt(en,e.__scopeMenu),u=o(t,a),d=G.useRef(!1),p=q(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(tn,{bubbles:!0,cancelable:!0});e.addEventListener(tn,e=>r?.(e),{once:!0}),l(e,t),t.defaultPrevented?d.current=!1:s.onClose()}},`handleSelect`);return(0,K.jsx)(rn,{...i,ref:u,disabled:n,onClick:f(e.onClick,p),onPointerDown:t=>{e.onPointerDown?.(t),d.current=!0},onPointerUp:f(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:f(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(c.searchRef.current===``||e.key!==` `)&&wt.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),rn=G.forwardRef(q(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,s=Jt(en,n),c=Ft(n),l=G.useRef(null),d=o(t,l),[p,m]=G.useState(!1),[h,g]=G.useState(``);return G.useEffect(()=>{let e=l.current;e&&g((e.textContent??``).trim())},[a.children]),(0,K.jsx)(kt.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,K.jsx)(Me,{asChild:!0,...c,focusable:!r,children:(0,K.jsx)(u.div,{role:`menuitem`,"data-highlighted":p?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:d,onPointerMove:f(e.onPointerMove,yn(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:f(e.onPointerLeave,yn(e=>s.onItemLeave(e))),onFocus:f(e.onFocus,()=>m(!0)),onBlur:f(e.onBlur,()=>m(!1))})})})},`MenuItemImpl`)),[an,on]=Mt(`MenuRadioGroup`,{value:void 0,onValueChange:q(()=>{},`onValueChange`)}),[sn,cn]=Mt(`MenuItemIndicator`,{checked:!1}),[ln,un]=Mt(`MenuSub`);function dn(e){return e?`open`:`closed`}q(dn,`getOpenState`);function fn(e){return e===`indeterminate`}q(fn,`isIndeterminate`);function pn(e){return fn(e)?`indeterminate`:e?`checked`:`unchecked`}q(pn,`getCheckedState`);function mn(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}q(mn,`focusFirst`);function hn(e,t){return e.map((n,r)=>e[(t+r)%e.length])}q(hn,`wrapArray`);function gn(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=hn(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}q(gn,`getNextMatch`);function _n(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}q(_n,`isPointInPolygon`);function vn(e,t){return t?_n({x:e.clientX,y:e.clientY},t):!1}q(vn,`isPointerInGraceArea`);function yn(e){return t=>t.pointerType===`mouse`?e(t):void 0}q(yn,`whenMouse`);var bn=Bt,xn=Vt,Sn=Gt,Cn=Yt,wn=nn,Tn=Object.defineProperty,En=(e,t)=>Tn(e,`name`,{value:t,configurable:!0}),Dn=`DropdownMenu`,[On,kn]=d(Dn,[Nt]),An=Nt(),[jn,Mn]=On(Dn),Nn=En(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,l=An(t),u=G.useRef(null),[d,f]=c({prop:i,defaultProp:a??!1,onChange:o,caller:Dn});return(0,K.jsx)(jn,{scope:t,triggerId:O(),triggerRef:u,contentId:O(),open:d,onOpenChange:f,onOpenToggle:G.useCallback(()=>f(e=>!e),[f]),modal:s,children:(0,K.jsx)(bn,{...l,open:d,onOpenChange:f,dir:r,modal:s,children:n})})},`DropdownMenu`),Pn=`DropdownMenuTrigger`,Fn=G.forwardRef(En(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Mn(Pn,n),s=An(n),c=o(t,a.triggerRef);return(0,K.jsx)(xn,{asChild:!0,...s,children:(0,K.jsx)(u.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:c,onPointerDown:f(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:f(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),In=En(e=>{let{__scopeDropdownMenu:t,...n}=e,r=An(t);return(0,K.jsx)(Sn,{...r,...n})},`DropdownMenuPortal`),Ln=`DropdownMenuContent`,Rn=G.forwardRef(En(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Mn(Ln,n),a=An(n),o=G.useRef(!1);return(0,K.jsx)(Cn,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:f(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:f(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),zn=G.forwardRef(En(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=An(n);return(0,K.jsx)(wn,{...i,...r,ref:t})},`DropdownMenuItem`)),Bn=Nn,Vn=Fn,Hn=In,Un=Rn,Wn=zn,Gn=Object.defineProperty,J=(e,t)=>Gn(e,`name`,{value:t,configurable:!0}),Kn=[`PageUp`,`PageDown`],qn=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Jn={"from-left":[`Home`,`PageDown`,`ArrowDown`,`ArrowLeft`],"from-right":[`Home`,`PageDown`,`ArrowDown`,`ArrowRight`],"from-bottom":[`Home`,`PageDown`,`ArrowDown`,`ArrowLeft`],"from-top":[`Home`,`PageDown`,`ArrowUp`,`ArrowLeft`]},Yn=`Slider`,[Xn,Zn,Qn]=We(Yn),[$n,er]=d(Yn,[Qn]),[tr,nr]=$n(Yn),rr=G.forwardRef(J(function(e,t){let{name:n,min:r=0,max:i=100,step:a=1,orientation:s=`horizontal`,disabled:l=!1,minStepsBetweenThumbs:u=0,defaultValue:d=[r],value:p,onValueChange:m=J(()=>{},`onValueChange`),onValueCommit:h=J(()=>{},`onValueCommit`),inverted:g=!1,form:_,...v}=e,y=G.useRef(new Set),b=G.useRef(0),x=G.useRef(!1),S=s===`horizontal`?or:sr,[C,w]=G.useState(null),T=o(t,w),[E=[],D]=c({prop:p,defaultProp:d,onChange:J(e=>{[...y.current][b.current]?.focus({preventScroll:!0,focusVisible:x.current}),x.current=!1,m(e)},`onChange`)}),O=G.useRef(E),k=G.useRef(E);G.useEffect(()=>{let e=_?C?.ownerDocument.getElementById(_):C?.closest(`form`);if(e instanceof HTMLFormElement){let t=J(()=>D(k.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[C,_,D]);function A(e){N(e,Tr(E,e))}J(A,`handleSlideStart`);function j(e){N(e,b.current)}J(j,`handleSlideMove`);function M(){String(E)!==String(O.current)&&h(E)}J(M,`handleSlideEnd`);function N(e,t,{commit:n}={commit:!1}){let o=Ar(a),s=jr(Math.round((e-r)/a)*a+r,o),c=te(s,[r,i]);D((e=[])=>{let r=Sr(e,c,t);if(Or(r,u*a)){b.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&h(r),t?r:e}return e})}return J(N,`updateValues`),(0,K.jsx)(tr,{scope:e.__scopeSlider,name:n,disabled:l,min:r,max:i,valueIndexToChangeRef:b,thumbs:y.current,values:E,orientation:s,form:_,children:(0,K.jsx)(Xn.Provider,{scope:e.__scopeSlider,children:(0,K.jsx)(Xn.Slot,{scope:e.__scopeSlider,children:(0,K.jsx)(S,{"aria-disabled":l,"data-disabled":l?``:void 0,...v,ref:T,onPointerDown:f(v.onPointerDown,()=>{l||(O.current=E,x.current=!1)}),min:r,max:i,inverted:g,onSlideStart:l?void 0:A,onSlideMove:l?void 0:j,onSlideEnd:l?void 0:M,onHomeKeyDown:()=>{l||(x.current=!0,N(r,0,{commit:!0}))},onEndKeyDown:()=>{l||(x.current=!0,N(i,E.length-1,{commit:!0}))},onStepKeyDown:({event:e,direction:t})=>{if(!l){x.current=!0;let n=Kn.includes(e.key)||e.shiftKey&&qn.includes(e.key)?10:1,i=b.current,o=E[i];N(Mr(o,{min:r,step:a,direction:t,multiplier:n}),i,{commit:!0})}}})})})})},`Slider`)),[ir,ar]=$n(Yn,{startEdge:`left`,endEdge:`right`,size:`width`,direction:1}),or=G.forwardRef(J(function(e,t){let{min:n,max:r,dir:i,inverted:a,onSlideStart:s,onSlideMove:c,onSlideEnd:l,onStepKeyDown:u,...d}=e,[f,p]=G.useState(null),m=o(t,p),h=G.useRef(void 0),g=De(i),_=g===`ltr`,v=_&&!a||!_&&a;function y(e){let t=h.current||f.getBoundingClientRect(),i=kr([0,t.width],v?[n,r]:[r,n]);return h.current=t,i(e-t.left)}return J(y,`getValueFromPointer`),(0,K.jsx)(ir,{scope:e.__scopeSlider,startEdge:v?`left`:`right`,endEdge:v?`right`:`left`,direction:v?1:-1,size:`width`,children:(0,K.jsx)(cr,{dir:g,"data-orientation":`horizontal`,...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":`translateX(-50%)`},onSlideStart:e=>{let t=y(e.clientX);s?.(t)},onSlideMove:e=>{let t=y(e.clientX);c?.(t)},onSlideEnd:()=>{h.current=void 0,l?.()},onStepKeyDown:e=>{let t=Jn[v?`from-left`:`from-right`].includes(e.key);u?.({event:e,direction:t?-1:1})}})})},`SliderHorizontal`)),sr=G.forwardRef(J(function(e,t){let{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...u}=e,d=G.useRef(null),f=o(t,d),p=G.useRef(void 0),m=!i;function h(e){let t=p.current||d.current.getBoundingClientRect(),i=kr([0,t.height],m?[r,n]:[n,r]);return p.current=t,i(e-t.top)}return J(h,`getValueFromPointer`),(0,K.jsx)(ir,{scope:e.__scopeSlider,startEdge:m?`bottom`:`top`,endEdge:m?`top`:`bottom`,size:`height`,direction:m?1:-1,children:(0,K.jsx)(cr,{"data-orientation":`vertical`,...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":`translateY(50%)`},onSlideStart:e=>{let t=h(e.clientY);a?.(t)},onSlideMove:e=>{let t=h(e.clientY);s?.(t)},onSlideEnd:()=>{p.current=void 0,c?.()},onStepKeyDown:e=>{let t=Jn[m?`from-bottom`:`from-top`].includes(e.key);l?.({event:e,direction:t?-1:1})}})})},`SliderVertical`)),cr=G.forwardRef(J(function(e,t){let{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:s,onStepKeyDown:c,...l}=e,d=nr(Yn,n);return(0,K.jsx)(u.span,{...l,ref:t,onKeyDown:f(e.onKeyDown,e=>{e.key===`Home`?(o(e),e.preventDefault()):e.key===`End`?(s(e),e.preventDefault()):Kn.concat(qn).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:f(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus({preventScroll:!0,focusVisible:!1}):r(e)}),onPointerMove:f(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:f(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),a(e))})})},`SliderImpl`)),lr=`SliderTrack`,ur=G.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=nr(lr,n);return(0,K.jsx)(u.span,{"data-disabled":i.disabled?``:void 0,"data-orientation":i.orientation,...r,ref:t})},`SliderTrack`)),dr=`SliderRange`,fr=G.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=nr(dr,n),a=ar(dr,n),s=G.useRef(null),c=o(t,s),l=i.values.length,d=i.values.map(e=>Cr(e,i.min,i.max)),f=l>1?Math.min(...d):0,p=100-Math.max(...d);return(0,K.jsx)(u.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?``:void 0,...r,ref:c,style:{...e.style,[a.startEdge]:f+`%`,[a.endEdge]:p+`%`}})},`SliderRange`)),[pr,mr]=$n(`SliderThumb`),hr=`SliderThumbProvider`;function gr(e){let{__scopeSlider:t,name:n,children:r,internal_do_not_use_render:i}=e,a=nr(hr,t),o=Zn(t),[s,c]=G.useState(null),l=G.useMemo(()=>s?o().findIndex(e=>e.ref.current===s):-1,[o,s]),u=g(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:Cr(f,a.min,a.max);G.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,K.jsx)(pr,{scope:t,...h,children:Nr(i)?i(h):r})}J(gr,`SliderThumbProvider`);var _r=`SliderThumbTrigger`,vr=G.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=nr(_r,n),a=ar(_r,n),{index:s,value:c,percent:l,size:d,onThumbChange:p}=mr(_r,n),m=o(t,p),h=wr(s,i.values.length),g=d?.[a.size],_=g?Er(g,l,a.direction):0;return(0,K.jsx)(`span`,{style:{transform:`var(--radix-slider-thumb-transform)`,position:`absolute`,[a.startEdge]:`calc(${l}% + ${_}px)`},children:(0,K.jsx)(Xn.ItemSlot,{scope:n,children:(0,K.jsx)(u.span,{role:`slider`,"aria-label":e[`aria-label`]||h,"aria-valuemin":i.min,"aria-valuenow":c,"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:c===void 0?{display:`none`}:e.style,onFocus:f(e.onFocus,()=>{i.valueIndexToChangeRef.current=s})})})})},`SliderThumbTrigger`)),yr=G.forwardRef(J(function(e,t){let{__scopeSlider:n,name:r,...i}=e;return(0,K.jsx)(gr,{__scopeSlider:n,name:r,internal_do_not_use_render:({index:e,isFormControl:r})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(vr,{...i,ref:t,__scopeSlider:n}),r?(0,K.jsx)(xr,{__scopeSlider:n},e):null]})})},`SliderThumb`)),br=`SliderBubbleInput`,xr=G.forwardRef(J(function({__scopeSlider:e,...t},n){let{value:r,name:i,form:a}=mr(br,e),s=G.useRef(null),c=o(s,n),l=ne(r);return G.useEffect(()=>{let e=s.current;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(l!==r&&n){let t=new Event(`input`,{bubbles:!0});n.call(e,r),e.dispatchEvent(t)}},[l,r]),(0,K.jsx)(u.input,{style:{display:`none`},name:i,form:a,...t,ref:c,defaultValue:r})},`SliderBubbleInput`));function Sr(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}J(Sr,`getNextSortedValues`);function Cr(e,t,n){let r=100/(n-t)*(e-t);return te(r,[0,100])}J(Cr,`convertValueToPercentage`);function wr(e,t){if(t>2)return`Value ${e+1} of ${t}`;if(t===2)return[`Minimum`,`Maximum`][e]}J(wr,`getLabel`);function Tr(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(Tr,`getClosestValueIndex`);function Er(e,t,n){let r=e/2;return(r-kr([0,50],[0,r])(t)*n)*n}J(Er,`getThumbInBoundsOffset`);function Dr(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}J(Dr,`getStepsBetweenValues`);function Or(e,t){if(t>0){let n=Dr(e);return Math.min(...n)>=t}return!0}J(Or,`hasMinStepsBetweenValues`);function kr(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(kr,`linearScale`);function Ar(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(Ar,`getDecimalCount`);function jr(e,t){let n=10**t;return Math.round(e*n)/n}J(jr,`roundValue`);function Mr(e,{min:t,step:n,direction:r,multiplier:i}){let a=Ar(n),o=(e-t)/n,s=Math.round(o),c=jr(s*n+t,a)===jr(e,a),l;return l=c?s+i*r:r>0?Math.ceil(o):Math.floor(o),jr(l*n+t,a)}J(Mr,`getNextStepValue`);function Nr(e){return typeof e==`function`}J(Nr,`isFunction`);var Pr=a(`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`}]]),Fr=a(`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`}]]),Ir=a(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),Lr=a(`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`}]]),Rr=a(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),zr=a(`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`}]]),Br=a(`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`}]]),Vr=a(`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`}]]),Hr=a(`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`}]]),Ur=a(`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`}]]),Wr=a(`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`}]]),Gr=a(`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`}]]),Kr=a(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),qr=a(`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`}]]),Jr=a(`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`}]]),Yr=a(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),Xr=a(`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`}]]),Zr=a(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Qr=a(`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`}]]),$r=a(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),ei=a(`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`}]]),ti=a(`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`}]]),Y=it,ni=tt,X=$e;function ri(e){return(0,K.jsx)(rt,{density:`compact`,...e})}var ii=`0.5.47`,ai=`https://ling-kong-ran.github.io/pisper/`,oi=`https://github.com/ling-kong-ran/pisper`,si=`${oi}/blob/release/LICENSE`;function ci({href:e,icon:t,label:n,value:r}){return(0,K.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`,children:[(0,K.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,K.jsx)(t,{size:16})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`strong`,{className:`block text-[13px] text-[var(--text)]`,children:n}),(0,K.jsx)(`small`,{className:`mt-0.5 block truncate text-[12px] text-[var(--text-muted)]`,children:r})]}),(0,K.jsx)(Le,{className:`text-[var(--text-muted)] transition-colors group-hover:text-[var(--star-strong)]`,size:14})]})}function li({update:e}){let{t}=h(),n=e.info?.version||ii;return(0,K.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 px-1 py-3`,children:[(0,K.jsx)(`img`,{className:`size-16 shrink-0 rounded-[14px] shadow-[0_10px_28px_-14px_var(--shadow)]`,src:`/favicon.svg`,alt:`Pisper`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h1`,{className:`text-[22px] font-bold tracking-[0]`,children:`Pisper`}),(0,K.jsxs)(X,{tone:`gray`,children:[`v`,n]})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[13px] leading-5 text-[var(--text-muted)]`,children:t(`config:aboutSettings.description`)})]})]}),(0,K.jsxs)(Y,{className:`p-5`,"data-config-card":`about-project`,children:[(0,K.jsx)(ni,{title:t(`config:aboutSettings.projectInformation`)}),(0,K.jsxs)(`div`,{className:`mt-3 divide-y divide-[var(--stroke-soft)] border-y border-[var(--stroke-soft)]`,children:[(0,K.jsx)(ci,{href:ai,icon:ce,label:t(`config:aboutSettings.website`),value:`ling-kong-ran.github.io/pisper`}),(0,K.jsx)(ci,{href:oi,icon:se,label:t(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`}),(0,K.jsx)(ci,{href:si,icon:Yr,label:t(`config:aboutSettings.license`),value:`MIT License`})]})]}),(0,K.jsx)(Y,{className:`p-5`,"data-config-card":`about-support`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(ni,{title:t(`config:aboutSettings.supportPisper`)}),(0,K.jsx)(`p`,{className:`mt-1 max-w-[520px] text-[13px] leading-5 text-[var(--text-muted)]`,children:t(`config:aboutSettings.supportDescription`)})]}),(0,K.jsx)(s,{asChild:!0,size:`lg`,className:`max-[540px]:w-full`,children:(0,K.jsxs)(`a`,{href:oi,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(Qr,{size:15}),t(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,K.jsx)(`p`,{className:`px-1 py-2 text-center text-[12px] text-[var(--text-muted)]`,children:t(`config:aboutSettings.copyright`)})]})}function ui({className:e,defaultValue:t,value:n,min:r=0,max:i=100,...a}){let o=G.useMemo(()=>Array.isArray(n)?n:Array.isArray(t)?t:[r,i],[n,t,r,i]);return(0,K.jsxs)(rr,{"data-slot":`slider`,defaultValue:t,value:n,min:r,max:i,className:re(`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,K.jsx)(ur,{"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,K.jsx)(fr,{"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,K.jsx)(yr,{"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 di(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function fi({notify:e,requestConfirm:t}){let{t:n}=h(),i=window.pisperDesktop,a=(0,G.useMemo)(()=>i?.getPetStatus?{getStatus:()=>i.getPetStatus(),setEnabled:e=>i.setPetEnabled(e),setOpacity:e=>i.setPetOpacity(e),search:e=>i.searchPets(e),install:e=>i.installPet(e),select:e=>i.selectPet(e),remove:e=>i.removePet(e),openCatalog:()=>void i.openPetdex?.()}:{getStatus:()=>r(`/api/desktop-pet`),setEnabled:e=>r(`/api/desktop-pet/enabled`,{method:`POST`,body:{enabled:e}}),setOpacity:e=>r(`/api/desktop-pet/opacity`,{method:`POST`,body:{opacity:e}}),search:e=>r(`/api/desktop-pet/catalog?query=${encodeURIComponent(e)}`),install:e=>r(`/api/desktop-pet/install`,{method:`POST`,body:{slug:e}}),select:e=>r(`/api/desktop-pet/select`,{method:`POST`,body:{slug:e}}),remove:e=>r(`/api/desktop-pet/${encodeURIComponent(e)}`,{method:`DELETE`}),openCatalog:()=>window.open(`https://petdex.dev`,`_blank`,`noopener,noreferrer`)},[i]),[o,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(100),[g,_]=(0,G.useState)(``),[v,y]=(0,G.useState)(``),b=(0,G.useCallback)(e=>{c(e),m(Math.round((e.opacity??1)*100))},[]),x=(0,G.useCallback)(async()=>{try{y(``),b(await a.getStatus())}catch(e){y(e instanceof Error?e.message:String(e))}},[b,a]),S=(0,G.useCallback)(async()=>{_(`search`);try{y(``),f(await a.search(l))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(``)}},[a,l]);(0,G.useEffect)(()=>{x(),a.search(``).then(f).catch(()=>{})},[a,x]);let C=async t=>{let r=o;c(e=>e&&{...e,enabled:t,running:!!(t&&e.installed.length)}),_(`toggle`);try{y(``);let r=await a.setEnabled(t);b(r),di(r),e(n(t?`config:desktopPetSettings.petEnabled`:`config:desktopPetSettings.petDisabled`))}catch(e){c(r),y(e instanceof Error?e.message:String(e))}finally{_(``)}},w=async e=>{_(`opacity`);try{y(``);let t=await a.setOpacity(e);b(t),di(t)}catch(e){m(Math.round((o?.opacity??1)*100)),y(e instanceof Error?e.message:String(e))}finally{_(``)}},T=async(t=l)=>{if(t.trim()){_(`install`);try{y(``);let r=await a.install(t);b(r),di(r),e(n(`config:desktopPetSettings.petInstalled`,{name:r.selectedName||t}))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(``)}}},E=async t=>{if(t!==o?.selectedSlug){_(`select:${t}`);try{y(``);let r=await a.select(t);b(r),di(r),e(n(`config:desktopPetSettings.petSelected`,{name:r.selectedName||t}))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(``)}}},D=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`})){_(`remove:${r.slug}`);try{y(``);let t=await a.remove(r.slug);b(t),di(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(``)}}};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-[12px] desktop-pet-settings`,children:[(0,K.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-settings`,children:[(0,K.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,K.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,K.jsx)(Lr,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:n(`config:desktopPetSettings.title`)}),(0,K.jsx)(`p`,{children:n(`config:desktopPetSettings.description`)})]})]}),o?(0,K.jsxs)(`div`,{className:`max-w-1/2`,children:[(0,K.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,K.jsx)(Lr,{size:18}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`font-bold`,children:n(`config:desktopPetSettings.showOnDesktop`)}),` `,(0,K.jsx)(X,{tone:o.running?`green`:`gray`,children:o.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)})]}),(0,K.jsx)(`span`,{className:`text-xs`,children:o.selectedName?n(`config:desktopPetSettings.currentPet`,{name:o.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`)})]}),(0,K.jsx)(ri,{value:o.enabled,disabled:!!g||!o.installed.length,onChange:C,ariaLabel:n(`config:desktopPetSettings.showOnDesktop`),className:`ml-4`})]}),o&&(0,K.jsxs)(`div`,{className:`flex items-center snotification-option gap-2.75 mt-4`,children:[(0,K.jsx)(Ir,{size:18}),(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,K.jsx)(`span`,{className:`font-bold`,children:n(`config:desktopPetSettings.opacity`)}),(0,K.jsxs)(`span`,{className:`text-xs`,children:[p,`%`]})]}),(0,K.jsx)(ui,{value:[p],min:20,max:100,step:5,disabled:g===`opacity`,onValueChange:([e])=>m(e),onValueCommit:([e])=>void w(e/100),"aria-label":n(`config:desktopPetSettings.opacity`),className:`flex-1 w-auto ml-4`})]})]}):(0,K.jsxs)(Ke,{className:`[margin-top:15px]`,children:[(0,K.jsx)(V,{className:`animate-spin`,size:16}),(0,K.jsx)(`span`,{children:n(`config:desktopPetSettings.loading`)})]}),v&&(0,K.jsx)(`div`,{className:`text-[var(--danger)] text-[13px] mt-3`,children:v})]}),(0,K.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-install`,children:[(0,K.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,K.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,K.jsx)(Qe,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:n(`config:desktopPetSettings.installTitle`)}),(0,K.jsx)(`p`,{children:n(`config:desktopPetSettings.installDescription`)})]})]}),(0,K.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,K.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:n(`config:desktopPetSettings.searchPlaceholder`),"aria-label":n(`config:desktopPetSettings.petSlug`)}),(0,K.jsxs)(s,{size:`lg`,className:`min-w-[104px]`,disabled:g===`search`,onClick:S,children:[g===`search`?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(ot,{size:14}),n(`config:desktopPetSettings.search`)]})]}),d.length>0&&(0,K.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:d.map(e=>{let t=o?.installed.some(t=>t.slug===e.slug);return(0,K.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:!!g,onClick:()=>t?E(e.slug):T(e.slug),children:[(0,K.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,K.jsx)(Lr,{size:16})}),(0,K.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,K.jsx)(`strong`,{children:e.displayName}),(0,K.jsx)(`small`,{children:e.slug})]}),(0,K.jsx)(X,{tone:t?`green`:`blue`,children:n(t?`config:desktopPetSettings.installed`:`config:desktopPetSettings.install`)})]},e.slug)})}),(0,K.jsx)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:a.openCatalog,children:[(0,K.jsx)(Le,{size:14}),n(`config:desktopPetSettings.browsePetdex`)]})})]}),o&&o.installed.length>0&&(0,K.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-installed`,children:[(0,K.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,K.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,K.jsx)(Lr,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:n(`config:desktopPetSettings.installedTitle`)}),(0,K.jsx)(`p`,{children:n(`config:desktopPetSettings.installedDescription`)})]})]}),(0,K.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:o.installed.map(e=>{let t=e.slug===o.selectedSlug;return(0,K.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,K.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:!!g,onClick:()=>E(e.slug),children:[(0,K.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,K.jsx)(Lr,{size:16})}),(0,K.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,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`small`,{children:e.slug})]}),(0,K.jsx)(X,{tone:e.source===`pisper`?`blue`:`gray`,children:e.source===`pisper`?`Pisper`:`Petdex`})]}),e.source===`pisper`&&(0,K.jsx)(s,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`text-content-muted hover:text-destructive`,disabled:!!g,onClick:()=>void D(e),"aria-label":n(`config:desktopPetSettings.delete`),title:n(`config:desktopPetSettings.delete`),children:g===`remove:${e.slug}`?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(xe,{size:14})})]},`${e.source}:${e.slug}`)})})]})]})}function pi(e,t){return t(e===`en-US`?`config:languageSettings.english`:`config:languageSettings.simplifiedChinese`)}function mi({notify:e}){let{language:t,setLanguage:n,t:r}=h(),i=r=>{r!==t&&(n(r),e(m(r===`en-US`?`config:languageSettings.displayLanguageChangedToEnglish`:`config:languageSettings.displayLanguageChangedToSimplifiedChinese`,r)))};return(0,K.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-language`,children:[(0,K.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,K.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,K.jsx)(Hr,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`config:languageSettings.displayLanguage`)}),(0,K.jsx)(`p`,{children:r(`config:languageSettings.chooseTheLanguageUsedByPisperChangesApplyImmediatelyAndAreSavedForYourNextVisit`)})]})]}),(0,K.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:p.map(e=>{let n=e.value===t;return(0,K.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,K.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,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[3px] [&_small]:text-[var(--text-muted)] [&_strong]:text-[13px]`,children:[(0,K.jsx)(`strong`,{children:pi(e.value,r)}),(0,K.jsx)(`small`,{children:e.value===`zh-CN`?r(`config:languageSettings.chineseInterface`):r(`config:languageSettings.englishInterface`)})]}),n&&(0,K.jsx)(`span`,{className:`grid size-[21px] place-items-center rounded-full bg-[var(--star)] text-[var(--on-accent)]`,children:(0,K.jsx)(z,{size:15})})]},e.value)})}),(0,K.jsxs)(Ke,{className:`mt-[15px]`,children:[(0,K.jsx)(Hr,{size:16}),(0,K.jsxs)(`span`,{children:[(0,K.jsxs)(`strong`,{children:[r(`config:languageSettings.currentLanguage`),` · `,pi(t,r)]}),(0,K.jsx)(`small`,{children:r(`config:languageSettings.thisSettingChangesInterfaceTextOnlyItDoesNotControlTheLanguageOfAgentResponses`)})]})]})]})}function hi({icon:e,title:t,description:n}){return(0,K.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,K.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,K.jsx)(e,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:t}),(0,K.jsx)(`p`,{children:n})]})]})}function gi({label:e,options:t,value:n,onChange:r,className:i}){return(0,K.jsx)(`div`,{className:re(`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,K.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,K.jsx)(`span`,{className:`grid size-8 place-items-center rounded-[var(--r-xs)] bg-[var(--solid)] text-[var(--star-strong)]`,children:(0,K.jsx)(i,{size:16})}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,K.jsx)(`strong`,{className:`text-[13px]`,children:e.label}),(0,K.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:e.description})]}),t&&(0,K.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-[var(--star)] text-[var(--on-accent)]`,children:(0,K.jsx)(z,{size:13})})]},e.value)})})}function _i({label:e,options:t,value:n,onChange:r}){return(0,K.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,K.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 vi={neutral:`#18181b`,blue:`#1677e8`,teal:`#0f766e`,violet:`#7557c8`,coral:`#c94f5d`,custom:`#1677e8`};function yi({notify:e}){let{t}=h(),n=B(e=>e.theme),r=B(e=>e.density),i=B(e=>e.accent),a=B(e=>e.customAccent),o=B(e=>e.fontScale),c=B(e=>e.radius),l=B(e=>e.motion),u=B(e=>e.setTheme),d=B(e=>e.setDensity),f=B(e=>e.setAccent),p=B(e=>e.setCustomAccent),m=B(e=>e.setFontScale),g=B(e=>e.setRadius),_=B(e=>e.setMotion),v=B(e=>e.resetAppearance),y=n!==Ve.theme||r!==Ve.density||i!==Ve.accent||a!==Ve.customAccent||o!==Ve.fontScale||c!==Ve.radius||l!==Ve.motion,[b,x]=(0,G.useState)(a);(0,G.useEffect)(()=>x(a),[a]);let S=Je(b),C=!!b.trim()&&!S,w=e=>{x(e);let t=Je(e);t&&E(p)(t)},T=()=>e(t(`config:interfaceSettings.preferencesUpdated`)),E=e=>t=>{e(t),T()},D=[{value:`system`,label:t(`config:interfaceSettings.followSystem`),description:t(`config:interfaceSettings.followSystemDescription`),icon:pe},{value:`scheduled`,label:t(`config:interfaceSettings.automaticByTime`),description:t(`config:interfaceSettings.automaticByTimeDescription`),icon:j},{value:`light`,label:t(`config:interfaceSettings.light`),description:t(`config:interfaceSettings.lightDescription`),icon:ue},{value:`dark`,label:t(`config:interfaceSettings.dark`),description:t(`config:interfaceSettings.darkDescription`),icon:fe}],O=[{value:`comfortable`,label:t(`config:interfaceSettings.comfortable`),description:t(`config:interfaceSettings.comfortableDescription`),icon:ti},{value:`compact`,label:t(`config:interfaceSettings.compact`),description:t(`config:interfaceSettings.compactDescription`),icon:Br}],k=[{value:`system`,label:t(`config:interfaceSettings.motionSystem`),description:t(`config:interfaceSettings.motionSystemDescription`),icon:pe},{value:`full`,label:t(`config:interfaceSettings.motionFull`),description:t(`config:interfaceSettings.motionFullDescription`),icon:Ye},{value:`reduced`,label:t(`config:interfaceSettings.motionReduced`),description:t(`config:interfaceSettings.motionReducedDescription`),icon:Pr}],M=[{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`)}],N=[{value:`small`,label:t(`config:interfaceSettings.small`)},{value:`default`,label:t(`config:interfaceSettings.standard`)},{value:`large`,label:t(`config:interfaceSettings.large`)}],ee=[{value:`sharp`,label:t(`config:interfaceSettings.sharp`)},{value:`default`,label:t(`config:interfaceSettings.standard`)},{value:`soft`,label:t(`config:interfaceSettings.soft`)}];return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-appearance`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4 max-[650px]:flex-col`,children:[(0,K.jsx)(hi,{icon:Gr,title:t(`config:interfaceSettings.appearance`),description:t(`config:interfaceSettings.appearanceDescription`)}),(0,K.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:!y,onClick:()=>{v(),e(t(`config:interfaceSettings.defaultsRestored`))},children:[(0,K.jsx)(A,{size:14}),t(`config:interfaceSettings.restoreDefaults`)]})]}),(0,K.jsx)(gi,{label:t(`config:interfaceSettings.colorMode`),options:D,value:n,onChange:E(u)}),(0,K.jsxs)(`div`,{className:`mt-5 border-t border-[var(--stroke-soft)] pt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-bold text-[var(--text-soft)]`,children:[(0,K.jsx)(Gr,{size:15}),t(`config:interfaceSettings.accentColor`)]}),(0,K.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":t(`config:interfaceSettings.accentColor`),children:M.map(e=>(0,K.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:()=>E(f)(e.value),children:[(0,K.jsx)(`span`,{className:`size-3.5 rounded-full border border-black/10 shadow-sm`,style:{backgroundColor:e.value===`custom`?a:vi[e.value]}}),e.label,i===e.value&&(0,K.jsx)(z,{size:13})]},e.value))}),i===`custom`&&(0,K.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,K.jsx)(`input`,{type:`color`,value:Je(a)||`#1677e8`,onChange:e=>E(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,K.jsx)(`input`,{type:`text`,value:b,onChange:e=>w(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)] ${C?`border-[var(--danger)]`:`border-[var(--stroke)]`}`}),(0,K.jsx)(`span`,{className:`text-[12px] ${C?`text-[var(--danger)]`:`text-[var(--text-muted)]`}`,children:t(C?`config:interfaceSettings.invalidAccentColor`:`config:interfaceSettings.customAccentHint`)})]})]}),(0,K.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,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-bold text-[var(--text-soft)]`,children:[(0,K.jsx)(ei,{size:15}),t(`config:interfaceSettings.interfaceStyle`)]}),(0,K.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 max-[470px]:grid-cols-1`,children:[(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:interfaceSettings.fontSize`)}),(0,K.jsx)(_i,{label:t(`config:interfaceSettings.fontSize`),options:N,value:o,onChange:E(m)})]}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:interfaceSettings.cornerStyle`)}),(0,K.jsx)(_i,{label:t(`config:interfaceSettings.cornerStyle`),options:ee,value:c,onChange:E(g)})]})]})]}),(0,K.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,K.jsxs)(`div`,{className:`flex h-8 items-center gap-1.5 border-b border-[var(--stroke)] bg-[var(--surface-subtle)] px-3`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--brand-blue)]`}),(0,K.jsx)(`span`,{className:`text-[11px] font-bold text-[var(--text-muted)]`,children:t(`config:interfaceSettings.livePreview`)})]}),(0,K.jsxs)(`div`,{className:`grid gap-2.5 p-3`,children:[(0,K.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,K.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,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,K.jsx)(`span`,{className:`block h-full w-2/3 rounded-full bg-[var(--brand-blue)]`})}),(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:`67%`})]})]})]})]})]}),(0,K.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-motion`,children:[(0,K.jsx)(hi,{icon:Pr,title:t(`config:interfaceSettings.displayAndMotion`),description:t(`config:interfaceSettings.displayAndMotionDescription`)}),(0,K.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-5 max-[720px]:grid-cols-1`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[13px] font-bold text-[var(--text-soft)]`,children:t(`config:interfaceSettings.interfaceDensity`)}),(0,K.jsx)(gi,{label:t(`config:interfaceSettings.interfaceDensity`),options:O,value:r,onChange:E(d),className:`grid-cols-2`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[13px] font-bold text-[var(--text-soft)]`,children:t(`config:interfaceSettings.motion`)}),(0,K.jsx)(gi,{label:t(`config:interfaceSettings.motion`),options:k,value:l,onChange:E(_),className:`grid-cols-2`})]})]})]}),(0,K.jsx)(mi,{notify:e})]})}function bi({...e}){return(0,K.jsx)(Bn,{"data-slot":`dropdown-menu`,...e})}function xi({...e}){return(0,K.jsx)(Vn,{"data-slot":`dropdown-menu-trigger`,...e})}function Si({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,K.jsx)(Hn,{children:(0,K.jsx)(Un,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:re(`z-[200] max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function Ci({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(Wn,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:re(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}var wi=[`voiceInput`,`sendMessage`,`commandPalette`,`primaryAction`],Ti=gt.filter(e=>!wi.includes(e));function Ei({requestConfirm:e}){let{t}=h(),n=_t(e=>e.bindings),r=_t(e=>e.setBinding),i=_t(e=>e.resetBindings),[a,o]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.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=yt(n,e,i);if(a){l({action:e,message:t(`config:shortcuts.conflict`,{action:f[a]})});return}try{ht({...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=pt(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`)})},g=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`)})}},_=gt.some(e=>n[e]!==mt[e]),v=e=>(0,K.jsxs)(`div`,{className:`py-3`,"data-shortcut-action":e,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[(0,K.jsx)(`label`,{htmlFor:`shortcut-${e}`,className:`min-w-0 text-sm font-medium`,children:f[e]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-1`,children:[(0,K.jsx)(s,{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":c?.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,K.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words text-left`,children:a===e?t(`config:shortcuts.recording`):vt(n[e])||t(`config:shortcuts.disabled`)})}),(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsx)(s,{variant:`ghost`,size:`icon`,title:t(`config:shortcuts.options`,{action:f[e]}),"aria-label":t(`config:shortcuts.options`,{action:f[e]}),children:(0,K.jsx)(F,{className:`size-4`})})}),(0,K.jsxs)(Si,{align:`end`,className:`w-40`,onCloseAutoFocus:e=>{document.activeElement?.hasAttribute(`data-shortcut-recorder`)&&e.preventDefault()},children:[(0,K.jsxs)(Ci,{disabled:n[e]===null,onSelect:()=>p(e,null),children:[(0,K.jsx)(Ce,{className:`size-4`}),t(`config:shortcuts.disableKey`)]}),(0,K.jsxs)(Ci,{disabled:n[e]===mt[e],onSelect:()=>p(e,mt[e]),children:[(0,K.jsx)(A,{className:`size-4`}),t(`config:shortcuts.resetAll`)]})]})]})]})]}),c?.action===e&&(0,K.jsx)(`p`,{id:`shortcut-error-${e}`,role:`alert`,className:`mt-2 text-sm text-destructive`,children:c.message})]},e);return(0,K.jsxs)(`section`,{className:`w-full min-w-0`,"data-config-card":`shortcuts-bindings`,children:[(0,K.jsxs)(`div`,{className:`mb-5 flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ue,{className:`size-5 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`config:configPage.shortcuts`)})]}),(0,K.jsx)(s,{variant:`ghost`,size:`icon`,disabled:!_,title:t(`config:shortcuts.resetAll`),"aria-label":t(`config:shortcuts.resetAll`),onClick:()=>void g(),children:(0,K.jsx)(A,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:`divide-y divide-border border-y border-border`,children:wi.map(v)}),(0,K.jsxs)(`details`,{className:`group mt-3`,onToggle:()=>o(null),children:[(0,K.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,K.jsx)(oe,{className:`size-4 transition-transform group-open:rotate-180`}),t(`config:shortcuts.more`)]}),(0,K.jsx)(`div`,{className:`divide-y divide-border border-b border-border`,children:Ti.map(v)})]}),(0,K.jsx)(`div`,{className:`mt-3 min-h-5 text-xs text-muted-foreground`,role:`status`,"aria-live":`polite`,children:c?.action===null?(0,K.jsx)(`span`,{className:`text-destructive`,children:c.message}):t(u?`config:shortcuts.saved`:`config:shortcuts.deviceScope`)})]})}var Di=[[`openai-responses`,`OpenAI Responses`],[`openai-completions`,`OpenAI Chat Completions`],[`anthropic-messages`,`Anthropic Messages`],[`google-generative-ai`,`Google Generative AI`]],Oi={openai:Ie,"openai-codex":Ie,anthropic:Pe,google:Ye,deepseek:se,xai:ge,openrouter:he,"kimi-coding":Ye,"zai-coding-cn":Pe};function ki({providers:e,defaultProviderId:t=``,toggling:n,onConfigure:r,onToggle:i,onDelete:a}){let{t:o}=h(),c=e.filter(e=>e.configured||e.custom);return(0,K.jsx)(`div`,{className:`grid [grid-template-columns:repeat(auto-fill,minmax(min(230px,100%),1fr))] gap-[8px]`,children:c.map(e=>{let c=Oi[e.id]||Ge,l=e.id===t,u=e.configured?e.enabled?o(`config:configPage.authenticationReady`):o(`config:configPage.disabled2`):e.id===`openai-codex`?o(`config:configPage.codexCLILoginRequired`):o(`config:configPage.apiKeyRequired`);return(0,K.jsxs)(`div`,{role:`button`,tabIndex:0,title:o(`config:configPage.configure`),className:`flex cursor-pointer flex-col gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-[10px_11px] hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,onClick:()=>r(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e))},children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[8px]`,children:[(0,K.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,K.jsx)(c,{size:16})}),(0,K.jsx)(`strong`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:e.name}),l&&(0,K.jsx)(X,{tone:`green`,children:o(`config:configPage.defaultBadge`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-[8px]`,children:[(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:u}),(0,K.jsxs)(`div`,{className:`flex flex-none items-center gap-[6px]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,K.jsx)(ri,{value:e.configured&&e.enabled,disabled:!e.configured||n===e.id,onChange:t=>i(e,t)}),e.custom&&(0,K.jsx)(s,{variant:`destructive`,size:`icon`,className:`h-[26px] w-[26px]`,title:o(`config:configPage.deleteProvider`),onClick:()=>a(e),children:(0,K.jsx)(xe,{size:13})})]})]})]},e.id)})})}function Ai({providers:e,defaultProviderId:t,toggling:n,onConfigure:r,onToggle:i,onDelete:a,onAddCustom:o}){let{t:c}=h();return(0,K.jsxs)(Y,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-[8px] [margin-bottom:8px]`,children:[(0,K.jsx)(ni,{title:c(`config:configPage.connections`)}),(0,K.jsxs)(s,{variant:`ghost`,size:`sm`,className:`h-[26px] px-[8px] text-[12px] text-[var(--text-muted)]`,onClick:o,children:[(0,K.jsx)(lt,{size:13}),c(`config:configPage.addCustomConnection`)]})]}),(0,K.jsx)(ki,{providers:e,defaultProviderId:t,toggling:n,onConfigure:r,onToggle:i,onDelete:a})]})}function ji({config:e,onQuickSetup:t,onChangeModel:n}){let{t:r}=h(),i=e.defaultProvider||e.provider,a=e.defaultModel||e.model,o=e.providers.find(e=>e.id===i),c=o?.models.find(e=>e.id===a),l=!!(o?.configured&&o?.enabled&&a);return(0,K.jsx)(Y,{className:`[margin-bottom:12px]`,"data-config-card":`models-current-model`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[12px] max-[650px]:grid max-[650px]:grid-cols-[40px_minmax(0,1fr)]`,children:[(0,K.jsx)(`span`,{className:`grid w-[40px] h-[40px] flex-none place-items-center rounded-[11px] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,K.jsx)(Ie,{size:19})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-[600] text-[var(--text-muted)]`,children:r(`config:configPage.currentChatModel`)}),l?(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-[7px]`,children:[(0,K.jsxs)(`strong`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[15px]`,children:[o?.name,` / `,c?.name||a]}),(0,K.jsxs)(X,{tone:`green`,children:[(0,K.jsx)(Te,{size:11,className:`mr-[3px] inline`}),r(`config:configPage.authenticationReady`)]})]}):(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,K.jsxs)(`strong`,{className:`flex items-center gap-[6px] text-[14px] text-[var(--warning-strong)]`,children:[(0,K.jsx)(Rr,{size:15}),r(`config:configPage.noModelConfiguredYet`)]}),(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`config:configPage.noModelConfiguredHint`)})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-none flex-wrap items-center gap-[7px] max-[650px]:col-span-full`,children:[l&&o&&(0,K.jsxs)(s,{variant:`outline`,className:`bg-surface-subtle`,onClick:n,children:[(0,K.jsx)(Kr,{size:13}),r(`config:configPage.changeModel`)]}),(0,K.jsxs)(s,{onClick:t,children:[(0,K.jsx)(M,{size:13}),r(`config:configPage.quickSetup`)]})]})]})})}function Mi({ids:e,onChange:t,placeholder:n,primaryId:r=``}){let{t:i}=h(),[a,o]=(0,G.useState)(``),c=()=>{let n=a.trim();!n||n===r.trim()||e.includes(n)||(t([...e,n]),o(``))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(W,{variant:`control`,children:[i(`config:configPage.manualModelIds`),(0,K.jsxs)(`div`,{className:`flex items-stretch gap-[6px]`,children:[(0,K.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())},placeholder:n}),(0,K.jsx)(s,{type:`button`,size:`icon`,className:`h-[31px] w-[31px] flex-none`,"aria-label":i(`config:configPage.manualModelIds`),disabled:!a.trim(),onClick:c,children:(0,K.jsx)(lt,{size:14})})]})]}),e.length>0&&(0,K.jsx)(`div`,{className:`flex flex-col gap-[6px]`,children:e.map(n=>(0,K.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,K.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:n}),(0,K.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,K.jsx)(Ce,{size:12})})]},n))}),(0,K.jsx)(`p`,{className:`[margin:0] text-[11px] text-[var(--text-tertiary)]`,children:i(`config:configPage.manualModelIdsHint`)})]})}function Ni(e,t){return t===`visual`?e?.models.find(e=>e.kind===`image`||e.kind===`video`):e?.models.find(e=>e.kind===`chat`)||e?.models[0]}function Pi({onClose:e,onCreated:t,initialProviderType:n=`chat`,initialProvider:i}){let{t:a}=h(),o=i?.type||n,c=Ni(i,o),l=!!i,[u,d]=(0,G.useState)({name:i?.name||``,id:i?.id||``,providerType:o,api:i?.api||`openai-responses`,baseUrl:i?.baseUrl||``,apiKey:``,model:c?.id||``,modelName:c?.name||``,modelKind:c?.kind===`image`||c?.kind===`video`?c.kind:o===`visual`?`image`:`chat`,reasoning:c?.reasoning!==!1,thinkingLevels:c?.thinkingLevels||[],enabled:i?.enabled??!0}),f=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[p,m]=(0,G.useState)(!1),g=e=>{m(!0),d(t=>({...t,thinkingLevels:t.thinkingLevels.includes(e)?t.thinkingLevels.filter(t=>t!==e):[...t.thinkingLevels,e]}))},[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)([]),C=e=>d(t=>({...t,name:e,id:t.id||e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}));return(0,G.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,K.jsx)(`div`,{className:`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=>t.target===t.currentTarget&&e(),children:(0,K.jsxs)(`form`,{role:`dialog`,"aria-modal":`true`,className:`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=>{e.preventDefault(),v(!0),b(``);try{let e=l?await r(`/api/config`,{method:`PUT`,body:JSON.stringify({...u,thinkingLevels:p?u.thinkingLevels:void 0,provider:u.id,providerName:u.name,setAsDefault:!1})}):await r(`/api/providers`,{method:`POST`,body:JSON.stringify({...u,thinkingLevels:p?u.thinkingLevels:void 0})}),n=new Set((i?.models||[]).map(e=>e.id)),a=x.filter(e=>e!==u.model.trim()&&!n.has(e));if(a.length){let t=e.createdProviderId||u.id;try{e=await r(`/api/providers/${encodeURIComponent(t)}/models/batch`,{method:`POST`,body:JSON.stringify({models:a.map(e=>({id:e,kind:u.providerType===`visual`?u.modelKind:`chat`}))})})}catch(e){b(e instanceof Error?e.message:String(e));return}}t(e)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},children:[(0,K.jsxs)(et,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:a(l?`config:configPage.editProviderConnection`:`config:configPage.addProviderConnection`)}),(0,K.jsx)(`p`,{children:a(l?`config:configPage.updateProviderKeyURLAndModelSettings`:`config:configPage.youCanCreateMultipleConnectionsUsingTheSameProtocolEachWithItsOwnKeyAndBaseURL`)})]}),(0,K.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`config:configPage.closeDialog`),onClick:t=>{t.preventDefault(),t.stopPropagation(),e()},children:(0,K.jsx)(Ce,{size:17})})]}),(0,K.jsxs)(`div`,{className:`form-grid grid gap-[9px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.displayName`),(0,K.jsx)(`input`,{value:u.name,onChange:e=>C(e.target.value),placeholder:a(`config:configPage.forExampleOpenAIOfficial`)})]}),(0,K.jsxs)(W,{variant:`control`,children:[`Provider ID`,(0,K.jsx)(`input`,{value:u.id,disabled:l,onChange:e=>d({...u,id:e.target.value}),placeholder:`openai-official`})]})]}),(0,K.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,K.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`config:configPage.providerPurpose`)}),(0,K.jsx)(`strong`,{className:`text-[12px]`,children:u.providerType===`visual`?a(`config:configPage.visualProvider`):a(`config:configPage.chatProvider`)})]}),(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.apiProtocol`),(0,K.jsx)(L,{value:u.api,onChange:e=>d({...u,api:e.target.value}),children:Di.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))})]}),(0,K.jsxs)(W,{variant:`control`,children:[`Base URL`,(0,K.jsx)(`input`,{value:u.baseUrl,onChange:e=>d({...u,baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})]}),(0,K.jsxs)(W,{variant:`control`,children:[`API Key`,(0,K.jsx)(`input`,{type:`password`,value:u.apiKey,onChange:e=>d({...u,apiKey:e.target.value}),placeholder:a(l?`config:configPage.keepExistingKeyBlank`:`config:configPage.enterTheAPIKeyForThisConnection`)})]}),(0,K.jsxs)(`div`,{className:`form-grid grid gap-[9px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.initialModelID`),(0,K.jsx)(`input`,{value:u.model,onChange:e=>d({...u,model:e.target.value}),placeholder:u.providerType===`visual`?`gpt-image-2 or grok-imagine-video`:`gpt-5.4 or gpt-image-1`})]}),(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.modelName`),(0,K.jsx)(`input`,{value:u.modelName,onChange:e=>d({...u,modelName:e.target.value}),placeholder:a(`config:configPage.leaveBlankToUseTheModelID`)})]})]}),(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.modelType`),u.providerType===`visual`?(0,K.jsxs)(L,{value:u.modelKind,onChange:e=>d({...u,modelKind:e.target.value}),children:[(0,K.jsx)(`option`,{value:`image`,children:a(`config:configPage.imageGenerationAndEditing`)}),(0,K.jsx)(`option`,{value:`video`,children:a(`config:configPage.videoGeneration`)})]}):(0,K.jsx)(`div`,{className:`rounded-[var(--r-xs)] bg-[var(--surface-subtle)] px-[10px] py-[8px] text-[13px] text-[var(--text-muted)]`,children:a(`config:configPage.chat`)})]}),(0,K.jsx)(`div`,{className:`grid gap-[9px]`,children:(0,K.jsx)(Mi,{ids:x,onChange:S,primaryId:u.model,placeholder:u.providerType===`visual`?`gpt-image-1`:`gpt-5.5`})}),u.modelKind===`chat`&&(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.modelThinkingLevels`),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:f.map(e=>{let t=e===`off`,n=t||u.thinkingLevels.includes(e),r=t||!u.reasoning&&e!==`off`;return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r,onClick:()=>!t&&g(e),className:re(`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,K.jsx)(z,{size:12}),e]},e)})}),(0,K.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:a(`config:configPage.modelThinkingLevelsHint`)})]}),(0,K.jsxs)(`div`,{className:`modal-toggle-row [&_>_span]:flex [&_>_span]:flex-col [&_>_span]:gap-[3px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] dark:bg-[var(--surface-subtle)] flex min-h-[45px] items-center justify-between gap-[12px] [margin-top:10px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:8px_10px]`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:a(`config:configPage.enableAfterCreation`)}),(0,K.jsx)(`small`,{children:a(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]}),(0,K.jsx)(ri,{value:u.enabled,onChange:e=>d({...u,enabled:e})})]}),y&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),y]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,K.jsx)(s,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:e,children:a(`config:configPage.cancel`)}),(0,K.jsxs)(s,{size:`lg`,disabled:_,children:[_?(0,K.jsx)(V,{className:`animate-spin`,size:14}):l?(0,K.jsx)(z,{size:14}):(0,K.jsx)(lt,{size:14}),a(_?`config:configPage.saving`:l?`config:configPage.saveChanges`:`config:configPage.createConnection`)]})]})]})})}function Fi(e){return(e.providers||[]).some(e=>e.importable&&!e.imported&&!e.conflict)}function Ii(e,t){return!t&&!Fi(e)}function Li(e,t,n){let r=e.providers||[],i=e.errors||[],a=Fi(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 Ri(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 zi(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 Bi(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 Vi({discovery:e,discovering:t,error:n,importing:r,onRefresh:i,onImport:a}){let{t:o}=h(),[c,l]=(0,G.useState)(null),u=e.providers||[],d=e.errors||[];if(!Li(e,t,n))return null;let f=c??Ii(e,t),p=()=>(l(null),i()),m=e=>(l(null),a(e)),g=e=>[`invalid_json`,`invalid_toml`].includes(e.code)?o(`config:configPage.invalidConfigurationFileFormat`):e.code===`unsupported_config`?o(`config:configPage.noImportableProviderConfigurationWasFound`):e.code===`invalid_login_state`?o(`config:configPage.incompleteLoginState`):e.code===`file_too_large`?o(`config:configPage.configurationFileIsTooLarge`):o(`config:configPage.unableToReadTheConfigurationFile`);return(0,K.jsxs)(Y,{className:`[margin-bottom:12px] [padding:12px_14px]`,children:[(0,K.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,K.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":!f,onClick:()=>l(!f),children:[(0,K.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,K.jsx)(Ge,{size:18})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:o(`config:configPage.localProviderConfiguration`)}),(0,K.jsx)(`small`,{children:o(`config:configPage.readProviderEndpointModelAndAuthenticationFieldsFromCodexConfigTomlAndClaudeSettingsJson`)})]}),(0,K.jsx)(oe,{size:15,className:`provider-discovery-caret [&.open]:[transform:rotate(180deg)] flex-none text-[var(--text-muted)] [transition:transform_var(--d1)_var(--ease-out)] ${f?``:`open`}`})]}),(0,K.jsxs)(s,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:t||!!r,onClick:p,children:[t?(0,K.jsx)(V,{className:`animate-spin`,size:13}):(0,K.jsx)(V,{size:13}),o(`config:configPage.rescan`)]})]}),!f&&(0,K.jsxs)(K.Fragment,{children:[t&&!u.length?(0,K.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,K.jsx)(V,{className:`animate-spin`,size:15}),o(`config:configPage.scanningProviderConfigurationFiles`)]}):u.length?(0,K.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:u.map(e=>{let t=Ri(e),n=r===e.id,i=e.source.startsWith(`claude-`)?Pe:Ie,a=e.kind===`authentication`?o(`config:configPage.officialProviderAuthenticationOnly`):e.models?.length?e.models.map(e=>e.id).join(`, `):o(`config:configPage.noModelSpecified`);return(0,K.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,K.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,K.jsx)(i,{size:17})}),(0,K.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,K.jsxs)(`strong`,{children:[t,` · `,e.providerName]}),(0,K.jsxs)(`small`,{children:[e.api,` · `,a]}),(0,K.jsxs)(`small`,{children:[e.kind===`authentication`?o(`config:configPage.officialEndpointOnly`):e.baseUrl||o(`config:configPage.noBaseURLSpecified`),` `,`· `,zi(e,o),` · `,e.location]})]}),(0,K.jsx)(`span`,{className:`flex min-w-0 flex-none items-center max-[650px]:col-start-2`,children:e.imported?(0,K.jsx)(X,{tone:`green`,children:o(`config:configPage.loaded`)}):e.conflict?(0,K.jsx)(X,{tone:`amber`,children:o(`config:configPage.conflictDetected`)}):e.importable?(0,K.jsxs)(s,{type:`button`,disabled:n||!!r,onClick:()=>m(e),children:[n?(0,K.jsx)(V,{className:`animate-spin`,size:12}):(0,K.jsx)(Qe,{size:12}),n?o(`config:configPage.loading`):e.kind===`authentication`?o(`config:configPage.loadLoginState`):o(`config:configPage.loadConfiguration`)]}):(0,K.jsx)(X,{tone:`gray`,children:o(`config:configPage.cannotLoad`)})})]},e.id)})}):(0,K.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,K.jsx)(Ge,{size:15}),o(`config:configPage.noImportableCodexOrClaudeProviderConfigurationWasDetected`)]}),(n||d.length>0||u.some(e=>e.warnings?.some(e=>e.code!==`login_auth_not_imported`)))&&(0,K.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,K.jsxs)(`span`,{children:[(0,K.jsx)(H,{size:13}),n]}),d.map((e,t)=>(0,K.jsxs)(`span`,{children:[(0,K.jsx)(H,{size:13}),Ri(e),` · `,g(e)]},`${e.source}-${e.code}-${t}`)),u.flatMap(e=>(e.warnings||[]).filter(e=>e.code!==`login_auth_not_imported`).map((t,n)=>(0,K.jsxs)(`span`,{children:[(0,K.jsx)(H,{size:13}),Ri(e),` · `,Bi(t.code,o)]},`${e.id}-${t.code}-${n}`)))]})]})]})}function Hi(e,t){try{let n=new URL(e).hostname.replace(/^www\./i,``),r=t===`visual`?`visual`:`chat`;return{id:`custom-${n.replace(/[^a-z0-9]+/gi,`-`)}-${r}`.replace(/^-+|-+$/g,``).slice(0,60)||`custom-provider`,name:n||`Custom Provider`}}catch{return{id:`custom-provider`,name:`Custom Provider`}}}function Ui(e,t){return String(e||``).replace(/\/+$/,``).toLowerCase()===t.replace(/\/+$/,``).toLowerCase()}function Wi({config:e,providerType:t=`chat`,initialProviderId:n,onClose:i,onCompleted:a}){let{t:o}=h(),c=n&&e.providers.find(e=>e.id===n)||null,[l,u]=(0,G.useState)(1),[d,f]=(0,G.useState)(c),[p,m]=(0,G.useState)(c?.baseUrl||``),[g,_]=(0,G.useState)(c?.api||`openai-responses`),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(c?.organization||``),[S,C]=(0,G.useState)(c?.name||``),[w,T]=(0,G.useState)([]),[E,D]=(0,G.useState)(``),[O,k]=(0,G.useState)([]),[A,j]=(0,G.useState)(t===`visual`?`image`:`chat`),[M,N]=(0,G.useState)(!1),[ee,P]=(0,G.useState)(``),[F,I]=(0,G.useState)(``),te=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let ne=()=>te.current?.value??v,R=Hi(p,t),ie=o(t===`visual`?`config:configPage.visualProvider`:`config:configPage.chatProvider`),oe=o(l===1?`config:configPage.quickSetupStepBaseUrl`:l===2?`config:configPage.quickSetupStepProtocol`:`config:configPage.quickSetupStepModel`),se=w.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`),ce=()=>{let n=p.trim();try{let e=new URL(n);if(![`http:`,`https:`].includes(e.protocol))throw Error()}catch{P(o(`config:configPage.providerBaseURLMustBeHTTPOrHTTPS`));return}P(``);let r=e.providers.find(e=>e.type===t&&Ui(e.baseUrl,n)&&e.api===g);f(r||null),r?(C(r.name),x(r.organization||``)):S.trim()||C(R.name),u(2)},le=()=>{if(!g){P(o(`config:configPage.selectAPIProtocol`));return}P(``),u(3)},ue=async()=>{let n=ne().trim();n!==v&&y(n);let i=e.providers.find(e=>e.type===t&&Ui(e.baseUrl,p)&&e.api===g);if(f(i||null),!n&&!i?.configured){P(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}N(!0),P(``),I(``);try{let e=((await r(`/api/providers/models/discover-connection`,{method:`POST`,body:JSON.stringify({providerId:i?.id||``,providerType:t,api:g,baseUrl:p,organization:b,apiKey:n})})).models||[]).filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`);if(!e.length){P(o(t===`visual`?`config:configPage.fetchOrAddAVisualModel`:`config:configPage.fetchOrAddAChatModel`));return}T(e);let a=e.find(e=>e.id===E)||e[0];D(a.id),j(t===`visual`?a.kind:`chat`)}catch(e){let n=e instanceof Error?e.message:String(e),r=i?.models.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`)||[];if(!/\(401\)|\(403\)|鉴权|认证|密钥|API Key/i.test(n)&&r.length){T(r);let e=r.find(e=>e.id===E)||r[0];D(e.id),j(t===`visual`?e.kind:`chat`),I(n)}else P(n)}finally{N(!1)}},de=async()=>{let n=E.trim()||O[0]||``;if(!n){P(o(`config:configPage.selectModelToFinish`));return}let i=new Set((d?.models||[]).map(e=>e.id)),s=O.filter(e=>e!==n&&!i.has(e));N(!0),P(``);try{let i=d?await r(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:d.id,providerType:t,api:g,baseUrl:p,organization:b,model:n,modelKind:t===`visual`?A:`chat`,apiKey:ne(),thinkingLevel:e.thinkingLevel,toolMode:e.toolMode,setAsDefault:!0,enabled:!0})}):await r(`/api/providers`,{method:`POST`,body:JSON.stringify({id:R.id,name:S.trim()||R.name,providerType:t,api:g,baseUrl:p,organization:b,apiKey:ne(),model:n,modelKind:t===`visual`?A:`chat`,enabled:!0})});if(s.length){let e=d?.id||R.id,n=t===`visual`?A:`chat`;try{i=await r(`/api/providers/${encodeURIComponent(e)}/models/batch`,{method:`POST`,body:JSON.stringify({models:s.map(e=>({id:e,kind:n}))})})}catch(e){P(e instanceof Error?e.message:String(e));return}}a(i)}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}};return(0,K.jsx)(`div`,{className:`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:e=>e.target===e.currentTarget&&i(),children:(0,K.jsxs)(`div`,{className:`modal max-h-[calc(100dvh_-_40px)] w-[min(520px,100%)] 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)]`,children:[(0,K.jsxs)(et,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:o(t===`visual`?`config:configPage.visualQuickSetupTitle`:`config:configPage.quickSetupTitle`)}),(0,K.jsxs)(`p`,{children:[o(`config:configPage.stepIndicator`,{current:l,total:3}),` · `,oe]})]}),(0,K.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":o(`config:configPage.closeDialog`),onClick:i,children:(0,K.jsx)(Ce,{size:17})})]}),(0,K.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,K.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,K.jsx)(Ge,{size:16})}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,K.jsx)(`strong`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:S||R.name}),(0,K.jsx)(`small`,{className:`text-[11px] text-[var(--text-muted)]`,children:ie})]}),(0,K.jsx)(X,{tone:`gray`,children:ie})]}),l===1&&(0,K.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[`Base URL`,(0,K.jsx)(`input`,{autoFocus:!0,value:p,onChange:e=>m(e.target.value),placeholder:`https://api.example.com/v1`,inputMode:`url`})]}),(0,K.jsx)(`p`,{className:`[margin:8px_0_0] text-[12px] leading-[1.5] text-[var(--text-muted)]`,children:o(`config:configPage.quickSetupBaseUrlHint`)})]}),l===2&&(0,K.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[o(`config:configPage.apiProtocol`),(0,K.jsx)(L,{value:g,onChange:e=>_(e.target.value),children:Di.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))})]}),(0,K.jsxs)(W,{variant:`control`,children:[`Organization`,(0,K.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:o(`config:configPage.optionalUsedOnlyForOpenAIOrganization`)})]})]}),l===3&&(0,K.jsxs)(`div`,{className:`[margin-top:14px]`,children:[!d&&(0,K.jsxs)(W,{variant:`control`,children:[o(`config:configPage.displayName`),(0,K.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),placeholder:R.name})]}),(0,K.jsxs)(W,{variant:`control`,children:[`API Key`,(0,K.jsx)(`input`,{ref:te,type:`password`,autoComplete:`new-password`,autoFocus:!0,value:v,onChange:e=>y(e.target.value),onInput:e=>y(e.currentTarget.value),placeholder:d?.configured?o(`config:configPage.keepExistingKeyBlank`):o(`config:configPage.enterTheAPIKeyForThisConnection`)})]}),(0,K.jsxs)(s,{type:`button`,size:`lg`,className:`[margin-top:10px] w-full`,disabled:M,onClick:()=>void ue(),children:[M?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(V,{size:14}),o(M?`config:configPage.fetchingModels`:`config:configPage.fetchModels`)]}),F&&(0,K.jsxs)(Ke,{className:`[margin-top:10px]`,children:[(0,K.jsx)(H,{size:15}),(0,K.jsx)(`small`,{children:o(`config:configPage.discoverFailedUsingExisting`,{message:F})})]}),se.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(`div`,{className:`flex max-h-[260px] flex-col gap-[6px] overflow-y-auto`,children:se.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:re(`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)]`,E===e.id&&`[border-color:var(--accent-border)] bg-[var(--accent-soft)]`),onClick:()=>{D(e.id),j(t===`visual`?e.kind:`chat`)},children:[(0,K.jsx)(`span`,{className:re(`grid w-[16px] h-[16px] flex-none place-items-center rounded-full [border:1px_solid_var(--stroke)] text-transparent`,E===e.id&&`[border-color:var(--brand-blue)] bg-[var(--brand-blue)] text-white`),children:(0,K.jsx)(z,{size:11})}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:e.name}),t===`visual`&&(0,K.jsx)(X,{tone:`gray`,children:e.kind===`video`?o(`config:configPage.visualVideoModel`):o(`config:configPage.visualImageModel`)})]},`${e.id}-${e.kind}`))})]}),(0,K.jsxs)(`div`,{className:`[margin-top:14px] grid gap-[9px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[o(`config:configPage.manualModelId`),(0,K.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:t===`visual`?`gpt-image-1`:`gpt-5.4`})]}),(0,K.jsx)(`p`,{className:`[margin:0] text-[11px] text-[var(--text-tertiary)]`,children:o(`config:configPage.manualModelIdHint`)}),t===`visual`&&(0,K.jsxs)(W,{variant:`control`,children:[o(`config:configPage.modelType`),(0,K.jsxs)(L,{value:A,onChange:e=>j(e.target.value),children:[(0,K.jsx)(`option`,{value:`image`,children:o(`config:configPage.imageGenerationAndEditing`)}),(0,K.jsx)(`option`,{value:`video`,children:o(`config:configPage.videoGeneration`)})]})]}),(0,K.jsx)(Mi,{ids:O,onChange:k,primaryId:E,placeholder:t===`visual`?`gpt-image-1`:`gpt-5.5`})]})]}),ee&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),ee]}),(0,K.jsxs)(`div`,{className:`flex justify-between gap-[8px] [margin-top:18px]`,children:[(0,K.jsxs)(s,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:M||l===1,onClick:()=>{P(``),u(l-1)},children:[(0,K.jsx)(je,{size:14}),o(`config:configPage.previousStep`)]}),l===1?(0,K.jsxs)(s,{type:`button`,size:`lg`,disabled:M||!p.trim(),onClick:ce,children:[(0,K.jsx)(ae,{size:14}),o(`config:configPage.nextStep`)]}):l===2?(0,K.jsxs)(s,{type:`button`,size:`lg`,disabled:M,onClick:le,children:[(0,K.jsx)(ae,{size:14}),o(`config:configPage.nextStep`)]}):(0,K.jsxs)(s,{type:`button`,size:`lg`,disabled:M||!E.trim()&&O.length===0,onClick:()=>void de(),children:[M?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(z,{size:14}),o(M?`config:configPage.saving`:`config:configPage.saveAndSetDefault`)]})]})]})})}function Gi({config:e,notify:t,onConfigChanged:n}){let{t:i}=h(),[a,o]=(0,G.useState)(e.thinkingLevel),[c,l]=(0,G.useState)(e.toolMode),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(``);(0,G.useEffect)(()=>{o(e.thinkingLevel),l(e.toolMode)},[e.thinkingLevel,e.toolMode]);let m=e.defaultProvider||e.provider,g=e.defaultModel||e.model,_=e.providers.find(e=>e.id===m),v=!!(_?.configured&&g),y=a!==e.thinkingLevel||c!==e.toolMode,b=async()=>{if(!(!_||!g)){d(!0),p(``);try{n(await r(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:_.id,providerType:_.type,api:_.api,baseUrl:_.baseUrl||``,organization:_.organization||``,model:g,thinkingLevel:a,toolMode:c,setAsDefault:!1})})),t(i(`config:configPage.runtimePolicySaved`))}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,K.jsxs)(Y,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-[8px]`,children:[(0,K.jsx)(ni,{title:i(`config:configPage.agentRuntimePolicy`)}),(0,K.jsxs)(s,{size:`sm`,className:`h-[27px] px-[10px] text-[12px]`,disabled:u||!y||!v,onClick:()=>void b(),children:[u?(0,K.jsx)(V,{className:`animate-spin`,size:13}):(0,K.jsx)(_e,{size:13}),i(u?`config:configPage.saving`:`config:configPage.saveSettings`)]})]}),(0,K.jsxs)(W,{variant:`control`,children:[i(`config:configPage.thinkingLevel`),(0,K.jsx)(L,{value:a,onChange:e=>o(e.target.value),children:[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`].map(e=>(0,K.jsx)(`option`,{children:e},e))})]}),(0,K.jsxs)(W,{variant:`control`,children:[i(`config:configPage.availableTools`),(0,K.jsxs)(L,{value:c,onChange:e=>l(e.target.value),children:[(0,K.jsx)(`option`,{value:`full`,children:i(`config:configPage.fullToolAccess`)}),(0,K.jsx)(`option`,{value:`custom`,children:i(`config:configPage.customManageEachToolOnThePluginsPage`)})]})]}),(0,K.jsxs)(Ke,{children:[(0,K.jsx)(ye,{size:16}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:i(`config:configPage.permissionsAreEnforcedByTheRuntime`)}),(0,K.jsx)(`small`,{children:i(`config:configPage.afterSavingExistingRuntimesAreReleasedAndNewChatsUseTheLatestPolicy`)})]})]}),f&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),f]})]})}function Ki(e){return e instanceof Error?e.message:String(e)}function qi({notify:e,requestConfirm:t,t:n}){let[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!0),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(``);return(0,G.useEffect)(()=>{let e=!0;return r(`/api/config`).then(t=>{if(e)return a(t),s(!1),r(`/api/providers/models/refresh`,{method:`POST`,body:`{}`})}).then(t=>{!e||!t?.config||a(t.config)}).catch(t=>{e&&(l(Ki(t)),s(!1))}),()=>{e=!1}},[]),{config:i,loading:o,error:c,toggling:u,applyConfig:(0,G.useCallback)(e=>{a(e),l(``)},[]),toggleProvider:(0,G.useCallback)(async(t,i)=>{d(t.id),l(``);try{let o=await r(`/api/providers/${encodeURIComponent(t.id)}/enabled`,{method:`PUT`,body:JSON.stringify({enabled:i})});a(o),e(n(`config:configPage.nameState`,{name:t.name,state:n(i?`config:configPage.enabled`:`config:configPage.disabled`)}))}catch(e){l(Ki(e))}finally{d(``)}},[e,n]),deleteProvider:(0,G.useCallback)(async i=>{if(await t({title:n(`config:configPage.deleteProviderConnection`),message:n(`config:configPage.deleteNameItsModelSettingsAndAuthenticationDetailsWillAlsoBeRemoved`,{name:i.name}),confirmLabel:n(`config:configPage.delete`)})){l(``);try{let t=await r(`/api/providers/${encodeURIComponent(i.id)}`,{method:`DELETE`});a(t),e(n(`config:configPage.providerConnectionDeleted`))}catch(e){l(Ki(e))}}},[e,t,n])}}function Ji({requestConfirm:e,onImported:t,t:n}){let[i,a]=(0,G.useState)({providers:[],errors:[]}),[o,s]=(0,G.useState)(!0),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(``),m=(0,G.useCallback)(async()=>{s(!0),l(``);try{a(await r(`/api/providers/discovery`))}catch(e){l(Ki(e))}finally{s(!1)}},[]);return(0,G.useEffect)(()=>{m()},[m]),{discovery:i,discovering:o,error:c,operationError:u,importing:f,refresh:m,importProvider:(0,G.useCallback)(async i=>{let o=i.source===`codex-config`?`Codex config.toml`:i.source===`claude-config`?`Claude settings.json`:i.source===`codex-auth`?`Codex login`:`Claude login`,s=i.kind===`authentication`;if(await e({title:n(s?`config:configPage.loadLoginState`:`config:configPage.loadProviderConfiguration`),message:n(s?`config:configPage.loadOfficialProviderLoginStateFromSource`:`config:configPage.loadThisProviderConfigurationFromSource`,{source:o}),confirmLabel:n(s?`config:configPage.loadLoginState`:`config:configPage.loadConfiguration`)})){p(i.id),d(``);try{let e=await r(`/api/providers/${encodeURIComponent(i.id)}/import`,{method:`POST`,body:`{}`});a(e.discovery),t(e)}catch(e){d(Ki(e))}finally{p(``)}}},[t,e,n])}}var Yi=`pisper.config.visualConnectionsOpen`,Z={running:null,result:null,error:``};function Xi(){return window.localStorage.getItem(Yi)===`1`}function Zi({config:e,notify:t,toggling:n,onToggleProvider:i,onDeleteProvider:a,onQuickSetup:o,onEditVisualProvider:c}){let{t:l}=h(),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(!0),[m,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(Xi),T=(0,G.useCallback)(async()=>{try{d(await r(`/api/visual/models`)),S(``)}catch(e){S(e instanceof Error?e.message:String(e))}finally{p(!1)}},[]);(0,G.useEffect)(()=>{T()},[T,e]),(0,G.useEffect)(()=>{Z.result&&b(Z.result),Z.error&&S(Z.error);let e=Z.running;if(!e)return;v(!0);let t=!0;return e.then(e=>{t&&b(e)}).catch(()=>{t&&S(Z.error)}).finally(()=>{t&&v(!1)}),()=>{t=!1}},[]);let E=async(e,n)=>{g(e),S(``);try{d(await r(`/api/visual/models/${e}`,{method:`PUT`,body:JSON.stringify({model:n})})),t(l(`config:configPage.visualModelUpdated`))}catch(e){S(e instanceof Error?e.message:String(e))}finally{g(``)}},D=async()=>{if(Z.running)return;v(!0),S(``),b(null),Z.result=null,Z.error=``;let e=r(`/api/visual/test`,{method:`POST`,body:`{}`,timeout:21e4});Z.running=e;try{let n=await e;Z.result=n,b(n),t(l(`config:configPage.testSucceeded`))}catch(e){let n=e instanceof Error?e.message:String(e);Z.error=n,S(n),t(n)}finally{Z.running=null,v(!1)}},O=e=>{w(e),window.localStorage.setItem(Yi,e?`1`:`0`)},k=e.providers.filter(e=>e.type===`visual`),A=k.filter(e=>e.configured||e.custom),j=u?.imageModels||[],F=u?.videoModels||[];return(0,K.jsxs)(`section`,{className:`[margin-top:12px]`,children:[(0,K.jsxs)(Y,{className:`[margin-bottom:12px]`,"data-config-card":`models-visual`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[12px] max-[650px]:grid max-[650px]:grid-cols-[40px_minmax(0,1fr)]`,children:[(0,K.jsx)(`span`,{className:`grid w-[40px] h-[40px] flex-none place-items-center rounded-[11px] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,K.jsx)(Ye,{size:19})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-[600] text-[var(--text-muted)]`,children:l(`config:configPage.currentVisualModel`)}),f?(0,K.jsxs)(`span`,{className:`flex items-center gap-[7px] text-[12px] text-[var(--text-muted)]`,children:[(0,K.jsx)(V,{className:`animate-spin`,size:13}),l(`config:configPage.loadingVisualStatus`)]}):u?.image?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-[7px]`,children:[(0,K.jsxs)(`strong`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[15px]`,children:[u.image.providerName,` / `,u.image.name]}),(0,K.jsxs)(X,{tone:`green`,children:[(0,K.jsx)(Te,{size:11,className:`mr-[3px] inline`}),l(`config:configPage.authenticationReady`)]})]}),u.video&&(0,K.jsxs)(`small`,{className:`text-[12px] text-[var(--text-muted)] [overflow-wrap:anywhere]`,children:[l(`config:configPage.visualVideoModel`),`:`,u.video.providerName,` /`,` `,u.video.name]})]}):(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,K.jsxs)(`strong`,{className:`flex items-center gap-[6px] text-[14px] text-[var(--warning-strong)]`,children:[(0,K.jsx)(Rr,{size:15}),l(`config:configPage.visualNoneConfigured`)]}),(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:l(`config:configPage.visualEmptyHint`)})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-none flex-wrap items-center gap-[7px] max-[650px]:col-span-full`,children:[u?.image&&(0,K.jsxs)(s,{variant:`outline`,className:`bg-surface-subtle`,disabled:_,onClick:()=>void D(),children:[_?(0,K.jsx)(V,{className:`animate-spin`,size:13}):(0,K.jsx)(ee,{size:13}),l(_?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,K.jsxs)(s,{onClick:o,children:[(0,K.jsx)(M,{size:13}),l(`config:configPage.visualQuickSetup`)]})]})]}),y&&(0,K.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:[y.previewDataUrl?(0,K.jsx)(`img`,{src:y.previewDataUrl,alt:y.modelName,className:`h-[44px] w-[44px] flex-none rounded-[var(--r-xs)] object-cover`}):(0,K.jsx)(z,{size:16,className:`flex-none text-[var(--success)]`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[1px] text-[12px]`,children:[(0,K.jsx)(`strong`,{className:`text-[var(--success-strong)]`,children:l(`config:configPage.testSucceeded`)}),(0,K.jsxs)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[var(--text-muted)]`,children:[y.providerName,` / `,y.modelName,` · `,y.path]})]})]})]}),(0,K.jsxs)(I,{open:C,onOpenChange:O,children:[(0,K.jsx)(P,{asChild:!0,children:(0,K.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,K.jsx)(oe,{size:15,className:`flex-none text-[var(--text-muted)] transition-transform group-data-[state=closed]:-rotate-90`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[13px] font-[700] text-[var(--text-secondary)]`,children:l(`config:configPage.visualConnections`)}),(0,K.jsx)(`span`,{className:`min-w-0 text-[12px] text-[var(--text-tertiary)]`,children:l(`config:configPage.visualConnectionsHint`)})]})}),(0,K.jsx)(N,{children:(0,K.jsxs)(Y,{children:[(0,K.jsx)(ki,{providers:k,toggling:n,onConfigure:e=>c(e.id),onToggle:i,onDelete:a}),A.length===0&&(0,K.jsx)(`p`,{className:`[margin:2px_0_0] text-[12px] text-[var(--text-muted)]`,children:l(`config:configPage.visualEmptyHint`)}),(j.length>0||F.length>0)&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-[8px] [border-top:1px_solid_var(--stroke-soft)] [margin-top:10px] pt-[10px]`,children:[j.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-[8px]`,children:[(0,K.jsx)(`span`,{className:`w-[64px] flex-none text-[12px] text-[var(--text-muted)]`,children:l(`config:configPage.visualImageModel`)}),(0,K.jsxs)(L,{className:`min-w-0 flex-1`,value:u?.imageSelection||``,disabled:m===`image`,"aria-label":l(`config:configPage.visualImageModel`),onChange:e=>void E(`image`,e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:l(`config:configPage.visualAutoSelected`)}),j.map(e=>(0,K.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),F.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-[8px]`,children:[(0,K.jsx)(`span`,{className:`w-[64px] flex-none text-[12px] text-[var(--text-muted)]`,children:l(`config:configPage.visualVideoModel`)}),(0,K.jsxs)(L,{className:`min-w-0 flex-1`,value:u?.videoSelection||``,disabled:m===`video`,"aria-label":l(`config:configPage.visualVideoModel`),onChange:e=>void E(`video`,e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:l(`config:configPage.visualAutoSelected`)}),F.map(e=>(0,K.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,K.jsx)(`small`,{className:`text-[11px] text-[var(--text-tertiary)]`,children:l(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),x&&(0,K.jsx)(`div`,{className:`[margin-top:10px]`,children:(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),x]})})]})}var Qi=`pisper.config.manageConnectionsOpen`;function $i(){let e=window.localStorage.getItem(Qi);return e===`1`||e!==`0`&&null}function ea({notify:e,registerPrimaryAction:t,requestConfirm:n}){let{t:r}=h(),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)($i),u=qi({notify:e,requestConfirm:n,t:r}),{config:d}=u,f=Ji({requestConfirm:n,onImported:t=>{u.applyConfig(t.config);let n=t.config.providers.find(e=>e.id===t.providerId);e(t.kind===`authentication`?r(`config:configPage.nameLoginStateHasBeenLoadedIntoPisper`,{name:n?.name||t.providerId}):r(`config:configPage.nameConfigurationHasBeenLoadedIntoPisper`,{name:n?.name||t.providerId}))},t:r});if(bt(t,()=>a({providerType:`chat`})),!d)return(0,K.jsxs)(nt,{children:[(0,K.jsx)(V,{className:`animate-spin`,size:24}),(0,K.jsx)(`h2`,{children:r(`config:configPage.loadingModelCatalog`)}),(0,K.jsx)(`p`,{children:r(`config:configPage.readingProvidersAndAuthenticationStatus`)}),u.error&&(0,K.jsx)(U,{children:u.error})]});let p=d.defaultProvider||d.provider,m=d.providers.find(e=>e.id===p),g=c??!1,_=e=>{l(e),window.localStorage.setItem(Qi,e?`1`:`0`)},v=e=>s({providerType:e.type,provider:e}),y=e=>a({providerId:e.id,providerType:e.type});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ji,{config:d,onQuickSetup:()=>a({providerType:`chat`}),onChangeModel:()=>m?y(m):a({providerType:`chat`})}),(0,K.jsxs)(I,{open:g,onOpenChange:_,"data-config-card":`models-connections`,children:[(0,K.jsx)(P,{asChild:!0,children:(0,K.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,K.jsx)(oe,{size:15,className:`shrink-0 text-[var(--text-muted)] transition-transform group-data-[state=closed]:-rotate-90`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[13px] font-[700] text-[var(--text-secondary)]`,children:r(`config:configPage.manageConnections`)}),(0,K.jsx)(`span`,{className:`min-w-0 text-[12px] text-[var(--text-tertiary)]`,children:r(`config:configPage.manageConnectionsHint`)})]})}),(0,K.jsxs)(N,{children:[(0,K.jsx)(Vi,{discovery:f.discovery,discovering:f.discovering,error:f.error||f.operationError,importing:f.importing,onRefresh:f.refresh,onImport:f.importProvider}),(0,K.jsx)(Ai,{providers:d.providers,defaultProviderId:p,toggling:u.toggling,onConfigure:v,onToggle:u.toggleProvider,onDelete:u.deleteProvider,onAddCustom:()=>s({providerType:`chat`})}),u.error&&(0,K.jsx)(U,{children:u.error}),(0,K.jsx)(`div`,{className:`[margin-top:12px]`,children:(0,K.jsx)(Gi,{config:d,notify:e,onConfigChanged:u.applyConfig})})]})]}),(0,K.jsx)(Zi,{config:d,notify:e,toggling:u.toggling,onToggleProvider:u.toggleProvider,onDeleteProvider:u.deleteProvider,onQuickSetup:()=>a({providerType:`visual`}),onEditVisualProvider:e=>{let t=d.providers.find(t=>t.id===e);t&&s({providerType:`visual`,provider:t})}}),i&&(0,K.jsx)(Wi,{config:d,providerType:i.providerType||`chat`,initialProviderId:i.providerId,onClose:()=>a(null),onCompleted:t=>{u.applyConfig(t),e(r(`config:configPage.setupComplete`)),a(null)}}),o&&(0,K.jsx)(Pi,{initialProviderType:o.providerType,initialProvider:o.provider,onClose:()=>s(null),onCreated:t=>{u.applyConfig(t),o.provider?e(r(`config:configPage.providerConnectionUpdated`)):e(r(`config:configPage.providerConnectionCreated`)),s(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 ta(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 na,$,ra,ia,aa=`__TAURI_TO_IPC_KEY__`;function oa(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var sa=class{constructor(e){na.set(this,void 0),$.set(this,0),ra.set(this,[]),ia.set(this,void 0),ta(this,na,e||(()=>{}),`f`),this.id=oa(e=>{let t=e.index;if(`end`in e){t==Q(this,$,`f`)?this.cleanupCallback():ta(this,ia,t,`f`);return}let n=e.message;if(t==Q(this,$,`f`)){for(Q(this,na,`f`).call(this,n),ta(this,$,Q(this,$,`f`)+1,`f`);Q(this,$,`f`)in Q(this,ra,`f`);){let e=Q(this,ra,`f`)[Q(this,$,`f`)];Q(this,na,`f`).call(this,e),delete Q(this,ra,`f`)[Q(this,$,`f`)],ta(this,$,Q(this,$,`f`)+1,`f`)}Q(this,$,`f`)===Q(this,ia,`f`)&&this.cleanupCallback()}else Q(this,ra,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){ta(this,na,e,`f`)}get onmessage(){return Q(this,na,`f`)}[(na=new WeakMap,$=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[aa]()}};function ca(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function la(e,t){return ca(`plugin:barcode-scanner|${e}`,t)}function ua(e){return e instanceof Error?e.message:String(e)}function da(e){return/cancel(?:led|ed)/i.test(ua(e))}function fa(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function pa(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function ma(e){if(!e.isActive||!e.port)return null;let t=pa(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=pa(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function ha(e){return new Promise(t=>window.setTimeout(t,e))}function ga({open:e,onOpenChange:t}){let{t:n}=h(),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(``),[m,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),y=(0,G.useRef)(!1),b=(0,G.useRef)(!1),x=(0,G.useRef)(!1),S=(0,G.useRef)(0),C=(0,G.useRef)(``),w=(0,G.useCallback)(e=>{y.current=e,o(e)},[]),T=(0,G.useCallback)(async()=>{b.current=!0,y.current&&await la(`cancel`).catch(()=>void 0),w(!1),i(null)},[w]);(0,G.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,G.useEffect)(()=>{if(!a)return;let e=`pisper-scanner-${Date.now()}`;window.history.pushState({...window.history.state,pisperScanner:e},``);let t=()=>void T();return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),!x.current&&window.history.state?.pisperScanner===e&&window.history.back()}},[T,a]);let E=e=>{if(!e.proxyUrl)throw Error(n(`config:mobileServer.pairFailed`));window.location.replace(e.proxyUrl)},D=(0,G.useCallback)(async()=>{let e=++S.current;d(!0),p(``),l([]);let t=new sa;t.onmessage=t=>{if(S.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=ma(t.service);r&&l(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await ca(`mobile_ensure_local_network_permission`),r=(await ca(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await ha(4300)}catch(t){S.current===e&&p(ua(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await ca(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),S.current===e&&d(!1)}},[n]);(0,G.useEffect)(()=>{if(!(!e||a))return D(),()=>{S.current+=1}},[D,e,a]);let O=(0,G.useCallback)(async()=>{let e=C.current;C.current=``,e&&await ca(`mobile_cancel_lan_pairing`,{operationId:e}).catch(()=>void 0),i(null),g(``)},[]),k=async e=>{let t=globalThis.crypto?.randomUUID?.()||`lan-${Date.now()}-${Math.random().toString(16).slice(2)}`;C.current=t,i(`lan:${e.id}`),v(``),g(n(`config:mobileServer.awaitingApproval`,{name:e.name}));try{let n=await ca(`mobile_pair_lan`,{operationId:t,name:e.name,url:e.url,fingerprint:e.fingerprint,deviceName:null});if(C.current!==t)return;E(n)}catch(e){C.current===t&&v(ua(e))}finally{C.current===t&&(C.current=``,i(null),g(``))}},A=async()=>{b.current=!1,x.current=!1,i(`scan`),v(``);try{let e=await la(`check_permissions`);if(e.camera!==`granted`&&(e=await la(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(b.current||(w(!0),await fa(),b.current))return;let t=await la(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));x.current=!0,E(await ca(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!b.current&&!da(e)&&v(ua(e))}finally{w(!1),i(null),b.current=!1}};return(0,K.jsx)(Ze,{open:e,onOpenChange:e=>{if(!e&&a){T();return}if(!e&&r?.startsWith(`lan:`)){O(),t(!1);return}r||(e||v(``),t(e))},children:(0,K.jsx)(we,{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,K.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,K.jsxs)(Fe,{className:`sr-only`,children:[(0,K.jsx)(Re,{children:n(`config:mobileServer.scanTitle`)}),(0,K.jsx)(Xe,{children:n(`config:mobileServer.scanHint`)})]}),(0,K.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,K.jsxs)(s,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void T(),children:[(0,K.jsx)(je,{}),n(`config:mobileServer.cancelScan`)]}),(0,K.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,K.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,K.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,K.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,K.jsx)(Xr,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,K.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,K.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,K.jsx)(s,{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 T(),children:n(`config:mobileServer.cancelScan`)})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Fe,{children:[(0,K.jsx)(Re,{children:n(`config:mobileServer.addServer`)}),(0,K.jsx)(Xe,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,K.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,K.jsx)(Jr,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,K.jsx)(s,{size:`icon-sm`,variant:`ghost`,disabled:u||r!==null,"aria-label":n(`config:mobileServer.rediscover`),onClick:()=>void D(),children:(0,K.jsx)(V,{className:u?`animate-spin`:void 0})})]}),c.length?(0,K.jsx)(`ul`,{className:`grid max-h-44 gap-1.5 overflow-y-auto`,children:c.map(e=>{let t=r===`lan:${e.id}`;return(0,K.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(Ge,{className:`size-4 flex-none text-muted-foreground`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,K.jsxs)(s,{size:`sm`,disabled:r!==null,onClick:()=>void k(e),children:[t?(0,K.jsx)(le,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(u?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),f?(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-destructive`,children:f}):null,m?(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed`,children:m}),(0,K.jsx)(s,{size:`sm`,variant:`outline`,onClick:()=>void O(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,K.jsxs)(`div`,{className:`relative py-1`,children:[(0,K.jsx)(R,{}),(0,K.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,K.jsxs)(s,{className:`w-full`,disabled:r!==null,onClick:()=>void A(),children:[r===`scan`?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(qr,{}),n(`config:mobileServer.scan`)]}),_?(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-destructive`,children:_}):null]})})})}function _a(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function va({requestConfirm:e}){let{t}=h(),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(``),[o,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(!1),d=(0,G.useCallback)(async()=>{try{r(await _a(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,G.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{c(n||e);try{r(await _a(e,t)),a(``)}catch(e){a(String(e))}finally{c(``)}},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=>{c(e);try{let t=await _a(`mobile_select_server`,{id:e});r(t),a(``),t.proxyUrl&&window.location.replace(t.proxyUrl)}catch(e){a(String(e))}finally{c(``)}},g=n?.mode===`local`,_=n?.mode===`remote`&&!!n.activeId,v=g||_,y=t(g?`config:mobileServer.currentLocal`:_?`config:mobileServer.current`:`config:mobileServer.empty`);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 rounded-[var(--r-sm)] border px-3 py-2 text-[12px] ${v?`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,K.jsx)(v?Te:Rr,{size:15,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:y}),n?.activeTransport?(0,K.jsx)(`span`,{className:`flex-none text-[11px] opacity-80`,children:n.activeTransport===`iroh`?t(`config:mobileServer.transportP2p`):t(`config:mobileServer.transportLan`)}):null]}),(0,K.jsx)(ga,{open:l,onOpenChange:u}),(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`mobile-server-main`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-[11px]`,children:[(0,K.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,K.jsx)(Oe,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-[16px]`,children:t(`config:mobileServer.title`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:mobileServer.description`)})]})]}),(0,K.jsxs)(s,{size:`sm`,className:`max-[650px]:h-10 max-[650px]:px-3`,onClick:()=>u(!0),children:[(0,K.jsx)(lt,{size:14}),t(`config:mobileServer.addServer`)]})]}),i?(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--danger)]`,children:i}):null]}),(0,K.jsx)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`mobile-server-local`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-48 items-start gap-[11px]`,children:[(0,K.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,K.jsx)(Zr,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`flex flex-wrap items-center gap-2 text-[16px]`,children:[t(`config:mobileServer.localTitle`),g?(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--star-strong)]`,children:t(`config:mobileServer.currentLocal`)}):null]}),(0,K.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:mobileServer.localDescription`)})]})]}),(0,K.jsx)(s,{size:`sm`,variant:`outline`,className:`flex-none max-[650px]:h-10 max-[650px]:px-3`,disabled:g||!!o,onClick:()=>void(async()=>{c(`mobile_enter_local`);try{let e=await _a(`mobile_enter_local`);e.onDevice.url&&window.location.replace(e.onDevice.url)}catch(e){a(String(e))}finally{c(``)}})(),children:t(g?`config:mobileServer.currentLocal`:`config:mobileServer.enterLocal`)})]})}),(0,K.jsx)(Y,{className:`flex flex-col gap-3 p-4`,children:n?.servers?.length?(0,K.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`),c=i?.url||(a?.nodeId?`Iroh ${a.nodeId.slice(0,12)}`:`Iroh`);return(0,K.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,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(Ge,{size:15,className:`flex-none text-[var(--text-muted)]`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`truncate text-[13px]`,children:[e.name,r?(0,K.jsx)(`span`,{className:`ml-2 text-[11px] text-[var(--star-strong)]`,children:t(`config:mobileServer.current`)}):null]}),(0,K.jsxs)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:[c,(0,K.jsx)(`span`,{className:`ml-2`,children:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`)})]}),r&&n.activeTransport?(0,K.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,K.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[r?null:(0,K.jsx)(s,{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,K.jsx)(s,{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,K.jsx)(xe,{size:14})})]})]},e.id)})}):(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:mobileServer.empty`)})})]})}var ya={feishu:{tone:`blue`},weixin:{tone:`green`},qq:{tone:`blue`},telegram:{tone:`blue`},browser:{tone:`blue`}};function ba(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 xa(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 Sa(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 Ca(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 wa(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&at()?`checking`:st()}function Ta(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function Ea(e){return e instanceof Error?e.message:String(e)}function Da({notify:e,onBrowserNotificationChange:t}){let{t:n}=h(),[i,a]=(0,G.useState)({browser:{enabled:!1},connections:{},scopes:[],templates:[]}),[o,c]=(0,G.useState)(!0),[l,u]=(0,G.useState)(``),d=!!window.pisperDesktop?.showNotification,f=at(),[p,m]=(0,G.useState)(wa),[g,_]=(0,G.useState)(!1),v=(0,G.useCallback)(async()=>{if(!d)return;let e=window.pisperDesktop?.getNotificationStatus;if(!e){m(`granted`);return}try{let t=await e(),n=t?.permission;m(n==="default"||n===`denied`||n===`granted`||n===`checking`||n===`unsupported`?n:t?.supported===!1?`unsupported`:`granted`)}catch{m(`unsupported`)}},[d]),y=(0,G.useCallback)(async()=>{try{u(``);let e=await r(`/api/settings/notifications`);a(e),t?.(e)}catch(e){u(Ea(e))}finally{c(!1)}},[t]);(0,G.useEffect)(()=>{y()},[y]),(0,G.useEffect)(()=>{if(!d)return;v();let e=()=>{v()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[d,v]);let b=(0,G.useCallback)(async()=>{if(!(d||!f))try{let e=await ut();m(e===!0?`granted`:e===!1?`denied`:`default`)}catch{m(`unsupported`)}},[d,f]);(0,G.useEffect)(()=>{if(d||!f)return;b();let e=()=>void b();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[d,f,b]);let x=async i=>{let o=``;if(i){if(d&&p!==`granted`)o=Ta(`system-disabled`,n);else if(!d&&f){let e=`denied`;try{let t=await ut()===!0?`granted`:await ct();e=t===`granted`?`granted`:t===`denied`?`denied`:`default`}catch{e=`unsupported`}m(e),e!==`granted`&&(o=n(`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`))}else if(!d){let e=await Ae();if(m(e),e!==`granted`)o=n(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await He()}catch{o=n(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}_(!0);try{let s=await r(`/api/settings/notifications/browser`,{method:`PATCH`,body:JSON.stringify({enabled:i})});a(s),t?.(s),o?e(n(`config:notificationSettings.savedButLocalDeliveryUnavailable`,{reason:o}),`info`):e(n(i?`config:notificationSettings.notificationsEnabled`:`config:notificationSettings.notificationsDisabled`))}catch(t){e(Ea(t),`error`)}finally{_(!1)}},S=(0,G.useCallback)(async(e,t,r=`pisper-browser-test`)=>{if(d){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 m(i.permission??`denied`),Error(Ta(i.reason,n));return i}return f?(await qe(e,t),{shown:!0,transport:`tauri`}):ke({title:e,body:t,tag:r,url:window.location.href})},[d,f,n]),C=async()=>{if(p!==`granted`){e(p===`unsupported`?Ta(`unsupported`,n):d?Ta(`system-disabled`,n):n(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await S(n(`config:notificationSettings.appNotificationTest`,{app:St}),n(`config:notificationSettings.notificationsAreWorking`)),e(n(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(Ea(t)||n(`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`),`error`)}},w=async()=>{try{await window.pisperDesktop?.openNotificationSettings?.()||e(n(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}catch{e(n(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}};if(o)return(0,K.jsxs)(nt,{children:[(0,K.jsx)(V,{className:`animate-spin`,size:23}),(0,K.jsx)(`h2`,{children:n(`config:notificationSettings.loadingNotificationSettings`)})]});let T=n(p===`granted`?`config:notificationSettings.permissionGranted`:p===`denied`?d?`config:notificationSettings.systemNotificationsAreOff`:`config:notificationSettings.browserNotificationsAreBlocked`:p===`unsupported`?`config:notificationSettings.notSupported`:p===`checking`?`config:notificationSettings.checking`:`config:notificationSettings.waitingForPermission`),E=p===`granted`?`green`:p==="default"||p===`checking`?`amber`:`red`;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-[12px]`,children:[l&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),l]}),(0,K.jsxs)(Y,{className:`browser-notification-card`,"data-config-card":`notifications-browser`,children:[(0,K.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,K.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)] ${i.browser.enabled?`blue`:``}`,children:i.browser.enabled?(0,K.jsx)(ze,{size:18}):(0,K.jsx)(Fr,{size:18})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:n(`config:notificationSettings.notification`)}),(0,K.jsx)(`small`,{children:n(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,K.jsx)(X,{tone:E,children:T}),(0,K.jsx)(ri,{value:i.browser.enabled,disabled:g||p===`checking`,onChange:x})]}),(0,K.jsxs)(Ke,{children:[(0,K.jsx)(ye,{size:15}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:n(d?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,K.jsx)(`small`,{children:n(d?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,K.jsxs)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:[d&&p===`denied`&&(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:w,children:[(0,K.jsx)(ye,{size:14}),n(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:!i.browser.enabled||p!==`granted`,onClick:C,children:[(0,K.jsx)(ze,{size:14}),n(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,K.jsx)(Oa,{data:i,setData:a,notify:e,permission:p,onBrowserTest:S,onSettingsChange:t})]})}function Oa({data:e,setData:t,notify:n,permission:i,onBrowserTest:a,onSettingsChange:o}){let{t:c}=h(),[l,u]=(0,G.useState)(e.templates[0]?.id||``),[d,f]=(0,G.useState)(`feishu`),p=e.templates.find(e=>e.id===l)||e.templates[0],m=p?.channels?.[d],[g,_]=(0,G.useState)(m?.content||``),[v,y]=(0,G.useState)(!1),b=e.scopes.find(e=>e.platform===d),x=d===`browser`?e.browser.enabled&&i===`granted`:!!b,S=ya;return(0,G.useEffect)(()=>{_(m?.content||``)},[l,d,m?.content]),p?(0,K.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,K.jsxs)(Y,{"data-config-card":`notifications-templates`,children:[(0,K.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,K.jsx)(ni,{title:c(`config:notificationSettings.notificationTemplates`)}),(0,K.jsx)(`span`,{children:c(`config:notificationSettings.sharedByChatsScheduledTasksAndWorkflows`)})]}),e.templates.map(e=>(0,K.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===p.id?`selected`:``}`,onClick:()=>u(e.id),children:[(0,K.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,K.jsx)(ve,{size:14})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:xa(e.id,e.name,c)}),(0,K.jsx)(`small`,{children:Sa(e.id,e.description,c)})]}),(0,K.jsx)(X,{tone:e.enabled?`green`:`gray`,children:e.enabled?c(`config:notificationSettings.enabled`):c(`config:notificationSettings.disabled`)})]},e.id))]}),(0,K.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,K.jsxs)(et,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:xa(p.id,p.name,c)}),(0,K.jsx)(`p`,{children:Sa(p.id,p.description,c)})]}),(0,K.jsx)(ri,{value:p.enabled,onChange:e=>t(t=>({...t,templates:t.templates.map(t=>t.id===p.id?{...t,enabled:e}:t)}))})]}),(0,K.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(S).map(([t,n])=>{let r=t===`browser`?e.browser.enabled:e.connections?.[t];return(0,K.jsxs)(`button`,{className:d===t?`active`:``,onClick:()=>f(t),children:[ba(t,c),(0,K.jsx)(X,{tone:r?n.tone:`red`,className:` absolute -top-2.5 -right-1.5`,children:c(r?t===`browser`?`config:notificationSettings.enabled2`:`config:notificationSettings.connected`:t===`browser`?`config:notificationSettings.notEnabled`:`config:notificationSettings.notConnected`)})]},t)})}),(0,K.jsxs)(W,{variant:`control`,children:[c(`config:notificationSettings.messageContent`),(0,K.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value)})]}),(0,K.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,K.jsx)(`span`,{children:c(`config:notificationSettings.availableVariables`)}),p.variables.map(e=>(0,K.jsx)(`code`,{children:`{{${e}}}`},e))]}),(0,K.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,K.jsx)(`small`,{children:c(`config:notificationSettings.preview`)}),(0,K.jsx)(`pre`,{children:Ca(g,c)})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:v||!x,onClick:async()=>{y(!0);try{let e=await r(`/api/settings/notifications/templates/${encodeURIComponent(p.id)}/${d}/test`,{method:`POST`,body:`{}`});d===`browser`&&await a?.(e.title||xa(p.id,p.name,c),e.body||e.preview||``,`pisper-template-${p.id}`),n(c(d===`browser`?`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`:`config:notificationSettings.testNotificationSentToCountChats`,{count:e.sent}))}catch(e){n(Ea(e),`error`)}finally{y(!1)}},children:[(0,K.jsx)(ve,{size:14}),c(`config:notificationSettings.sendTest`)]}),(0,K.jsxs)(s,{size:`lg`,disabled:v||!g.trim(),onClick:async()=>{y(!0);try{let e=await r(`/api/settings/notifications/templates/${encodeURIComponent(p.id)}/${d}`,{method:`PUT`,body:JSON.stringify({enabled:p.enabled,content:g})});t(e),o?.(e),n(c(`config:notificationSettings.notificationTemplateSaved`))}catch(e){n(Ea(e),`error`)}finally{y(!1)}},children:[v?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(_e,{size:14}),c(`config:notificationSettings.saveTemplate`)]})]})]})]}):null}function ka({notify:e}){let{t,language:n}=h(),[i,a]=(0,G.useState)(null),[o,c]=(0,G.useState)(null),[l,u]=(0,G.useState)([]),[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(``),E=(0,G.useCallback)(async()=>{try{let[e,t,n,i]=await Promise.all([r(`/api/remote/status`),r(`/api/remote/devices`),r(`/api/remote/pairing-requests`).catch(()=>({requests:[]})),r(`/api/remote/firewall`).catch(e=>{if(e&&typeof e==`object`&&`status`in e&&e.status===403)return null;throw e})]);a(e),c(i),u(t.devices.filter(e=>!e.revokedAt)),f(n.requests),T(``)}catch{T(t(`config:remoteAccess.loadFailed`))}},[t]);(0,G.useEffect)(()=>{E()},[E]),(0,G.useEffect)(()=>{if(!i?.listening)return;let e=window.setInterval(()=>void E(),2e3);return()=>window.clearInterval(e)},[E,i?.listening]);let D=async n=>{C(!0);try{await r(`/api/remote/enabled`,{method:`PUT`,body:{enabled:n,configureFirewall:o!==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||(m(null),_(!1),y(``)),await E()}catch(n){e(t(`config:remoteAccess.toggleFailed`,{message:String(n)}),`error`)}finally{C(!1)}},O=async()=>{C(!0);try{await r(`/api/remote/firewall/retry`,{method:`POST`,body:{},timeout:15e4}),await E()}catch(n){e(t(`config:remoteAccess.firewallRetryFailed`,{message:String(n)}),`error`)}finally{C(!1)}},k={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`)},A={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`)},j=async()=>{C(!0),y(``);try{let e=await r(`/api/remote/pairing-code`,{method:`POST`});if(!e?.code||!e?.expiresAt)throw Error(t(`config:remoteAccess.qrUnavailable`));m(e),_(!0),e.qrDataUrl||y(t(`config:remoteAccess.qrUnavailable`))}catch(n){let r=t(`config:remoteAccess.pairingFailed`,{message:String(n)});y(r),e(r,`error`)}finally{C(!1)}},M=async(n,i)=>{x(n.id);try{await r(`/api/remote/pairing-requests/${encodeURIComponent(n.id)}/decision`,{method:`POST`,body:{approved:i}}),await E()}catch(n){e(t(`config:remoteAccess.approvalFailed`,{message:String(n)}),`error`)}finally{x(``)}},N=async n=>{if(window.confirm(t(`config:remoteAccess.revokeConfirm`,{name:n.name})))try{await r(`/api/remote/devices/${encodeURIComponent(n.id)}/revoke`,{method:`POST`}),await E()}catch(n){e(t(`config:remoteAccess.revokeFailed`,{message:String(n)}),`error`)}};return w?(0,K.jsx)(Y,{className:`p-4 text-[13px] text-[var(--text-muted)]`,children:w}):i?(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsx)(Ze,{open:g&&p!==null,onOpenChange:_,children:(0,K.jsxs)(we,{className:`sm:max-w-md`,children:[(0,K.jsxs)(Fe,{children:[(0,K.jsx)(Re,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,K.jsx)(Xe,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[p?.qrDataUrl?(0,K.jsx)(`img`,{src:p.qrDataUrl,alt:t(`config:remoteAccess.qrAlt`),className:`size-64 max-w-full rounded-[var(--r-sm)] bg-white p-2`}):null,v?(0,K.jsx)(`p`,{className:`text-center text-[12px] leading-relaxed text-[var(--danger)]`,children:v}):null,p?(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`font-mono text-[20px] tracking-[0.2em]`,children:p.code}),(0,K.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.codeExpiresAt`,{time:Ee(p.expiresAt,n)})})]}):null]}),(0,K.jsx)(Ne,{children:(0,K.jsxs)(s,{disabled:S,onClick:()=>void j(),children:[S?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(V,{}),t(S?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-main`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-[11px]`,children:[(0,K.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,K.jsx)(Oe,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-[16px]`,children:t(`config:remoteAccess.title`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:remoteAccess.description`)})]})]}),(0,K.jsx)(ri,{value:i.enabled,disabled:S,onChange:e=>void D(e),ariaLabel:t(`config:remoteAccess.title`)})]}),i.error?(0,K.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:i.error})}):null]}),o?(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"aria-live":`polite`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h3`,{className:`text-[14px]`,children:t(`config:remoteAccess.firewallTitle`)}),i.enabled||o.state===`cleanup_pending`?(0,K.jsxs)(s,{size:`sm`,disabled:S||o.busy,onClick:()=>void O(),children:[S||o.busy?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(V,{}),i.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):null]}),(0,K.jsx)(`p`,{className:`text-[13px]`,children:o.busy?t(`config:remoteAccess.firewallWorking`):k[o.state]}),o.reason&&A[o.reason]?(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:A[o.reason]}):null,i.enabled?(0,K.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:o.scope===`application`?t(`config:remoteAccess.firewallApplicationScope`):o.scope===`program_port`?t(`config:remoteAccess.firewallProgramPortScope`,{port:o.port??`—`}):t(`config:remoteAccess.firewallPortScope`,{port:o.port??`—`})}):null,(0,K.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:t(`config:remoteAccess.firewallReachability`)}),o.checkedAt?(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:Ee(o.checkedAt,n)})}):null]}):null,i.listening&&d.length?(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"aria-live":`polite`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,K.jsx)(Zr,{size:16}),t(`config:remoteAccess.pendingApprovals`)]}),(0,K.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:t(`config:remoteAccess.pendingApprovalsDescription`)}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-sm)] border border-[var(--border)] px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-[13px]`,children:e.deviceName}),(0,K.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.requestedAt`,{time:Ee(e.requestedAt,n)})}),(0,K.jsx)(`code`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})})]}),(0,K.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[(0,K.jsxs)(s,{size:`sm`,variant:`ghost`,disabled:b===e.id,onClick:()=>void M(e,!1),children:[(0,K.jsx)(Ce,{}),t(`config:remoteAccess.reject`)]}),(0,K.jsxs)(s,{size:`sm`,disabled:b===e.id,onClick:()=>void M(e,!0),children:[b===e.id?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(z,{}),t(`config:remoteAccess.approve`)]})]})]},e.id))})]}):null,i.listening?(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-pairing`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,K.jsx)(qr,{size:16}),t(`config:remoteAccess.pairing`)]}),(0,K.jsxs)(s,{size:`sm`,disabled:S,onClick:()=>void j(),children:[S?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(qr,{}),t(S?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]})]}),(0,K.jsx)(`p`,{className:`text-[12px] leading-[1.6] text-[var(--text-muted)]`,children:t(`config:remoteAccess.pairingDescription`)}),v&&!g?(0,K.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--danger)]`,"aria-live":`polite`,children:v}):null]}):null,(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-devices`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,K.jsx)(Zr,{size:16}),t(`config:remoteAccess.devices`)]}),(0,K.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>void E(),"aria-label":t(`config:remoteAccess.refresh`),children:(0,K.jsx)(V,{size:14})})]}),l.length===0?(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.noDevices`)}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-sm)] border border-[var(--border)] px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`truncate text-[13px]`,children:[e.name,e.current?(0,K.jsx)(`span`,{className:`ml-2 text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.currentDevice`)}):null]}),(0,K.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.lastSeen`,{time:Ee(e.lastSeenAt,n)})})]}),(0,K.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>void N(e),children:t(`config:remoteAccess.revoke`)})]},e.id))})]})]}):null}function Aa({notify:e}){let{t}=h(),n=window.pisperDesktop,[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(``),[c,l]=(0,G.useState)(``);(0,G.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,K.jsxs)(Y,{className:`[padding:18px] cli-settings-card`,"data-config-card":`updates-cli`,children:[(0,K.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,K.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,K.jsx)($r,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:t(`config:cliSettings.title`)}),(0,K.jsx)(`p`,{children:t(`config:cliSettings.description`)})]}),(0,K.jsx)(X,{tone:r?.installed&&!r.needsRepair?`green`:r?.needsRepair?`blue`:`gray`,children:m})]}),r&&(0,K.jsxs)(Ke,{className:`[margin-top:15px] cli-settings-status [&_small]:[overflow-wrap:anywhere]`,children:[r.installed&&!r.needsRepair?(0,K.jsx)(Te,{size:16}):(0,K.jsx)($r,{size:16}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:r.installed?t(`config:cliSettings.commandReady`,{command:r.command}):t(`config:cliSettings.commandNotInstalled`,{command:r.command})}),(0,K.jsx)(`small`,{children:r.installPath}),r.installed&&(0,K.jsx)(`small`,{children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),c&&(0,K.jsx)(U,{children:c}),u&&(0,K.jsxs)(`div`,{className:`mt-3.5 flex justify-end gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,K.jsxs)(s,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(xe,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,K.jsxs)(s,{type:`button`,size:`lg`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,K.jsx)(V,{className:`animate-spin`,size:14}):r?.needsRepair?(0,K.jsx)(Se,{size:14}):(0,K.jsx)(Qe,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),u&&(0,K.jsx)(`small`,{className:`block [margin:9px_1px_0] text-[var(--text-muted)] text-[12px]`,children:t(`config:cliSettings.restartTerminal`)})]})}var ja=`0.5.47`,Ma=9e5,Na=2592e6;function Pa(){try{let e=JSON.parse(localStorage.getItem(ie.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 Fa(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 Ia(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 La({notify:e,update:t}){let{t:n,language:i}=h(),a=t?.info||{desktop:!1,packaged:!1,version:ja,platform:`browser`,arch:``},o=t?.status||{state:`idle`},c=!!a.desktop,l=!!a.mobile,u=c||l,[d,f]=(0,G.useState)({version:ja,date:``,notes:``}),[p,m]=(0,G.useState)([]),[g,_]=(0,G.useState)(``),[v,y]=(0,G.useState)(Pa);(0,G.useEffect)(()=>{let e=!0;return fetch(`/release-notes.json`,{cache:`no-store`}).then(e=>e.ok?e.json():null).then(t=>{e&&t&&f(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,G.useEffect)(()=>{let e=!0,t=(t=!1)=>r(`/api/sponsors/settings-updates?locale=${encodeURIComponent(i)}${t?`&refresh=1`:``}`).then(t=>{e&&m(Array.isArray(t.campaigns)?t.campaigns:[])}).catch(()=>{e&&!t&&m([])});t();let n=window.setInterval(()=>void t(!0),Ma);return()=>{e=!1,window.clearInterval(n)}},[i]);let b=e=>{let t={...v,[e]:Date.now()+Na};y(t);try{localStorage.setItem(ie.sponsorDismissals,JSON.stringify(t))}catch{}},x=async()=>{if(t){_(`check`);try{await t.check()}finally{_(``)}}},S=()=>t?.openReleases(),C=()=>t?.openUpdateLog?.(),w=async()=>{_(c?`install`:``);try{c?await t?.installComponents():await t?.download()}catch(t){e(t instanceof Error?t.message:String(t),`error`)}finally{_(``)}},T=()=>t?.install(),E=d.version===a.version?d:null,D=o.notes||(u?E?.notes||n(`config:updateSettings.noReleaseNotesAreAvailableForThisVersion`):o.state===`current`?n(`config:updateSettings.theCurrentWebSourceIsSyncedWithBranch`,{branch:o.branch||`main`}):n(`config:updateSettings.commitsThatHaveNotBeenSyncedWillAppearHereAfterTheCheck`)),O=o.state===`available`,k=o.state===`error`&&o.canResume&&o.canDownload,A=o.state===`downloaded`,j=o.state===`checking`||g===`check`,M=o.state===`downloading`||g===`install`,N=j?`checking`:M?`downloading`:o.state,ee=u?`v${a.version}`:`v${a.version}${o.currentCommit?` · ${o.currentCommit.slice(0,7)}`:``}`,P=u?`v${o.availableVersion||E?.version||a.version}`:o.availableCommit?.slice(0,7)||o.currentCommit?.slice(0,7)||d.version||a.version,F=p.filter(e=>(v[e.id]||0)<=Date.now()),I=(0,G.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]),te=(0,G.useMemo)(()=>({idle:[n(`config:updateSettings.notChecked`),`gray`],checking:[n(`config:updateSettings.checking`),`blue`],current:[n(`config:updateSettings.upToDate`),`green`],available:[n(u?`config:updateSettings.updateAvailable`:`config:updateSettings.sourceUpdatesAvailable`),`blue`],downloading:[n(`config:updateSettings.downloading`),`blue`],downloaded:[n(`config:updateSettings.readyToRestart`),`green`],installed:[n(`config:updateSettings.upToDate`),`green`],error:[n(k?`config:updateSettings.downloadPaused`:`config:updateSettings.checkFailed`),`red`]})[N]||[n(`config:updateSettings.notChecked`),`gray`],[u,N,k,n]);return(0,K.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-3`,children:[(0,K.jsxs)(Y,{className:`p-5`,"data-config-card":`updates-main`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,K.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,K.jsx)(Wr,{size:19})}),(0,K.jsx)(`span`,{className:`min-w-0`,children:(0,K.jsx)(`strong`,{className:`block text-[16px]`,children:n(`config:updateSettings.pisperAppUpdates`)})})]}),(0,K.jsx)(X,{tone:te[1],children:te[0]})]}),(0,K.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(u?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,K.jsx)(`strong`,{className:`mt-1 block font-mono text-[14px]`,children:ee})]}),(0,K.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`config:updateSettings.platform`)}),(0,K.jsx)(`strong`,{className:`mt-1 block text-[14px]`,children:Fa(a,n)})]}),(0,K.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`config:updateSettings.updateChannel`)}),(0,K.jsx)(`strong`,{className:`mt-1 block text-[14px]`,children:u?`Stable`:o.branch||`main`})]})]}),o.message&&(0,K.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,K.jsx)(H,{className:`mt-0.5 shrink-0`,size:15}):(0,K.jsx)(Ur,{className:`mt-0.5 shrink-0`,size:15}),(0,K.jsx)(`span`,{children:o.message})]}),k&&(0,K.jsx)(`small`,{className:`mt-2 block text-[12px] text-[var(--text-muted)]`,children:n(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),M&&(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-[12px] text-[var(--text-muted)]`,children:[(0,K.jsx)(`span`,{children:n(`config:updateSettings.downloadProgress`)}),(0,K.jsxs)(`span`,{children:[Math.round(o.percent||0),`% · `,Ia(o.transferred,i),` /`,` `,Ia(o.total,i)]})]}),(0,K.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-[var(--progress-track)]`,children:(0,K.jsx)(`i`,{className:`block h-full bg-[var(--star)] transition-[width]`,style:{width:`${o.percent||0}%`}})})]}),(0,K.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,K.jsxs)(s,{size:`lg`,disabled:j||M||!!g,onClick:A?T:O||k?w:x,children:[j||M?(0,K.jsx)(V,{className:`animate-spin`,size:14}):A?(0,K.jsx)(dt,{size:14}):O||k?o.canDownload?(0,K.jsx)(Qe,{size:14}):(0,K.jsx)(Le,{size:14}):(0,K.jsx)(V,{size:14}),j||M?n(M&&c?`config:updateSettings.installingUpdates`:`config:updateSettings.checking2`):A?n(`config:updateSettings.restartAndInstall`):k?n(`config:updateSettings.resumeDownload`):O?o.canDownload?n(c?`config:updateSettings.downloadAndInstallUpdates`:`config:updateSettings.downloadUpdate`):n(u?`config:updateSettings.viewRelease`:`config:updateSettings.viewSourceUpdates`):n(`config:updateSettings.checkForUpdates`)]}),(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:S,children:[(0,K.jsx)(Le,{size:14}),u?`GitHub Releases`:`GitHub Compare`]}),c&&(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:C,children:[(0,K.jsx)(Le,{size:14}),n(`config:updateSettings.viewUpdateDiagnosticLog`)]})]}),!l&&(0,K.jsxs)(`div`,{className:`mt-6 border-t border-[var(--border)] pt-5`,"data-config-card":`updates-components`,children:[(0,K.jsx)(ni,{title:n(`config:updateSettings.appComponents`)}),(0,K.jsx)(`div`,{className:`mt-3 divide-y divide-[var(--border)]`,children:I.map(e=>{let t=e.component===`desktop`?Ur:e.component===`tui`?be:zr,r=e.component===`desktop`?n(`config:updateSettings.desktopFrontend`):e.component===`tui`?n(`config:updateSettings.tuiClient`):n(`config:updateSettings.runtime`),a=e.state===`error`?`red`:e.state===`available`?`blue`:e.state===`installed`||e.state===`current`?`green`:`gray`,o=e.state===`checking`?n(`config:updateSettings.checking`):e.state===`downloading`?n(`config:updateSettings.downloading`):e.state===`available`?n(`config:updateSettings.updateAvailable`):e.state===`installed`?n(`config:updateSettings.installed`):e.state===`error`?n(`config:updateSettings.checkFailed`):e.state===`current`?n(`config:updateSettings.upToDate`):n(`config:updateSettings.notChecked`);return(0,K.jsxs)(`div`,{className:`grid min-h-[68px] items-center gap-3 py-3 sm:grid-cols-[minmax(0,1fr)_auto_auto]`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,K.jsx)(t,{className:`shrink-0 text-[var(--text-muted)]`,size:17}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`strong`,{className:`block text-[14px]`,children:r}),e.message&&(0,K.jsx)(`small`,{className:`mt-0.5 block text-[12px] text-[var(--text-muted)]`,children:e.message})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[12px]`,children:[(0,K.jsxs)(`span`,{children:[`v`,e.currentVersion]}),e.availableVersion&&e.availableVersion!==e.currentVersion&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ae,{size:12}),(0,K.jsxs)(`span`,{children:[`v`,e.availableVersion]})]}),e.size>0&&e.state===`available`&&(0,K.jsx)(`span`,{className:`font-sans text-[var(--text-muted)]`,children:Ia(e.size,i)})]}),(0,K.jsx)(X,{tone:a,children:o})]},e.component)})})]})]}),!l&&(0,K.jsx)(Aa,{notify:e}),(0,K.jsxs)(Y,{className:`p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(ni,{title:n(u?O||k||A||M?`config:updateSettings.newVersionReleaseNotes`:`config:updateSettings.currentReleaseNotes`:O?`config:updateSettings.commitsToSync`:`config:updateSettings.currentSourceStatus`)}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px] text-[var(--text-muted)]`,children:[(0,K.jsx)(Te,{size:13}),O||k||A||M?P:u?`v${E?.version||a.version}`:o.currentCommit?.slice(0,7)||n(`config:updateSettings.notChecked`)]})]}),(o.releaseDate||u&&E?.date)&&(0,K.jsx)(`small`,{className:`mt-2 block text-[12px] text-[var(--text-muted)]`,children:new Intl.DateTimeFormat(i,{dateStyle:`long`}).format(new Date(o.releaseDate||E?.date||``))}),(0,K.jsx)(`div`,{className:`mt-4 rounded-[var(--r-sm)] border border-[var(--stroke-soft)] bg-[var(--surface-subtle)] p-4`,children:(0,K.jsx)(xt,{children:D})})]}),F.length>0&&(0,K.jsxs)(Y,{className:`p-5`,"data-config-card":`updates-sponsors`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,K.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,K.jsx)(Vr,{size:19})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(ni,{title:n(`config:updateSettings.sponsors`)}),(0,K.jsx)(`small`,{className:`mt-1 block text-[12px] leading-5 text-[var(--text-muted)]`,children:n(`config:updateSettings.sponsorsDescription`)})]})]}),(0,K.jsx)(`div`,{className:`mt-4 divide-y divide-[var(--stroke-soft)] border-y border-[var(--stroke-soft)]`,children:F.map(e=>(0,K.jsxs)(`div`,{className:`grid min-h-16 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3 py-3`,children:[(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:`mb-1 flex items-center gap-2`,children:[(0,K.jsx)(`strong`,{className:`truncate text-[14px]`,children:e.name}),(0,K.jsx)(X,{tone:`gray`,children:n(`config:updateSettings.sponsored`)})]}),(0,K.jsx)(`small`,{className:`block text-[12px] leading-5 text-[var(--text-muted)]`,children:e.description})]}),(0,K.jsx)(s,{asChild:!0,variant:`outline`,className:`bg-surface-subtle`,children:(0,K.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer sponsored`,children:[(0,K.jsx)(Le,{size:13}),n(`config:updateSettings.visitSponsor`)]})}),(0,K.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0`,"aria-label":n(`config:updateSettings.hideSponsor`),title:n(`config:updateSettings.hideSponsor`),onClick:()=>b(e.id),children:(0,K.jsx)(Ce,{size:15})})]},e.id))})]})]})}function Ra({notify:e,registerPrimaryAction:t,section:n,onBrowserNotificationChange:r,requestConfirm:i,update:a}){de(n);let o;return o=n===`notifications`?(0,K.jsx)(Da,{notify:e,onBrowserNotificationChange:r}):n===`interface`?(0,K.jsx)(yi,{notify:e}):n===`shortcuts`?(0,K.jsx)(Ei,{requestConfirm:i}):n===`desktop-pet`?(0,K.jsx)(fi,{notify:e,requestConfirm:i}):n===`mobile-server`?(0,K.jsx)(va,{requestConfirm:i}):n===`remote-access`?(0,K.jsx)(ka,{notify:e}):n===`updates`?(0,K.jsx)(La,{notify:e,update:a}):n===`about`?(0,K.jsx)(li,{update:a}):(0,K.jsx)(ea,{notify:e,registerPrimaryAction:t,requestConfirm:i}),(0,K.jsx)(`div`,{"data-config-card":me,children:o})}export{Ra as ConfigPage};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{t as r}from"./api-B6CluO7V.js";import{i,n as a,o,t as s}from"./button-XhIEgIsg.js";import{d as c,g as l,h as u,m as d,p as f,r as p,s as m,t as h,u as g}from"./use-i18n-jYw5s_Yn.js";import{c as _,i as v,o as y,s as b}from"./use-mobile-C1OVAMOm.js";import{a as x,i as S,n as C,r as w,s as T,t as E,u as D}from"./es2015-DycjrqX-.js";import{n as O,t as k}from"./dist-cR3ayBwn.js";import{a as A,c as j,i as M,n as N,o as ee,r as P,s as F,t as I}from"./collapsible-U8Wh2f7S.js";import{n as te,r as ne,t as L}from"./AppSelect-kDqZkETY.js";import{t as R}from"./separator-Br2F2Mir.js";import{t as re}from"./utils-C8uzG5AZ.js";import{t as ie}from"./storage-BE5DCCG3.js";import{t as ae}from"./arrow-right-KWvgbo3p.js";import{t as z}from"./check-jIXqkGKr.js";import{t as oe}from"./chevron-down-DT6AXwTP.js";import{t as se}from"./code-xml-Z4K2ea1N.js";import{t as ce}from"./earth-DR_clkZ9.js";import{t as le}from"./loader-circle-72TYCcVQ.js";import{a as ue,i as de,o as fe,s as pe,t as me}from"./config-search-CdRsMMUS.js";import{n as he,t as ge}from"./zap-CFsp4Y1u.js";import{t as _e}from"./save-CVL5N6eP.js";import{t as ve}from"./send-DcLH_sg0.js";import{t as ye}from"./shield-check-BQHFfxVy.js";import{t as be}from"./square-terminal-DpCa0gzM.js";import{t as xe}from"./trash-2-mhzzyC6i.js";import{t as Se}from"./wrench-BqeVhocX.js";import{t as Ce}from"./x-bw26XDZM.js";import{A as we,At as Te,B as Ee,Bt as De,C as B,Ct as Oe,D as ke,E as Ae,Ft as je,Lt as Me,M as Ne,Mt as Pe,N as Fe,Nt as Ie,Ot as Le,P as Re,Pt as ze,Rt as Be,S as Ve,T as He,Tt as Ue,Vt as We,_t as Ge,a as Ke,b as qe,bt as V,dt as Je,gt as Ye,ht as H,i as U,j as Xe,k as Ze,kt as Qe,l as $e,n as et,o as tt,r as nt,s as rt,t as it,v as at,vt as ot,w as st,x as ct,xt as lt,y as ut,yt as dt,zt as ft}from"./index-Bd5A8V1V.js";import{t as W}from"./field-t72VAR-1.js";import{a as pt,c as mt,d as ht,l as gt,s as _t,t as vt,u as yt}from"./shortcuts-BIzphxhz.js";import{t as bt}from"./usePagePrimaryAction-Bw0OFTDZ.js";import{t as xt}from"./MarkdownMessage-Dbgb5XkJ.js";import{t as St}from"./brand-DIEc3fK8.js";var G=e(t(),1),K=n(),Ct=Object.defineProperty,q=(e,t)=>Ct(e,`name`,{value:t,configurable:!0}),wt=[`Enter`,` `],Tt=[`ArrowDown`,`PageUp`,`Home`],Et=[`ArrowUp`,`PageDown`,`End`],Dt=[...Tt,...Et];[...wt],[...wt];var Ot=`Menu`,[kt,At,jt]=We(Ot),[Mt,Nt]=d(Ot,[jt,_,ft]),Pt=_(),Ft=ft(),[It,Lt]=Mt(Ot),[Rt,zt]=Mt(Ot),Bt=q(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Pt(t),[c,l]=G.useState(null),u=G.useRef(!1),d=k(a),f=De(i);return G.useEffect(()=>{let e=q(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=q(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),G.useEffect(()=>{if(!n)return;let e=q(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,K.jsx)(b,{...s,children:(0,K.jsx)(It,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,K.jsx)(Rt,{scope:t,onClose:G.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),Vt=G.forwardRef(q(function(e,t){let{__scopeMenu:n,...r}=e,i=Pt(n);return(0,K.jsx)(v,{...i,...r,ref:t})},`MenuAnchor`)),Ht=`MenuPortal`,[Ut,Wt]=Mt(Ht,{forceMount:void 0}),Gt=q(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Lt(Ht,t);return(0,K.jsx)(Ut,{scope:t,forceMount:n,children:(0,K.jsx)(D,{present:n||a.open,children:(0,K.jsx)(S,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Kt=`MenuContent`,[qt,Jt]=Mt(Kt),Yt=G.forwardRef(q(function(e,t){let n=Wt(Kt,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Lt(Kt,e.__scopeMenu),o=zt(Kt,e.__scopeMenu);return(0,K.jsx)(kt.Provider,{scope:e.__scopeMenu,children:(0,K.jsx)(D,{present:r||a.open,children:(0,K.jsx)(kt.Slot,{scope:e.__scopeMenu,children:o.modal?(0,K.jsx)(Xt,{...i,ref:t}):(0,K.jsx)(Zt,{...i,ref:t})})})})},`MenuContent`)),Xt=G.forwardRef(q(function(e,t){let n=Lt(Kt,e.__scopeMenu),r=G.useRef(null),i=o(t,r);return G.useEffect(()=>{let e=r.current;if(e)return E(e)},[]),(0,K.jsx)($t,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:f(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Zt=G.forwardRef(q(function(e,t){let n=Lt(Kt,e.__scopeMenu);return(0,K.jsx)($t,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Qt=i(`MenuContent.ScrollLock`),$t=G.forwardRef(q(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:h,disableOutsideScroll:g,..._}=e,v=Lt(Kt,n),b=zt(Kt,n),S=Pt(n),E=Ft(n),D=At(n),[O,k]=G.useState(null),A=G.useRef(null),j=o(t,A,v.onContentChange),M=G.useRef(0),N=G.useRef(``),ee=G.useRef(0),P=G.useRef(null),F=G.useRef(`right`),I=G.useRef(0),te=g?C:G.Fragment,ne=g?{as:Qt,allowPinchZoom:!0}:void 0,L=q(e=>{let t=N.current+e,n=D().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=gn(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;q((function e(t){N.current=t,window.clearTimeout(M.current),t!==``&&(M.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);G.useEffect(()=>()=>window.clearTimeout(M.current),[]),w();let R=G.useCallback(e=>F.current===P.current?.side&&vn(e,P.current?.area),[]);return(0,K.jsx)(qt,{scope:n,searchRef:N,onItemEnter:G.useCallback(e=>{R(e)&&e.preventDefault()},[R]),onItemLeave:G.useCallback(e=>{R(e)||(A.current?.focus(),k(null))},[R]),onTriggerLeave:G.useCallback(e=>{R(e)&&e.preventDefault()},[R]),pointerGraceTimerRef:ee,onPointerGraceIntentChange:G.useCallback(e=>{P.current=e},[]),children:(0,K.jsx)(te,{...ne,children:(0,K.jsx)(x,{asChild:!0,trapped:i,onMountAutoFocus:f(a,e=>{e.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:(0,K.jsx)(T,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:h,children:(0,K.jsx)(Be,{asChild:!0,...E,dir:b.dir,orientation:`vertical`,loop:r,currentTabStopId:O,onCurrentTabStopIdChange:k,onEntryFocus:f(l,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,K.jsx)(y,{role:`menu`,"aria-orientation":`vertical`,"data-state":dn(v.open),"data-radix-menu-content":``,dir:b.dir,...S,..._,ref:j,style:{outline:`none`,..._.style},onKeyDown:f(_.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&L(e.key));let i=A.current;if(e.target!==i||!Dt.includes(e.key))return;e.preventDefault();let a=D().filter(e=>!e.disabled).map(e=>e.ref.current);Et.includes(e.key)&&a.reverse(),mn(a)}),onBlur:f(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),N.current=``)}),onPointerMove:f(e.onPointerMove,yn(e=>{let t=e.target,n=I.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>I.current?`right`:`left`;F.current=t,I.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),en=`MenuItem`,tn=`menu.itemSelect`,nn=G.forwardRef(q(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=G.useRef(null),s=zt(en,e.__scopeMenu),c=Jt(en,e.__scopeMenu),u=o(t,a),d=G.useRef(!1),p=q(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(tn,{bubbles:!0,cancelable:!0});e.addEventListener(tn,e=>r?.(e),{once:!0}),l(e,t),t.defaultPrevented?d.current=!1:s.onClose()}},`handleSelect`);return(0,K.jsx)(rn,{...i,ref:u,disabled:n,onClick:f(e.onClick,p),onPointerDown:t=>{e.onPointerDown?.(t),d.current=!0},onPointerUp:f(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:f(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(c.searchRef.current===``||e.key!==` `)&&wt.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),rn=G.forwardRef(q(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,s=Jt(en,n),c=Ft(n),l=G.useRef(null),d=o(t,l),[p,m]=G.useState(!1),[h,g]=G.useState(``);return G.useEffect(()=>{let e=l.current;e&&g((e.textContent??``).trim())},[a.children]),(0,K.jsx)(kt.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,K.jsx)(Me,{asChild:!0,...c,focusable:!r,children:(0,K.jsx)(u.div,{role:`menuitem`,"data-highlighted":p?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:d,onPointerMove:f(e.onPointerMove,yn(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:f(e.onPointerLeave,yn(e=>s.onItemLeave(e))),onFocus:f(e.onFocus,()=>m(!0)),onBlur:f(e.onBlur,()=>m(!1))})})})},`MenuItemImpl`)),[an,on]=Mt(`MenuRadioGroup`,{value:void 0,onValueChange:q(()=>{},`onValueChange`)}),[sn,cn]=Mt(`MenuItemIndicator`,{checked:!1}),[ln,un]=Mt(`MenuSub`);function dn(e){return e?`open`:`closed`}q(dn,`getOpenState`);function fn(e){return e===`indeterminate`}q(fn,`isIndeterminate`);function pn(e){return fn(e)?`indeterminate`:e?`checked`:`unchecked`}q(pn,`getCheckedState`);function mn(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}q(mn,`focusFirst`);function hn(e,t){return e.map((n,r)=>e[(t+r)%e.length])}q(hn,`wrapArray`);function gn(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=hn(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}q(gn,`getNextMatch`);function _n(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}q(_n,`isPointInPolygon`);function vn(e,t){return t?_n({x:e.clientX,y:e.clientY},t):!1}q(vn,`isPointerInGraceArea`);function yn(e){return t=>t.pointerType===`mouse`?e(t):void 0}q(yn,`whenMouse`);var bn=Bt,xn=Vt,Sn=Gt,Cn=Yt,wn=nn,Tn=Object.defineProperty,En=(e,t)=>Tn(e,`name`,{value:t,configurable:!0}),Dn=`DropdownMenu`,[On,kn]=d(Dn,[Nt]),An=Nt(),[jn,Mn]=On(Dn),Nn=En(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,l=An(t),u=G.useRef(null),[d,f]=c({prop:i,defaultProp:a??!1,onChange:o,caller:Dn});return(0,K.jsx)(jn,{scope:t,triggerId:O(),triggerRef:u,contentId:O(),open:d,onOpenChange:f,onOpenToggle:G.useCallback(()=>f(e=>!e),[f]),modal:s,children:(0,K.jsx)(bn,{...l,open:d,onOpenChange:f,dir:r,modal:s,children:n})})},`DropdownMenu`),Pn=`DropdownMenuTrigger`,Fn=G.forwardRef(En(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Mn(Pn,n),s=An(n),c=o(t,a.triggerRef);return(0,K.jsx)(xn,{asChild:!0,...s,children:(0,K.jsx)(u.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:c,onPointerDown:f(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:f(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),In=En(e=>{let{__scopeDropdownMenu:t,...n}=e,r=An(t);return(0,K.jsx)(Sn,{...r,...n})},`DropdownMenuPortal`),Ln=`DropdownMenuContent`,Rn=G.forwardRef(En(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Mn(Ln,n),a=An(n),o=G.useRef(!1);return(0,K.jsx)(Cn,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:f(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:f(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),zn=G.forwardRef(En(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=An(n);return(0,K.jsx)(wn,{...i,...r,ref:t})},`DropdownMenuItem`)),Bn=Nn,Vn=Fn,Hn=In,Un=Rn,Wn=zn,Gn=Object.defineProperty,J=(e,t)=>Gn(e,`name`,{value:t,configurable:!0}),Kn=[`PageUp`,`PageDown`],qn=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`],Jn={"from-left":[`Home`,`PageDown`,`ArrowDown`,`ArrowLeft`],"from-right":[`Home`,`PageDown`,`ArrowDown`,`ArrowRight`],"from-bottom":[`Home`,`PageDown`,`ArrowDown`,`ArrowLeft`],"from-top":[`Home`,`PageDown`,`ArrowUp`,`ArrowLeft`]},Yn=`Slider`,[Xn,Zn,Qn]=We(Yn),[$n,er]=d(Yn,[Qn]),[tr,nr]=$n(Yn),rr=G.forwardRef(J(function(e,t){let{name:n,min:r=0,max:i=100,step:a=1,orientation:s=`horizontal`,disabled:l=!1,minStepsBetweenThumbs:u=0,defaultValue:d=[r],value:p,onValueChange:m=J(()=>{},`onValueChange`),onValueCommit:h=J(()=>{},`onValueCommit`),inverted:g=!1,form:_,...v}=e,y=G.useRef(new Set),b=G.useRef(0),x=G.useRef(!1),S=s===`horizontal`?or:sr,[C,w]=G.useState(null),T=o(t,w),[E=[],D]=c({prop:p,defaultProp:d,onChange:J(e=>{[...y.current][b.current]?.focus({preventScroll:!0,focusVisible:x.current}),x.current=!1,m(e)},`onChange`)}),O=G.useRef(E),k=G.useRef(E);G.useEffect(()=>{let e=_?C?.ownerDocument.getElementById(_):C?.closest(`form`);if(e instanceof HTMLFormElement){let t=J(()=>D(k.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[C,_,D]);function A(e){N(e,Tr(E,e))}J(A,`handleSlideStart`);function j(e){N(e,b.current)}J(j,`handleSlideMove`);function M(){String(E)!==String(O.current)&&h(E)}J(M,`handleSlideEnd`);function N(e,t,{commit:n}={commit:!1}){let o=Ar(a),s=jr(Math.round((e-r)/a)*a+r,o),c=te(s,[r,i]);D((e=[])=>{let r=Sr(e,c,t);if(Or(r,u*a)){b.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&h(r),t?r:e}return e})}return J(N,`updateValues`),(0,K.jsx)(tr,{scope:e.__scopeSlider,name:n,disabled:l,min:r,max:i,valueIndexToChangeRef:b,thumbs:y.current,values:E,orientation:s,form:_,children:(0,K.jsx)(Xn.Provider,{scope:e.__scopeSlider,children:(0,K.jsx)(Xn.Slot,{scope:e.__scopeSlider,children:(0,K.jsx)(S,{"aria-disabled":l,"data-disabled":l?``:void 0,...v,ref:T,onPointerDown:f(v.onPointerDown,()=>{l||(O.current=E,x.current=!1)}),min:r,max:i,inverted:g,onSlideStart:l?void 0:A,onSlideMove:l?void 0:j,onSlideEnd:l?void 0:M,onHomeKeyDown:()=>{l||(x.current=!0,N(r,0,{commit:!0}))},onEndKeyDown:()=>{l||(x.current=!0,N(i,E.length-1,{commit:!0}))},onStepKeyDown:({event:e,direction:t})=>{if(!l){x.current=!0;let n=Kn.includes(e.key)||e.shiftKey&&qn.includes(e.key)?10:1,i=b.current,o=E[i];N(Mr(o,{min:r,step:a,direction:t,multiplier:n}),i,{commit:!0})}}})})})})},`Slider`)),[ir,ar]=$n(Yn,{startEdge:`left`,endEdge:`right`,size:`width`,direction:1}),or=G.forwardRef(J(function(e,t){let{min:n,max:r,dir:i,inverted:a,onSlideStart:s,onSlideMove:c,onSlideEnd:l,onStepKeyDown:u,...d}=e,[f,p]=G.useState(null),m=o(t,p),h=G.useRef(void 0),g=De(i),_=g===`ltr`,v=_&&!a||!_&&a;function y(e){let t=h.current||f.getBoundingClientRect(),i=kr([0,t.width],v?[n,r]:[r,n]);return h.current=t,i(e-t.left)}return J(y,`getValueFromPointer`),(0,K.jsx)(ir,{scope:e.__scopeSlider,startEdge:v?`left`:`right`,endEdge:v?`right`:`left`,direction:v?1:-1,size:`width`,children:(0,K.jsx)(cr,{dir:g,"data-orientation":`horizontal`,...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":`translateX(-50%)`},onSlideStart:e=>{let t=y(e.clientX);s?.(t)},onSlideMove:e=>{let t=y(e.clientX);c?.(t)},onSlideEnd:()=>{h.current=void 0,l?.()},onStepKeyDown:e=>{let t=Jn[v?`from-left`:`from-right`].includes(e.key);u?.({event:e,direction:t?-1:1})}})})},`SliderHorizontal`)),sr=G.forwardRef(J(function(e,t){let{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...u}=e,d=G.useRef(null),f=o(t,d),p=G.useRef(void 0),m=!i;function h(e){let t=p.current||d.current.getBoundingClientRect(),i=kr([0,t.height],m?[r,n]:[n,r]);return p.current=t,i(e-t.top)}return J(h,`getValueFromPointer`),(0,K.jsx)(ir,{scope:e.__scopeSlider,startEdge:m?`bottom`:`top`,endEdge:m?`top`:`bottom`,size:`height`,direction:m?1:-1,children:(0,K.jsx)(cr,{"data-orientation":`vertical`,...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":`translateY(50%)`},onSlideStart:e=>{let t=h(e.clientY);a?.(t)},onSlideMove:e=>{let t=h(e.clientY);s?.(t)},onSlideEnd:()=>{p.current=void 0,c?.()},onStepKeyDown:e=>{let t=Jn[m?`from-bottom`:`from-top`].includes(e.key);l?.({event:e,direction:t?-1:1})}})})},`SliderVertical`)),cr=G.forwardRef(J(function(e,t){let{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:s,onStepKeyDown:c,...l}=e,d=nr(Yn,n);return(0,K.jsx)(u.span,{...l,ref:t,onKeyDown:f(e.onKeyDown,e=>{e.key===`Home`?(o(e),e.preventDefault()):e.key===`End`?(s(e),e.preventDefault()):Kn.concat(qn).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:f(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus({preventScroll:!0,focusVisible:!1}):r(e)}),onPointerMove:f(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:f(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),a(e))})})},`SliderImpl`)),lr=`SliderTrack`,ur=G.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=nr(lr,n);return(0,K.jsx)(u.span,{"data-disabled":i.disabled?``:void 0,"data-orientation":i.orientation,...r,ref:t})},`SliderTrack`)),dr=`SliderRange`,fr=G.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=nr(dr,n),a=ar(dr,n),s=G.useRef(null),c=o(t,s),l=i.values.length,d=i.values.map(e=>Cr(e,i.min,i.max)),f=l>1?Math.min(...d):0,p=100-Math.max(...d);return(0,K.jsx)(u.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?``:void 0,...r,ref:c,style:{...e.style,[a.startEdge]:f+`%`,[a.endEdge]:p+`%`}})},`SliderRange`)),[pr,mr]=$n(`SliderThumb`),hr=`SliderThumbProvider`;function gr(e){let{__scopeSlider:t,name:n,children:r,internal_do_not_use_render:i}=e,a=nr(hr,t),o=Zn(t),[s,c]=G.useState(null),l=G.useMemo(()=>s?o().findIndex(e=>e.ref.current===s):-1,[o,s]),u=g(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:Cr(f,a.min,a.max);G.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,K.jsx)(pr,{scope:t,...h,children:Nr(i)?i(h):r})}J(gr,`SliderThumbProvider`);var _r=`SliderThumbTrigger`,vr=G.forwardRef(J(function(e,t){let{__scopeSlider:n,...r}=e,i=nr(_r,n),a=ar(_r,n),{index:s,value:c,percent:l,size:d,onThumbChange:p}=mr(_r,n),m=o(t,p),h=wr(s,i.values.length),g=d?.[a.size],_=g?Er(g,l,a.direction):0;return(0,K.jsx)(`span`,{style:{transform:`var(--radix-slider-thumb-transform)`,position:`absolute`,[a.startEdge]:`calc(${l}% + ${_}px)`},children:(0,K.jsx)(Xn.ItemSlot,{scope:n,children:(0,K.jsx)(u.span,{role:`slider`,"aria-label":e[`aria-label`]||h,"aria-valuemin":i.min,"aria-valuenow":c,"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:c===void 0?{display:`none`}:e.style,onFocus:f(e.onFocus,()=>{i.valueIndexToChangeRef.current=s})})})})},`SliderThumbTrigger`)),yr=G.forwardRef(J(function(e,t){let{__scopeSlider:n,name:r,...i}=e;return(0,K.jsx)(gr,{__scopeSlider:n,name:r,internal_do_not_use_render:({index:e,isFormControl:r})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(vr,{...i,ref:t,__scopeSlider:n}),r?(0,K.jsx)(xr,{__scopeSlider:n},e):null]})})},`SliderThumb`)),br=`SliderBubbleInput`,xr=G.forwardRef(J(function({__scopeSlider:e,...t},n){let{value:r,name:i,form:a}=mr(br,e),s=G.useRef(null),c=o(s,n),l=ne(r);return G.useEffect(()=>{let e=s.current;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(l!==r&&n){let t=new Event(`input`,{bubbles:!0});n.call(e,r),e.dispatchEvent(t)}},[l,r]),(0,K.jsx)(u.input,{style:{display:`none`},name:i,form:a,...t,ref:c,defaultValue:r})},`SliderBubbleInput`));function Sr(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}J(Sr,`getNextSortedValues`);function Cr(e,t,n){let r=100/(n-t)*(e-t);return te(r,[0,100])}J(Cr,`convertValueToPercentage`);function wr(e,t){if(t>2)return`Value ${e+1} of ${t}`;if(t===2)return[`Minimum`,`Maximum`][e]}J(wr,`getLabel`);function Tr(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(Tr,`getClosestValueIndex`);function Er(e,t,n){let r=e/2;return(r-kr([0,50],[0,r])(t)*n)*n}J(Er,`getThumbInBoundsOffset`);function Dr(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}J(Dr,`getStepsBetweenValues`);function Or(e,t){if(t>0){let n=Dr(e);return Math.min(...n)>=t}return!0}J(Or,`hasMinStepsBetweenValues`);function kr(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(kr,`linearScale`);function Ar(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(Ar,`getDecimalCount`);function jr(e,t){let n=10**t;return Math.round(e*n)/n}J(jr,`roundValue`);function Mr(e,{min:t,step:n,direction:r,multiplier:i}){let a=Ar(n),o=(e-t)/n,s=Math.round(o),c=jr(s*n+t,a)===jr(e,a),l;return l=c?s+i*r:r>0?Math.ceil(o):Math.floor(o),jr(l*n+t,a)}J(Mr,`getNextStepValue`);function Nr(e){return typeof e==`function`}J(Nr,`isFunction`);var Pr=a(`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`}]]),Fr=a(`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`}]]),Ir=a(`blend`,[[`circle`,{cx:`9`,cy:`9`,r:`7`,key:`p2h5vp`}],[`circle`,{cx:`15`,cy:`15`,r:`7`,key:`19ennj`}]]),Lr=a(`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`}]]),Rr=a(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),zr=a(`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`}]]),Br=a(`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`}]]),Vr=a(`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`}]]),Hr=a(`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`}]]),Ur=a(`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`}]]),Wr=a(`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`}]]),Gr=a(`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`}]]),Kr=a(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),qr=a(`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`}]]),Jr=a(`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`}]]),Yr=a(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),Xr=a(`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`}]]),Zr=a(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Qr=a(`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`}]]),$r=a(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),ei=a(`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`}]]),ti=a(`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`}]]),Y=it,ni=tt,X=$e;function ri(e){return(0,K.jsx)(rt,{density:`compact`,...e})}var ii=`0.5.48`,ai=`https://ling-kong-ran.github.io/pisper/`,oi=`https://github.com/ling-kong-ran/pisper`,si=`${oi}/blob/release/LICENSE`;function ci({href:e,icon:t,label:n,value:r}){return(0,K.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`,children:[(0,K.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,K.jsx)(t,{size:16})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`strong`,{className:`block text-[13px] text-[var(--text)]`,children:n}),(0,K.jsx)(`small`,{className:`mt-0.5 block truncate text-[12px] text-[var(--text-muted)]`,children:r})]}),(0,K.jsx)(Le,{className:`text-[var(--text-muted)] transition-colors group-hover:text-[var(--star-strong)]`,size:14})]})}function li({update:e}){let{t}=h(),n=e.info?.version||ii;return(0,K.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 px-1 py-3`,children:[(0,K.jsx)(`img`,{className:`size-16 shrink-0 rounded-[14px] shadow-[0_10px_28px_-14px_var(--shadow)]`,src:`/favicon.svg`,alt:`Pisper`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h1`,{className:`text-[22px] font-bold tracking-[0]`,children:`Pisper`}),(0,K.jsxs)(X,{tone:`gray`,children:[`v`,n]})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[13px] leading-5 text-[var(--text-muted)]`,children:t(`config:aboutSettings.description`)})]})]}),(0,K.jsxs)(Y,{className:`p-5`,"data-config-card":`about-project`,children:[(0,K.jsx)(ni,{title:t(`config:aboutSettings.projectInformation`)}),(0,K.jsxs)(`div`,{className:`mt-3 divide-y divide-[var(--stroke-soft)] border-y border-[var(--stroke-soft)]`,children:[(0,K.jsx)(ci,{href:ai,icon:ce,label:t(`config:aboutSettings.website`),value:`ling-kong-ran.github.io/pisper`}),(0,K.jsx)(ci,{href:oi,icon:se,label:t(`config:aboutSettings.sourceCode`),value:`github.com/ling-kong-ran/pisper`}),(0,K.jsx)(ci,{href:si,icon:Yr,label:t(`config:aboutSettings.license`),value:`MIT License`})]})]}),(0,K.jsx)(Y,{className:`p-5`,"data-config-card":`about-support`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 max-[540px]:flex-col max-[540px]:items-stretch`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(ni,{title:t(`config:aboutSettings.supportPisper`)}),(0,K.jsx)(`p`,{className:`mt-1 max-w-[520px] text-[13px] leading-5 text-[var(--text-muted)]`,children:t(`config:aboutSettings.supportDescription`)})]}),(0,K.jsx)(s,{asChild:!0,size:`lg`,className:`max-[540px]:w-full`,children:(0,K.jsxs)(`a`,{href:oi,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(Qr,{size:15}),t(`config:aboutSettings.starOnGitHub`)]})})]})}),(0,K.jsx)(`p`,{className:`px-1 py-2 text-center text-[12px] text-[var(--text-muted)]`,children:t(`config:aboutSettings.copyright`)})]})}function ui({className:e,defaultValue:t,value:n,min:r=0,max:i=100,...a}){let o=G.useMemo(()=>Array.isArray(n)?n:Array.isArray(t)?t:[r,i],[n,t,r,i]);return(0,K.jsxs)(rr,{"data-slot":`slider`,defaultValue:t,value:n,min:r,max:i,className:re(`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,K.jsx)(ur,{"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,K.jsx)(fr,{"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,K.jsx)(yr,{"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 di(e){window.dispatchEvent(new CustomEvent(`pisper:desktop-pet-changed`,{detail:e}))}function fi({notify:e,requestConfirm:t}){let{t:n}=h(),i=window.pisperDesktop,a=(0,G.useMemo)(()=>i?.getPetStatus?{getStatus:()=>i.getPetStatus(),setEnabled:e=>i.setPetEnabled(e),setOpacity:e=>i.setPetOpacity(e),search:e=>i.searchPets(e),install:e=>i.installPet(e),select:e=>i.selectPet(e),remove:e=>i.removePet(e),openCatalog:()=>void i.openPetdex?.()}:{getStatus:()=>r(`/api/desktop-pet`),setEnabled:e=>r(`/api/desktop-pet/enabled`,{method:`POST`,body:{enabled:e}}),setOpacity:e=>r(`/api/desktop-pet/opacity`,{method:`POST`,body:{opacity:e}}),search:e=>r(`/api/desktop-pet/catalog?query=${encodeURIComponent(e)}`),install:e=>r(`/api/desktop-pet/install`,{method:`POST`,body:{slug:e}}),select:e=>r(`/api/desktop-pet/select`,{method:`POST`,body:{slug:e}}),remove:e=>r(`/api/desktop-pet/${encodeURIComponent(e)}`,{method:`DELETE`}),openCatalog:()=>window.open(`https://petdex.dev`,`_blank`,`noopener,noreferrer`)},[i]),[o,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(100),[g,_]=(0,G.useState)(``),[v,y]=(0,G.useState)(``),b=(0,G.useCallback)(e=>{c(e),m(Math.round((e.opacity??1)*100))},[]),x=(0,G.useCallback)(async()=>{try{y(``),b(await a.getStatus())}catch(e){y(e instanceof Error?e.message:String(e))}},[b,a]),S=(0,G.useCallback)(async()=>{_(`search`);try{y(``),f(await a.search(l))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(``)}},[a,l]);(0,G.useEffect)(()=>{x(),a.search(``).then(f).catch(()=>{})},[a,x]);let C=async t=>{let r=o;c(e=>e&&{...e,enabled:t,running:!!(t&&e.installed.length)}),_(`toggle`);try{y(``);let r=await a.setEnabled(t);b(r),di(r),e(n(t?`config:desktopPetSettings.petEnabled`:`config:desktopPetSettings.petDisabled`))}catch(e){c(r),y(e instanceof Error?e.message:String(e))}finally{_(``)}},w=async e=>{_(`opacity`);try{y(``);let t=await a.setOpacity(e);b(t),di(t)}catch(e){m(Math.round((o?.opacity??1)*100)),y(e instanceof Error?e.message:String(e))}finally{_(``)}},T=async(t=l)=>{if(t.trim()){_(`install`);try{y(``);let r=await a.install(t);b(r),di(r),e(n(`config:desktopPetSettings.petInstalled`,{name:r.selectedName||t}))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(``)}}},E=async t=>{if(t!==o?.selectedSlug){_(`select:${t}`);try{y(``);let r=await a.select(t);b(r),di(r),e(n(`config:desktopPetSettings.petSelected`,{name:r.selectedName||t}))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(``)}}},D=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`})){_(`remove:${r.slug}`);try{y(``);let t=await a.remove(r.slug);b(t),di(t),e(n(`config:desktopPetSettings.petRemoved`,{name:r.name}))}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(``)}}};return(0,K.jsxs)(`div`,{className:`flex flex-col gap-[12px] desktop-pet-settings`,children:[(0,K.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-settings`,children:[(0,K.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,K.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,K.jsx)(Lr,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:n(`config:desktopPetSettings.title`)}),(0,K.jsx)(`p`,{children:n(`config:desktopPetSettings.description`)})]})]}),o?(0,K.jsxs)(`div`,{className:`max-w-1/2`,children:[(0,K.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,K.jsx)(Lr,{size:18}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`font-bold`,children:n(`config:desktopPetSettings.showOnDesktop`)}),` `,(0,K.jsx)(X,{tone:o.running?`green`:`gray`,children:o.running?n(`config:desktopPetSettings.running`):n(`config:desktopPetSettings.stopped`)})]}),(0,K.jsx)(`span`,{className:`text-xs`,children:o.selectedName?n(`config:desktopPetSettings.currentPet`,{name:o.selectedName}):n(`config:desktopPetSettings.installBeforeEnabling`)})]}),(0,K.jsx)(ri,{value:o.enabled,disabled:!!g||!o.installed.length,onChange:C,ariaLabel:n(`config:desktopPetSettings.showOnDesktop`),className:`ml-4`})]}),o&&(0,K.jsxs)(`div`,{className:`flex items-center snotification-option gap-2.75 mt-4`,children:[(0,K.jsx)(Ir,{size:18}),(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,K.jsx)(`span`,{className:`font-bold`,children:n(`config:desktopPetSettings.opacity`)}),(0,K.jsxs)(`span`,{className:`text-xs`,children:[p,`%`]})]}),(0,K.jsx)(ui,{value:[p],min:20,max:100,step:5,disabled:g===`opacity`,onValueChange:([e])=>m(e),onValueCommit:([e])=>void w(e/100),"aria-label":n(`config:desktopPetSettings.opacity`),className:`flex-1 w-auto ml-4`})]})]}):(0,K.jsxs)(Ke,{className:`[margin-top:15px]`,children:[(0,K.jsx)(V,{className:`animate-spin`,size:16}),(0,K.jsx)(`span`,{children:n(`config:desktopPetSettings.loading`)})]}),v&&(0,K.jsx)(`div`,{className:`text-[var(--danger)] text-[13px] mt-3`,children:v})]}),(0,K.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-install`,children:[(0,K.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,K.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,K.jsx)(Qe,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:n(`config:desktopPetSettings.installTitle`)}),(0,K.jsx)(`p`,{children:n(`config:desktopPetSettings.installDescription`)})]})]}),(0,K.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,K.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:n(`config:desktopPetSettings.searchPlaceholder`),"aria-label":n(`config:desktopPetSettings.petSlug`)}),(0,K.jsxs)(s,{size:`lg`,className:`min-w-[104px]`,disabled:g===`search`,onClick:S,children:[g===`search`?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(ot,{size:14}),n(`config:desktopPetSettings.search`)]})]}),d.length>0&&(0,K.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:d.map(e=>{let t=o?.installed.some(t=>t.slug===e.slug);return(0,K.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:!!g,onClick:()=>t?E(e.slug):T(e.slug),children:[(0,K.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,K.jsx)(Lr,{size:16})}),(0,K.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,K.jsx)(`strong`,{children:e.displayName}),(0,K.jsx)(`small`,{children:e.slug})]}),(0,K.jsx)(X,{tone:t?`green`:`blue`,children:n(t?`config:desktopPetSettings.installed`:`config:desktopPetSettings.install`)})]},e.slug)})}),(0,K.jsx)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:a.openCatalog,children:[(0,K.jsx)(Le,{size:14}),n(`config:desktopPetSettings.browsePetdex`)]})})]}),o&&o.installed.length>0&&(0,K.jsxs)(Y,{className:`[padding:18px]`,"data-config-card":`desktop-pet-installed`,children:[(0,K.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,K.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,K.jsx)(Lr,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:n(`config:desktopPetSettings.installedTitle`)}),(0,K.jsx)(`p`,{children:n(`config:desktopPetSettings.installedDescription`)})]})]}),(0,K.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:o.installed.map(e=>{let t=e.slug===o.selectedSlug;return(0,K.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,K.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:!!g,onClick:()=>E(e.slug),children:[(0,K.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,K.jsx)(Lr,{size:16})}),(0,K.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,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`small`,{children:e.slug})]}),(0,K.jsx)(X,{tone:e.source===`pisper`?`blue`:`gray`,children:e.source===`pisper`?`Pisper`:`Petdex`})]}),e.source===`pisper`&&(0,K.jsx)(s,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`text-content-muted hover:text-destructive`,disabled:!!g,onClick:()=>void D(e),"aria-label":n(`config:desktopPetSettings.delete`),title:n(`config:desktopPetSettings.delete`),children:g===`remove:${e.slug}`?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(xe,{size:14})})]},`${e.source}:${e.slug}`)})})]})]})}function pi(e,t){return t(e===`en-US`?`config:languageSettings.english`:`config:languageSettings.simplifiedChinese`)}function mi({notify:e}){let{language:t,setLanguage:n,t:r}=h(),i=r=>{r!==t&&(n(r),e(m(r===`en-US`?`config:languageSettings.displayLanguageChangedToEnglish`:`config:languageSettings.displayLanguageChangedToSimplifiedChinese`,r)))};return(0,K.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-language`,children:[(0,K.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,K.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,K.jsx)(Hr,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:r(`config:languageSettings.displayLanguage`)}),(0,K.jsx)(`p`,{children:r(`config:languageSettings.chooseTheLanguageUsedByPisperChangesApplyImmediatelyAndAreSavedForYourNextVisit`)})]})]}),(0,K.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:p.map(e=>{let n=e.value===t;return(0,K.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,K.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,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[3px] [&_small]:text-[var(--text-muted)] [&_strong]:text-[13px]`,children:[(0,K.jsx)(`strong`,{children:pi(e.value,r)}),(0,K.jsx)(`small`,{children:e.value===`zh-CN`?r(`config:languageSettings.chineseInterface`):r(`config:languageSettings.englishInterface`)})]}),n&&(0,K.jsx)(`span`,{className:`grid size-[21px] place-items-center rounded-full bg-[var(--star)] text-[var(--on-accent)]`,children:(0,K.jsx)(z,{size:15})})]},e.value)})}),(0,K.jsxs)(Ke,{className:`mt-[15px]`,children:[(0,K.jsx)(Hr,{size:16}),(0,K.jsxs)(`span`,{children:[(0,K.jsxs)(`strong`,{children:[r(`config:languageSettings.currentLanguage`),` · `,pi(t,r)]}),(0,K.jsx)(`small`,{children:r(`config:languageSettings.thisSettingChangesInterfaceTextOnlyItDoesNotControlTheLanguageOfAgentResponses`)})]})]})]})}function hi({icon:e,title:t,description:n}){return(0,K.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,K.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,K.jsx)(e,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:t}),(0,K.jsx)(`p`,{children:n})]})]})}function gi({label:e,options:t,value:n,onChange:r,className:i}){return(0,K.jsx)(`div`,{className:re(`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,K.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,K.jsx)(`span`,{className:`grid size-8 place-items-center rounded-[var(--r-xs)] bg-[var(--solid)] text-[var(--star-strong)]`,children:(0,K.jsx)(i,{size:16})}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,K.jsx)(`strong`,{className:`text-[13px]`,children:e.label}),(0,K.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:e.description})]}),t&&(0,K.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-[var(--star)] text-[var(--on-accent)]`,children:(0,K.jsx)(z,{size:13})})]},e.value)})})}function _i({label:e,options:t,value:n,onChange:r}){return(0,K.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,K.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 vi={neutral:`#18181b`,blue:`#1677e8`,teal:`#0f766e`,violet:`#7557c8`,coral:`#c94f5d`,custom:`#1677e8`};function yi({notify:e}){let{t}=h(),n=B(e=>e.theme),r=B(e=>e.density),i=B(e=>e.accent),a=B(e=>e.customAccent),o=B(e=>e.fontScale),c=B(e=>e.radius),l=B(e=>e.motion),u=B(e=>e.setTheme),d=B(e=>e.setDensity),f=B(e=>e.setAccent),p=B(e=>e.setCustomAccent),m=B(e=>e.setFontScale),g=B(e=>e.setRadius),_=B(e=>e.setMotion),v=B(e=>e.resetAppearance),y=n!==Ve.theme||r!==Ve.density||i!==Ve.accent||a!==Ve.customAccent||o!==Ve.fontScale||c!==Ve.radius||l!==Ve.motion,[b,x]=(0,G.useState)(a);(0,G.useEffect)(()=>x(a),[a]);let S=Je(b),C=!!b.trim()&&!S,w=e=>{x(e);let t=Je(e);t&&E(p)(t)},T=()=>e(t(`config:interfaceSettings.preferencesUpdated`)),E=e=>t=>{e(t),T()},D=[{value:`system`,label:t(`config:interfaceSettings.followSystem`),description:t(`config:interfaceSettings.followSystemDescription`),icon:pe},{value:`scheduled`,label:t(`config:interfaceSettings.automaticByTime`),description:t(`config:interfaceSettings.automaticByTimeDescription`),icon:j},{value:`light`,label:t(`config:interfaceSettings.light`),description:t(`config:interfaceSettings.lightDescription`),icon:ue},{value:`dark`,label:t(`config:interfaceSettings.dark`),description:t(`config:interfaceSettings.darkDescription`),icon:fe}],O=[{value:`comfortable`,label:t(`config:interfaceSettings.comfortable`),description:t(`config:interfaceSettings.comfortableDescription`),icon:ti},{value:`compact`,label:t(`config:interfaceSettings.compact`),description:t(`config:interfaceSettings.compactDescription`),icon:Br}],k=[{value:`system`,label:t(`config:interfaceSettings.motionSystem`),description:t(`config:interfaceSettings.motionSystemDescription`),icon:pe},{value:`full`,label:t(`config:interfaceSettings.motionFull`),description:t(`config:interfaceSettings.motionFullDescription`),icon:Ye},{value:`reduced`,label:t(`config:interfaceSettings.motionReduced`),description:t(`config:interfaceSettings.motionReducedDescription`),icon:Pr}],M=[{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`)}],N=[{value:`small`,label:t(`config:interfaceSettings.small`)},{value:`default`,label:t(`config:interfaceSettings.standard`)},{value:`large`,label:t(`config:interfaceSettings.large`)}],ee=[{value:`sharp`,label:t(`config:interfaceSettings.sharp`)},{value:`default`,label:t(`config:interfaceSettings.standard`)},{value:`soft`,label:t(`config:interfaceSettings.soft`)}];return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-appearance`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4 max-[650px]:flex-col`,children:[(0,K.jsx)(hi,{icon:Gr,title:t(`config:interfaceSettings.appearance`),description:t(`config:interfaceSettings.appearanceDescription`)}),(0,K.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:!y,onClick:()=>{v(),e(t(`config:interfaceSettings.defaultsRestored`))},children:[(0,K.jsx)(A,{size:14}),t(`config:interfaceSettings.restoreDefaults`)]})]}),(0,K.jsx)(gi,{label:t(`config:interfaceSettings.colorMode`),options:D,value:n,onChange:E(u)}),(0,K.jsxs)(`div`,{className:`mt-5 border-t border-[var(--stroke-soft)] pt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-bold text-[var(--text-soft)]`,children:[(0,K.jsx)(Gr,{size:15}),t(`config:interfaceSettings.accentColor`)]}),(0,K.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":t(`config:interfaceSettings.accentColor`),children:M.map(e=>(0,K.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:()=>E(f)(e.value),children:[(0,K.jsx)(`span`,{className:`size-3.5 rounded-full border border-black/10 shadow-sm`,style:{backgroundColor:e.value===`custom`?a:vi[e.value]}}),e.label,i===e.value&&(0,K.jsx)(z,{size:13})]},e.value))}),i===`custom`&&(0,K.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,K.jsx)(`input`,{type:`color`,value:Je(a)||`#1677e8`,onChange:e=>E(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,K.jsx)(`input`,{type:`text`,value:b,onChange:e=>w(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)] ${C?`border-[var(--danger)]`:`border-[var(--stroke)]`}`}),(0,K.jsx)(`span`,{className:`text-[12px] ${C?`text-[var(--danger)]`:`text-[var(--text-muted)]`}`,children:t(C?`config:interfaceSettings.invalidAccentColor`:`config:interfaceSettings.customAccentHint`)})]})]}),(0,K.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,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-bold text-[var(--text-soft)]`,children:[(0,K.jsx)(ei,{size:15}),t(`config:interfaceSettings.interfaceStyle`)]}),(0,K.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 max-[470px]:grid-cols-1`,children:[(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:interfaceSettings.fontSize`)}),(0,K.jsx)(_i,{label:t(`config:interfaceSettings.fontSize`),options:N,value:o,onChange:E(m)})]}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:interfaceSettings.cornerStyle`)}),(0,K.jsx)(_i,{label:t(`config:interfaceSettings.cornerStyle`),options:ee,value:c,onChange:E(g)})]})]})]}),(0,K.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,K.jsxs)(`div`,{className:`flex h-8 items-center gap-1.5 border-b border-[var(--stroke)] bg-[var(--surface-subtle)] px-3`,children:[(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--brand-blue)]`}),(0,K.jsx)(`span`,{className:`text-[11px] font-bold text-[var(--text-muted)]`,children:t(`config:interfaceSettings.livePreview`)})]}),(0,K.jsxs)(`div`,{className:`grid gap-2.5 p-3`,children:[(0,K.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,K.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,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,K.jsx)(`span`,{className:`block h-full w-2/3 rounded-full bg-[var(--brand-blue)]`})}),(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:`67%`})]})]})]})]})]}),(0,K.jsxs)(Y,{className:`p-[18px]`,"data-config-card":`interface-motion`,children:[(0,K.jsx)(hi,{icon:Pr,title:t(`config:interfaceSettings.displayAndMotion`),description:t(`config:interfaceSettings.displayAndMotionDescription`)}),(0,K.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-5 max-[720px]:grid-cols-1`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[13px] font-bold text-[var(--text-soft)]`,children:t(`config:interfaceSettings.interfaceDensity`)}),(0,K.jsx)(gi,{label:t(`config:interfaceSettings.interfaceDensity`),options:O,value:r,onChange:E(d),className:`grid-cols-2`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[13px] font-bold text-[var(--text-soft)]`,children:t(`config:interfaceSettings.motion`)}),(0,K.jsx)(gi,{label:t(`config:interfaceSettings.motion`),options:k,value:l,onChange:E(_),className:`grid-cols-2`})]})]})]}),(0,K.jsx)(mi,{notify:e})]})}function bi({...e}){return(0,K.jsx)(Bn,{"data-slot":`dropdown-menu`,...e})}function xi({...e}){return(0,K.jsx)(Vn,{"data-slot":`dropdown-menu-trigger`,...e})}function Si({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,K.jsx)(Hn,{children:(0,K.jsx)(Un,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:re(`z-[200] max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function Ci({className:e,inset:t,variant:n=`default`,...r}){return(0,K.jsx)(Wn,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:re(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}var wi=[`voiceInput`,`sendMessage`,`commandPalette`,`primaryAction`],Ti=gt.filter(e=>!wi.includes(e));function Ei({requestConfirm:e}){let{t}=h(),n=_t(e=>e.bindings),r=_t(e=>e.setBinding),i=_t(e=>e.resetBindings),[a,o]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.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=yt(n,e,i);if(a){l({action:e,message:t(`config:shortcuts.conflict`,{action:f[a]})});return}try{ht({...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=pt(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`)})},g=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`)})}},_=gt.some(e=>n[e]!==mt[e]),v=e=>(0,K.jsxs)(`div`,{className:`py-3`,"data-shortcut-action":e,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[(0,K.jsx)(`label`,{htmlFor:`shortcut-${e}`,className:`min-w-0 text-sm font-medium`,children:f[e]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-1`,children:[(0,K.jsx)(s,{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":c?.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,K.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words text-left`,children:a===e?t(`config:shortcuts.recording`):vt(n[e])||t(`config:shortcuts.disabled`)})}),(0,K.jsxs)(bi,{children:[(0,K.jsx)(xi,{asChild:!0,children:(0,K.jsx)(s,{variant:`ghost`,size:`icon`,title:t(`config:shortcuts.options`,{action:f[e]}),"aria-label":t(`config:shortcuts.options`,{action:f[e]}),children:(0,K.jsx)(F,{className:`size-4`})})}),(0,K.jsxs)(Si,{align:`end`,className:`w-40`,onCloseAutoFocus:e=>{document.activeElement?.hasAttribute(`data-shortcut-recorder`)&&e.preventDefault()},children:[(0,K.jsxs)(Ci,{disabled:n[e]===null,onSelect:()=>p(e,null),children:[(0,K.jsx)(Ce,{className:`size-4`}),t(`config:shortcuts.disableKey`)]}),(0,K.jsxs)(Ci,{disabled:n[e]===mt[e],onSelect:()=>p(e,mt[e]),children:[(0,K.jsx)(A,{className:`size-4`}),t(`config:shortcuts.resetAll`)]})]})]})]})]}),c?.action===e&&(0,K.jsx)(`p`,{id:`shortcut-error-${e}`,role:`alert`,className:`mt-2 text-sm text-destructive`,children:c.message})]},e);return(0,K.jsxs)(`section`,{className:`w-full min-w-0`,"data-config-card":`shortcuts-bindings`,children:[(0,K.jsxs)(`div`,{className:`mb-5 flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ue,{className:`size-5 text-muted-foreground`,"aria-hidden":`true`}),(0,K.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`config:configPage.shortcuts`)})]}),(0,K.jsx)(s,{variant:`ghost`,size:`icon`,disabled:!_,title:t(`config:shortcuts.resetAll`),"aria-label":t(`config:shortcuts.resetAll`),onClick:()=>void g(),children:(0,K.jsx)(A,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:`divide-y divide-border border-y border-border`,children:wi.map(v)}),(0,K.jsxs)(`details`,{className:`group mt-3`,onToggle:()=>o(null),children:[(0,K.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,K.jsx)(oe,{className:`size-4 transition-transform group-open:rotate-180`}),t(`config:shortcuts.more`)]}),(0,K.jsx)(`div`,{className:`divide-y divide-border border-b border-border`,children:Ti.map(v)})]}),(0,K.jsx)(`div`,{className:`mt-3 min-h-5 text-xs text-muted-foreground`,role:`status`,"aria-live":`polite`,children:c?.action===null?(0,K.jsx)(`span`,{className:`text-destructive`,children:c.message}):t(u?`config:shortcuts.saved`:`config:shortcuts.deviceScope`)})]})}var Di=[[`openai-responses`,`OpenAI Responses`],[`openai-completions`,`OpenAI Chat Completions`],[`anthropic-messages`,`Anthropic Messages`],[`google-generative-ai`,`Google Generative AI`]],Oi={openai:Ie,"openai-codex":Ie,anthropic:Pe,google:Ye,deepseek:se,xai:ge,openrouter:he,"kimi-coding":Ye,"zai-coding-cn":Pe};function ki({providers:e,defaultProviderId:t=``,toggling:n,onConfigure:r,onToggle:i,onDelete:a}){let{t:o}=h(),c=e.filter(e=>e.configured||e.custom);return(0,K.jsx)(`div`,{className:`grid [grid-template-columns:repeat(auto-fill,minmax(min(230px,100%),1fr))] gap-[8px]`,children:c.map(e=>{let c=Oi[e.id]||Ge,l=e.id===t,u=e.configured?e.enabled?o(`config:configPage.authenticationReady`):o(`config:configPage.disabled2`):e.id===`openai-codex`?o(`config:configPage.codexCLILoginRequired`):o(`config:configPage.apiKeyRequired`);return(0,K.jsxs)(`div`,{role:`button`,tabIndex:0,title:o(`config:configPage.configure`),className:`flex cursor-pointer flex-col gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-[10px_11px] hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,onClick:()=>r(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e))},children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[8px]`,children:[(0,K.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,K.jsx)(c,{size:16})}),(0,K.jsx)(`strong`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:e.name}),l&&(0,K.jsx)(X,{tone:`green`,children:o(`config:configPage.defaultBadge`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-[8px]`,children:[(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:u}),(0,K.jsxs)(`div`,{className:`flex flex-none items-center gap-[6px]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,K.jsx)(ri,{value:e.configured&&e.enabled,disabled:!e.configured||n===e.id,onChange:t=>i(e,t)}),e.custom&&(0,K.jsx)(s,{variant:`destructive`,size:`icon`,className:`h-[26px] w-[26px]`,title:o(`config:configPage.deleteProvider`),onClick:()=>a(e),children:(0,K.jsx)(xe,{size:13})})]})]})]},e.id)})})}function Ai({providers:e,defaultProviderId:t,toggling:n,onConfigure:r,onToggle:i,onDelete:a,onAddCustom:o}){let{t:c}=h();return(0,K.jsxs)(Y,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-[8px] [margin-bottom:8px]`,children:[(0,K.jsx)(ni,{title:c(`config:configPage.connections`)}),(0,K.jsxs)(s,{variant:`ghost`,size:`sm`,className:`h-[26px] px-[8px] text-[12px] text-[var(--text-muted)]`,onClick:o,children:[(0,K.jsx)(lt,{size:13}),c(`config:configPage.addCustomConnection`)]})]}),(0,K.jsx)(ki,{providers:e,defaultProviderId:t,toggling:n,onConfigure:r,onToggle:i,onDelete:a})]})}function ji({config:e,onQuickSetup:t,onChangeModel:n}){let{t:r}=h(),i=e.defaultProvider||e.provider,a=e.defaultModel||e.model,o=e.providers.find(e=>e.id===i),c=o?.models.find(e=>e.id===a),l=!!(o?.configured&&o?.enabled&&a);return(0,K.jsx)(Y,{className:`[margin-bottom:12px]`,"data-config-card":`models-current-model`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[12px] max-[650px]:grid max-[650px]:grid-cols-[40px_minmax(0,1fr)]`,children:[(0,K.jsx)(`span`,{className:`grid w-[40px] h-[40px] flex-none place-items-center rounded-[11px] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,K.jsx)(Ie,{size:19})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-[600] text-[var(--text-muted)]`,children:r(`config:configPage.currentChatModel`)}),l?(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-[7px]`,children:[(0,K.jsxs)(`strong`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[15px]`,children:[o?.name,` / `,c?.name||a]}),(0,K.jsxs)(X,{tone:`green`,children:[(0,K.jsx)(Te,{size:11,className:`mr-[3px] inline`}),r(`config:configPage.authenticationReady`)]})]}):(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,K.jsxs)(`strong`,{className:`flex items-center gap-[6px] text-[14px] text-[var(--warning-strong)]`,children:[(0,K.jsx)(Rr,{size:15}),r(`config:configPage.noModelConfiguredYet`)]}),(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:r(`config:configPage.noModelConfiguredHint`)})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-none flex-wrap items-center gap-[7px] max-[650px]:col-span-full`,children:[l&&o&&(0,K.jsxs)(s,{variant:`outline`,className:`bg-surface-subtle`,onClick:n,children:[(0,K.jsx)(Kr,{size:13}),r(`config:configPage.changeModel`)]}),(0,K.jsxs)(s,{onClick:t,children:[(0,K.jsx)(M,{size:13}),r(`config:configPage.quickSetup`)]})]})]})})}function Mi({ids:e,onChange:t,placeholder:n,primaryId:r=``}){let{t:i}=h(),[a,o]=(0,G.useState)(``),c=()=>{let n=a.trim();!n||n===r.trim()||e.includes(n)||(t([...e,n]),o(``))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(W,{variant:`control`,children:[i(`config:configPage.manualModelIds`),(0,K.jsxs)(`div`,{className:`flex items-stretch gap-[6px]`,children:[(0,K.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())},placeholder:n}),(0,K.jsx)(s,{type:`button`,size:`icon`,className:`h-[31px] w-[31px] flex-none`,"aria-label":i(`config:configPage.manualModelIds`),disabled:!a.trim(),onClick:c,children:(0,K.jsx)(lt,{size:14})})]})]}),e.length>0&&(0,K.jsx)(`div`,{className:`flex flex-col gap-[6px]`,children:e.map(n=>(0,K.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,K.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:n}),(0,K.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,K.jsx)(Ce,{size:12})})]},n))}),(0,K.jsx)(`p`,{className:`[margin:0] text-[11px] text-[var(--text-tertiary)]`,children:i(`config:configPage.manualModelIdsHint`)})]})}function Ni(e,t){return t===`visual`?e?.models.find(e=>e.kind===`image`||e.kind===`video`):e?.models.find(e=>e.kind===`chat`)||e?.models[0]}function Pi({onClose:e,onCreated:t,initialProviderType:n=`chat`,initialProvider:i}){let{t:a}=h(),o=i?.type||n,c=Ni(i,o),l=!!i,[u,d]=(0,G.useState)({name:i?.name||``,id:i?.id||``,providerType:o,api:i?.api||`openai-responses`,baseUrl:i?.baseUrl||``,apiKey:``,model:c?.id||``,modelName:c?.name||``,modelKind:c?.kind===`image`||c?.kind===`video`?c.kind:o===`visual`?`image`:`chat`,reasoning:c?.reasoning!==!1,thinkingLevels:c?.thinkingLevels||[],enabled:i?.enabled??!0}),f=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[p,m]=(0,G.useState)(!1),g=e=>{m(!0),d(t=>({...t,thinkingLevels:t.thinkingLevels.includes(e)?t.thinkingLevels.filter(t=>t!==e):[...t.thinkingLevels,e]}))},[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)([]),C=e=>d(t=>({...t,name:e,id:t.id||e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)}));return(0,G.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,K.jsx)(`div`,{className:`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=>t.target===t.currentTarget&&e(),children:(0,K.jsxs)(`form`,{role:`dialog`,"aria-modal":`true`,className:`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=>{e.preventDefault(),v(!0),b(``);try{let e=l?await r(`/api/config`,{method:`PUT`,body:JSON.stringify({...u,thinkingLevels:p?u.thinkingLevels:void 0,provider:u.id,providerName:u.name,setAsDefault:!1})}):await r(`/api/providers`,{method:`POST`,body:JSON.stringify({...u,thinkingLevels:p?u.thinkingLevels:void 0})}),n=new Set((i?.models||[]).map(e=>e.id)),a=x.filter(e=>e!==u.model.trim()&&!n.has(e));if(a.length){let t=e.createdProviderId||u.id;try{e=await r(`/api/providers/${encodeURIComponent(t)}/models/batch`,{method:`POST`,body:JSON.stringify({models:a.map(e=>({id:e,kind:u.providerType===`visual`?u.modelKind:`chat`}))})})}catch(e){b(e instanceof Error?e.message:String(e));return}}t(e)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},children:[(0,K.jsxs)(et,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:a(l?`config:configPage.editProviderConnection`:`config:configPage.addProviderConnection`)}),(0,K.jsx)(`p`,{children:a(l?`config:configPage.updateProviderKeyURLAndModelSettings`:`config:configPage.youCanCreateMultipleConnectionsUsingTheSameProtocolEachWithItsOwnKeyAndBaseURL`)})]}),(0,K.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`config:configPage.closeDialog`),onClick:t=>{t.preventDefault(),t.stopPropagation(),e()},children:(0,K.jsx)(Ce,{size:17})})]}),(0,K.jsxs)(`div`,{className:`form-grid grid gap-[9px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.displayName`),(0,K.jsx)(`input`,{value:u.name,onChange:e=>C(e.target.value),placeholder:a(`config:configPage.forExampleOpenAIOfficial`)})]}),(0,K.jsxs)(W,{variant:`control`,children:[`Provider ID`,(0,K.jsx)(`input`,{value:u.id,disabled:l,onChange:e=>d({...u,id:e.target.value}),placeholder:`openai-official`})]})]}),(0,K.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,K.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:a(`config:configPage.providerPurpose`)}),(0,K.jsx)(`strong`,{className:`text-[12px]`,children:u.providerType===`visual`?a(`config:configPage.visualProvider`):a(`config:configPage.chatProvider`)})]}),(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.apiProtocol`),(0,K.jsx)(L,{value:u.api,onChange:e=>d({...u,api:e.target.value}),children:Di.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))})]}),(0,K.jsxs)(W,{variant:`control`,children:[`Base URL`,(0,K.jsx)(`input`,{value:u.baseUrl,onChange:e=>d({...u,baseUrl:e.target.value}),placeholder:`https://api.openai.com/v1`})]}),(0,K.jsxs)(W,{variant:`control`,children:[`API Key`,(0,K.jsx)(`input`,{type:`password`,value:u.apiKey,onChange:e=>d({...u,apiKey:e.target.value}),placeholder:a(l?`config:configPage.keepExistingKeyBlank`:`config:configPage.enterTheAPIKeyForThisConnection`)})]}),(0,K.jsxs)(`div`,{className:`form-grid grid gap-[9px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.initialModelID`),(0,K.jsx)(`input`,{value:u.model,onChange:e=>d({...u,model:e.target.value}),placeholder:u.providerType===`visual`?`gpt-image-2 or grok-imagine-video`:`gpt-5.4 or gpt-image-1`})]}),(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.modelName`),(0,K.jsx)(`input`,{value:u.modelName,onChange:e=>d({...u,modelName:e.target.value}),placeholder:a(`config:configPage.leaveBlankToUseTheModelID`)})]})]}),(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.modelType`),u.providerType===`visual`?(0,K.jsxs)(L,{value:u.modelKind,onChange:e=>d({...u,modelKind:e.target.value}),children:[(0,K.jsx)(`option`,{value:`image`,children:a(`config:configPage.imageGenerationAndEditing`)}),(0,K.jsx)(`option`,{value:`video`,children:a(`config:configPage.videoGeneration`)})]}):(0,K.jsx)(`div`,{className:`rounded-[var(--r-xs)] bg-[var(--surface-subtle)] px-[10px] py-[8px] text-[13px] text-[var(--text-muted)]`,children:a(`config:configPage.chat`)})]}),(0,K.jsx)(`div`,{className:`grid gap-[9px]`,children:(0,K.jsx)(Mi,{ids:x,onChange:S,primaryId:u.model,placeholder:u.providerType===`visual`?`gpt-image-1`:`gpt-5.5`})}),u.modelKind===`chat`&&(0,K.jsxs)(W,{variant:`control`,children:[a(`config:configPage.modelThinkingLevels`),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:f.map(e=>{let t=e===`off`,n=t||u.thinkingLevels.includes(e),r=t||!u.reasoning&&e!==`off`;return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r,onClick:()=>!t&&g(e),className:re(`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,K.jsx)(z,{size:12}),e]},e)})}),(0,K.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:a(`config:configPage.modelThinkingLevelsHint`)})]}),(0,K.jsxs)(`div`,{className:`modal-toggle-row [&_>_span]:flex [&_>_span]:flex-col [&_>_span]:gap-[3px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] dark:bg-[var(--surface-subtle)] flex min-h-[45px] items-center justify-between gap-[12px] [margin-top:10px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:8px_10px]`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:a(`config:configPage.enableAfterCreation`)}),(0,K.jsx)(`small`,{children:a(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]}),(0,K.jsx)(ri,{value:u.enabled,onChange:e=>d({...u,enabled:e})})]}),y&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),y]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,K.jsx)(s,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:e,children:a(`config:configPage.cancel`)}),(0,K.jsxs)(s,{size:`lg`,disabled:_,children:[_?(0,K.jsx)(V,{className:`animate-spin`,size:14}):l?(0,K.jsx)(z,{size:14}):(0,K.jsx)(lt,{size:14}),a(_?`config:configPage.saving`:l?`config:configPage.saveChanges`:`config:configPage.createConnection`)]})]})]})})}function Fi(e){return(e.providers||[]).some(e=>e.importable&&!e.imported&&!e.conflict)}function Ii(e,t){return!t&&!Fi(e)}function Li(e,t,n){let r=e.providers||[],i=e.errors||[],a=Fi(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 Ri(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 zi(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 Bi(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 Vi({discovery:e,discovering:t,error:n,importing:r,onRefresh:i,onImport:a}){let{t:o}=h(),[c,l]=(0,G.useState)(null),u=e.providers||[],d=e.errors||[];if(!Li(e,t,n))return null;let f=c??Ii(e,t),p=()=>(l(null),i()),m=e=>(l(null),a(e)),g=e=>[`invalid_json`,`invalid_toml`].includes(e.code)?o(`config:configPage.invalidConfigurationFileFormat`):e.code===`unsupported_config`?o(`config:configPage.noImportableProviderConfigurationWasFound`):e.code===`invalid_login_state`?o(`config:configPage.incompleteLoginState`):e.code===`file_too_large`?o(`config:configPage.configurationFileIsTooLarge`):o(`config:configPage.unableToReadTheConfigurationFile`);return(0,K.jsxs)(Y,{className:`[margin-bottom:12px] [padding:12px_14px]`,children:[(0,K.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,K.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":!f,onClick:()=>l(!f),children:[(0,K.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,K.jsx)(Ge,{size:18})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:o(`config:configPage.localProviderConfiguration`)}),(0,K.jsx)(`small`,{children:o(`config:configPage.readProviderEndpointModelAndAuthenticationFieldsFromCodexConfigTomlAndClaudeSettingsJson`)})]}),(0,K.jsx)(oe,{size:15,className:`provider-discovery-caret [&.open]:[transform:rotate(180deg)] flex-none text-[var(--text-muted)] [transition:transform_var(--d1)_var(--ease-out)] ${f?``:`open`}`})]}),(0,K.jsxs)(s,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:t||!!r,onClick:p,children:[t?(0,K.jsx)(V,{className:`animate-spin`,size:13}):(0,K.jsx)(V,{size:13}),o(`config:configPage.rescan`)]})]}),!f&&(0,K.jsxs)(K.Fragment,{children:[t&&!u.length?(0,K.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,K.jsx)(V,{className:`animate-spin`,size:15}),o(`config:configPage.scanningProviderConfigurationFiles`)]}):u.length?(0,K.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:u.map(e=>{let t=Ri(e),n=r===e.id,i=e.source.startsWith(`claude-`)?Pe:Ie,a=e.kind===`authentication`?o(`config:configPage.officialProviderAuthenticationOnly`):e.models?.length?e.models.map(e=>e.id).join(`, `):o(`config:configPage.noModelSpecified`);return(0,K.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,K.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,K.jsx)(i,{size:17})}),(0,K.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,K.jsxs)(`strong`,{children:[t,` · `,e.providerName]}),(0,K.jsxs)(`small`,{children:[e.api,` · `,a]}),(0,K.jsxs)(`small`,{children:[e.kind===`authentication`?o(`config:configPage.officialEndpointOnly`):e.baseUrl||o(`config:configPage.noBaseURLSpecified`),` `,`· `,zi(e,o),` · `,e.location]})]}),(0,K.jsx)(`span`,{className:`flex min-w-0 flex-none items-center max-[650px]:col-start-2`,children:e.imported?(0,K.jsx)(X,{tone:`green`,children:o(`config:configPage.loaded`)}):e.conflict?(0,K.jsx)(X,{tone:`amber`,children:o(`config:configPage.conflictDetected`)}):e.importable?(0,K.jsxs)(s,{type:`button`,disabled:n||!!r,onClick:()=>m(e),children:[n?(0,K.jsx)(V,{className:`animate-spin`,size:12}):(0,K.jsx)(Qe,{size:12}),n?o(`config:configPage.loading`):e.kind===`authentication`?o(`config:configPage.loadLoginState`):o(`config:configPage.loadConfiguration`)]}):(0,K.jsx)(X,{tone:`gray`,children:o(`config:configPage.cannotLoad`)})})]},e.id)})}):(0,K.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,K.jsx)(Ge,{size:15}),o(`config:configPage.noImportableCodexOrClaudeProviderConfigurationWasDetected`)]}),(n||d.length>0||u.some(e=>e.warnings?.some(e=>e.code!==`login_auth_not_imported`)))&&(0,K.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,K.jsxs)(`span`,{children:[(0,K.jsx)(H,{size:13}),n]}),d.map((e,t)=>(0,K.jsxs)(`span`,{children:[(0,K.jsx)(H,{size:13}),Ri(e),` · `,g(e)]},`${e.source}-${e.code}-${t}`)),u.flatMap(e=>(e.warnings||[]).filter(e=>e.code!==`login_auth_not_imported`).map((t,n)=>(0,K.jsxs)(`span`,{children:[(0,K.jsx)(H,{size:13}),Ri(e),` · `,Bi(t.code,o)]},`${e.id}-${t.code}-${n}`)))]})]})]})}function Hi(e,t){try{let n=new URL(e).hostname.replace(/^www\./i,``),r=t===`visual`?`visual`:`chat`;return{id:`custom-${n.replace(/[^a-z0-9]+/gi,`-`)}-${r}`.replace(/^-+|-+$/g,``).slice(0,60)||`custom-provider`,name:n||`Custom Provider`}}catch{return{id:`custom-provider`,name:`Custom Provider`}}}function Ui(e,t){return String(e||``).replace(/\/+$/,``).toLowerCase()===t.replace(/\/+$/,``).toLowerCase()}function Wi({config:e,providerType:t=`chat`,initialProviderId:n,onClose:i,onCompleted:a}){let{t:o}=h(),c=n&&e.providers.find(e=>e.id===n)||null,[l,u]=(0,G.useState)(1),[d,f]=(0,G.useState)(c),[p,m]=(0,G.useState)(c?.baseUrl||``),[g,_]=(0,G.useState)(c?.api||`openai-responses`),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(c?.organization||``),[S,C]=(0,G.useState)(c?.name||``),[w,T]=(0,G.useState)([]),[E,D]=(0,G.useState)(``),[O,k]=(0,G.useState)([]),[A,j]=(0,G.useState)(t===`visual`?`image`:`chat`),[M,N]=(0,G.useState)(!1),[ee,P]=(0,G.useState)(``),[F,I]=(0,G.useState)(``),te=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let ne=()=>te.current?.value??v,R=Hi(p,t),ie=o(t===`visual`?`config:configPage.visualProvider`:`config:configPage.chatProvider`),oe=o(l===1?`config:configPage.quickSetupStepBaseUrl`:l===2?`config:configPage.quickSetupStepProtocol`:`config:configPage.quickSetupStepModel`),se=w.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`),ce=()=>{let n=p.trim();try{let e=new URL(n);if(![`http:`,`https:`].includes(e.protocol))throw Error()}catch{P(o(`config:configPage.providerBaseURLMustBeHTTPOrHTTPS`));return}P(``);let r=e.providers.find(e=>e.type===t&&Ui(e.baseUrl,n)&&e.api===g);f(r||null),r?(C(r.name),x(r.organization||``)):S.trim()||C(R.name),u(2)},le=()=>{if(!g){P(o(`config:configPage.selectAPIProtocol`));return}P(``),u(3)},ue=async()=>{let n=ne().trim();n!==v&&y(n);let i=e.providers.find(e=>e.type===t&&Ui(e.baseUrl,p)&&e.api===g);if(f(i||null),!n&&!i?.configured){P(o(`config:configPage.enterTheAPIKeyForThisConnection`));return}N(!0),P(``),I(``);try{let e=((await r(`/api/providers/models/discover-connection`,{method:`POST`,body:JSON.stringify({providerId:i?.id||``,providerType:t,api:g,baseUrl:p,organization:b,apiKey:n})})).models||[]).filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`);if(!e.length){P(o(t===`visual`?`config:configPage.fetchOrAddAVisualModel`:`config:configPage.fetchOrAddAChatModel`));return}T(e);let a=e.find(e=>e.id===E)||e[0];D(a.id),j(t===`visual`?a.kind:`chat`)}catch(e){let n=e instanceof Error?e.message:String(e),r=i?.models.filter(e=>t===`visual`?e.kind===`image`||e.kind===`video`:e.kind===`chat`)||[];if(!/\(401\)|\(403\)|鉴权|认证|密钥|API Key/i.test(n)&&r.length){T(r);let e=r.find(e=>e.id===E)||r[0];D(e.id),j(t===`visual`?e.kind:`chat`),I(n)}else P(n)}finally{N(!1)}},de=async()=>{let n=E.trim()||O[0]||``;if(!n){P(o(`config:configPage.selectModelToFinish`));return}let i=new Set((d?.models||[]).map(e=>e.id)),s=O.filter(e=>e!==n&&!i.has(e));N(!0),P(``);try{let i=d?await r(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:d.id,providerType:t,api:g,baseUrl:p,organization:b,model:n,modelKind:t===`visual`?A:`chat`,apiKey:ne(),thinkingLevel:e.thinkingLevel,toolMode:e.toolMode,setAsDefault:!0,enabled:!0})}):await r(`/api/providers`,{method:`POST`,body:JSON.stringify({id:R.id,name:S.trim()||R.name,providerType:t,api:g,baseUrl:p,organization:b,apiKey:ne(),model:n,modelKind:t===`visual`?A:`chat`,enabled:!0})});if(s.length){let e=d?.id||R.id,n=t===`visual`?A:`chat`;try{i=await r(`/api/providers/${encodeURIComponent(e)}/models/batch`,{method:`POST`,body:JSON.stringify({models:s.map(e=>({id:e,kind:n}))})})}catch(e){P(e instanceof Error?e.message:String(e));return}}a(i)}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}};return(0,K.jsx)(`div`,{className:`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:e=>e.target===e.currentTarget&&i(),children:(0,K.jsxs)(`div`,{className:`modal max-h-[calc(100dvh_-_40px)] w-[min(520px,100%)] 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)]`,children:[(0,K.jsxs)(et,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:o(t===`visual`?`config:configPage.visualQuickSetupTitle`:`config:configPage.quickSetupTitle`)}),(0,K.jsxs)(`p`,{children:[o(`config:configPage.stepIndicator`,{current:l,total:3}),` · `,oe]})]}),(0,K.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":o(`config:configPage.closeDialog`),onClick:i,children:(0,K.jsx)(Ce,{size:17})})]}),(0,K.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,K.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,K.jsx)(Ge,{size:16})}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,K.jsx)(`strong`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:S||R.name}),(0,K.jsx)(`small`,{className:`text-[11px] text-[var(--text-muted)]`,children:ie})]}),(0,K.jsx)(X,{tone:`gray`,children:ie})]}),l===1&&(0,K.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[`Base URL`,(0,K.jsx)(`input`,{autoFocus:!0,value:p,onChange:e=>m(e.target.value),placeholder:`https://api.example.com/v1`,inputMode:`url`})]}),(0,K.jsx)(`p`,{className:`[margin:8px_0_0] text-[12px] leading-[1.5] text-[var(--text-muted)]`,children:o(`config:configPage.quickSetupBaseUrlHint`)})]}),l===2&&(0,K.jsxs)(`div`,{className:`[margin-top:14px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[o(`config:configPage.apiProtocol`),(0,K.jsx)(L,{value:g,onChange:e=>_(e.target.value),children:Di.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))})]}),(0,K.jsxs)(W,{variant:`control`,children:[`Organization`,(0,K.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:o(`config:configPage.optionalUsedOnlyForOpenAIOrganization`)})]})]}),l===3&&(0,K.jsxs)(`div`,{className:`[margin-top:14px]`,children:[!d&&(0,K.jsxs)(W,{variant:`control`,children:[o(`config:configPage.displayName`),(0,K.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),placeholder:R.name})]}),(0,K.jsxs)(W,{variant:`control`,children:[`API Key`,(0,K.jsx)(`input`,{ref:te,type:`password`,autoComplete:`new-password`,autoFocus:!0,value:v,onChange:e=>y(e.target.value),onInput:e=>y(e.currentTarget.value),placeholder:d?.configured?o(`config:configPage.keepExistingKeyBlank`):o(`config:configPage.enterTheAPIKeyForThisConnection`)})]}),(0,K.jsxs)(s,{type:`button`,size:`lg`,className:`[margin-top:10px] w-full`,disabled:M,onClick:()=>void ue(),children:[M?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(V,{size:14}),o(M?`config:configPage.fetchingModels`:`config:configPage.fetchModels`)]}),F&&(0,K.jsxs)(Ke,{className:`[margin-top:10px]`,children:[(0,K.jsx)(H,{size:15}),(0,K.jsx)(`small`,{children:o(`config:configPage.discoverFailedUsingExisting`,{message:F})})]}),se.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsx)(`div`,{className:`flex max-h-[260px] flex-col gap-[6px] overflow-y-auto`,children:se.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:re(`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)]`,E===e.id&&`[border-color:var(--accent-border)] bg-[var(--accent-soft)]`),onClick:()=>{D(e.id),j(t===`visual`?e.kind:`chat`)},children:[(0,K.jsx)(`span`,{className:re(`grid w-[16px] h-[16px] flex-none place-items-center rounded-full [border:1px_solid_var(--stroke)] text-transparent`,E===e.id&&`[border-color:var(--brand-blue)] bg-[var(--brand-blue)] text-white`),children:(0,K.jsx)(z,{size:11})}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px]`,children:e.name}),t===`visual`&&(0,K.jsx)(X,{tone:`gray`,children:e.kind===`video`?o(`config:configPage.visualVideoModel`):o(`config:configPage.visualImageModel`)})]},`${e.id}-${e.kind}`))})]}),(0,K.jsxs)(`div`,{className:`[margin-top:14px] grid gap-[9px]`,children:[(0,K.jsxs)(W,{variant:`control`,children:[o(`config:configPage.manualModelId`),(0,K.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:t===`visual`?`gpt-image-1`:`gpt-5.4`})]}),(0,K.jsx)(`p`,{className:`[margin:0] text-[11px] text-[var(--text-tertiary)]`,children:o(`config:configPage.manualModelIdHint`)}),t===`visual`&&(0,K.jsxs)(W,{variant:`control`,children:[o(`config:configPage.modelType`),(0,K.jsxs)(L,{value:A,onChange:e=>j(e.target.value),children:[(0,K.jsx)(`option`,{value:`image`,children:o(`config:configPage.imageGenerationAndEditing`)}),(0,K.jsx)(`option`,{value:`video`,children:o(`config:configPage.videoGeneration`)})]})]}),(0,K.jsx)(Mi,{ids:O,onChange:k,primaryId:E,placeholder:t===`visual`?`gpt-image-1`:`gpt-5.5`})]})]}),ee&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),ee]}),(0,K.jsxs)(`div`,{className:`flex justify-between gap-[8px] [margin-top:18px]`,children:[(0,K.jsxs)(s,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:M||l===1,onClick:()=>{P(``),u(l-1)},children:[(0,K.jsx)(je,{size:14}),o(`config:configPage.previousStep`)]}),l===1?(0,K.jsxs)(s,{type:`button`,size:`lg`,disabled:M||!p.trim(),onClick:ce,children:[(0,K.jsx)(ae,{size:14}),o(`config:configPage.nextStep`)]}):l===2?(0,K.jsxs)(s,{type:`button`,size:`lg`,disabled:M,onClick:le,children:[(0,K.jsx)(ae,{size:14}),o(`config:configPage.nextStep`)]}):(0,K.jsxs)(s,{type:`button`,size:`lg`,disabled:M||!E.trim()&&O.length===0,onClick:()=>void de(),children:[M?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(z,{size:14}),o(M?`config:configPage.saving`:`config:configPage.saveAndSetDefault`)]})]})]})})}function Gi({config:e,notify:t,onConfigChanged:n}){let{t:i}=h(),[a,o]=(0,G.useState)(e.thinkingLevel),[c,l]=(0,G.useState)(e.toolMode),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(``);(0,G.useEffect)(()=>{o(e.thinkingLevel),l(e.toolMode)},[e.thinkingLevel,e.toolMode]);let m=e.defaultProvider||e.provider,g=e.defaultModel||e.model,_=e.providers.find(e=>e.id===m),v=!!(_?.configured&&g),y=a!==e.thinkingLevel||c!==e.toolMode,b=async()=>{if(!(!_||!g)){d(!0),p(``);try{n(await r(`/api/config`,{method:`PUT`,body:JSON.stringify({provider:_.id,providerType:_.type,api:_.api,baseUrl:_.baseUrl||``,organization:_.organization||``,model:g,thinkingLevel:a,toolMode:c,setAsDefault:!1})})),t(i(`config:configPage.runtimePolicySaved`))}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,K.jsxs)(Y,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-[8px]`,children:[(0,K.jsx)(ni,{title:i(`config:configPage.agentRuntimePolicy`)}),(0,K.jsxs)(s,{size:`sm`,className:`h-[27px] px-[10px] text-[12px]`,disabled:u||!y||!v,onClick:()=>void b(),children:[u?(0,K.jsx)(V,{className:`animate-spin`,size:13}):(0,K.jsx)(_e,{size:13}),i(u?`config:configPage.saving`:`config:configPage.saveSettings`)]})]}),(0,K.jsxs)(W,{variant:`control`,children:[i(`config:configPage.thinkingLevel`),(0,K.jsx)(L,{value:a,onChange:e=>o(e.target.value),children:[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`].map(e=>(0,K.jsx)(`option`,{children:e},e))})]}),(0,K.jsxs)(W,{variant:`control`,children:[i(`config:configPage.availableTools`),(0,K.jsxs)(L,{value:c,onChange:e=>l(e.target.value),children:[(0,K.jsx)(`option`,{value:`full`,children:i(`config:configPage.fullToolAccess`)}),(0,K.jsx)(`option`,{value:`custom`,children:i(`config:configPage.customManageEachToolOnThePluginsPage`)})]})]}),(0,K.jsxs)(Ke,{children:[(0,K.jsx)(ye,{size:16}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:i(`config:configPage.permissionsAreEnforcedByTheRuntime`)}),(0,K.jsx)(`small`,{children:i(`config:configPage.afterSavingExistingRuntimesAreReleasedAndNewChatsUseTheLatestPolicy`)})]})]}),f&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),f]})]})}function Ki(e){return e instanceof Error?e.message:String(e)}function qi({notify:e,requestConfirm:t,t:n}){let[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!0),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(``);return(0,G.useEffect)(()=>{let e=!0;return r(`/api/config`).then(t=>{if(e)return a(t),s(!1),r(`/api/providers/models/refresh`,{method:`POST`,body:`{}`})}).then(t=>{!e||!t?.config||a(t.config)}).catch(t=>{e&&(l(Ki(t)),s(!1))}),()=>{e=!1}},[]),{config:i,loading:o,error:c,toggling:u,applyConfig:(0,G.useCallback)(e=>{a(e),l(``)},[]),toggleProvider:(0,G.useCallback)(async(t,i)=>{d(t.id),l(``);try{let o=await r(`/api/providers/${encodeURIComponent(t.id)}/enabled`,{method:`PUT`,body:JSON.stringify({enabled:i})});a(o),e(n(`config:configPage.nameState`,{name:t.name,state:n(i?`config:configPage.enabled`:`config:configPage.disabled`)}))}catch(e){l(Ki(e))}finally{d(``)}},[e,n]),deleteProvider:(0,G.useCallback)(async i=>{if(await t({title:n(`config:configPage.deleteProviderConnection`),message:n(`config:configPage.deleteNameItsModelSettingsAndAuthenticationDetailsWillAlsoBeRemoved`,{name:i.name}),confirmLabel:n(`config:configPage.delete`)})){l(``);try{let t=await r(`/api/providers/${encodeURIComponent(i.id)}`,{method:`DELETE`});a(t),e(n(`config:configPage.providerConnectionDeleted`))}catch(e){l(Ki(e))}}},[e,t,n])}}function Ji({requestConfirm:e,onImported:t,t:n}){let[i,a]=(0,G.useState)({providers:[],errors:[]}),[o,s]=(0,G.useState)(!0),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(``),m=(0,G.useCallback)(async()=>{s(!0),l(``);try{a(await r(`/api/providers/discovery`))}catch(e){l(Ki(e))}finally{s(!1)}},[]);return(0,G.useEffect)(()=>{m()},[m]),{discovery:i,discovering:o,error:c,operationError:u,importing:f,refresh:m,importProvider:(0,G.useCallback)(async i=>{let o=i.source===`codex-config`?`Codex config.toml`:i.source===`claude-config`?`Claude settings.json`:i.source===`codex-auth`?`Codex login`:`Claude login`,s=i.kind===`authentication`;if(await e({title:n(s?`config:configPage.loadLoginState`:`config:configPage.loadProviderConfiguration`),message:n(s?`config:configPage.loadOfficialProviderLoginStateFromSource`:`config:configPage.loadThisProviderConfigurationFromSource`,{source:o}),confirmLabel:n(s?`config:configPage.loadLoginState`:`config:configPage.loadConfiguration`)})){p(i.id),d(``);try{let e=await r(`/api/providers/${encodeURIComponent(i.id)}/import`,{method:`POST`,body:`{}`});a(e.discovery),t(e)}catch(e){d(Ki(e))}finally{p(``)}}},[t,e,n])}}var Yi=`pisper.config.visualConnectionsOpen`,Z={running:null,result:null,error:``};function Xi(){return window.localStorage.getItem(Yi)===`1`}function Zi({config:e,notify:t,toggling:n,onToggleProvider:i,onDeleteProvider:a,onQuickSetup:o,onEditVisualProvider:c}){let{t:l}=h(),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(!0),[m,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(Xi),T=(0,G.useCallback)(async()=>{try{d(await r(`/api/visual/models`)),S(``)}catch(e){S(e instanceof Error?e.message:String(e))}finally{p(!1)}},[]);(0,G.useEffect)(()=>{T()},[T,e]),(0,G.useEffect)(()=>{Z.result&&b(Z.result),Z.error&&S(Z.error);let e=Z.running;if(!e)return;v(!0);let t=!0;return e.then(e=>{t&&b(e)}).catch(()=>{t&&S(Z.error)}).finally(()=>{t&&v(!1)}),()=>{t=!1}},[]);let E=async(e,n)=>{g(e),S(``);try{d(await r(`/api/visual/models/${e}`,{method:`PUT`,body:JSON.stringify({model:n})})),t(l(`config:configPage.visualModelUpdated`))}catch(e){S(e instanceof Error?e.message:String(e))}finally{g(``)}},D=async()=>{if(Z.running)return;v(!0),S(``),b(null),Z.result=null,Z.error=``;let e=r(`/api/visual/test`,{method:`POST`,body:`{}`,timeout:21e4});Z.running=e;try{let n=await e;Z.result=n,b(n),t(l(`config:configPage.testSucceeded`))}catch(e){let n=e instanceof Error?e.message:String(e);Z.error=n,S(n),t(n)}finally{Z.running=null,v(!1)}},O=e=>{w(e),window.localStorage.setItem(Yi,e?`1`:`0`)},k=e.providers.filter(e=>e.type===`visual`),A=k.filter(e=>e.configured||e.custom),j=u?.imageModels||[],F=u?.videoModels||[];return(0,K.jsxs)(`section`,{className:`[margin-top:12px]`,children:[(0,K.jsxs)(Y,{className:`[margin-bottom:12px]`,"data-config-card":`models-visual`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[12px] max-[650px]:grid max-[650px]:grid-cols-[40px_minmax(0,1fr)]`,children:[(0,K.jsx)(`span`,{className:`grid w-[40px] h-[40px] flex-none place-items-center rounded-[11px] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,K.jsx)(Ye,{size:19})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-[600] text-[var(--text-muted)]`,children:l(`config:configPage.currentVisualModel`)}),f?(0,K.jsxs)(`span`,{className:`flex items-center gap-[7px] text-[12px] text-[var(--text-muted)]`,children:[(0,K.jsx)(V,{className:`animate-spin`,size:13}),l(`config:configPage.loadingVisualStatus`)]}):u?.image?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-[7px]`,children:[(0,K.jsxs)(`strong`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[15px]`,children:[u.image.providerName,` / `,u.image.name]}),(0,K.jsxs)(X,{tone:`green`,children:[(0,K.jsx)(Te,{size:11,className:`mr-[3px] inline`}),l(`config:configPage.authenticationReady`)]})]}),u.video&&(0,K.jsxs)(`small`,{className:`text-[12px] text-[var(--text-muted)] [overflow-wrap:anywhere]`,children:[l(`config:configPage.visualVideoModel`),`:`,u.video.providerName,` /`,` `,u.video.name]})]}):(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[2px]`,children:[(0,K.jsxs)(`strong`,{className:`flex items-center gap-[6px] text-[14px] text-[var(--warning-strong)]`,children:[(0,K.jsx)(Rr,{size:15}),l(`config:configPage.visualNoneConfigured`)]}),(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:l(`config:configPage.visualEmptyHint`)})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-none flex-wrap items-center gap-[7px] max-[650px]:col-span-full`,children:[u?.image&&(0,K.jsxs)(s,{variant:`outline`,className:`bg-surface-subtle`,disabled:_,onClick:()=>void D(),children:[_?(0,K.jsx)(V,{className:`animate-spin`,size:13}):(0,K.jsx)(ee,{size:13}),l(_?`config:configPage.testingGeneration`:`config:configPage.testGeneration`)]}),(0,K.jsxs)(s,{onClick:o,children:[(0,K.jsx)(M,{size:13}),l(`config:configPage.visualQuickSetup`)]})]})]}),y&&(0,K.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:[y.previewDataUrl?(0,K.jsx)(`img`,{src:y.previewDataUrl,alt:y.modelName,className:`h-[44px] w-[44px] flex-none rounded-[var(--r-xs)] object-cover`}):(0,K.jsx)(z,{size:16,className:`flex-none text-[var(--success)]`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[1px] text-[12px]`,children:[(0,K.jsx)(`strong`,{className:`text-[var(--success-strong)]`,children:l(`config:configPage.testSucceeded`)}),(0,K.jsxs)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap text-[var(--text-muted)]`,children:[y.providerName,` / `,y.modelName,` · `,y.path]})]})]})]}),(0,K.jsxs)(I,{open:C,onOpenChange:O,children:[(0,K.jsx)(P,{asChild:!0,children:(0,K.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,K.jsx)(oe,{size:15,className:`flex-none text-[var(--text-muted)] transition-transform group-data-[state=closed]:-rotate-90`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[13px] font-[700] text-[var(--text-secondary)]`,children:l(`config:configPage.visualConnections`)}),(0,K.jsx)(`span`,{className:`min-w-0 text-[12px] text-[var(--text-tertiary)]`,children:l(`config:configPage.visualConnectionsHint`)})]})}),(0,K.jsx)(N,{children:(0,K.jsxs)(Y,{children:[(0,K.jsx)(ki,{providers:k,toggling:n,onConfigure:e=>c(e.id),onToggle:i,onDelete:a}),A.length===0&&(0,K.jsx)(`p`,{className:`[margin:2px_0_0] text-[12px] text-[var(--text-muted)]`,children:l(`config:configPage.visualEmptyHint`)}),(j.length>0||F.length>0)&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-[8px] [border-top:1px_solid_var(--stroke-soft)] [margin-top:10px] pt-[10px]`,children:[j.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-[8px]`,children:[(0,K.jsx)(`span`,{className:`w-[64px] flex-none text-[12px] text-[var(--text-muted)]`,children:l(`config:configPage.visualImageModel`)}),(0,K.jsxs)(L,{className:`min-w-0 flex-1`,value:u?.imageSelection||``,disabled:m===`image`,"aria-label":l(`config:configPage.visualImageModel`),onChange:e=>void E(`image`,e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:l(`config:configPage.visualAutoSelected`)}),j.map(e=>(0,K.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),F.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-[8px]`,children:[(0,K.jsx)(`span`,{className:`w-[64px] flex-none text-[12px] text-[var(--text-muted)]`,children:l(`config:configPage.visualVideoModel`)}),(0,K.jsxs)(L,{className:`min-w-0 flex-1`,value:u?.videoSelection||``,disabled:m===`video`,"aria-label":l(`config:configPage.visualVideoModel`),onChange:e=>void E(`video`,e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:l(`config:configPage.visualAutoSelected`)}),F.map(e=>(0,K.jsxs)(`option`,{value:`${e.providerId}/${e.id}`,children:[e.providerName,` · `,e.name]},`${e.providerId}/${e.id}`))]})]}),(0,K.jsx)(`small`,{className:`text-[11px] text-[var(--text-tertiary)]`,children:l(`config:configPage.visualModelsAreSelectedByTheVisualGenerationToolAndDoNotAppearInTheChatModelList`)})]})]})})]}),x&&(0,K.jsx)(`div`,{className:`[margin-top:10px]`,children:(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),x]})})]})}var Qi=`pisper.config.manageConnectionsOpen`;function $i(){let e=window.localStorage.getItem(Qi);return e===`1`||e!==`0`&&null}function ea({notify:e,registerPrimaryAction:t,requestConfirm:n}){let{t:r}=h(),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)($i),u=qi({notify:e,requestConfirm:n,t:r}),{config:d}=u,f=Ji({requestConfirm:n,onImported:t=>{u.applyConfig(t.config);let n=t.config.providers.find(e=>e.id===t.providerId);e(t.kind===`authentication`?r(`config:configPage.nameLoginStateHasBeenLoadedIntoPisper`,{name:n?.name||t.providerId}):r(`config:configPage.nameConfigurationHasBeenLoadedIntoPisper`,{name:n?.name||t.providerId}))},t:r});if(bt(t,()=>a({providerType:`chat`})),!d)return(0,K.jsxs)(nt,{children:[(0,K.jsx)(V,{className:`animate-spin`,size:24}),(0,K.jsx)(`h2`,{children:r(`config:configPage.loadingModelCatalog`)}),(0,K.jsx)(`p`,{children:r(`config:configPage.readingProvidersAndAuthenticationStatus`)}),u.error&&(0,K.jsx)(U,{children:u.error})]});let p=d.defaultProvider||d.provider,m=d.providers.find(e=>e.id===p),g=c??!1,_=e=>{l(e),window.localStorage.setItem(Qi,e?`1`:`0`)},v=e=>s({providerType:e.type,provider:e}),y=e=>a({providerId:e.id,providerType:e.type});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ji,{config:d,onQuickSetup:()=>a({providerType:`chat`}),onChangeModel:()=>m?y(m):a({providerType:`chat`})}),(0,K.jsxs)(I,{open:g,onOpenChange:_,"data-config-card":`models-connections`,children:[(0,K.jsx)(P,{asChild:!0,children:(0,K.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,K.jsx)(oe,{size:15,className:`shrink-0 text-[var(--text-muted)] transition-transform group-data-[state=closed]:-rotate-90`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[13px] font-[700] text-[var(--text-secondary)]`,children:r(`config:configPage.manageConnections`)}),(0,K.jsx)(`span`,{className:`min-w-0 text-[12px] text-[var(--text-tertiary)]`,children:r(`config:configPage.manageConnectionsHint`)})]})}),(0,K.jsxs)(N,{children:[(0,K.jsx)(Vi,{discovery:f.discovery,discovering:f.discovering,error:f.error||f.operationError,importing:f.importing,onRefresh:f.refresh,onImport:f.importProvider}),(0,K.jsx)(Ai,{providers:d.providers,defaultProviderId:p,toggling:u.toggling,onConfigure:v,onToggle:u.toggleProvider,onDelete:u.deleteProvider,onAddCustom:()=>s({providerType:`chat`})}),u.error&&(0,K.jsx)(U,{children:u.error}),(0,K.jsx)(`div`,{className:`[margin-top:12px]`,children:(0,K.jsx)(Gi,{config:d,notify:e,onConfigChanged:u.applyConfig})})]})]}),(0,K.jsx)(Zi,{config:d,notify:e,toggling:u.toggling,onToggleProvider:u.toggleProvider,onDeleteProvider:u.deleteProvider,onQuickSetup:()=>a({providerType:`visual`}),onEditVisualProvider:e=>{let t=d.providers.find(t=>t.id===e);t&&s({providerType:`visual`,provider:t})}}),i&&(0,K.jsx)(Wi,{config:d,providerType:i.providerType||`chat`,initialProviderId:i.providerId,onClose:()=>a(null),onCompleted:t=>{u.applyConfig(t),e(r(`config:configPage.setupComplete`)),a(null)}}),o&&(0,K.jsx)(Pi,{initialProviderType:o.providerType,initialProvider:o.provider,onClose:()=>s(null),onCreated:t=>{u.applyConfig(t),o.provider?e(r(`config:configPage.providerConnectionUpdated`)):e(r(`config:configPage.providerConnectionCreated`)),s(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 ta(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 na,$,ra,ia,aa=`__TAURI_TO_IPC_KEY__`;function oa(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var sa=class{constructor(e){na.set(this,void 0),$.set(this,0),ra.set(this,[]),ia.set(this,void 0),ta(this,na,e||(()=>{}),`f`),this.id=oa(e=>{let t=e.index;if(`end`in e){t==Q(this,$,`f`)?this.cleanupCallback():ta(this,ia,t,`f`);return}let n=e.message;if(t==Q(this,$,`f`)){for(Q(this,na,`f`).call(this,n),ta(this,$,Q(this,$,`f`)+1,`f`);Q(this,$,`f`)in Q(this,ra,`f`);){let e=Q(this,ra,`f`)[Q(this,$,`f`)];Q(this,na,`f`).call(this,e),delete Q(this,ra,`f`)[Q(this,$,`f`)],ta(this,$,Q(this,$,`f`)+1,`f`)}Q(this,$,`f`)===Q(this,ia,`f`)&&this.cleanupCallback()}else Q(this,ra,`f`)[t]=n})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){ta(this,na,e,`f`)}get onmessage(){return Q(this,na,`f`)}[(na=new WeakMap,$=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[aa]()}};function ca(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function la(e,t){return ca(`plugin:barcode-scanner|${e}`,t)}function ua(e){return e instanceof Error?e.message:String(e)}function da(e){return/cancel(?:led|ed)/i.test(ua(e))}function fa(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function pa(e){return Array.isArray(e)?new TextDecoder().decode(Uint8Array.from(e)):``}function ma(e){if(!e.isActive||!e.port)return null;let t=pa(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=pa(e.txt.name)||e.name||`Pisper Desktop`,a=`https://${r}:${e.port}`;return{id:`${e.fullName}:${a}`,name:i,url:a,fingerprint:t}}function ha(e){return new Promise(t=>window.setTimeout(t,e))}function ga({open:e,onOpenChange:t}){let{t:n}=h(),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(``),[m,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),y=(0,G.useRef)(!1),b=(0,G.useRef)(!1),x=(0,G.useRef)(!1),S=(0,G.useRef)(0),C=(0,G.useRef)(``),w=(0,G.useCallback)(e=>{y.current=e,o(e)},[]),T=(0,G.useCallback)(async()=>{b.current=!0,y.current&&await la(`cancel`).catch(()=>void 0),w(!1),i(null)},[w]);(0,G.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,G.useEffect)(()=>{if(!a)return;let e=`pisper-scanner-${Date.now()}`;window.history.pushState({...window.history.state,pisperScanner:e},``);let t=()=>void T();return window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`popstate`,t),!x.current&&window.history.state?.pisperScanner===e&&window.history.back()}},[T,a]);let E=e=>{if(!e.proxyUrl)throw Error(n(`config:mobileServer.pairFailed`));window.location.replace(e.proxyUrl)},D=(0,G.useCallback)(async()=>{let e=++S.current;d(!0),p(``),l([]);let t=new sa;t.onmessage=t=>{if(S.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=ma(t.service);r&&l(e=>[...e.filter(e=>e.fingerprint!==r.fingerprint),r])};let r=null;try{await ca(`mobile_ensure_local_network_permission`),r=(await ca(`plugin:dns-sd|browse_start`,{options:{service:{type:`pisper`,protocol:`tcp`,domain:`local`},timeoutMs:4e3},channel:t})).browseId,await ha(4300)}catch(t){S.current===e&&p(ua(t).includes(`local_network_permission_denied`)?n(`config:mobileServer.localNetworkDenied`):n(`config:mobileServer.discoveryFailed`))}finally{r!==null&&await ca(`plugin:dns-sd|browse_stop`,{browseId:r}).catch(()=>void 0),S.current===e&&d(!1)}},[n]);(0,G.useEffect)(()=>{if(!(!e||a))return D(),()=>{S.current+=1}},[D,e,a]);let O=(0,G.useCallback)(async()=>{let e=C.current;C.current=``,e&&await ca(`mobile_cancel_lan_pairing`,{operationId:e}).catch(()=>void 0),i(null),g(``)},[]),k=async e=>{let t=globalThis.crypto?.randomUUID?.()||`lan-${Date.now()}-${Math.random().toString(16).slice(2)}`;C.current=t,i(`lan:${e.id}`),v(``),g(n(`config:mobileServer.awaitingApproval`,{name:e.name}));try{let n=await ca(`mobile_pair_lan`,{operationId:t,name:e.name,url:e.url,fingerprint:e.fingerprint,deviceName:null});if(C.current!==t)return;E(n)}catch(e){C.current===t&&v(ua(e))}finally{C.current===t&&(C.current=``,i(null),g(``))}},A=async()=>{b.current=!1,x.current=!1,i(`scan`),v(``);try{let e=await la(`check_permissions`);if(e.camera!==`granted`&&(e=await la(`request_permissions`)),e.camera!==`granted`)throw Error(n(`config:mobileServer.cameraDenied`));if(b.current||(w(!0),await fa(),b.current))return;let t=await la(`scan`,{windowed:!0,formats:[]});if(!t.content)throw Error(n(`config:mobileServer.scanFailed`));x.current=!0,E(await ca(`mobile_pair`,{payloadJson:t.content,deviceName:null}))}catch(e){!b.current&&!da(e)&&v(ua(e))}finally{w(!1),i(null),b.current=!1}};return(0,K.jsx)(Ze,{open:e,onOpenChange:e=>{if(!e&&a){T();return}if(!e&&r?.startsWith(`lan:`)){O(),t(!1);return}r||(e||v(``),t(e))},children:(0,K.jsx)(we,{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,K.jsxs)(`div`,{className:`flex h-dvh w-screen flex-col overflow-hidden`,children:[(0,K.jsxs)(Fe,{className:`sr-only`,children:[(0,K.jsx)(Re,{children:n(`config:mobileServer.scanTitle`)}),(0,K.jsx)(Xe,{children:n(`config:mobileServer.scanHint`)})]}),(0,K.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,K.jsxs)(s,{variant:`ghost`,className:`h-10 bg-black/40 px-3 text-white hover:bg-black/70 hover:text-white`,onClick:()=>void T(),children:[(0,K.jsx)(je,{}),n(`config:mobileServer.cancelScan`)]}),(0,K.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,children:n(`config:mobileServer.scanTitle`)}),(0,K.jsx)(`div`,{className:`w-[88px]`,"aria-hidden":`true`})]}),(0,K.jsx)(`main`,{className:`grid min-h-0 flex-1 place-items-center p-6`,children:(0,K.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,K.jsx)(Xr,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 text-white/75`})})}),(0,K.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,K.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-white/90`,children:n(`config:mobileServer.scanHint`)}),(0,K.jsx)(s,{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 T(),children:n(`config:mobileServer.cancelScan`)})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Fe,{children:[(0,K.jsx)(Re,{children:n(`config:mobileServer.addServer`)}),(0,K.jsx)(Xe,{children:n(`config:mobileServer.discoverDescription`)})]}),(0,K.jsxs)(`section`,{className:`grid gap-2`,"aria-live":`polite`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,K.jsx)(Jr,{className:`size-4`}),n(`config:mobileServer.nearby`)]}),(0,K.jsx)(s,{size:`icon-sm`,variant:`ghost`,disabled:u||r!==null,"aria-label":n(`config:mobileServer.rediscover`),onClick:()=>void D(),children:(0,K.jsx)(V,{className:u?`animate-spin`:void 0})})]}),c.length?(0,K.jsx)(`ul`,{className:`grid max-h-44 gap-1.5 overflow-y-auto`,children:c.map(e=>{let t=r===`lan:${e.id}`;return(0,K.jsxs)(`li`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(Ge,{className:`size-4 flex-none text-muted-foreground`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]}),(0,K.jsxs)(s,{size:`sm`,disabled:r!==null,onClick:()=>void k(e),children:[t?(0,K.jsx)(le,{className:`animate-spin`}):null,n(`config:mobileServer.requestConnect`)]})]},e.id)})}):(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(u?`config:mobileServer.discovering`:`config:mobileServer.noNearby`)}),f?(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-destructive`,children:f}):null,m?(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md bg-muted px-3 py-2`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed`,children:m}),(0,K.jsx)(s,{size:`sm`,variant:`outline`,onClick:()=>void O(),children:n(`config:mobileServer.cancelRequest`)})]}):null]}),(0,K.jsxs)(`div`,{className:`relative py-1`,children:[(0,K.jsx)(R,{}),(0,K.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,K.jsxs)(s,{className:`w-full`,disabled:r!==null,onClick:()=>void A(),children:[r===`scan`?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(qr,{}),n(`config:mobileServer.scan`)]}),_?(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-destructive`,children:_}):null]})})})}function _a(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`native bridge unavailable`))}function va({requestConfirm:e}){let{t}=h(),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(``),[o,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(!1),d=(0,G.useCallback)(async()=>{try{r(await _a(`mobile_state`)),a(``)}catch{a(t(`config:mobileServer.loadFailed`))}},[t]);(0,G.useEffect)(()=>{d()},[d]);let f=async(e,t,n=``)=>{c(n||e);try{r(await _a(e,t)),a(``)}catch(e){a(String(e))}finally{c(``)}},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=>{c(e);try{let t=await _a(`mobile_select_server`,{id:e});r(t),a(``),t.proxyUrl&&window.location.replace(t.proxyUrl)}catch(e){a(String(e))}finally{c(``)}},g=n?.mode===`local`,_=n?.mode===`remote`&&!!n.activeId,v=g||_,y=t(g?`config:mobileServer.currentLocal`:_?`config:mobileServer.current`:`config:mobileServer.empty`);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 rounded-[var(--r-sm)] border px-3 py-2 text-[12px] ${v?`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,K.jsx)(v?Te:Rr,{size:15,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:y}),n?.activeTransport?(0,K.jsx)(`span`,{className:`flex-none text-[11px] opacity-80`,children:n.activeTransport===`iroh`?t(`config:mobileServer.transportP2p`):t(`config:mobileServer.transportLan`)}):null]}),(0,K.jsx)(ga,{open:l,onOpenChange:u}),(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`mobile-server-main`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-[11px]`,children:[(0,K.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,K.jsx)(Oe,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-[16px]`,children:t(`config:mobileServer.title`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:mobileServer.description`)})]})]}),(0,K.jsxs)(s,{size:`sm`,className:`max-[650px]:h-10 max-[650px]:px-3`,onClick:()=>u(!0),children:[(0,K.jsx)(lt,{size:14}),t(`config:mobileServer.addServer`)]})]}),i?(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--danger)]`,children:i}):null]}),(0,K.jsx)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`mobile-server-local`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-48 items-start gap-[11px]`,children:[(0,K.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,K.jsx)(Zr,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`flex flex-wrap items-center gap-2 text-[16px]`,children:[t(`config:mobileServer.localTitle`),g?(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--star-strong)]`,children:t(`config:mobileServer.currentLocal`)}):null]}),(0,K.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:mobileServer.localDescription`)})]})]}),(0,K.jsx)(s,{size:`sm`,variant:`outline`,className:`flex-none max-[650px]:h-10 max-[650px]:px-3`,disabled:g||!!o,onClick:()=>void(async()=>{c(`mobile_enter_local`);try{let e=await _a(`mobile_enter_local`);e.onDevice.url&&window.location.replace(e.onDevice.url)}catch(e){a(String(e))}finally{c(``)}})(),children:t(g?`config:mobileServer.currentLocal`:`config:mobileServer.enterLocal`)})]})}),(0,K.jsx)(Y,{className:`flex flex-col gap-3 p-4`,children:n?.servers?.length?(0,K.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`),c=i?.url||(a?.nodeId?`Iroh ${a.nodeId.slice(0,12)}`:`Iroh`);return(0,K.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,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(Ge,{size:15,className:`flex-none text-[var(--text-muted)]`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`truncate text-[13px]`,children:[e.name,r?(0,K.jsx)(`span`,{className:`ml-2 text-[11px] text-[var(--star-strong)]`,children:t(`config:mobileServer.current`)}):null]}),(0,K.jsxs)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:[c,(0,K.jsx)(`span`,{className:`ml-2`,children:t(i&&a?`config:mobileServer.transportLanP2p`:a?`config:mobileServer.transportP2p`:`config:mobileServer.transportLan`)})]}),r&&n.activeTransport?(0,K.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,K.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[r?null:(0,K.jsx)(s,{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,K.jsx)(s,{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,K.jsx)(xe,{size:14})})]})]},e.id)})}):(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:mobileServer.empty`)})})]})}var ya={feishu:{tone:`blue`},weixin:{tone:`green`},qq:{tone:`blue`},telegram:{tone:`blue`},browser:{tone:`blue`}};function ba(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 xa(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 Sa(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 Ca(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 wa(){return typeof window<`u`&&window.pisperDesktop?.showNotification?window.pisperDesktop.getNotificationStatus?`checking`:`granted`:typeof window<`u`&&at()?`checking`:st()}function Ta(e,t){return t(e===`system-disabled`||e===`app-disabled`?`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`:e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`)}function Ea(e){return e instanceof Error?e.message:String(e)}function Da({notify:e,onBrowserNotificationChange:t}){let{t:n}=h(),[i,a]=(0,G.useState)({browser:{enabled:!1},connections:{},scopes:[],templates:[]}),[o,c]=(0,G.useState)(!0),[l,u]=(0,G.useState)(``),d=!!window.pisperDesktop?.showNotification,f=at(),[p,m]=(0,G.useState)(wa),[g,_]=(0,G.useState)(!1),v=(0,G.useCallback)(async()=>{if(!d)return;let e=window.pisperDesktop?.getNotificationStatus;if(!e){m(`granted`);return}try{let t=await e(),n=t?.permission;m(n==="default"||n===`denied`||n===`granted`||n===`checking`||n===`unsupported`?n:t?.supported===!1?`unsupported`:`granted`)}catch{m(`unsupported`)}},[d]),y=(0,G.useCallback)(async()=>{try{u(``);let e=await r(`/api/settings/notifications`);a(e),t?.(e)}catch(e){u(Ea(e))}finally{c(!1)}},[t]);(0,G.useEffect)(()=>{y()},[y]),(0,G.useEffect)(()=>{if(!d)return;v();let e=()=>{v()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[d,v]);let b=(0,G.useCallback)(async()=>{if(!(d||!f))try{let e=await ut();m(e===!0?`granted`:e===!1?`denied`:`default`)}catch{m(`unsupported`)}},[d,f]);(0,G.useEffect)(()=>{if(d||!f)return;b();let e=()=>void b();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[d,f,b]);let x=async i=>{let o=``;if(i){if(d&&p!==`granted`)o=Ta(`system-disabled`,n);else if(!d&&f){let e=`denied`;try{let t=await ut()===!0?`granted`:await ct();e=t===`granted`?`granted`:t===`denied`?`denied`:`default`}catch{e=`unsupported`}m(e),e!==`granted`&&(o=n(`config:notificationSettings.systemNotificationsAreOffAllowPisperToSendNotificationsInYourOperatingSystemSettings`))}else if(!d){let e=await Ae();if(m(e),e!==`granted`)o=n(e===`unsupported`?`config:notificationSettings.systemNotificationsAreNotSupportedInThisEnvironment`:`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`);else try{await He()}catch{o=n(`config:notificationSettings.theBrowserBackgroundNotificationServiceCouldNotBeRegistered`)}}}_(!0);try{let s=await r(`/api/settings/notifications/browser`,{method:`PATCH`,body:JSON.stringify({enabled:i})});a(s),t?.(s),o?e(n(`config:notificationSettings.savedButLocalDeliveryUnavailable`,{reason:o}),`info`):e(n(i?`config:notificationSettings.notificationsEnabled`:`config:notificationSettings.notificationsDisabled`))}catch(t){e(Ea(t),`error`)}finally{_(!1)}},S=(0,G.useCallback)(async(e,t,r=`pisper-browser-test`)=>{if(d){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 m(i.permission??`denied`),Error(Ta(i.reason,n));return i}return f?(await qe(e,t),{shown:!0,transport:`tauri`}):ke({title:e,body:t,tag:r,url:window.location.href})},[d,f,n]),C=async()=>{if(p!==`granted`){e(p===`unsupported`?Ta(`unsupported`,n):d?Ta(`system-disabled`,n):n(`config:notificationSettings.notificationPermissionWasNotGrantedAllowNotificationsInTheBrowserSiteSettings`),`error`);return}try{await S(n(`config:notificationSettings.appNotificationTest`,{app:St}),n(`config:notificationSettings.notificationsAreWorking`)),e(n(`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`),`info`)}catch(t){e(Ea(t)||n(`config:notificationSettings.theOperatingSystemDidNotAcceptTheNotificationCheckYourSystemNotificationSettings`),`error`)}},w=async()=>{try{await window.pisperDesktop?.openNotificationSettings?.()||e(n(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}catch{e(n(`config:notificationSettings.openNotificationPermissionsInYourOperatingSystemSettings`),`info`)}};if(o)return(0,K.jsxs)(nt,{children:[(0,K.jsx)(V,{className:`animate-spin`,size:23}),(0,K.jsx)(`h2`,{children:n(`config:notificationSettings.loadingNotificationSettings`)})]});let T=n(p===`granted`?`config:notificationSettings.permissionGranted`:p===`denied`?d?`config:notificationSettings.systemNotificationsAreOff`:`config:notificationSettings.browserNotificationsAreBlocked`:p===`unsupported`?`config:notificationSettings.notSupported`:p===`checking`?`config:notificationSettings.checking`:`config:notificationSettings.waitingForPermission`),E=p===`granted`?`green`:p==="default"||p===`checking`?`amber`:`red`;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-[12px]`,children:[l&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{size:13}),l]}),(0,K.jsxs)(Y,{className:`browser-notification-card`,"data-config-card":`notifications-browser`,children:[(0,K.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,K.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)] ${i.browser.enabled?`blue`:``}`,children:i.browser.enabled?(0,K.jsx)(ze,{size:18}):(0,K.jsx)(Fr,{size:18})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{children:n(`config:notificationSettings.notification`)}),(0,K.jsx)(`small`,{children:n(`config:notificationSettings.pisperUsesTheCurrentPlatformNotificationSystemWhenAnAgentCompletesOrFails`)})]}),(0,K.jsx)(X,{tone:E,children:T}),(0,K.jsx)(ri,{value:i.browser.enabled,disabled:g||p===`checking`,onChange:x})]}),(0,K.jsxs)(Ke,{children:[(0,K.jsx)(ye,{size:15}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:n(d?`config:notificationSettings.controlledByOperatingSystemNotificationSettings`:`config:notificationSettings.controlledByBrowserSitePermissions`)}),(0,K.jsx)(`small`,{children:n(d?`config:notificationSettings.theDesktopAppUsesOperatingSystemNotificationsTurningThisOffDoesNotChangeTheOperatingSystemPermis`:`config:notificationSettings.theWebAppUsesBrowserSiteNotificationsTurningThisOffDoesNotChangeTheBrowserPermissionItself`)})]})]}),(0,K.jsxs)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:[d&&p===`denied`&&(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:w,children:[(0,K.jsx)(ye,{size:14}),n(`config:notificationSettings.openSystemNotificationSettings`)]}),(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:!i.browser.enabled||p!==`granted`,onClick:C,children:[(0,K.jsx)(ze,{size:14}),n(`config:notificationSettings.sendTestNotification`)]})]})]}),(0,K.jsx)(Oa,{data:i,setData:a,notify:e,permission:p,onBrowserTest:S,onSettingsChange:t})]})}function Oa({data:e,setData:t,notify:n,permission:i,onBrowserTest:a,onSettingsChange:o}){let{t:c}=h(),[l,u]=(0,G.useState)(e.templates[0]?.id||``),[d,f]=(0,G.useState)(`feishu`),p=e.templates.find(e=>e.id===l)||e.templates[0],m=p?.channels?.[d],[g,_]=(0,G.useState)(m?.content||``),[v,y]=(0,G.useState)(!1),b=e.scopes.find(e=>e.platform===d),x=d===`browser`?e.browser.enabled&&i===`granted`:!!b,S=ya;return(0,G.useEffect)(()=>{_(m?.content||``)},[l,d,m?.content]),p?(0,K.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,K.jsxs)(Y,{"data-config-card":`notifications-templates`,children:[(0,K.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,K.jsx)(ni,{title:c(`config:notificationSettings.notificationTemplates`)}),(0,K.jsx)(`span`,{children:c(`config:notificationSettings.sharedByChatsScheduledTasksAndWorkflows`)})]}),e.templates.map(e=>(0,K.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===p.id?`selected`:``}`,onClick:()=>u(e.id),children:[(0,K.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,K.jsx)(ve,{size:14})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:xa(e.id,e.name,c)}),(0,K.jsx)(`small`,{children:Sa(e.id,e.description,c)})]}),(0,K.jsx)(X,{tone:e.enabled?`green`:`gray`,children:e.enabled?c(`config:notificationSettings.enabled`):c(`config:notificationSettings.disabled`)})]},e.id))]}),(0,K.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,K.jsxs)(et,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:xa(p.id,p.name,c)}),(0,K.jsx)(`p`,{children:Sa(p.id,p.description,c)})]}),(0,K.jsx)(ri,{value:p.enabled,onChange:e=>t(t=>({...t,templates:t.templates.map(t=>t.id===p.id?{...t,enabled:e}:t)}))})]}),(0,K.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(S).map(([t,n])=>{let r=t===`browser`?e.browser.enabled:e.connections?.[t];return(0,K.jsxs)(`button`,{className:d===t?`active`:``,onClick:()=>f(t),children:[ba(t,c),(0,K.jsx)(X,{tone:r?n.tone:`red`,className:` absolute -top-2.5 -right-1.5`,children:c(r?t===`browser`?`config:notificationSettings.enabled2`:`config:notificationSettings.connected`:t===`browser`?`config:notificationSettings.notEnabled`:`config:notificationSettings.notConnected`)})]},t)})}),(0,K.jsxs)(W,{variant:`control`,children:[c(`config:notificationSettings.messageContent`),(0,K.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value)})]}),(0,K.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,K.jsx)(`span`,{children:c(`config:notificationSettings.availableVariables`)}),p.variables.map(e=>(0,K.jsx)(`code`,{children:`{{${e}}}`},e))]}),(0,K.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,K.jsx)(`small`,{children:c(`config:notificationSettings.preview`)}),(0,K.jsx)(`pre`,{children:Ca(g,c)})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:v||!x,onClick:async()=>{y(!0);try{let e=await r(`/api/settings/notifications/templates/${encodeURIComponent(p.id)}/${d}/test`,{method:`POST`,body:`{}`});d===`browser`&&await a?.(e.title||xa(p.id,p.name,c),e.body||e.preview||``,`pisper-template-${p.id}`),n(c(d===`browser`?`config:notificationSettings.theTestNotificationWasSentCheckYourSystemNotificationCenter`:`config:notificationSettings.testNotificationSentToCountChats`,{count:e.sent}))}catch(e){n(Ea(e),`error`)}finally{y(!1)}},children:[(0,K.jsx)(ve,{size:14}),c(`config:notificationSettings.sendTest`)]}),(0,K.jsxs)(s,{size:`lg`,disabled:v||!g.trim(),onClick:async()=>{y(!0);try{let e=await r(`/api/settings/notifications/templates/${encodeURIComponent(p.id)}/${d}`,{method:`PUT`,body:JSON.stringify({enabled:p.enabled,content:g})});t(e),o?.(e),n(c(`config:notificationSettings.notificationTemplateSaved`))}catch(e){n(Ea(e),`error`)}finally{y(!1)}},children:[v?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(_e,{size:14}),c(`config:notificationSettings.saveTemplate`)]})]})]})]}):null}function ka({notify:e}){let{t,language:n}=h(),[i,a]=(0,G.useState)(null),[o,c]=(0,G.useState)(null),[l,u]=(0,G.useState)([]),[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(``),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(``),E=(0,G.useCallback)(async()=>{try{let[e,t,n,i]=await Promise.all([r(`/api/remote/status`),r(`/api/remote/devices`),r(`/api/remote/pairing-requests`).catch(()=>({requests:[]})),r(`/api/remote/firewall`).catch(e=>{if(e&&typeof e==`object`&&`status`in e&&e.status===403)return null;throw e})]);a(e),c(i),u(t.devices.filter(e=>!e.revokedAt)),f(n.requests),T(``)}catch{T(t(`config:remoteAccess.loadFailed`))}},[t]);(0,G.useEffect)(()=>{E()},[E]),(0,G.useEffect)(()=>{if(!i?.listening)return;let e=window.setInterval(()=>void E(),2e3);return()=>window.clearInterval(e)},[E,i?.listening]);let D=async n=>{C(!0);try{await r(`/api/remote/enabled`,{method:`PUT`,body:{enabled:n,configureFirewall:o!==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||(m(null),_(!1),y(``)),await E()}catch(n){e(t(`config:remoteAccess.toggleFailed`,{message:String(n)}),`error`)}finally{C(!1)}},O=async()=>{C(!0);try{await r(`/api/remote/firewall/retry`,{method:`POST`,body:{},timeout:15e4}),await E()}catch(n){e(t(`config:remoteAccess.firewallRetryFailed`,{message:String(n)}),`error`)}finally{C(!1)}},k={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`)},A={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`)},j=async()=>{C(!0),y(``);try{let e=await r(`/api/remote/pairing-code`,{method:`POST`});if(!e?.code||!e?.expiresAt)throw Error(t(`config:remoteAccess.qrUnavailable`));m(e),_(!0),e.qrDataUrl||y(t(`config:remoteAccess.qrUnavailable`))}catch(n){let r=t(`config:remoteAccess.pairingFailed`,{message:String(n)});y(r),e(r,`error`)}finally{C(!1)}},M=async(n,i)=>{x(n.id);try{await r(`/api/remote/pairing-requests/${encodeURIComponent(n.id)}/decision`,{method:`POST`,body:{approved:i}}),await E()}catch(n){e(t(`config:remoteAccess.approvalFailed`,{message:String(n)}),`error`)}finally{x(``)}},N=async n=>{if(window.confirm(t(`config:remoteAccess.revokeConfirm`,{name:n.name})))try{await r(`/api/remote/devices/${encodeURIComponent(n.id)}/revoke`,{method:`POST`}),await E()}catch(n){e(t(`config:remoteAccess.revokeFailed`,{message:String(n)}),`error`)}};return w?(0,K.jsx)(Y,{className:`p-4 text-[13px] text-[var(--text-muted)]`,children:w}):i?(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsx)(Ze,{open:g&&p!==null,onOpenChange:_,children:(0,K.jsxs)(we,{className:`sm:max-w-md`,children:[(0,K.jsxs)(Fe,{children:[(0,K.jsx)(Re,{children:t(`config:remoteAccess.pairingQrTitle`)}),(0,K.jsx)(Xe,{children:t(`config:remoteAccess.scanQrDescription`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-2`,"aria-live":`polite`,children:[p?.qrDataUrl?(0,K.jsx)(`img`,{src:p.qrDataUrl,alt:t(`config:remoteAccess.qrAlt`),className:`size-64 max-w-full rounded-[var(--r-sm)] bg-white p-2`}):null,v?(0,K.jsx)(`p`,{className:`text-center text-[12px] leading-relaxed text-[var(--danger)]`,children:v}):null,p?(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`font-mono text-[20px] tracking-[0.2em]`,children:p.code}),(0,K.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.codeExpiresAt`,{time:Ee(p.expiresAt,n)})})]}):null]}),(0,K.jsx)(Ne,{children:(0,K.jsxs)(s,{disabled:S,onClick:()=>void j(),children:[S?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(V,{}),t(S?`config:remoteAccess.generatingQr`:`config:remoteAccess.regenerate`)]})})]})}),(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-main`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-[11px]`,children:[(0,K.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,K.jsx)(Oe,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-[16px]`,children:t(`config:remoteAccess.title`)}),(0,K.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.55] text-[var(--text-muted)]`,children:t(`config:remoteAccess.description`)})]})]}),(0,K.jsx)(ri,{value:i.enabled,disabled:S,onChange:e=>void D(e),ariaLabel:t(`config:remoteAccess.title`)})]}),i.error?(0,K.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:i.error})}):null]}),o?(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"aria-live":`polite`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`h3`,{className:`text-[14px]`,children:t(`config:remoteAccess.firewallTitle`)}),i.enabled||o.state===`cleanup_pending`?(0,K.jsxs)(s,{size:`sm`,disabled:S||o.busy,onClick:()=>void O(),children:[S||o.busy?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(V,{}),i.enabled?t(`config:remoteAccess.firewallRetry`):t(`config:remoteAccess.firewallRetryCleanup`)]}):null]}),(0,K.jsx)(`p`,{className:`text-[13px]`,children:o.busy?t(`config:remoteAccess.firewallWorking`):k[o.state]}),o.reason&&A[o.reason]?(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:A[o.reason]}):null,i.enabled?(0,K.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:o.scope===`application`?t(`config:remoteAccess.firewallApplicationScope`):o.scope===`program_port`?t(`config:remoteAccess.firewallProgramPortScope`,{port:o.port??`—`}):t(`config:remoteAccess.firewallPortScope`,{port:o.port??`—`})}):null,(0,K.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:t(`config:remoteAccess.firewallReachability`)}),o.checkedAt?(0,K.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.firewallCheckedAt`,{time:Ee(o.checkedAt,n)})}):null]}):null,i.listening&&d.length?(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"aria-live":`polite`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,K.jsx)(Zr,{size:16}),t(`config:remoteAccess.pendingApprovals`)]}),(0,K.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-muted)]`,children:t(`config:remoteAccess.pendingApprovalsDescription`)}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-sm)] border border-[var(--border)] px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-[13px]`,children:e.deviceName}),(0,K.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.requestedAt`,{time:Ee(e.requestedAt,n)})}),(0,K.jsx)(`code`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.requestSource`,{ip:e.ip})})]}),(0,K.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[(0,K.jsxs)(s,{size:`sm`,variant:`ghost`,disabled:b===e.id,onClick:()=>void M(e,!1),children:[(0,K.jsx)(Ce,{}),t(`config:remoteAccess.reject`)]}),(0,K.jsxs)(s,{size:`sm`,disabled:b===e.id,onClick:()=>void M(e,!0),children:[b===e.id?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(z,{}),t(`config:remoteAccess.approve`)]})]})]},e.id))})]}):null,i.listening?(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-pairing`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,K.jsx)(qr,{size:16}),t(`config:remoteAccess.pairing`)]}),(0,K.jsxs)(s,{size:`sm`,disabled:S,onClick:()=>void j(),children:[S?(0,K.jsx)(le,{className:`animate-spin`}):(0,K.jsx)(qr,{}),t(S?`config:remoteAccess.generatingQr`:`config:remoteAccess.generateQr`)]})]}),(0,K.jsx)(`p`,{className:`text-[12px] leading-[1.6] text-[var(--text-muted)]`,children:t(`config:remoteAccess.pairingDescription`)}),v&&!g?(0,K.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--danger)]`,"aria-live":`polite`,children:v}):null]}):null,(0,K.jsxs)(Y,{className:`flex flex-col gap-3 p-4`,"data-config-card":`remote-access-devices`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,K.jsx)(Zr,{size:16}),t(`config:remoteAccess.devices`)]}),(0,K.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>void E(),"aria-label":t(`config:remoteAccess.refresh`),children:(0,K.jsx)(V,{size:14})})]}),l.length===0?(0,K.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.noDevices`)}):(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-3 rounded-[var(--r-sm)] border border-[var(--border)] px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`truncate text-[13px]`,children:[e.name,e.current?(0,K.jsx)(`span`,{className:`ml-2 text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.currentDevice`)}):null]}),(0,K.jsx)(`div`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`config:remoteAccess.lastSeen`,{time:Ee(e.lastSeenAt,n)})})]}),(0,K.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>void N(e),children:t(`config:remoteAccess.revoke`)})]},e.id))})]})]}):null}function Aa({notify:e}){let{t}=h(),n=window.pisperDesktop,[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(``),[c,l]=(0,G.useState)(``);(0,G.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,K.jsxs)(Y,{className:`[padding:18px] cli-settings-card`,"data-config-card":`updates-cli`,children:[(0,K.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,K.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,K.jsx)($r,{size:19})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{children:t(`config:cliSettings.title`)}),(0,K.jsx)(`p`,{children:t(`config:cliSettings.description`)})]}),(0,K.jsx)(X,{tone:r?.installed&&!r.needsRepair?`green`:r?.needsRepair?`blue`:`gray`,children:m})]}),r&&(0,K.jsxs)(Ke,{className:`[margin-top:15px] cli-settings-status [&_small]:[overflow-wrap:anywhere]`,children:[r.installed&&!r.needsRepair?(0,K.jsx)(Te,{size:16}):(0,K.jsx)($r,{size:16}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`strong`,{children:r.installed?t(`config:cliSettings.commandReady`,{command:r.command}):t(`config:cliSettings.commandNotInstalled`,{command:r.command})}),(0,K.jsx)(`small`,{children:r.installPath}),r.installed&&(0,K.jsx)(`small`,{children:r.pathConfigured?t(`config:cliSettings.pathConfigured`):t(`config:cliSettings.pathNeedsRepair`)})]})]}),c&&(0,K.jsx)(U,{children:c}),u&&(0,K.jsxs)(`div`,{className:`mt-3.5 flex justify-end gap-2 max-[650px]:flex-wrap`,children:[r?.installed&&(0,K.jsxs)(s,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:!!a,onClick:()=>void f(),children:[a===`uninstall`?(0,K.jsx)(V,{className:`animate-spin`,size:14}):(0,K.jsx)(xe,{size:14}),t(`config:cliSettings.uninstall`)]}),(!r?.installed||r.needsRepair)&&(0,K.jsxs)(s,{type:`button`,size:`lg`,disabled:!!a||p||r?.supported===!1,onClick:()=>void d(),children:[a===`install`?(0,K.jsx)(V,{className:`animate-spin`,size:14}):r?.needsRepair?(0,K.jsx)(Se,{size:14}):(0,K.jsx)(Qe,{size:14}),r?.needsRepair?t(`config:cliSettings.repair`):t(`config:cliSettings.install`)]})]}),u&&(0,K.jsx)(`small`,{className:`block [margin:9px_1px_0] text-[var(--text-muted)] text-[12px]`,children:t(`config:cliSettings.restartTerminal`)})]})}var ja=`0.5.48`,Ma=9e5,Na=2592e6;function Pa(){try{let e=JSON.parse(localStorage.getItem(ie.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 Fa(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 Ia(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 La({notify:e,update:t}){let{t:n,language:i}=h(),a=t?.info||{desktop:!1,packaged:!1,version:ja,platform:`browser`,arch:``},o=t?.status||{state:`idle`},c=!!a.desktop,l=!!a.mobile,u=c||l,[d,f]=(0,G.useState)({version:ja,date:``,notes:``}),[p,m]=(0,G.useState)([]),[g,_]=(0,G.useState)(``),[v,y]=(0,G.useState)(Pa);(0,G.useEffect)(()=>{let e=!0;return fetch(`/release-notes.json`,{cache:`no-store`}).then(e=>e.ok?e.json():null).then(t=>{e&&t&&f(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,G.useEffect)(()=>{let e=!0,t=(t=!1)=>r(`/api/sponsors/settings-updates?locale=${encodeURIComponent(i)}${t?`&refresh=1`:``}`).then(t=>{e&&m(Array.isArray(t.campaigns)?t.campaigns:[])}).catch(()=>{e&&!t&&m([])});t();let n=window.setInterval(()=>void t(!0),Ma);return()=>{e=!1,window.clearInterval(n)}},[i]);let b=e=>{let t={...v,[e]:Date.now()+Na};y(t);try{localStorage.setItem(ie.sponsorDismissals,JSON.stringify(t))}catch{}},x=async()=>{if(t){_(`check`);try{await t.check()}finally{_(``)}}},S=()=>t?.openReleases(),C=()=>t?.openUpdateLog?.(),w=async()=>{_(c?`install`:``);try{c?await t?.installComponents():await t?.download()}catch(t){e(t instanceof Error?t.message:String(t),`error`)}finally{_(``)}},T=()=>t?.install(),E=d.version===a.version?d:null,D=o.notes||(u?E?.notes||n(`config:updateSettings.noReleaseNotesAreAvailableForThisVersion`):o.state===`current`?n(`config:updateSettings.theCurrentWebSourceIsSyncedWithBranch`,{branch:o.branch||`main`}):n(`config:updateSettings.commitsThatHaveNotBeenSyncedWillAppearHereAfterTheCheck`)),O=o.state===`available`,k=o.state===`error`&&o.canResume&&o.canDownload,A=o.state===`downloaded`,j=o.state===`checking`||g===`check`,M=o.state===`downloading`||g===`install`,N=j?`checking`:M?`downloading`:o.state,ee=u?`v${a.version}`:`v${a.version}${o.currentCommit?` · ${o.currentCommit.slice(0,7)}`:``}`,P=u?`v${o.availableVersion||E?.version||a.version}`:o.availableCommit?.slice(0,7)||o.currentCommit?.slice(0,7)||d.version||a.version,F=p.filter(e=>(v[e.id]||0)<=Date.now()),I=(0,G.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]),te=(0,G.useMemo)(()=>({idle:[n(`config:updateSettings.notChecked`),`gray`],checking:[n(`config:updateSettings.checking`),`blue`],current:[n(`config:updateSettings.upToDate`),`green`],available:[n(u?`config:updateSettings.updateAvailable`:`config:updateSettings.sourceUpdatesAvailable`),`blue`],downloading:[n(`config:updateSettings.downloading`),`blue`],downloaded:[n(`config:updateSettings.readyToRestart`),`green`],installed:[n(`config:updateSettings.upToDate`),`green`],error:[n(k?`config:updateSettings.downloadPaused`:`config:updateSettings.checkFailed`),`red`]})[N]||[n(`config:updateSettings.notChecked`),`gray`],[u,N,k,n]);return(0,K.jsxs)(`div`,{className:`mx-auto flex w-full flex-col gap-3`,children:[(0,K.jsxs)(Y,{className:`p-5`,"data-config-card":`updates-main`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,K.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,K.jsx)(Wr,{size:19})}),(0,K.jsx)(`span`,{className:`min-w-0`,children:(0,K.jsx)(`strong`,{className:`block text-[16px]`,children:n(`config:updateSettings.pisperAppUpdates`)})})]}),(0,K.jsx)(X,{tone:te[1],children:te[0]})]}),(0,K.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(u?`config:updateSettings.currentVersion`:`config:updateSettings.currentSource`)}),(0,K.jsx)(`strong`,{className:`mt-1 block font-mono text-[14px]`,children:ee})]}),(0,K.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`config:updateSettings.platform`)}),(0,K.jsx)(`strong`,{className:`mt-1 block text-[14px]`,children:Fa(a,n)})]}),(0,K.jsxs)(`div`,{className:`rounded-[var(--r-sm)] bg-[var(--surface-muted)] p-3`,children:[(0,K.jsx)(`small`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`config:updateSettings.updateChannel`)}),(0,K.jsx)(`strong`,{className:`mt-1 block text-[14px]`,children:u?`Stable`:o.branch||`main`})]})]}),o.message&&(0,K.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,K.jsx)(H,{className:`mt-0.5 shrink-0`,size:15}):(0,K.jsx)(Ur,{className:`mt-0.5 shrink-0`,size:15}),(0,K.jsx)(`span`,{children:o.message})]}),k&&(0,K.jsx)(`small`,{className:`mt-2 block text-[12px] text-[var(--text-muted)]`,children:n(`config:updateSettings.downloadedDataWasPreservedAndCanResumeFromTheInterruptionPoint`)}),M&&(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-[12px] text-[var(--text-muted)]`,children:[(0,K.jsx)(`span`,{children:n(`config:updateSettings.downloadProgress`)}),(0,K.jsxs)(`span`,{children:[Math.round(o.percent||0),`% · `,Ia(o.transferred,i),` /`,` `,Ia(o.total,i)]})]}),(0,K.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-[var(--progress-track)]`,children:(0,K.jsx)(`i`,{className:`block h-full bg-[var(--star)] transition-[width]`,style:{width:`${o.percent||0}%`}})})]}),(0,K.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,K.jsxs)(s,{size:`lg`,disabled:j||M||!!g,onClick:A?T:O||k?w:x,children:[j||M?(0,K.jsx)(V,{className:`animate-spin`,size:14}):A?(0,K.jsx)(dt,{size:14}):O||k?o.canDownload?(0,K.jsx)(Qe,{size:14}):(0,K.jsx)(Le,{size:14}):(0,K.jsx)(V,{size:14}),j||M?n(M&&c?`config:updateSettings.installingUpdates`:`config:updateSettings.checking2`):A?n(`config:updateSettings.restartAndInstall`):k?n(`config:updateSettings.resumeDownload`):O?o.canDownload?n(c?`config:updateSettings.downloadAndInstallUpdates`:`config:updateSettings.downloadUpdate`):n(u?`config:updateSettings.viewRelease`:`config:updateSettings.viewSourceUpdates`):n(`config:updateSettings.checkForUpdates`)]}),(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:S,children:[(0,K.jsx)(Le,{size:14}),u?`GitHub Releases`:`GitHub Compare`]}),c&&(0,K.jsxs)(s,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:C,children:[(0,K.jsx)(Le,{size:14}),n(`config:updateSettings.viewUpdateDiagnosticLog`)]})]}),!l&&(0,K.jsxs)(`div`,{className:`mt-6 border-t border-[var(--border)] pt-5`,"data-config-card":`updates-components`,children:[(0,K.jsx)(ni,{title:n(`config:updateSettings.appComponents`)}),(0,K.jsx)(`div`,{className:`mt-3 divide-y divide-[var(--border)]`,children:I.map(e=>{let t=e.component===`desktop`?Ur:e.component===`tui`?be:zr,r=e.component===`desktop`?n(`config:updateSettings.desktopFrontend`):e.component===`tui`?n(`config:updateSettings.tuiClient`):n(`config:updateSettings.runtime`),a=e.state===`error`?`red`:e.state===`available`?`blue`:e.state===`installed`||e.state===`current`?`green`:`gray`,o=e.state===`checking`?n(`config:updateSettings.checking`):e.state===`downloading`?n(`config:updateSettings.downloading`):e.state===`available`?n(`config:updateSettings.updateAvailable`):e.state===`installed`?n(`config:updateSettings.installed`):e.state===`error`?n(`config:updateSettings.checkFailed`):e.state===`current`?n(`config:updateSettings.upToDate`):n(`config:updateSettings.notChecked`);return(0,K.jsxs)(`div`,{className:`grid min-h-[68px] items-center gap-3 py-3 sm:grid-cols-[minmax(0,1fr)_auto_auto]`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,K.jsx)(t,{className:`shrink-0 text-[var(--text-muted)]`,size:17}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`strong`,{className:`block text-[14px]`,children:r}),e.message&&(0,K.jsx)(`small`,{className:`mt-0.5 block text-[12px] text-[var(--text-muted)]`,children:e.message})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[12px]`,children:[(0,K.jsxs)(`span`,{children:[`v`,e.currentVersion]}),e.availableVersion&&e.availableVersion!==e.currentVersion&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ae,{size:12}),(0,K.jsxs)(`span`,{children:[`v`,e.availableVersion]})]}),e.size>0&&e.state===`available`&&(0,K.jsx)(`span`,{className:`font-sans text-[var(--text-muted)]`,children:Ia(e.size,i)})]}),(0,K.jsx)(X,{tone:a,children:o})]},e.component)})})]})]}),!l&&(0,K.jsx)(Aa,{notify:e}),(0,K.jsxs)(Y,{className:`p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(ni,{title:n(u?O||k||A||M?`config:updateSettings.newVersionReleaseNotes`:`config:updateSettings.currentReleaseNotes`:O?`config:updateSettings.commitsToSync`:`config:updateSettings.currentSourceStatus`)}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px] text-[var(--text-muted)]`,children:[(0,K.jsx)(Te,{size:13}),O||k||A||M?P:u?`v${E?.version||a.version}`:o.currentCommit?.slice(0,7)||n(`config:updateSettings.notChecked`)]})]}),(o.releaseDate||u&&E?.date)&&(0,K.jsx)(`small`,{className:`mt-2 block text-[12px] text-[var(--text-muted)]`,children:new Intl.DateTimeFormat(i,{dateStyle:`long`}).format(new Date(o.releaseDate||E?.date||``))}),(0,K.jsx)(`div`,{className:`mt-4 rounded-[var(--r-sm)] border border-[var(--stroke-soft)] bg-[var(--surface-subtle)] p-4`,children:(0,K.jsx)(xt,{children:D})})]}),F.length>0&&(0,K.jsxs)(Y,{className:`p-5`,"data-config-card":`updates-sponsors`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,K.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,K.jsx)(Vr,{size:19})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(ni,{title:n(`config:updateSettings.sponsors`)}),(0,K.jsx)(`small`,{className:`mt-1 block text-[12px] leading-5 text-[var(--text-muted)]`,children:n(`config:updateSettings.sponsorsDescription`)})]})]}),(0,K.jsx)(`div`,{className:`mt-4 divide-y divide-[var(--stroke-soft)] border-y border-[var(--stroke-soft)]`,children:F.map(e=>(0,K.jsxs)(`div`,{className:`grid min-h-16 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3 py-3`,children:[(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:`mb-1 flex items-center gap-2`,children:[(0,K.jsx)(`strong`,{className:`truncate text-[14px]`,children:e.name}),(0,K.jsx)(X,{tone:`gray`,children:n(`config:updateSettings.sponsored`)})]}),(0,K.jsx)(`small`,{className:`block text-[12px] leading-5 text-[var(--text-muted)]`,children:e.description})]}),(0,K.jsx)(s,{asChild:!0,variant:`outline`,className:`bg-surface-subtle`,children:(0,K.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer sponsored`,children:[(0,K.jsx)(Le,{size:13}),n(`config:updateSettings.visitSponsor`)]})}),(0,K.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0`,"aria-label":n(`config:updateSettings.hideSponsor`),title:n(`config:updateSettings.hideSponsor`),onClick:()=>b(e.id),children:(0,K.jsx)(Ce,{size:15})})]},e.id))})]})]})}function Ra({notify:e,registerPrimaryAction:t,section:n,onBrowserNotificationChange:r,requestConfirm:i,update:a}){de(n);let o;return o=n===`notifications`?(0,K.jsx)(Da,{notify:e,onBrowserNotificationChange:r}):n===`interface`?(0,K.jsx)(yi,{notify:e}):n===`shortcuts`?(0,K.jsx)(Ei,{requestConfirm:i}):n===`desktop-pet`?(0,K.jsx)(fi,{notify:e,requestConfirm:i}):n===`mobile-server`?(0,K.jsx)(va,{requestConfirm:i}):n===`remote-access`?(0,K.jsx)(ka,{notify:e}):n===`updates`?(0,K.jsx)(La,{notify:e,update:a}):n===`about`?(0,K.jsx)(li,{update:a}):(0,K.jsx)(ea,{notify:e,registerPrimaryAction:t,requestConfirm:i}),(0,K.jsx)(`div`,{"data-config-card":me,children:o})}export{Ra as ConfigPage};