@yuriai/web 0.3.2-beta.2 → 0.3.2-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/assets/{AgentAvatar-B9ucI2MO.js → AgentAvatar-Dl75CmK8.js} +1 -1
  2. package/dist/assets/AssistantConversationSurface-Dp6zs0yn.js +3 -0
  3. package/dist/assets/AssistantSessionCard-WrAhcmUB.js +2 -0
  4. package/dist/assets/{AssistantUnreadBadge-RQ0DmUi6.js → AssistantUnreadBadge-DuhElWPK.js} +1 -1
  5. package/dist/assets/{AssistantView-Bo5BZS0L.js → AssistantView-BZYpqpnI.js} +1 -1
  6. package/dist/assets/{DiagramView-B-78GB_f.js → DiagramView-GcCsdA5z.js} +1 -1
  7. package/dist/assets/{FadeInOnReveal-C-CtY8g9.js → FadeInOnReveal-Ct1rl1tS.js} +1 -1
  8. package/dist/assets/{GuiPluginPage-B1YKmblD.js → GuiPluginPage-DvExR9I-.js} +1 -1
  9. package/dist/assets/{GuiPluginSurface-hm7K6byY.js → GuiPluginSurface-BFnUCbwm.js} +1 -1
  10. package/dist/assets/{GuiPluginWindow-7DO5ZOvG.js → GuiPluginWindow-C3B4RM6F.js} +1 -1
  11. package/dist/assets/{Icon-C6CNZZkk.js → Icon-DgBJx_JJ.js} +1 -1
  12. package/dist/assets/{ImageLoadingPlaceholder-B6Zer2YL.js → ImageLoadingPlaceholder-CxCcAKA_.js} +1 -1
  13. package/dist/assets/{LoadingImage-BPX-DCAP.js → LoadingImage-BfbEFJO6.js} +1 -1
  14. package/dist/assets/{MarkdownRenderer-DrXbG9Y5.js → MarkdownRenderer-BGMefVz0.js} +2 -2
  15. package/dist/assets/{MarkdownRendererImpl-D9FUbv9O.js → MarkdownRendererImpl-CkjS_Et2.js} +2 -2
  16. package/dist/assets/{MarkstreamRendererImpl-BXEYnxur.js → MarkstreamRendererImpl-B0teEFDV.js} +2 -2
  17. package/dist/assets/{MobileDetailNavigation-CpjB_jck.js → MobileDetailNavigation-9113s_ma.js} +1 -1
  18. package/dist/assets/{MobileResizableSheet-Cn4FFye8.js → MobileResizableSheet-BJ-iOaK0.js} +1 -1
  19. package/dist/assets/{MobileShareBridge-DuDpHmZD.js → MobileShareBridge-Dx3f6fUw.js} +1 -1
  20. package/dist/assets/MobileSurface-D9mhWzTr.js +2 -0
  21. package/dist/assets/{MultiRunWindow--3wAH_2i.js → MultiRunWindow-DN-EY73Y.js} +1 -1
  22. package/dist/assets/{OnboardingScreen-Cr6g_uej.js → OnboardingScreen-ClBvuMe9.js} +1 -1
  23. package/dist/assets/{OverlayScrollbar-CHgqvqG3.js → OverlayScrollbar-PIPr1Evo.js} +1 -1
  24. package/dist/assets/{RemoteAssistantSessionCard-CE-B_FHL.js → RemoteAssistantSessionCard-CJiC-EkZ.js} +1 -1
  25. package/dist/assets/{SettingsView-BoQRiuVv.js → SettingsView-Bq_efBmE.js} +13 -13
  26. package/dist/assets/{SettingsWindow-B1JkVKIr.js → SettingsWindow-BuwGUijj.js} +1 -1
  27. package/dist/assets/{SetupTourDialog-B43dbK2I.js → SetupTourDialog-CvlBSC6d.js} +1 -1
  28. package/dist/assets/{TerminalView-DKS2KRh0.js → TerminalView-DuSAe2hR.js} +1 -1
  29. package/dist/assets/ToolOutputDialog-BVEHo8-L.js +16 -0
  30. package/dist/assets/{VoiceSettings-C6jznmzY.js → VoiceSettings-CK9kIRt_.js} +2 -2
  31. package/dist/assets/{capgoAdapter-B3s9u7sG.js → capgoAdapter-DcCzS0K2.js} +1 -1
  32. package/dist/assets/{checkbox-Cossbslk.js → checkbox-LxYTavVR.js} +1 -1
  33. package/dist/assets/{collapsible-Bt9trgB2.js → collapsible-QODzeNp0.js} +1 -1
  34. package/dist/assets/{context-menu-DUzve8Id.js → context-menu-COAkU7Ah.js} +1 -1
  35. package/dist/assets/{diagram-CCwMM241.js → diagram-C5Eusp6S.js} +1 -1
  36. package/dist/assets/dialog-Cc0snjnm.js +1 -0
  37. package/dist/assets/dialog-DYOEW9DC.css +1 -0
  38. package/dist/assets/{fileMentionTouchSelection-BsMdH79T.js → fileMentionTouchSelection-CgtX2i5j.js} +1 -1
  39. package/dist/assets/{gitApi-6bjyfJ0P.js → gitApi-2YB0zq5C.js} +1 -1
  40. package/dist/assets/{input-Dc9Few6S.js → input-BU5xc-yv.js} +1 -1
  41. package/dist/assets/{insertionBoundaries-DImWCHHe.js → insertionBoundaries-BythIGNL.js} +1 -1
  42. package/dist/assets/{main-C27KIa4w.js → main-9i7pD__G.js} +14 -14
  43. package/dist/assets/{main-ClvHuS1l.js → main-CH2eMc3E.js} +2 -2
  44. package/dist/assets/{markdownHeightCache-CgEzszwt.js → markdownHeightCache-MrVUTvbP.js} +1 -1
  45. package/dist/assets/{mcpQueries-D-c3h-8F.js → mcpQueries-DRVf_ZiV.js} +1 -1
  46. package/dist/assets/miniChat-BpjBFTDv.js +2 -0
  47. package/dist/assets/mobile-C2jRZnAH.js +2 -0
  48. package/dist/assets/{mobileBackNavigation-CX1dqatK.js → mobileBackNavigation-DAVsjgP7.js} +1 -1
  49. package/dist/assets/mobileConnections-CcRHORuJ.js +2 -0
  50. package/dist/assets/{multirun-BqGvXgzB.js → multirun-PwvGTGVN.js} +1 -1
  51. package/dist/assets/{native-config--i6wCD4P.js → native-config-xhyB-MaV.js} +1 -1
  52. package/dist/assets/{navigation-DEIXKsz9.js → navigation-s17OGXvr.js} +1 -1
  53. package/dist/assets/openRemoteProjectSession-DW8-T60S.js +1 -0
  54. package/dist/assets/projectMeta-BlxvELCP.js +1 -0
  55. package/dist/assets/{pwa-CUF8fchS.js → pwa-2oTUkDoj.js} +1 -1
  56. package/dist/assets/{queue-abort-optimistic-DnJeXLxG.js → queue-abort-optimistic-D1Jn8qwM.js} +1 -1
  57. package/dist/assets/{react-_vsw1y6L.js → react-MiIkeefI.js} +1 -1
  58. package/dist/assets/{readiness-jkhl68VV.js → readiness-E_AfME9f.js} +2 -2
  59. package/dist/assets/{reference-history-D9aLqiz1.js → reference-history-XALwogYf.js} +1 -1
  60. package/dist/assets/{remoteSessionReference-BODrh2wf.js → remoteSessionReference-CtOv1v_b.js} +1 -1
  61. package/dist/assets/{renderElectronMiniChatApp-Bj1TCHnZ.js → renderElectronMiniChatApp-3NuBbRwT.js} +2 -2
  62. package/dist/assets/renderMobileApp-CuZ9yAVb.js +29 -0
  63. package/dist/assets/{runtimeConfig-9qXX2ix1.js → runtimeConfig-D18VaKC1.js} +1 -1
  64. package/dist/assets/{runtimeEndpointReset-BUGfn7y0.css → runtimeEndpointReset-BIrMtGn5.css} +1 -1
  65. package/dist/assets/{runtimeEndpointReset-nUC5uMtu.js → runtimeEndpointReset-DVZ8ANvq.js} +9 -9
  66. package/dist/assets/{select-RfWO-Q8r.js → select-ByHtaCLt.js} +1 -1
  67. package/dist/assets/{sessionLookup-BnWJnI1i.js → sessionLookup-BxkJtFS9.js} +1 -1
  68. package/dist/assets/{sortable-tabs-strip-BQhg8ugs.js → sortable-tabs-strip-BC9YfP7U.js} +1 -1
  69. package/dist/assets/{speechSettingsQueries-B5nF726M.js → speechSettingsQueries-UKlLEXtl.js} +1 -1
  70. package/dist/assets/src-DRyZ4dLj.css +2 -0
  71. package/dist/assets/{textarea-7J-b5mR2.js → textarea-tBNaGlCt.js} +1 -1
  72. package/dist/assets/{tooltip-IVmealjG.js → tooltip-CcltSswM.js} +1 -1
  73. package/dist/assets/{types-fkNzcMt6.js → types-DoOzRsH8.js} +1 -1
  74. package/dist/assets/{useAppFontEffects-BGhC1aSo.js → useAppFontEffects-BCtKtzi1.js} +62 -62
  75. package/dist/assets/{useDesktopWindowControlsLayout-CqAP968J.js → useDesktopWindowControlsLayout-DkvuepaL.js} +1 -1
  76. package/dist/assets/{useEffectiveDirectory-D_gt64gp.js → useEffectiveDirectory-BpUyuk6I.js} +1 -1
  77. package/dist/assets/useMobileNavigationStore-DGdNSKHn.js +13 -0
  78. package/dist/assets/{usePluginsStore-GVUi9ssB.js → usePluginsStore-C4DtZir8.js} +1 -1
  79. package/dist/assets/{useProjectRuntimeAPIs-MBstcTXw.js → useProjectRuntimeAPIs-D-HLNg2d.js} +1 -1
  80. package/dist/assets/{useStreamingTextThrottle-B9fGpeQT.js → useStreamingTextThrottle-C4HYcuiO.js} +1 -1
  81. package/dist/index.html +6 -6
  82. package/dist/mini-chat.html +6 -6
  83. package/dist/mobile.html +2 -2
  84. package/package.json +1 -1
  85. package/server/lib/notifications/DOCUMENTATION.md +11 -1
  86. package/server/lib/notifications/session-unread-store.js +20 -6
  87. package/server/lib/notifications/session-unread.test.js +80 -0
  88. package/server/lib/scheduled-tasks/DOCUMENTATION.md +14 -5
  89. package/server/lib/scheduled-tasks/runtime.js +29 -25
  90. package/server/lib/scheduled-tasks/runtime.test.js +88 -1
  91. package/dist/assets/AssistantConversationSurface-Blm96EOU.js +0 -3
  92. package/dist/assets/AssistantSessionCard-DX38brAH.js +0 -2
  93. package/dist/assets/MobileSurface-D93ybkxD.js +0 -2
  94. package/dist/assets/ToolOutputDialog-CBk9ZNkY.js +0 -16
  95. package/dist/assets/dialog-CDfUL86v.js +0 -1
  96. package/dist/assets/dialog-CTYD3Sbr.css +0 -1
  97. package/dist/assets/miniChat-BV82mwxi.js +0 -2
  98. package/dist/assets/mobile-CiUCPZu-.js +0 -2
  99. package/dist/assets/mobileConnections-BdfBfyV4.js +0 -2
  100. package/dist/assets/openRemoteProjectSession-DkaBkopU.js +0 -1
  101. package/dist/assets/projectMeta-CX7xsn7U.js +0 -1
  102. package/dist/assets/renderMobileApp-ZBJF50-1.js +0 -29
  103. package/dist/assets/src-INJJ62RE.css +0 -2
  104. package/dist/assets/useMobileNavigationStore-Dlt-Ip-3.js +0 -13
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-CBk9ZNkY.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-wF65ZFgV.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-fom6orB6.js","assets/vendor-react-D5BntRmA.js","assets/vendor-tanstack-react-query-ChSd65dm.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-DnhWnndu.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-B8s-Rcd-.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-CYex4rbF.js","assets/vendor-zustand-CNn3HHhT.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-DUquFMmd.js","assets/runtime-file-download-Dc459c9e.js","assets/vendor-pierre-diffs-HJfPTtu2.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/i18n-OsFhnlRH.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-Dj5cSf8B.js","assets/tour-CMXP3Kif.js","assets/useMobileNavigationStore-Dlt-Ip-3.js","assets/gitApiHttp-BEMPJCIG.js","assets/client-CgAFd1ew.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-8bssUUT3.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-Y-KPX915.js","assets/useAssistantUIStore-CphyXHEY.js","assets/input-store-DRTu4uZc.js","assets/remoteProjectQueries-8giIAvzL.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-D2YBbLma.js","assets/vendor-framer-motion-DiGWHm7K.js","assets/Icon-C6CNZZkk.js","assets/dialog-CDfUL86v.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MarkdownRenderer-DrXbG9Y5.js","assets/useEffectiveDirectory-D_gt64gp.js","assets/markdownHeightCache-CgEzszwt.js","assets/dualLimitLru-D8Sphgua.js","assets/MobileWindowStack-DGLdgoGr.js","assets/mobileBackNavigation-CX1dqatK.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-ZB1bYt51.js","assets/image-loading-DA9JEHD8.css","assets/ImageLoadingPlaceholder-B6Zer2YL.js","assets/vendor-tanstack-react-virtual-WY42p6U6.js","assets/markdownTheme-C2LJ3cJo.js","assets/markdown-worker-oBGEB9Eg.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-BMjl5Y5W.js";import{n as r,r as i}from"./platform-wF65ZFgV.js";import{a}from"./vendor-zustand-CNn3HHhT.js";import{B as o,F as s,I as c,L as l,P as u,R as d,ot as f,st as p,z as m}from"./vendor-base-ui-fom6orB6.js";import{En as h,On as g,Tn as _,_n as v,vn as y,wn as b,xn as x}from"./gitApiHttp-BEMPJCIG.js";import{f as S}from"./prompt-attachment-upload-8bssUUT3.js";import{n as C}from"./vendor-react-D5BntRmA.js";import{s as w}from"./vendor-tanstack-react-query-ChSd65dm.js";import{L as T}from"./runtime-file-resource-DnhWnndu.js";import{a as E,i as D,m as O,o as k,p as A,r as j}from"./vendor-reactuses-core-B8s-Rcd-.js";import{o as M}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as N}from"./useUIStore-CYex4rbF.js";import{t as ee}from"./uuid-D-SDZijH.js";import{t as P}from"./i18n-OsFhnlRH.js";import{N as te,_ as ne,f as re,g as ie,h as ae,j as oe,r as se,u as ce,v as le,w as ue}from"./MobileDetailNavigation-CpjB_jck.js";import{In as F,Rn as I,s as L,yi as de}from"./useMobileNavigationStore-Dlt-Ip-3.js";import{n as R}from"./useAssistantUIStore-CphyXHEY.js";import{a as z,r as fe}from"./MobileShareBridge-DuDpHmZD.js";import{a as B}from"./fileMentionAutocompleteState-BZJqfgae.js";import{o as pe,p as me,t as V}from"./AgentAvatar-B9ucI2MO.js";import{d as H,o as U,t as he}from"./vendor-framer-motion-DiGWHm7K.js";import{n as W}from"./Icon-C6CNZZkk.js";import{t as G}from"./scheduledTaskNavigation-Bi7sRiFW.js";import{a as ge,i as _e,t as ve}from"./MarkdownRenderer-DrXbG9Y5.js";import{a as ye,b as K,c as be,h as xe,i as Se,l as q,n as Ce,o as we,r as Te,t as Ee,u as De,v as Oe,y as ke}from"./reference-history-D9aLqiz1.js";import{a as Ae,n as J,r as je,t as Me}from"./fileMentionTouchSelection-BsMdH79T.js";import{c as Ne,s as Pe}from"./image-loading-ZB1bYt51.js";import{t as Fe}from"./ImageLoadingPlaceholder-B6Zer2YL.js";import{t as Ie}from"./LoadingImage-BPX-DCAP.js";import{n as Le}from"./textarea-7J-b5mR2.js";import{c as Re}from"./sessionLookup-BnWJnI1i.js";import{t as ze}from"./vendor-motion-DtmZZeEm.js";import{i as Be,n as Ve,r as He}from"./assistant-attachment-cache-zu9sz4ex.js";import{a as Y,c as Ue,i as X,l as We,o as Ge,r as Ke,s as qe,t as Je}from"./AssistantSessionCard-DX38brAH.js";var Z=C(),Q=e(p(),1),$=f();function Ye(e){let i=(0,Z.c)(12),{assistantID:a,position:o}=e,s=Q.useRef(null),c=Q.useRef(!1),l;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={busy:!1,done:!1,retryAt:0},i[0]=l):l=i[0];let u=Q.useRef(l),[d]=Q.useState(tt),f;i[1]!==a||i[2]!==o||i[3]!==d?(f=()=>{let e=s.current;if(!e||!c.current||u.current.busy||u.current.done||Date.now()<u.current.retryAt||d.transport!==t()||d.generation!==n()||document.visibilityState!==`visible`||(r()?!document.documentElement.classList.contains(`yuri-native-app-active`):!document.hasFocus())||e.parentElement?.closest(`[inert], [aria-hidden="true"]`))return;let i=e.closest(`[data-assistant-contact-transcript]`);if(!i||i.scrollHeight-i.scrollTop-i.clientHeight>2)return;let l=e.getBoundingClientRect(),f=i.getBoundingClientRect(),p=window.visualViewport,m=p?.offsetTop??0,h=m+(p?.height??window.innerHeight);l.height<=0||l.width<=0||l.bottom>Math.min(f.bottom,h)||l.top<Math.max(f.top,m)||l.right<=Math.max(f.left,0)||l.left>=Math.min(f.right,window.innerWidth)||(u.current.busy=!0,ce(a,o).then(()=>{u.current.done=!0}).catch(()=>{u.current.retryAt=Date.now()+15e3}).finally(()=>{u.current.busy=!1}))},i[1]=a,i[2]=o,i[3]=d,i[4]=f):f=i[4];let p=j(f),m;i[5]===p?m=i[6]:(m=e=>{c.current=e.some(et),p()},i[5]=p,i[6]=m);let h;i[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={threshold:1},i[7]=h):h=i[7],E(s,j(m),h),D(`visibilitychange`,p,$e),D(`focus`,p,Qe),D(`resize`,p,Ze);let g,_;i[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>s.current?.closest(`[data-assistant-contact-transcript]`),_={passive:!0},i[8]=g,i[9]=_):(g=i[8],_=i[9]),D(`scroll`,p,g,_);let v;i[10]===Symbol.for(`react.memo_cache_sentinel`)?(v={attributes:!0,attributeFilter:[`class`]},i[10]=v):v=i[10],A(p,Xe,v),k(p,15e3);let y;return i[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{ref:s,"aria-hidden":`true`,className:`absolute bottom-0 left-0 block h-px w-px`,"data-assistant-read-marker":``}),i[11]=y):y=i[11],y}function Xe(){return document.documentElement}function Ze(){return window.visualViewport}function Qe(){return window}function $e(){return document}function et(e){return e.isIntersecting&&e.intersectionRatio===1}function tt(){return{transport:t(),generation:n()}}var nt=()=>{},rt=Q.memo(K),it=e=>e?.directories.flatMap(({directory:e,sessions:t})=>e?t.filter(e=>!e.time.archived).map(t=>({...t,directory:e||t.location?.directory||t.directory||``})).filter(e=>e.directory.length>0):[])??null,at=Q.forwardRef(({query:e,isMobile:t,listId:n,onHighlightChange:r,onSelect:i,onClose:a},o)=>{let{t:s}=P(),c=Ne(),l=w({...de(c),select:it}),u=l.isPending,d=l.isError,f=Q.useMemo(()=>B({sessions:l.data??[],currentSessionId:null,searchQuery:e,limit:e.trim()?10:3}),[l.data,e]),[p,m]=Q.useState({query:e,index:0}),h=Math.min(p.query===e?p.index:0,Math.max(0,f.length-1)),g=Q.useRef(null),_=Q.useRef([]),v=Q.useMemo(Me,[]);D(`pointerdown`,e=>{e.target instanceof Node&&!g.current?.contains(e.target)&&a()},void 0,{capture:!0}),Q.useLayoutEffect(()=>{_.current[h]?.scrollIntoView?.({block:`nearest`})},[h]),Q.useLayoutEffect(()=>{r(f.length?`${n}-${h}`:void 0)},[h,n,f.length,r]);let y=j(t=>{if(t===`Escape`){a();return}f.length&&(t===`ArrowDown`&&m({query:e,index:(h+1)%f.length}),t===`ArrowUp`&&m({query:e,index:(h-1+f.length)%f.length}),(t===`Enter`||t===`Tab`)&&i(f[h]))});return Q.useImperativeHandle(o,()=>({keyDown:y}),[y]),(0,$.jsxs)(J,{ref:g,isMobile:t,className:`max-w-[640px] max-h-64`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-3 py-1`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`assistants.contact.sessionMention.scope`)}),(0,$.jsx)(F,{type:`button`,size:`xs`,variant:`ghost`,"aria-label":s(`dialog.common.actions.close`),onClick:a,children:(0,$.jsx)(W,{name:`close`,className:`size-4`})})]}),u?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(`common.loading`)}):null,d?(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 typography-meta text-[var(--status-error)]`,children:[s(`assistants.contact.sessionMention.loadFailed`),(0,$.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{l.refetch()},children:s(`chat.history.retry`)})]}):null,l.isSuccess&&!u&&!d&&!f.length?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(l.data===null?`common.unavailable`:`sessions.sidebar.empty.noMatches.title`)}):null,(0,$.jsx)(Le,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsx)(`div`,{id:n,role:`listbox`,"aria-label":s(`chat.fileMentionAutocomplete.groups.sessions`),className:`p-1.5`,children:f.map((r,a)=>(0,$.jsxs)(`div`,{id:`${n}-${a}`,role:`option`,"aria-selected":a===h,ref:e=>{_.current[a]=e},className:I(`flex min-h-10 cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 typography-ui-label`,je(t,a===h)),onMouseDown:e=>e.preventDefault(),onMouseMove:()=>m({query:e,index:a}),onPointerDown:e=>{e.pointerType===`touch`&&v.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&v.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&v.pointerUp(()=>i(r))&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>v.pointerCancel(),onClick:()=>v.click(()=>i(r)),children:[(0,$.jsx)(W,{name:`chat-thread`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium leading-5`,title:r.title,children:r.title||s(`chat.fileMentionAutocomplete.untitledSession`)}),(0,$.jsx)(`div`,{className:`truncate text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,title:r.directory,children:r.directory})]})]},JSON.stringify([r.directory,r.id])))})}),t?null:(0,$.jsx)(`div`,{className:`mx-1.5 shrink-0 border-t px-1.5 py-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`chat.autocomplete.keyboardHint`)})]})}),ot=e=>{let t=(0,Z.c)(122),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({active:n,onChange:r,onVoiceSend:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{t:o}=P(),s=Q.useRef(null),c=n&&!!a.isMobile&&!!i,l;t[5]===c?l=t[6]:(l={available:c},t[5]=c,t[6]=l);let{enabled:u,hint:d,onHintChange:f}=ke(l),p;t[7]!==d||t[8]!==a.placeholder||t[9]!==o?(p=d===null?a.placeholder:o(d===`recording`?`chat.dictation.releaseSend`:d===`cancelling`?`chat.dictation.releaseCancel`:d===`editing`?`chat.dictation.releaseEdit`:`chat.dictation.processing`),t[7]=d,t[8]=a.placeholder,t[9]=o,t[10]=p):p=t[10];let m=p,g;t[11]===a.value?g=t[12]:(g=()=>({canonical:a.value,document:x(a.value,new Map)}),t[11]=a.value,t[12]=g);let[C,w]=Q.useState(g),T;t[13]!==C.canonical||t[14]!==C.document||t[15]!==a.value?(T=C.canonical===a.value?C.document:x(a.value,new Map),t[13]=C.canonical,t[14]=C.document,t[15]=a.value,t[16]=T):T=t[16];let E=T,[D,O]=Q.useState(0),[k,A]=Q.useState(!0),[M,N]=Q.useState(!1),[ee,te]=Q.useState(),ne=Q.useRef(null),re=Q.useRef(null),ie=Q.useRef(null),ae=Q.useRef(null),oe;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(oe=Ce(),t[17]=oe):oe=t[17];let se=Q.useRef(oe),ce=Q.useId(),le;t[18]!==n||t[19]!==M||t[20]!==D||t[21]!==k||t[22]!==E.text||t[23]!==a.disabled||t[24]!==a.pending?(le=n&&!a.pending&&!a.disabled&&!k&&!M?Ae({text:E.text,cursor:D}):null,t[18]=n,t[19]=M,t[20]=D,t[21]=k,t[22]=E.text,t[23]=a.disabled,t[24]=a.pending,t[25]=le):le=t[25];let ue=le,F=ue?.kind===`mention`?ue:null,L;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{ae.current!==null&&(ne.current?.focus({preventScroll:!0}),ne.current?.setSelectionRange(ae.current,ae.current),ae.current=null)},t[26]=L):L=t[26];let de;t[27]===E?de=t[28]:(de=[E],t[27]=E,t[28]=de),Q.useLayoutEffect(L,de);let R;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>A(!0),t[29]=R):R=t[29];let z=j(R),fe;t[30]!==M||t[31]!==D||t[32]!==E||t[33]!==r?(fe=(e,t,n)=>{let i=n===void 0||n,a=h(e);a.ok&&(i&&(se.current=Te(se.current,{before:Ee(E,[],{start:ne.current?.selectionStart??D,end:ne.current?.selectionEnd??D}),after:Ee(e,[],{start:t,end:t})})),M||(ae.current=t),O(t),w({canonical:a.text,document:e}),r(a.text))},t[30]=M,t[31]=D,t[32]=E,t[33]=r,t[34]=fe):fe=t[34];let B=j(fe),pe;t[35]!==B||t[36]!==E||t[37]!==F||t[38]!==o?(pe=e=>{if(!F)return;let t=e.title||o(`chat.fileMentionAutocomplete.untitledSession`),n=y(E,F.tokenStart,F.tokenEnd,{id:`session:${e.id}:${crypto.randomUUID()}`,kind:`session`,sessionId:e.id,directory:e.directory,display:S({trigger:`@`,icon:`chat-thread`,label:t})},{inlineBoundaries:!0,padDocumentEdges:!0}),r=n.caret+ +(n.document.text[n.caret]===` `);A(!0),B(n.document,r)},t[35]=B,t[36]=E,t[37]=F,t[38]=o,t[39]=pe):pe=t[39];let me=j(pe),V;t[40]!==n||t[41]!==B||t[42]!==E||t[43]!==a.disabled||t[44]!==a.pending?(V=e=>{if(!n||a.pending||a.disabled||!e.trim())return;let t=E.text?`${E.text} ${e}`:e,r=b(E,t,t.length,t.length);B(r.document,r.caret),A(!0)},t[40]=n,t[41]=B,t[42]=E,t[43]=a.disabled,t[44]=a.pending,t[45]=V):V=t[45];let H=j(V),U;t[46]!==n||t[47]!==E.text||t[48]!==H||t[49]!==r||t[50]!==i||t[51]!==a.disabled||t[52]!==a.pending?(U=e=>{if(!(!n||a.pending||a.disabled||!e.trim())){if(E.text){H(e);return}r(e),i?.(e)}},t[46]=n,t[47]=E.text,t[48]=H,t[49]=r,t[50]=i,t[51]=a.disabled,t[52]=a.pending,t[53]=U):U=t[53];let he=j(U),W;t[54]!==B||t[55]!==E?(W=(e,t)=>{let n=e.currentTarget;if(n.selectionStart===n.selectionEnd||!e.clipboardData||!E.references.some(e=>e.start<n.selectionEnd&&e.end>n.selectionStart))return;let r=v(n.selectionStart,n.selectionEnd,E.references)??{start:n.selectionStart,end:n.selectionEnd},i=h({text:E.text.slice(r.start,r.end),references:E.references.filter(e=>e.start>=r.start&&e.end<=r.end).map(e=>({...e,start:e.start-r.start,end:e.end-r.start}))});if(i.ok&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,i.text),t)){let e=b(E,E.text.slice(0,r.start)+E.text.slice(r.end),r.start,r.start);B(e.document,e.caret)}},t[54]=B,t[55]=E,t[56]=W):W=t[56];let G=j(W),ge;t[57]!==E.references||t[58]!==E.text?(ge=De(E.text,E.references.map(st))?.map(ct),t[57]=E.references,t[58]=E.text,t[59]=ge):ge=t[59];let _e=ge,ve=u&&E.text.length===0?`true`:void 0,K;t[60]!==u||t[61]!==H||t[62]!==a.disabled||t[63]!==a.pending||t[64]!==he||t[65]!==f?(K=u&&(0,$.jsx)(rt,{containerRef:s,disabled:!!(a.pending||a.disabled),onInsert:H,onSend:he,onRelease:nt,onHintChange:f}),t[60]=u,t[61]=H,t[62]=a.disabled,t[63]=a.pending,t[64]=he,t[65]=f,t[66]=K):K=t[66];let be=E.text,q=a.pending,we=n&&a.layout===`inline`,J;t[67]===a?J=t[68]:(J=()=>{a.pending||a.onSubmit()},t[67]=a,t[68]=J);let je=a.layout===`inline`?`py-3 leading-6`:`pt-4 pb-2`,Me=a.layout===`inline`&&a.isMobile&&`pl-2`,Ne;t[69]!==a.textLayoutClassName||t[70]!==je||t[71]!==Me?(Ne=I(`whitespace-pre-wrap break-words overflow-hidden px-3 typography-markdown md:typography-ui-label`,je,Me,a.textLayoutClassName),t[69]=a.textLayoutClassName,t[70]=je,t[71]=Me,t[72]=Ne):Ne=t[72];let Pe;t[73]!==B||t[74]!==E?(Pe=(e,t)=>{let n=b(E,e,t?.target.selectionStart??e.length,t?.target.selectionEnd??e.length);B(n.document,n.caret),A(t?.nativeEvent?.inputType===`insertFromPaste`)},t[73]=B,t[74]=E,t[75]=Pe):Pe=t[75];let Fe=F?ce:void 0,Ie=F?ee:void 0,Le;t[76]===a.textareaProps?Le=t[77]:(Le=e=>{a.textareaProps?.onScroll?.(e),re.current&&(re.current.scrollTop=e.currentTarget.scrollTop,re.current.scrollLeft=e.currentTarget.scrollLeft)},t[76]=a.textareaProps,t[77]=Le);let Re,ze;t[78]!==G||t[79]!==a.textareaProps?(Re=e=>{a.textareaProps?.onCopy?.(e),e.defaultPrevented||G(e,!1)},ze=e=>{a.textareaProps?.onCut?.(e),e.defaultPrevented||G(e,!0)},t[78]=G,t[79]=a.textareaProps,t[80]=Re,t[81]=ze):(Re=t[80],ze=t[81]);let Be;t[82]===a.textareaProps?Be=t[83]:(Be=e=>{O(e.currentTarget.selectionStart),a.textareaProps?.onSelect?.(e)},t[82]=a.textareaProps,t[83]=Be);let Ve,He;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=()=>{N(!0)},He=e=>{N(!1),O(e.currentTarget.selectionStart)},t[84]=Ve,t[85]=He):(Ve=t[84],He=t[85]);let Y;t[86]!==B||t[87]!==M||t[88]!==E||t[89]!==F||t[90]!==a.textareaProps?(Y=e=>{if(a.textareaProps?.onKeyDown?.(e),!(e.defaultPrevented||Oe(e))){if(M){e.key===`Enter`&&e.preventDefault();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){let t=e.shiftKey?Se(se.current,E):ye(se.current,E);t&&(e.preventDefault(),se.current=t.history,B(t.snapshot.document,t.snapshot.selection.end,!1),A(!0));return}if(e.key===`Backspace`||e.key===`Delete`){let t=_(E,{key:e.key,selectionStart:e.currentTarget.selectionStart,selectionEnd:e.currentTarget.selectionEnd,altKey:e.altKey});if(t){e.preventDefault(),B(t.document,t.caret),A(!0);return}}F&&[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),ie.current?.keyDown(e.key))}},t[86]=B,t[87]=M,t[88]=E,t[89]=F,t[90]=a.textareaProps,t[91]=Y):Y=t[91];let Ue;t[92]!==a.textareaProps||t[93]!==Fe||t[94]!==Ie||t[95]!==Le||t[96]!==Re||t[97]!==ze||t[98]!==Be||t[99]!==Y?(Ue={...a.textareaProps,"aria-controls":Fe,"aria-activedescendant":Ie,"aria-autocomplete":`list`,onScroll:Le,onCopy:Re,onCut:ze,onSelect:Be,onCompositionStart:Ve,onCompositionEnd:He,onKeyDown:Y},t[92]=a.textareaProps,t[93]=Fe,t[94]=Ie,t[95]=Le,t[96]=Re,t[97]=ze,t[98]=Be,t[99]=Y,t[100]=Ue):Ue=t[100];let X;t[101]!==z||t[102]!==ce||t[103]!==F||t[104]!==a.isMobile||t[105]!==me?(X=F?(0,$.jsx)(at,{ref:ie,query:F.query,isMobile:a.isMobile??!1,listId:ce,onHighlightChange:te,onSelect:me,onClose:z}):null,t[101]=z,t[102]=ce,t[103]=F,t[104]=a.isMobile,t[105]=me,t[106]=X):X=t[106];let We;t[107]!==E.text||t[108]!==_e||t[109]!==m||t[110]!==a||t[111]!==we||t[112]!==J||t[113]!==Ne||t[114]!==Pe||t[115]!==Ue||t[116]!==X?(We=(0,$.jsx)(xe,{...a,value:be,pending:q,animateResize:we,placeholder:m,disableInputWhilePending:!1,inputRef:ne,onSubmit:J,highlightedContent:_e,highlightRef:re,textLayoutClassName:Ne,onChange:Pe,textareaProps:Ue,children:X}),t[107]=E.text,t[108]=_e,t[109]=m,t[110]=a,t[111]=we,t[112]=J,t[113]=Ne,t[114]=Pe,t[115]=Ue,t[116]=X,t[117]=We):We=t[117];let Ge;return t[118]!==ve||t[119]!==K||t[120]!==We?(Ge=(0,$.jsxs)(`div`,{ref:s,className:`yuri-hold-to-talk-container`,"data-hold-to-talk-empty":ve,children:[K,We]}),t[118]=ve,t[119]=K,t[120]=We,t[121]=Ge):Ge=t[121],Ge};function st(e){return{start:e.start,end:e.end,priority:103,...g(e)}}function ct(e,t){return(0,$.jsx)(`span`,{className:e.className,children:e.visual?(0,$.jsx)(q,{visual:e.visual,text:e.text}):e.text},`${t}-${e.text.length}`)}var lt=`rounded-[var(--contact-bubble-radius,1.125rem)] border border-border/40 cursor-zoom-in`;function ut({assistantID:e,descriptor:t,onShowPopup:n}){let{t:r}=P(),i=Ne(),{attachmentID:a,sha256:o,size:s,mime:c,filename:l}=t,u=Q.useMemo(()=>({type:`file`,attachmentID:a,sha256:o,size:s,mime:c,filename:l}),[a,o,s,c,l]),d=c.startsWith(`image/`),f=_e(l??``,c),[p,m]=Q.useState(0),[h,g]=Q.useState(``),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x=Q.useRef(null),S=Q.useRef([]);Q.useEffect(()=>{g(``),v(!1);let t=new AbortController,n;return d&&He(e,u,{signal:t.signal}).then(e=>{if(t.signal.aborted){e.release();return}n=e.release,g(e.url)}).catch(()=>{t.signal.aborted||v(!0)}),()=>{t.abort(),n?.()}},[e,u,i,d,p]),Q.useEffect(()=>()=>{x.current?.abort(),S.current.forEach(e=>URL.revokeObjectURL(e)),S.current=[]},[e,u,i]);let C=j(async(t=!1)=>{if(x.current)return;let i=new AbortController;x.current=i,b(!0),v(!1);try{let a=await Ve(e,u,{signal:i.signal});if(i.signal.aborted)return;S.current.forEach(e=>URL.revokeObjectURL(e));let o=URL.createObjectURL(a);if(S.current=[o],t&&n){n({open:!0,title:l||r(`assistants.contact.attachment.file`),content:``,video:{url:o,mimeType:c,filename:l}});return}let s=document.createElement(`a`);s.href=o,s.download=l||r(`assistants.contact.attachment.file`),document.body.appendChild(s),s.click(),s.remove()}catch{i.signal.aborted||v(!0)}finally{x.current===i&&(x.current=null),i.signal.aborted||b(!1)}}),w=l||r(d?`assistants.contact.attachment.image`:`assistants.contact.attachment.file`),T=j(e=>{!n||!h||n({open:!0,title:w,content:``,metadata:{tool:`image-preview`,filename:w,mime:c},previewSource:e.currentTarget,image:{url:h,mimeType:c,filename:w,size:s,gallery:[{url:h,mimeType:c,filename:w,size:s}],index:0}})});return d&&h&&!_?(0,$.jsx)(Ie,{src:h,alt:w,contentFrame:!0,className:lt,onError:()=>v(!0),onClick:T,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T(e))},role:`button`,tabIndex:0,"data-assistant-contact-image":``}):d&&!_?(0,$.jsx)(Fe,{className:`h-[var(--yuri-content-image-height)] w-[min(20rem,100%)] rounded-[var(--contact-bubble-radius,1.125rem)]`}):(0,$.jsxs)(`div`,{className:`flex max-w-full flex-col gap-1 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5 ring-1 ring-inset ring-[var(--surface-subtle)]`,"data-assistant-contact-file":``,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(W,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:w})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:r(`assistants.contact.attachment.loadFailed`)}):null,d&&!_||y?(0,$.jsx)(`span`,{role:`status`,className:`typography-micro text-muted-foreground`,children:r(`common.loading`)}):(0,$.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:d?()=>m(e=>e+1):()=>void C(f&&!!n),children:r(_?`chat.history.retry`:f&&n?`contextPanel.mode.preview`:`assistants.contact.attachment.download`)})]})}function dt(e){let t=(0,Z.c)(39),{part:n,onShowPopup:r}=e,{t:i}=P(),a=/^(?:https?:|data:|blob:)/i.test(n.url)?n.url:``,o=Pe(a,``),[s,c]=Q.useState(!1),l;t[0]!==n.filename||t[1]!==i?(l=n.filename||i(`assistants.contact.attachment.image`),t[0]=n.filename,t[1]=i,t[2]=l):l=t[2];let u=l,d;t[3]!==u||t[4]!==r||t[5]!==o?(d=e=>{!r||!o||r({open:!0,title:u,content:``,metadata:{tool:`image-preview`,filename:u},previewSource:e.currentTarget,image:{url:o,filename:u,gallery:[{url:o,filename:u}],index:0}})},t[3]=u,t[4]=r,t[5]=o,t[6]=d):d=t[6];let f=j(d);if(_e(a,n.mime)&&a&&r){let e;t[7]!==r||t[8]!==n.filename||t[9]!==n.mime||t[10]!==a||t[11]!==i?(e=()=>r({open:!0,title:n.filename||i(`assistants.contact.attachment.file`),content:``,video:{url:a,filename:n.filename,mimeType:n.mime}}),t[7]=r,t[8]=n.filename,t[9]=n.mime,t[10]=a,t[11]=i,t[12]=e):e=t[12];let o;t[13]!==n.filename||t[14]!==i?(o=n.filename||i(`contextPanel.mode.preview`),t[13]=n.filename,t[14]=i,t[15]=o):o=t[15];let s;return t[16]!==e||t[17]!==o?(s=(0,$.jsx)(F,{variant:`secondary`,size:`sm`,onClick:e,children:o}),t[16]=e,t[17]=o,t[18]=s):s=t[18],s}if(n.mime.startsWith(`image/`)&&o&&!s){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>c(!0),t[19]=e):e=t[19];let n;t[20]===f?n=t[21]:(n=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f(e))},t[20]=f,t[21]=n);let r;return t[22]!==u||t[23]!==f||t[24]!==o||t[25]!==n?(r=(0,$.jsx)(Ie,{src:o,alt:u,contentFrame:!0,className:lt,onError:e,onClick:f,onKeyDown:n,role:`button`,tabIndex:0,"data-assistant-contact-image":``}),t[22]=u,t[23]=f,t[24]=o,t[25]=n,t[26]=r):r=t[26],r}let p;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(W,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),t[27]=p):p=t[27];let m;t[28]!==n.filename||t[29]!==i?(m=n.filename||i(`assistants.contact.attachment.file`),t[28]=n.filename,t[29]=i,t[30]=m):m=t[30];let h;t[31]===m?h=t[32]:(h=(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:m}),t[31]=m,t[32]=h);let g;t[33]!==s||t[34]!==i?(g=s?(0,$.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:i(`chat.history.retry`)}):null,t[33]=s,t[34]=i,t[35]=g):g=t[35];let _;return t[36]!==h||t[37]!==g?(_=(0,$.jsxs)(`div`,{className:`flex max-w-full items-center gap-2.5 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5`,"data-assistant-contact-file":``,children:[p,h,g]}),t[36]=h,t[37]=g,t[38]=_):_=t[38],_}function ft(e){let t=(0,Z.c)(5),{assistantID:n,part:r,onShowPopup:i}=e,a=Ne(),o;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=`attachmentID`in r?(0,$.jsx)(ut,{assistantID:n,descriptor:r,onShowPopup:i},`${a}:${n}:${r.attachmentID}:${r.sha256}`):(0,$.jsx)(dt,{part:r,onShowPopup:i},`${a}:${r.url}`),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var pt=Q.memo(e=>{let t=(0,Z.c)(32),{turn:n,retryDisabled:r,onRetry:i}=e,{t:a}=P(),f;t[0]===a?f=t[1]:(f=a(`assistants.contact.sendError.viewDetails`),t[0]=a,t[1]=f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(W,{name:`exclamation-fill`,className:`size-[18px] text-[var(--status-error)]`,"data-assistant-contact-error-dot":``}),t[2]=p):p=t[2];let h;t[3]===f?h=t[4]:(h=(0,$.jsx)(m,{type:`button`,"aria-label":f,"data-assistant-contact-send-error":``,className:`absolute right-full top-1/2 mr-1.5 flex size-9 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 shadow-none outline-none focus-visible:opacity-70`,children:p}),t[3]=f,t[4]=h);let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={side:`flip`,align:`shift`,fallbackAxisSide:`end`},t[5]=g):g=t[5];let _;t[6]===a?_=t[7]:(_=a(`assistants.contact.sendError.title`),t[6]=a,t[7]=_);let v;t[8]===_?v=t[9]:(v=(0,$.jsx)(s,{className:`typography-ui-label font-medium`,children:_}),t[8]=_,t[9]=v);let y;t[10]!==a||t[11]!==n.error?(y=n.error||a(`assistants.contact.sendFailed`),t[10]=a,t[11]=n.error,t[12]=y):y=t[12];let b;t[13]===y?b=t[14]:(b=(0,$.jsx)(u,{role:`alert`,className:`mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap typography-meta leading-relaxed [overflow-wrap:anywhere]`,children:y}),t[13]=y,t[14]=b);let x;t[15]!==i||t[16]!==n.messageID?(x=()=>i(n.messageID),t[15]=i,t[16]=n.messageID,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(W,{name:`refresh`,className:`size-3`}),t[18]=S):S=t[18];let C;t[19]===a?C=t[20]:(C=a(`chat.history.retry`),t[19]=a,t[20]=C);let w;t[21]!==r||t[22]!==C||t[23]!==x?(w=(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(F,{type:`button`,size:`xs`,disabled:r,onClick:x,children:[S,C]})}),t[21]=r,t[22]=C,t[23]=x,t[24]=w):w=t[24];let T;t[25]!==w||t[26]!==v||t[27]!==b?(T=(0,$.jsx)(d,{children:(0,$.jsx)(l,{side:`left`,align:`center`,sideOffset:6,collisionPadding:12,collisionAvoidance:g,className:`z-50`,children:(0,$.jsxs)(c,{className:`yuri-mobile-overlay-surface w-72 max-w-[calc(100vw-2rem)] rounded-xl p-4 text-foreground outline-none`,"data-assistant-contact-send-error-popup":``,children:[v,b,w]})})}),t[25]=w,t[26]=v,t[27]=b,t[28]=T):T=t[28];let E;return t[29]!==T||t[30]!==h?(E=(0,$.jsxs)(o,{children:[h,T]}),t[29]=T,t[30]=h,t[31]=E):E=t[31],E});function mt(e){let t=(0,Z.c)(7),{children:n,failedTurn:r,retryDisabled:i,onRetry:a}=e,o;t[0]!==r||t[1]!==a||t[2]!==i?(o=r?.status===`failed`?(0,$.jsx)(pt,{turn:r,retryDisabled:i,onRetry:a}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o):o=t[3];let s;return t[4]!==n||t[5]!==o?(s=(0,$.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,"data-assistant-contact-user-part":``,children:[n,o]}),t[4]=n,t[5]=o,t[6]=s):s=t[6],s}function ht(e){let t=(0,Z.c)(38),{children:n,outgoing:r,joinedBefore:i,joinedAfter:a,createdAt:o,time:s,media:c,mobile:l,hidden:u,colors:d,label:f}=e,p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g;t[0]!==a||t[1]!==c||t[2]!==r?(g=()=>{let e=p.current,t=m.current,n=h.current;if(!e||!t||!n||c)return;let{width:i,height:o}=e.getBoundingClientRect();if(!i||!o)return;let s=window.getComputedStyle(e),l=e=>Math.min(Number.parseFloat(e)||0,i/2,o/2),u=l(s.borderTopLeftRadius),d=l(s.borderTopRightRadius),f=l(s.borderBottomLeftRadius),g=l(s.borderBottomRightRadius),_=8+i,v=r&&!a?`V ${o-10} C ${_} ${o-5} ${_+3} ${o-1} ${_+8} ${o}`:`V ${o-g} A ${g} ${g} 0 0 1 ${_-g} ${o}`,y=!r&&!a?`H 0 C 5 ${o-1} 8 ${o-5} 8 ${o-10}`:`H ${8+f} A ${f} ${f} 0 0 1 8 ${o-f}`;t.setAttribute(`viewBox`,`0 0 ${i+16} ${o}`),n.setAttribute(`d`,`M ${8+u} 0 H ${_-d} A ${d} ${d} 0 0 1 ${_} ${d} ${v} ${y} V ${u} A ${u} ${u} 0 0 1 ${8+u} 0 Z`)},t[0]=a,t[1]=c,t[2]=r,t[3]=g):g=t[3];let _=j(g),v;t[4]===_?v=t[5]:(v=()=>{_()},t[4]=_,t[5]=v);let y;t[6]!==_||t[7]!==a||t[8]!==i||t[9]!==c||t[10]!==l||t[11]!==r?(y=[r,i,a,l,c,_],t[6]=_,t[7]=a,t[8]=i,t[9]=c,t[10]=l,t[11]=r,t[12]=y):y=t[12],Q.useLayoutEffect(v,y),O(typeof ResizeObserver<`u`&&!c?p:null,_);let b=c||void 0,x=r?`outgoing`:`incoming`,S=i||void 0,C=a||void 0,w=l&&!c&&`touch-manipulation [-webkit-user-select:all] [user-select:all]`,T;t[13]===w?T=t[14]:(T=I(`yuri-contact-bubble min-w-0 max-w-full [overflow-wrap:anywhere]`,w),t[13]=w,t[14]=T);let E=d?.background,D=d?.foreground,k=u?`hidden`:void 0,A;t[15]!==E||t[16]!==D||t[17]!==k?(A={"--contact-bubble-fill":E,color:D,visibility:k},t[15]=E,t[16]=D,t[17]=k,t[18]=A):A=t[18];let M=A,N;t[19]===c?N=t[20]:(N=c?null:(0,$.jsx)(`svg`,{ref:m,className:`yuri-contact-bubble-outline`,"aria-hidden":`true`,preserveAspectRatio:`none`,children:(0,$.jsx)(`path`,{ref:h})}),t[19]=c,t[20]=N);let ee;t[21]===n?ee=t[22]:(ee=(0,$.jsx)(`div`,{className:`yuri-contact-bubble-body`,"data-assistant-contact-body":``,children:n}),t[21]=n,t[22]=ee);let P;t[23]!==o||t[24]!==c||t[25]!==s?(P=c?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`yuri-contact-bubble-time-space`,children:s}),(0,$.jsx)(`time`,{className:`yuri-contact-bubble-time`,dateTime:new Date(o).toISOString(),children:s})]}),t[23]=o,t[24]=c,t[25]=s,t[26]=P):P=t[26];let te;return t[27]!==f||t[28]!==M||t[29]!==N||t[30]!==ee||t[31]!==P||t[32]!==b||t[33]!==x||t[34]!==S||t[35]!==C||t[36]!==T?(te=(0,$.jsxs)(`div`,{ref:p,"aria-label":f,"data-assistant-contact-text":``,"data-assistant-contact-media":b,"data-contact-bubble-direction":x,"data-contact-bubble-joined-before":S,"data-contact-bubble-joined-after":C,className:T,style:M,children:[N,ee,P]}),t[27]=f,t[28]=M,t[29]=N,t[30]=ee,t[31]=P,t[32]=b,t[33]=x,t[34]=S,t[35]=C,t[36]=T,t[37]=te):te=t[37],te}var gt=[],_t=e=>e.flatMap(e=>e.type===`text`&&e.text.trim()?[e.text]:[]).join(`
3
- `),vt=(e,t,n,r=Date.now())=>({assistantID:e,messageID:t,parts:n,status:`sending`,createdAt:r}),yt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},bt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},xt=(e,t,n,r)=>({messageID:t?`${e.turnID}:preview:${t.bubbleIndex}`:`${e.turnID}:preview:${r}`,assistantID:e.assistantID,role:`assistant`,turnID:e.turnID,bubbleIndex:t?.bubbleIndex??0,createdAt:t?.occurredAt??e.occurredAt,ordinal:n,status:r,fromAssistantID:null,fromAssistantName:null,parts:t?[{type:`text`,text:t.text}]:[],text:t?.text??``,cards:[]}),St=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>xt(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`failed`?[...r,xt(e,null,n+r.length,`failed`)]:e.status===`admitted`||e.status===`streaming`?[...r,xt(e,null,n+r.length,`admitted`)]:r},Ct=(e,t,n,r=[])=>{let i=new Set(e.map(e=>e.messageID)),a=t.flatMap((t,r)=>t.assistantID!==n||i.has(t.messageID)?[]:[{messageID:t.messageID,assistantID:n,role:`user`,turnID:t.messageID,bubbleIndex:0,createdAt:t.createdAt,ordinal:e.length+r,status:t.status,fromAssistantID:null,fromAssistantName:null,parts:[...t.parts],text:_t(t.parts),cards:[]}]),o=a.length===0?e:[...e,...a],s=r.filter(e=>e.assistantID===n);if(s.length===0)return o;let c=new Map,l=new Map;o.forEach((e,t)=>{if(c.set(e.turnID,t),e.role!==`assistant`||e.messageID.includes(`:preview:`))return;let n=l.get(e.turnID)??new Set;n.add(e.bubbleIndex),l.set(e.turnID,n)});let u=new Map,d=[];for(let e of s){let t=St(e,l.get(e.turnID)??new Set,o.length+d.length);if(t.length===0)continue;let n=c.get(e.turnID);if(n===void 0){if(e.status===`failed`&&o.some(t=>t.turnID!==e.turnID))continue;d.push(...t);continue}let r=u.get(n)??[];r.push(...t),u.set(n,r)}return u.size===0&&d.length===0?o:o.flatMap((e,t)=>[e,...u.get(t)??[]]).concat(d)},wt=(e,t)=>{let n=new Set(t.map(e=>e.messageID)),r=e.filter(e=>!n.has(e.messageID));return r.length===e.length?e:r},Tt=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),Et=(e,t,n,r=Date.now())=>{let i=e.filter(e=>e.assistantID!==t||e.status!==`failed`||e.turnID===n);return i.some(e=>e.assistantID===t&&e.turnID===n)?i.length===e.length?e:i:[...i,{assistantID:t,turnID:n,status:`admitted`,bubbles:[],occurredAt:r}]},Dt=(e,t,n)=>!t?.turnID||!t.assistantID||n?.has(t.turnID)?e:Et(e,t.assistantID,t.turnID,t.admittedAt),Ot=(e,t)=>{let n=t.assistantID,r=t.pendingSendTurnIDs??new Set,i=t.settledTurnIDs??new Set,a=typeof t.snapshotRevision==`number`&&Number.isFinite(t.snapshotRevision)?t.snapshotRevision:null,o=t.admissionRevisionByTurnID instanceof Map?t.admissionRevisionByTurnID:new Map(Object.entries(t.admissionRevisionByTurnID??{}).map(([e,t])=>[e,Number(t)])),s=t.occurredAt??Date.now(),c=t.activeContactTurn&&t.activeContactTurn.turnID?t.activeContactTurn:null,l=!!(t.serverWorking||c),u=Dt(e,c?{assistantID:n,turnID:c.turnID,admittedAt:c.admittedAt}:null,i),d=Array.isArray(t.messages)?t.messages:[];for(let e of d)e.role===`assistant`&&e.status===`error`&&(r.has(e.turnID)||i.has(e.turnID)||(u=At(u,{assistantID:n,turnID:e.turnID,status:`error`,error:e.text||`upstream_error`,occurredAt:s})));if(u=jt(u,d),l){let t=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID)||c&&e.turnID===c.turnID)return!0;let t=o.get(e.turnID);return typeof t==`number`&&a!=null&&a<t?!0:typeof t==`number`&&a!=null&&a>=t&&e.turnID!==c?.turnID?!1:!c||e.turnID===c.turnID});return t.length===e.length&&t.every((t,n)=>t===e[n])?e:t}if(a==null)return u.length===e.length&&u.every((t,n)=>t===e[n])?e:u;let f=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID))return!0;if(i.has(e.turnID))return!1;let t=o.get(e.turnID);return typeof t==`number`&&a<t});return f.length===e.length&&f.every((t,n)=>t===e[n])?e:f.length===u.length?u:f},kt=(e,t)=>Et(e,t.assistantID,t.turnID,t.occurredAt).map(e=>{if(e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`failed`||e.status===`complete`)return e;let n=e.bubbles.find(e=>e.bubbleIndex===t.bubbleIndex);if(n?.done)return e;let r=n?{...n,text:`${n.text}${t.delta}`,done:t.done,occurredAt:t.occurredAt}:{bubbleIndex:t.bubbleIndex,text:t.delta,done:t.done,occurredAt:t.occurredAt},i=n?e.bubbles.map(e=>e.bubbleIndex===t.bubbleIndex?r:e):[...e.bubbles,r].sort((e,t)=>e.bubbleIndex-t.bubbleIndex);return{...e,status:`streaming`,bubbles:i}}),At=(e,t,n={})=>n.requireExisting&&!e.some(e=>e.assistantID===t.assistantID&&e.turnID===t.turnID)?e:Et(e,t.assistantID,t.turnID,t.occurredAt).map(e=>e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`complete`||e.status===`failed`?e:{...e,status:t.status===`error`?`failed`:`complete`,...t.error?{error:t.error}:{}}),jt=(e,t)=>{let n=new Set(t.map(e=>e.turnID).filter(Boolean)),r=t.length>0?t[t.length-1]?.turnID??null:null,i=[...e].reverse().find(e=>e.status===`admitted`||e.status===`streaming`)?.turnID??r,a=new Set(t.flatMap(e=>e.role===`assistant`?[e.turnID]:[])),o=e.filter(e=>e.status===`admitted`||e.status===`streaming`||!(e.status===`complete`&&a.has(e.turnID)||!n.has(e.turnID)||e.status===`failed`&&(i&&i!==e.turnID||r&&r!==e.turnID)));return o.length===e.length?e:o},Mt=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),Nt=(e,t)=>e instanceof oe?e.code===`no_provider`?t.noProvider:e.code===`admission_timeout`||e.code===`generate_timeout`?t.timedOut:e.message&&e.message!==e.code?e.message:`${t.sendFailed}\n\n${e.code} (HTTP ${e.status})`:te(e)?t.timedOut:e instanceof Error&&e.message.trim()?e.message:t.sendFailed,Pt=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},Ft=e=>{let t=e.text.trim();if(e.sending||!t&&e.attachments.length===0||!e.gate.tryAcquire())return{ok:!1};let n=[...t?[{type:`text`,text:t}]:[],...e.attachments.map(e=>({type:`file`,mime:e.mime,url:e.url,filename:e.name}))],r=e.createMessageID();return{ok:!0,messageID:r,parts:n,turn:vt(e.assistantID,r,n,e.createdAt)}},It=e=>e.some(e=>e.status===`sending`),Lt=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),Rt=a(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),zt=({sending:e=!1,processing:t=!1,serverWorking:n=!1})=>e||t||n,Bt=(e,t)=>{let n=(0,Z.c)(5),r=t!==void 0&&t,i;n[0]===e?i=n[1]:(i=t=>!!t.workingByID[e],n[0]=e,n[1]=i);let a=Rt(i),o;return n[2]!==a||n[3]!==r?(o=zt({processing:a,serverWorking:r}),n[2]=a,n[3]=r,n[4]=o):o=n[4],o},Vt=e=>{let t=(0,Z.c)(25),{name:n,avatarSeed:r,size:i,label:a,working:o,showWorkingDot:s,className:c,hoverTarget:l,followPointer:u,blinkOnMount:d}=e,f=i===void 0?24:i,p=s===void 0||s,m=d===void 0||d,{t:h}=P(),g;t[0]!==n||t[1]!==o?(g=e=>o!==void 0&&!!e.workingByID[n],t[0]=n,t[1]=o,t[2]=g):g=t[2];let _=Rt(g),v=!!(o||_),y=`calc(${f}px * var(--dpt-n, 1))`,b;t[3]===c?b=t[4]:(b=I(`relative inline-block shrink-0 align-middle leading-none`,c),t[3]=c,t[4]=b);let x;t[5]===y?x=t[6]:(x={width:y,minWidth:y,maxWidth:y,height:y,minHeight:y,maxHeight:y},t[5]=y,t[6]=x);let S=o===void 0?void 0:v?`working`:`idle`,C=r??n,w;t[7]!==m||t[8]!==u||t[9]!==l||t[10]!==a||t[11]!==n||t[12]!==f||t[13]!==S||t[14]!==C?(w=(0,$.jsx)(V,{kind:`assistant`,motion:S,name:C,size:f,label:a,hoverTarget:l,followPointer:u,animationKey:n,blinkOnMount:m}),t[7]=m,t[8]=u,t[9]=l,t[10]=a,t[11]=n,t[12]=f,t[13]=S,t[14]=C,t[15]=w):w=t[15];let T;t[16]!==p||t[17]!==h||t[18]!==o?(T=o&&p?(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2.5 translate-x-0.5 translate-y-0.5 rounded-full bg-[var(--status-success)] ring-2 ring-background`,"data-assistant-working-dot":``,"aria-label":h(`assistants.contact.working`)}):null,t[16]=p,t[17]=h,t[18]=o,t[19]=T):T=t[19];let E;return t[20]!==T||t[21]!==b||t[22]!==x||t[23]!==w?(E=(0,$.jsxs)(`span`,{className:b,style:x,"data-assistant-working-avatar":``,children:[w,T]}),t[20]=T,t[21]=b,t[22]=x,t[23]=w,t[24]=E):E=t[24],E},Ht=e=>{let t=(0,Z.c)(36),{card:n,assistant:r,active:a}=e,o=a===void 0||a,{t:s}=P(),c=Re(),l;t[0]===c?l=t[1]:(l=c&&!i(),t[0]=c,t[1]=l);let u=!!l,d=n.name,f=`${n.providerID}/${n.modelID}`,p=Q.useContext(Ue),m;t[2]!==n.assistantID||t[3]!==u||t[4]!==p?(m=()=>{if(p)return p({assistantID:n.assistantID});if(u){L.getState().openAssistant(n.assistantID);return}R(n.assistantID)},t[2]=n.assistantID,t[3]=u,t[4]=p,t[5]=m):m=t[5];let h=j(m),g;t[6]===h?g=t[7]:(g=e=>{qe(e,h)},t[6]=h,t[7]=g);let _=j(g),v;t[8]!==s||t[9]!==d?(v=s(`assistants.contact.card.assistant.aria`,{name:d}),t[8]=s,t[9]=d,t[10]=v):v=t[10];let y=r?.avatarSeed,b=o?!!(r?.working||r?.activeContactTurn):void 0,x;t[11]!==n.assistantID||t[12]!==y||t[13]!==b?(x=(0,$.jsx)(`span`,{className:`relative inline-block shrink-0 leading-none`,"aria-hidden":!0,children:(0,$.jsx)(Vt,{name:n.assistantID,avatarSeed:y,size:32,working:b,showWorkingDot:!1,followPointer:!1})}),t[11]=n.assistantID,t[12]=y,t[13]=b,t[14]=x):x=t[14];let S;t[15]===s?S=t[16]:(S=s(`assistants.contact.card.assistant.label`),t[15]=s,t[16]=S);let C;t[17]===S?C=t[18]:(C=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[0.8em] leading-4 text-muted-foreground`,children:S}),t[17]=S,t[18]=C);let w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(W,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[19]=w):w=t[19];let T;t[20]!==C||t[21]!==x?(T=(0,$.jsxs)(`div`,{className:Y,children:[x,C,w]}),t[20]=C,t[21]=x,t[22]=T):T=t[22];let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=I(Ge,`row-span-2 self-center`),t[23]=E):E=t[23];let D;t[24]===d?D=t[25]:(D=(0,$.jsx)(`h3`,{className:E,title:d,children:d}),t[24]=d,t[25]=D);let O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=I(X,`justify-end pb-1`),t[26]=O):O=t[26];let k;t[27]===f?k=t[28]:(k=(0,$.jsx)(`div`,{className:O,children:(0,$.jsx)(`div`,{className:`flex h-4 min-w-0 items-center`,children:(0,$.jsx)(We,{value:f})})}),t[27]=f,t[28]=k);let A;return t[29]!==_||t[30]!==h||t[31]!==T||t[32]!==D||t[33]!==k||t[34]!==v?(A=(0,$.jsxs)(`article`,{className:Ke,role:`button`,tabIndex:0,"aria-label":v,"data-assistant-contact-card":`assistant`,onClick:h,onKeyDown:_,children:[T,D,k]}),t[29]=_,t[30]=h,t[31]=T,t[32]=D,t[33]=k,t[34]=v,t[35]=A):A=t[35],A},Ut=e=>!!(e&&typeof e==`object`&&!Array.isArray(e)),Wt=e=>typeof e==`string`&&/^([01]\d|2[0-3]):[0-5]\d$/.test(e),Gt=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6,Kt=e=>e.kind===`cron`?e.cron===void 0:e.kind===`once`?e.date===void 0:e.kind===`weekly`?e.times===void 0||e.weekdays===void 0:e.kind===`daily`&&e.times===void 0,qt=e=>{if(!Ut(e)||e.timezone!==void 0&&typeof e.timezone!=`string`)return!1;if(e.kind===`cron`)return typeof e.cron==`string`&&!!e.cron.trim();if(e.kind===`once`)return typeof e.date==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e.date)&&Wt(e.time);let t=Array.isArray(e.times)&&e.times.length>0&&e.times.every(Wt);return e.kind===`daily`?t||Wt(e.time):e.kind===`weekly`&&(t||Wt(e.time))&&Array.isArray(e.weekdays)&&e.weekdays.length>0&&e.weekdays.every(Gt)},Jt=(e,t)=>{if(!Kt(e)||!qt(t?.schedule))return e;let n=t.schedule;return{...e,kind:n.kind,time:n.time??n.times?.[0]??null,timezone:n.timezone??e.timezone,cron:n.cron??null,date:n.date??null,times:n.times??null,weekdays:n.weekdays??null}},Yt=(e,t)=>{let n=e.kind===`daily`||e.kind===`weekly`||e.kind===`once`||e.kind===`cron`?t(`sessions.scheduledTasks.editor.scheduleType.${e.kind}`):e.kind||``,r=[...new Set((e.times?.length?e.times:e.time?[e.time]:[]).filter(Wt))].sort(),i=r.join(`, `),a=n,o=r.length===1;if(e.kind===`cron`)i=e.cron?.trim()||n,a=e.cron?.trim()?n:``,o=!1;else if(e.kind===`once`)i=[e.date?.trim(),i].filter(Boolean).join(` `),o=!1;else if(e.kind===`weekly`&&e.weekdays?.length){let n=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];a=[...new Set(e.weekdays.filter(Gt))].sort((e,t)=>e-t).map(e=>t(`sessions.scheduledTasks.dialog.schedule.weekdayShort.${n[e]}`)).join(`, `)}return{value:i||t(`assistants.contact.card.schedule.timeUnavailable`),cadence:a,clock:o,timezone:e.timezone}},Xt=e=>{let t=(0,Z.c)(44),{card:n,task:r}=e,{t:i}=P(),a=n.name,o;t[0]!==n||t[1]!==i||t[2]!==r?(o=Yt(Jt(n,r),i),t[0]=n,t[1]=i,t[2]=r,t[3]=o):o=t[3];let s=o,c;t[4]===n.prompt?c=t[5]:(c=n.prompt?.trim(),t[4]=n.prompt,t[5]=c);let l=c,u=Q.useContext(Ue),d;t[6]!==n.projectID||t[7]!==n.taskID||t[8]!==u?(d=()=>{if(u)return u({projectID:n.projectID,taskID:n.taskID});G(n.projectID,n.taskID)},t[6]=n.projectID,t[7]=n.taskID,t[8]=u,t[9]=d):d=t[9];let f=j(d),p;t[10]===f?p=t[11]:(p=e=>{qe(e,f)},t[10]=f,t[11]=p);let m=j(p),h;t[12]!==i||t[13]!==a?(h=i(`assistants.contact.card.schedule.aria`,{name:a}),t[12]=i,t[13]=a,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(W,{name:`calendar`,weight:`medium`,className:`size-4 shrink-0`}),t[15]=g):g=t[15];let _;t[16]===i?_=t[17]:(_=i(`assistants.contact.card.schedule.label`),t[16]=i,t[17]=_);let v;t[18]===_?v=t[19]:(v=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[0.8em] leading-4 text-muted-foreground`,children:[g,(0,$.jsx)(`span`,{className:`truncate`,children:_})]}),t[18]=_,t[19]=v);let y;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(W,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[20]=y):y=t[20];let b;t[21]===v?b=t[22]:(b=(0,$.jsxs)(`div`,{className:Y,children:[v,y]}),t[21]=v,t[22]=b);let x;t[23]===a?x=t[24]:(x=(0,$.jsx)(`h3`,{className:Ge,title:a,children:a}),t[23]=a,t[24]=x);let S;t[25]===l?S=t[26]:(S=l?(0,$.jsx)(`p`,{className:`row-start-3 mt-1 min-w-0 truncate text-[0.8em] leading-4 text-muted-foreground`,title:l,children:l}):null,t[25]=l,t[26]=S);let C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=I(X,`justify-end`),t[27]=C):C=t[27];let w;t[28]===s.cadence?w=t[29]:(w=s.cadence?(0,$.jsx)(`span`,{"data-contact-schedule-cadence":``,className:`min-w-0 max-w-[36%] flex-[0_1_auto] truncate text-[0.75em] leading-4 text-muted-foreground`,title:s.cadence,children:s.cadence}):null,t[28]=s.cadence,t[29]=w);let T=`min-w-0 flex-[0_1_auto] truncate leading-[22px] text-foreground tabular-nums ${s.clock?`text-[1.25em] font-normal tracking-[-0.3px]`:`text-[0.85em]`}`,E;t[30]!==s.value||t[31]!==T?(E=(0,$.jsx)(`p`,{className:T,title:s.value,children:s.value}),t[30]=s.value,t[31]=T,t[32]=E):E=t[32];let D;t[33]!==w||t[34]!==E?(D=(0,$.jsx)(`div`,{className:C,children:(0,$.jsxs)(`div`,{"data-contact-schedule-time":``,className:`flex min-w-0 flex-none items-baseline gap-1.5`,children:[w,E]})}),t[33]=w,t[34]=E,t[35]=D):D=t[35];let O;return t[36]!==m||t[37]!==f||t[38]!==b||t[39]!==x||t[40]!==S||t[41]!==D||t[42]!==h?(O=(0,$.jsxs)(`article`,{className:Ke,role:`button`,tabIndex:0,"aria-label":h,"data-assistant-contact-card":`schedule`,onClick:f,onKeyDown:m,children:[b,x,S,D]}),t[36]=m,t[37]=f,t[38]=b,t[39]=x,t[40]=S,t[41]=D,t[42]=h,t[43]=O):O=t[43],O},Zt=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();function Qt(e){let t=new Map,n=null;for(let r of e){if(!(r.status===`error`||r.status===`failed`||r.parts.some(e=>e.type!==`text`||e.text.trim()&&!e.text.trim().startsWith(`yuri.settle.`)&&!e.text.trim().startsWith(`oc.settle.`))))continue;let e=new Date(r.createdAt);Number.isFinite(e.getTime())&&((!n||!Zt(n,e))&&t.set(r.messageID,r.createdAt),n=e)}return t}function $t(e,t,n,r){let i=new Date(r);i.setDate(i.getDate()-1);let a=new Intl.DateTimeFormat(e,{month:`long`,day:`numeric`}),o=new Intl.DateTimeFormat(e,{year:`numeric`,month:`long`,day:`numeric`});return e=>{let s=new Date(e);return Zt(s,r)?t:Zt(s,i)?n:(s.getFullYear()===r.getFullYear()?a:o).format(s)}}function en(e,t,n){let r=new Intl.DateTimeFormat(e,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),i=new Intl.DateTimeFormat(e,{month:`long`,day:`numeric`}),a=new Intl.DateTimeFormat(e,{year:`numeric`,month:`long`,day:`numeric`});return e=>{let o=new Date(e);return`${Zt(o,n)?t:(o.getFullYear()===n.getFullYear()?i:a).format(o)} ${r.format(o)}`}}var tn=2,nn=1500,rn=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),an=e=>e.scrollHeight-e.scrollTop-e.clientHeight,on=e=>an(e)<=tn,sn=(e,t)=>{let n=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;n&&n!==e;){if(n instanceof HTMLElement&&n.scrollHeight>n.clientHeight+1&&n.scrollTop+n.clientHeight<n.scrollHeight-1)return!0;n=n.parentElement}return!1},cn=e=>e.altKey||e.ctrlKey||e.metaKey?!1:e.key===`ArrowDown`||e.key===`PageDown`||e.key===`End`,ln=({active:e,assistantID:t,contentRevision:n,onLoadEarlier:r,overlayComposerRef:i})=>{let a=Q.useRef(null),[o,s]=Q.useState(null),[c,l]=Q.useState(null),u=Q.useRef(!0),d=Q.useRef(null),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(0),h=Q.useRef(null),g=Q.useRef(null),_=Q.useRef(e);_.current=e;let v=he(),y=Q.useRef(!1),b=Q.useRef(null),x=Q.useRef(null),S=Q.useRef(0),C=Q.useRef(null),w=j(e=>{let t=C.current;C.current=null,t?.(e)}),T=j(()=>{S.current+=1,b.current?.stop(),b.current=null,x.current=null}),E=Q.useMemo(()=>e=>{a.current=e,s(t=>t===e?t:e)},[]),k=Q.useMemo(()=>e=>{l(t=>t===e?t:e)},[]),A=j(()=>{let e=a.current,t=e?.parentElement;if(!e||!t||!_.current)return;let n=`${Math.max(0,e.offsetWidth-e.clientWidth)}px`;t.style.getPropertyValue(`--contact-scrollbar-width`)!==n&&t.style.setProperty(`--contact-scrollbar-width`,n)});Q.useLayoutEffect(()=>{A()},[e,o,A]);let M=j(()=>{let e=a.current;if(!e||!_.current||u.current)return;let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.getBoundingClientRect().bottom>t);d.current=n?{id:n.dataset.messageId,offset:n.getBoundingClientRect().top-t,scrollTop:e.scrollTop}:null}),N=j(()=>{let e=a.current,t=d.current;if(!e||!_.current||u.current)return;if(!t){M();return}let n=e.scrollTop-t.scrollTop;if(Math.abs(n)>.5&&h.current){m.current=e.scrollTop,M();return}let r=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.dataset.messageId===t.id);if(!r){M();return}let i=r.getBoundingClientRect().top-e.getBoundingClientRect().top-(t.offset-n);Math.abs(i)>.5&&(e.scrollTop+=i),m.current=e.scrollTop,d.current={id:t.id,offset:r.getBoundingClientRect().top-e.getBoundingClientRect().top,scrollTop:e.scrollTop}}),ee=j(()=>{T(),w(!1),u.current=!1,m.current=a.current?.scrollTop??0,M()}),P=Q.useRef(null),te=j((e,t)=>{let n=a.current;if(!_.current||!n){t?.(!1);return}T(),w(!1);let r=!on(rn(n));C.current=r?t??null:null,P.current=r&&t?null:e??null,u.current=!0,d.current=null,g.current=null,m.current=n.scrollTop,r||t?.(!0)}),ne=j(()=>{if(!_.current||!u.current)return!1;let e=a.current;if(!e)return!1;let t=rn(e),n=Math.min(m.current,Math.max(0,t.scrollHeight-t.clientHeight));if(t.scrollTop<n-.5)return T(),u.current=!1,m.current=t.scrollTop,M(),w(!1),!1;let r=!y.current;if(r&&e.querySelector(`[data-message-id]`)&&(y.current=!0),on(t))return T(),m.current=t.scrollTop,w(!0),!1;let i=Math.max(0,t.scrollHeight-t.clientHeight);if(!r&&!v){if(x.current===i)return!1;T(),x.current=i;let t=S.current,n=P.current;return P.current=null,b.current=U(e.scrollTop,i,{duration:n?.duration??.22,ease:n?[...n.ease]:`easeOut`,onUpdate:n=>{if(S.current!==t||!_.current||!u.current||a.current!==e)return;let r=Math.max(0,e.scrollHeight-e.clientHeight);if(e.scrollTop<Math.min(m.current,r)-.5){u.current=!1,T(),m.current=e.scrollTop,M(),w(!1);return}e.scrollTop=Math.min(Math.max(e.scrollTop,n),r),m.current=e.scrollTop},onComplete:()=>{S.current===t&&(b.current=null,x.current=null,ne())}}),!0}return T(),e.scrollTop=i,m.current=e.scrollTop,w(!0),!0}),re=j(e=>{g.current={direction:e,expiresAt:performance.now()+nn}}),ie=j(()=>{let e=g.current;return e?performance.now()>e.expiresAt?(g.current=null,null):e.direction:null}),ae=j(()=>{T(),w(!1),P.current=null,u.current=!1,M()}),oe=j(()=>{if(!_.current)return;let e=a.current;if(!e)return;let t=rn(e),n=t.scrollTop>m.current,i=Math.min(m.current,Math.max(0,t.scrollHeight-t.clientHeight));if(m.current=t.scrollTop,u.current){t.scrollTop<i-.5&&ae();return}let o=ie();N(),t.scrollTop<=80&&o===`up`&&r?.(),n&&on(t)&&(o===`down`||o===`scrollbar`)&&(u.current=!0)}),se=j(e=>{let t=a.current;if(!(!t||e.deltaY===0)){if(e.deltaY<0){if(be(t,e.target))return;re(`up`),ae(),t.scrollTop<=80&&r?.();return}sn(t,e.target)||re(`down`)}}),ce=j(e=>{g.current=null;let t=e.touches.item(0);h.current=t?{x:t.clientX,y:t.clientY,deltaX:0,deltaY:0}:null}),le=j(e=>{let t=a.current,n=e.touches.item(0);if(!t||!n){h.current=null;return}let i=h.current;if(!i)return;let o=n.clientY-i.y,s=o*i.deltaY<0,c=(s?0:i.deltaX)+n.clientX-i.x,l=(s?0:i.deltaY)+o;if(h.current={x:n.clientX,y:n.clientY,deltaX:c,deltaY:l},!(Math.abs(c)>=Math.abs(l))){if(l>0&&be(t,e.target)||l<0&&sn(t,e.target)){h.current.deltaX=0,h.current.deltaY=0;return}re(l>0?`up`:`down`),l>2&&(ae(),t.scrollTop<=80&&r?.())}}),ue=j(()=>{h.current=null}),F=j(e=>{if(we(e)){re(`up`),ae(),(a.current?.scrollTop??1/0)<=80&&r?.();return}cn(e)&&re(`down`)}),I=j(e=>{let t=a.current;e.pointerType===`mouse`&&e.target===t&&re(`scrollbar`)}),L=j(()=>{let e=a.current?.parentElement;if(!e||!_.current)return!1;let t=`${i?.current?.offsetHeight??0}px`;return e.style.getPropertyValue(`--contact-composer-height`)!==t&&(e.style.setProperty(`--contact-composer-height`,t),!0)});Q.useLayoutEffect(()=>{L()},[e,o,i,L]),Q.useLayoutEffect(()=>{let n=e?t:null,r=a.current;(f.current!==n||p.current!==r)&&(T(),w(!1),P.current=null,y.current=!1,f.current=n,p.current=r,u.current=!0,d.current=null,g.current=null,h.current=null,m.current=r?.scrollTop??0),e&&(ne(),N())},[e,t,n,o,v,i]),Q.useLayoutEffect(()=>()=>{T(),w(!1)},[e,t,o,T,w]);let de=Q.useMemo(()=>()=>void 0,[]),R=e&&o?o:de,z=Q.useMemo(()=>({passive:!0}),[]);D(`scroll`,oe,R,z),D(`wheel`,se,R,z),D(`touchstart`,ce,R,z),D(`touchmove`,le,R,z),D(`touchend`,ue,R,z),D(`touchcancel`,ue,R,z),D(`keydown`,F,R),D(`pointerdown`,I,R,z);let fe=Q.useRef(null),B=j(()=>{let e=a.current;fe.current=e&&_.current?{element:e,top:e.scrollTop,height:e.clientHeight}:null}),pe=j(()=>{A();let e=a.current,t=fe.current;!e||t?.element!==e||t.height===e.clientHeight||(fe.current=null,T(),e.scrollTop=Math.max(0,t.top+t.height-e.clientHeight),m.current=e.scrollTop,u.current?ne():M())});D(`yuri:keyboard-native-layout`,B,e&&typeof window<`u`?window:de);let me=j(()=>{ne(),N()}),V=j(()=>{L()&&me()}),H=typeof ResizeObserver<`u`;return O(H&&e?c:null,me),O(H&&e?o:null,pe),O(H&&e&&i?i:null,V,{box:`border-box`}),{scrollRef:E,contentRef:k,preparePrepend:ee,followLatest:te}},un=.3,dn=[.19919472913616398,.010644531250000006,.27920937042459737,.91025390625],fn=[.23,1,.32,1],pn=H(...dn),mn=H(...fn),hn=.15,gn=.1,_n=.08,vn=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),yn=e=>Number.parseFloat(e)||0,bn=(e,t,n)=>e+(t-e)*n,xn=e=>[e.borderTopLeftRadius,e.borderTopRightRadius,e.borderBottomRightRadius,e.borderBottomLeftRadius],Sn=e=>{let t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=t.left+yn(n.borderLeftWidth)+yn(n.paddingLeft),i=t.top+yn(n.borderTopWidth)+yn(n.paddingTop);return{left:r,top:i,width:t.right-yn(n.borderRightWidth)-yn(n.paddingRight)-r,height:t.bottom-yn(n.borderBottomWidth)-yn(n.paddingBottom)-i}},Cn=e=>({color:e.color,fontFamily:e.fontFamily,fontSize:e.fontSize,fontWeight:e.fontWeight,fontFeatureSettings:e.fontFeatureSettings,letterSpacing:e.letterSpacing,lineHeight:e.lineHeight,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`}),wn=(e,t,n=!1)=>{if(!t.value.trim())return null;let r=e.querySelector(`[data-composer-material]`)??e,i=window.getComputedStyle(r),a=Sn(t),o=t.parentElement?.querySelector(`[data-composer-highlight]`),s=Cn(window.getComputedStyle(t));return o&&(s.color=window.getComputedStyle(o).color),{compact:n,background:vn(r.getBoundingClientRect()),backgroundColor:i.backgroundColor,radii:xn(i),text:t.value,textBox:{...a,top:a.top-t.scrollTop},textStyle:s}},Tn=e=>{let t=document.createElement(`div`);return Object.assign(t.style,{position:`absolute`,pointerEvents:`none`,margin:`0px`,...e}),t},En=(e,t,n,r)=>(e.style.opacity=String(t),U(e,{opacity:[t,n]},{duration:r,ease:`linear`})),Dn=(e,t,n=t,r)=>{let i=window.getComputedStyle(t),a=t.querySelector(`.yuri-contact-bubble-outline path`),o=a?window.getComputedStyle(a).fill:i.backgroundColor,s=xn(i),c=vn(t.getBoundingClientRect()),l=Sn(t),u=e.compact?{...e.background,left:e.textBox.left-yn(i.paddingLeft),width:Math.min(e.background.width,Math.max(120,c.width+32))}:e.background,d={left:u.left,top:u.top+u.height-c.height},f={x:e.textBox.left-d.left-(l.left-c.left),y:e.textBox.top-d.top-(l.top-c.top)},p=Tn({position:`fixed`,left:`0px`,top:`0px`,overflow:`hidden`,zIndex:`60`,willChange:`transform, width, height`});p.setAttribute(`aria-hidden`,`true`),p.setAttribute(`data-assistant-contact-send-flight`,``),p.style.backgroundColor=e.backgroundColor;let m=Tn({...e.textStyle,left:`0px`,top:`0px`,width:`${e.textBox.width}px`});m.textContent=e.text;let h=Tn({...Cn(i),left:`0px`,top:`0px`,width:`${l.width}px`});h.textContent=(t.querySelector(`[data-assistant-contact-body]`)??t).textContent??``,p.append(m,h);let g=n=>{let r=pn(n),i=mn(n),a=vn(t.getBoundingClientRect()),o=u,g=bn(o.left,a.left,i),_=bn(o.left+o.width,a.left+a.width,i),v=bn(o.top+o.height,a.top+a.height,r),y=bn(o.height,a.height,r),b=v-y;p.style.transform=`translate3d(${g}px, ${b}px, 0)`,p.style.width=`${_-g}px`,p.style.height=`${y}px`,p.style.borderRadius=s.map((t,n)=>`${bn(yn(e.radii[n]),yn(t),r)}px`).join(` `);let x=a.left+(d.left-c.left)*(1-i),S=a.top+(d.top-c.top)*(1-r),C=`translate3d(${x+(l.left-c.left)+f.x*(1-r)-g}px, ${S+(l.top-c.top)+f.y*(1-r)-b}px, 0)`;m.style.transform=C,h.style.transform=C},_=!1,v=[],y=()=>{_||(_=!0,v.forEach(e=>e.stop()),p.remove(),n.style.visibility=``,r?.())};return n.style.visibility=`hidden`,g(0),document.body.appendChild(p),v.push(U(p,{backgroundColor:[e.backgroundColor,o]},{duration:hn,ease:`linear`}),En(m,1,0,gn),En(h,0,1,_n),U(0,1,{duration:un,ease:`linear`,onUpdate:g,onComplete:y})),y},On=64,kn=e=>{if(!e)return[];let t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e instanceof File)},An=e=>Array.from(e?.files||[]),jn=async(e,t=ee)=>{let n=[],r=0;for(let i of Array.from(e||[])){if(!i||i.size<=0)continue;if(i.size>26214400){r+=1;continue}let e=URL.createObjectURL(i);n.push({id:t(),url:e,name:i.name.trim()||`attachment`,mime:i.type.trim()||`application/octet-stream`,file:i})}return{attachments:n,skippedTooLarge:r}},Mn=(e,t)=>{let n=[...e,...t];for(let e of n.slice(On))e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url);return n.slice(0,On)},Nn=ge(()=>M(()=>import(`./ToolOutputDialog-CBk9ZNkY.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78]))),Pn=e=>e.trim().startsWith(`yuri.settle.`)||e.trim().startsWith(`oc.settle.`),Fn=e=>e.status===`error`||e.status===`failed`&&e.messageID.endsWith(`:preview:failed`),In=e=>e.role===`assistant`&&e.status!==`error`&&e.parts.some(e=>e.type===`text`)?`${e.turnID}:assistant:${e.bubbleIndex}`:e.messageID,Ln=({assistant:e,warning:t,active:n,overlayHeader:r=!1,overlayComposer:i=!1})=>{let{t:a,locale:o}=P(),s=Ne(),c=N(e=>e.isMobile),l=ae(),u=le(),d=ie(e.id,n),f=N(e=>e.isSettingsDialogOpen),p=n&&!f&&!d.hasMessageGap?ue(e,d.data):null,m=z(e.name).displayName||e.name,h=pe(me(e.avatarSeed??e.id).color),g=(e,t)=>{let n=e?u.data?.assistants.find(t=>t.id===e):void 0;return n?z(n.name).displayName||n.name:t||a(`assistants.contact.peer.unknown`)},[_,v]=Q.useState(``),[y,b]=Q.useState([]),x=Q.useRef(new Map),S=Q.useRef(new Map),C=Q.useRef(new AbortController);Q.useEffect(()=>{let e=new AbortController;return C.current=e,()=>e.abort()},[e.id,s]);let w=Q.useRef(new Set),[E,D]=Q.useState([]);Q.useEffect(()=>{let e=new Set(y.map(e=>e.url));for(let t of x.current.values())for(let n of t.attachments)e.add(n.url);for(let t of w.current)e.has(t)||URL.revokeObjectURL(t);w.current=e},[y,E]),Q.useEffect(()=>()=>{for(let e of w.current)URL.revokeObjectURL(e)},[]);let[O,k]=Q.useState([]),[A,M]=Q.useState(null),[te,ce]=Q.useState({open:!1,title:``,content:``}),L=N(e=>e.setImagePreviewOpen),de=j(e=>{(e.image||e.mermaid||e.video)&&(ce(e),L(!0))}),R=j(e=>{ce(t=>({...t,open:e})),L(e)});Q.useEffect(()=>()=>{L(!1)},[L]),Q.useEffect(()=>{S.current.clear(),x.current.clear(),D([]),k([]),M(null)},[s]);let B=Q.useMemo(()=>Pt(),[]),V=Q.useRef(new Set),H=Q.useRef(new Map),U=Rt(e=>e.setWorking),G=d.data?.messages??gt,ge=Q.useMemo(()=>G.some(e=>e.parts.some(e=>e.type===`card`&&e.cardType===`schedule`&&Kt(e))),[G]),_e=ne(e.id,n&&ge),ye=Q.useMemo(()=>{let e=new Map;for(let t of _e.data?.tasks??[]){if(!t.task)continue;let n=e.get(t.projectID);n||(n=new Map,e.set(t.projectID,n)),n.set(t.taskID,t.task)}return e},[_e.data]),K=yt(E,e.id),be=bt(O,e.id),xe=Ct(G,K,e.id,be).filter(e=>{if(e.status===`admitted`&&e.messageID.endsWith(`:preview:admitted`))return!1;let t=Array.isArray(e.parts)?e.parts:[];return t.length===0||t.some(e=>!(e.type===`text`&&Pn(e.text)))}),Se=xe.length-1;for(;Se>=0&&Fn(xe[Se]);)--Se;let q=xe.filter((e,t)=>!Fn(e)||t>Se),Ce=Qt(q),we=`${s}:${e.id}`,Te=Q.useRef(null),Ee=Te.current?.scope===we?Te.current.keys:null,De=[],Oe=new Set,ke=new Map;for(let[e,t]of q.entries()){let n=De.at(-1),r=n?.rows.at(-1)?.message,i=In(t);if(n&&r&&t.role!==`user`&&t.role===r.role&&t.turnID===r.turnID&&t.fromAssistantID===r.fromAssistantID&&!Fn(t)&&!Fn(r))n.rows.push({message:t,index:e});else{let n=Ee?.get(i),r=n&&!Oe.has(n)?n:i;De.push({key:r,rows:[{message:t,index:e}]}),Oe.add(r)}ke.set(i,De.at(-1).key)}for(let e of De){if(e.rows.some(({message:t})=>Ee?.get(In(t))===e.key))continue;let t=e.rows.map(({message:e})=>Ee?.get(In(e))).find(e=>e&&!Oe.has(e));if(t){Oe.delete(e.key),e.key=t,Oe.add(t);for(let{message:n}of e.rows)ke.set(In(n),t)}}Q.useLayoutEffect(()=>{Te.current={scope:we,keys:ke}});let Ae=he(),J=`${s}:${e.id}`,je=Q.useRef(null),Me=je.current,Pe=Me?.lastID?q.findIndex(e=>In(e)===Me.lastID):-1,Fe=n&&!Ae&&Me?.scope===J&&Me.ready&&(Me.lastID===null||Pe>=0);Q.useLayoutEffect(()=>{let e=q.at(-1);je.current={scope:J,ready:n&&d.isSuccess,lastID:e?In(e):null}});let Ie=new Date().toDateString(),Le=a(`common.date.today`),Re=a(`common.date.yesterday`),Ve=Q.useMemo(()=>$t(o,Le,Re,new Date(Ie)),[o,Le,Re,Ie]),He=Q.useMemo(()=>new Intl.DateTimeFormat(o,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),[o]),Y=It(K),Ue=Lt(be),X=!!(e.working||e.activeContactTurn),We=u.data?.revision??null,Ge=be.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),Ke=new Map(be.map(e=>[e.turnID,e])),qe=Q.useRef(!1),Z=j(async(e=!1)=>{if(!(!n||qe.current||d.isFetchingPreviousPage||d.isFillingMessageGap)&&!(e&&d.previousPageError)&&!(!d.hasPreviousPage&&!d.hasMessageGap)){qe.current=!0,$e();try{d.hasMessageGap?await d.retryMessageGap():await d.fetchPreviousPage()}catch{}finally{qe.current=!1}}}),Xe=Q.useRef(null),{scrollRef:Ze,contentRef:Qe,preparePrepend:$e,followLatest:et}=ln({active:n,assistantID:e.id,contentRevision:`${q[0]?.messageID}:${q.length}:${Ge}:${d.isFetchingPreviousPage}:${d.hasPreviousPage}:${d.isFillingMessageGap}`,onLoadEarlier:()=>{Z(!0)},overlayComposerRef:i?Xe:void 0}),tt=Q.useRef(null),nt=Q.useRef(null),rt=Q.useRef(null),it=Q.useRef(null),[at,st]=Q.useState(null),ct=()=>{let e=Xe.current?.querySelector(`[data-assistant-contact-composer-surface]`),t=e?.querySelector(`textarea`);return e&&t?wn(e,t,!c):null};Q.useLayoutEffect(()=>{let e=nt.current;if(!e?.ready||!n)return;nt.current=null;let t=Array.from(tt.current?.querySelectorAll(`[data-message-id]`)??[]).find(t=>t.dataset.messageId===e.messageID)?.querySelector(`[data-assistant-contact-text]`),r=()=>st(t=>t?.messageID===e.messageID?null:t);if(!t){r();return}it.current?.(),it.current=Dn(e.source,t,t,r)}),Q.useEffect(()=>()=>{nt.current=null,it.current?.(),it.current=null},[n,e.id,s]),Q.useEffect(()=>{M(null),x.current.clear(),S.current.clear(),V.current.clear(),H.current=new Map,D(t=>yt(t,e.id)),k(t=>bt(t,e.id)),ce({open:!1,title:``,content:``}),L(!1)},[e.id,L]),Q.useEffect(()=>{for(let e of G){let t=x.current.get(e.messageID);if(t){for(let e of t.attachments)S.current.delete(`${t.assistantID}:${e.id}`);x.current.delete(e.messageID)}}D(e=>wt(e,G))},[G]),Q.useEffect(()=>{let t=new Set(K.filter(e=>e.status===`sending`).map(e=>e.messageID));k(n=>Ot(n,{assistantID:e.id,activeContactTurn:e.activeContactTurn?{turnID:e.activeContactTurn.turnID,admittedAt:e.activeContactTurn.admittedAt}:null,serverWorking:X,snapshotRevision:We,admissionRevisionByTurnID:H.current,pendingSendTurnIDs:t,messages:G,settledTurnIDs:V.current}))},[e.activeContactTurn,e.id,G,K,X,We]),Q.useEffect(()=>{U(e.id,Y||Ue||X)},[e.id,Ue,Y,X,U]),Q.useEffect(()=>{let t=e.id;return()=>{U(t,!1)}},[e.id,U]);let lt=j(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){V.current.delete(t.turnID),k(e=>Et(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(V.current.has(t.turnID))return;k(e=>kt(e,t));return}t.type===`contact-turn-end`&&(V.current.add(t.turnID),k(e=>jt(At(e,t,{requireExisting:!0}),G)))}});Q.useEffect(()=>{if(n)return T(lt)},[n,e.id]);let ut=j(async e=>{if(Y)return;let t=C.current,n=await jn(e);if(t.signal.aborted){n.attachments.forEach(e=>URL.revokeObjectURL(e.url));return}n.skippedTooLarge>0&&M(a(`assistants.contact.attachment.tooLarge`)),n.attachments.length!==0&&b(e=>Mn(e,n.attachments))}),dt=j(e=>{let t=kn(e.clipboardData);t.length!==0&&(e.preventDefault(),ut(t))}),pt=j(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),_t=j(e=>{let t=An(e.dataTransfer);t.length!==0&&(e.preventDefault(),ut(t))}),vt=j(async(t,r)=>{let i=C.current,o=e.id,s=r?x.current.get(r):void 0;if(r&&(!s||s.assistantID!==o))return;let c=s?.text??t??_,u=s?.attachments??y,d=Ft({gate:B,sending:It(K),text:c,attachments:u,assistantID:o,createMessageID:()=>r||`yuri_contact_${ee()}`});if(!d.ok)return;U(o,!0),x.current.set(d.messageID,{assistantID:o,text:c,attachments:u});let f=u.length===0&&t===void 0&&!r&&n&&!Ae?ct():null;it.current?.(),it.current=null;let p=f?{messageID:d.messageID,source:f,ready:!1}:null;nt.current=p,st(f?{scope:J,messageID:d.messageID,phase:`scrolling`}:null),rt.current=f?d.messageID:rt.current,r||(et(f?{duration:un,ease:dn}:void 0,p?e=>{nt.current===p&&(e?p.ready=!0:nt.current=null,st(t=>t?.messageID===d.messageID?e?{...t,phase:`flying`}:null:t))}:void 0),v(e=>e===c?``:e),b(e=>e.filter(e=>!u.includes(e)))),D(e=>e.some(e=>e.messageID===d.messageID)?e.map(e=>e.messageID===d.messageID?{...d.turn,createdAt:e.createdAt}:e):[...e,d.turn]),M(null);let h=()=>{u.forEach(e=>S.current.delete(`${o}:${e.id}`)),x.current.delete(d.messageID)};try{let t=[];for(let e of u){let n=`${o}:${e.id}`,r=S.current.get(n);if(!r){if(r=await Be(o,e.file,e.id,i.signal),i.signal.aborted)return;S.current.set(n,r)}t.push(r)}if(i.signal.aborted)return;let n=[...d.parts.filter(e=>e.type===`text`),...t];D(e=>e.map(e=>e.messageID===d.messageID?{...e,parts:n}:e));let r=await re(o,d.messageID,{parts:n});if(i.signal.aborted)return;h(),typeof r.revision==`number`&&H.current.set(d.messageID,r.revision),D(e=>Tt(e,d.messageID)),V.current.has(d.messageID)||k(e=>Et(e,o,d.messageID)),l.data?.serverInstanceID&&fe({serverInstanceID:l.data.serverInstanceID,assistantID:o,name:m,avatarSeed:e.avatarSeed??o}).catch(()=>void 0)}catch(e){if(i.signal.aborted)return;if(e instanceof oe&&e.code===`admission_timeout`)try{let e=await se(o,d.messageID);if(i.signal.aborted)return;if(e){h(),typeof e.revision==`number`&&H.current.set(d.messageID,e.revision),D(e=>Tt(e,d.messageID)),V.current.has(d.messageID)||k(e=>Et(e,o,d.messageID));return}}catch{}let t=Nt(e,{noProvider:a(`assistants.contact.noProvider`),sendFailed:a(`assistants.contact.sendFailed`),timedOut:a(`assistants.contact.timedOut`)});D(e=>Mt(e,d.messageID,t))}finally{B.release()}}),xt=j(e=>{vt(void 0,e)}),St=d.isError&&q.length===0,Dt=d.isSuccess&&q.length===0,zt=new Map(K.map(e=>[e.messageID,e]));return(0,$.jsxs)(`div`,{ref:tt,className:`yuri-contact-conversation flex min-h-0 flex-1 flex-col bg-transparent`,"data-contact-layout":c?`mobile`:`desktop`,"data-composer-overlay":i||void 0,children:[(0,$.jsxs)(`div`,{ref:Ze,className:I(`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 sm:px-8`,c&&`pb-11`,r?`pt-[calc(max(0.625rem,var(--yuri-safe-area-top,0px))+var(--yuri-mobile-detail-navigation-height)+1.25rem)]`:`pt-5 sm:pt-7`),style:{overflowAnchor:`none`,overscrollBehavior:`contain`,overscrollBehaviorY:`contain`},"data-assistant-contact-transcript":``,children:[t?(0,$.jsx)(`p`,{className:`mb-3 typography-micro text-[var(--status-warning)]`,children:t}):null,St?(0,$.jsxs)(`div`,{ref:Qe,className:`mx-auto flex h-full min-h-56 max-w-xs flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-error":``,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Vt,{name:e.id,avatarSeed:e.avatarSeed,size:44,label:m,working:n?X:void 0,showWorkingDot:!1,followPointer:!1}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--surface-elevated)] text-[var(--status-error)] ring-2 ring-background`,children:(0,$.jsx)(W,{name:`error-warning`,className:`size-3`})})]}),(0,$.jsx)(`p`,{className:`mt-4 typography-ui-label font-medium text-foreground`,children:m}),(0,$.jsx)(`p`,{className:`mt-1.5 typography-ui leading-6 text-muted-foreground`,children:a(`assistants.contact.loadFailed`)}),(0,$.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void d.refetch(),children:a(`chat.history.retry`)})]}):Dt?(0,$.jsxs)(`div`,{ref:Qe,className:`mx-auto flex h-full min-h-56 max-w-sm flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-empty":``,children:[(0,$.jsx)(Vt,{name:e.id,avatarSeed:e.avatarSeed,size:48,label:m,className:`opacity-90`,working:n?X:void 0,showWorkingDot:!1,followPointer:!1}),(0,$.jsx)(`p`,{className:`mt-5 typography-ui-header font-medium tracking-[-0.01em] text-foreground`,children:a(`assistants.conversation.emptyTitle`,{name:m})}),(0,$.jsx)(`p`,{className:`mt-2 max-w-xs typography-ui leading-6 text-muted-foreground/80`,children:a(`assistants.contact.empty`)})]}):(0,$.jsxs)(`div`,{ref:Qe,className:`relative mx-auto flex w-full flex-col pb-12`,"data-assistant-contact-content":``,children:[d.isPending?(0,$.jsx)(`p`,{role:`status`,className:`py-3 text-center typography-micro text-muted-foreground`,children:a(`common.loading`)}):null,d.hasPreviousPage||d.hasMessageGap?(0,$.jsxs)(`div`,{className:`mb-3 flex flex-col items-center gap-1`,"data-assistant-contact-pagination":``,"aria-busy":d.isFetchingPreviousPage||d.isFillingMessageGap,children:[d.previousPageError?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:a(`chat.history.loadOlderFailed`)}):null,d.hasMessageGap?(0,$.jsx)(`p`,{role:`status`,className:`typography-micro text-muted-foreground`,children:a(`assistants.contact.history.gap`)}):null,(0,$.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,disabled:d.isFetchingPreviousPage||d.isFillingMessageGap,onClick:()=>void Z(),children:a(d.isFetchingPreviousPage||d.isFillingMessageGap?`chat.history.loadingMore`:d.previousPageError||d.hasMessageGap?`chat.history.retry`:`chat.history.loadOlder`)})]}):null,De.map(t=>{let r=t.rows[0].message,i=r.role!==`user`&&!Fn(r),o=r.role===`peer`&&r.fromAssistantID?u.data?.assistants.find(e=>e.id===r.fromAssistantID):e,l=r.role===`peer`?g(r.fromAssistantID,r.fromAssistantName):m;return(0,$.jsxs)(`div`,{className:I(`relative flex w-full`,!Ce.has(r.messageID)&&(i?`mt-4 first:mt-0`:`mt-6 first:mt-0`)),"data-assistant-contact-group":``,children:[i?(0,$.jsx)(`div`,{className:I(`sticky bottom-2 flex shrink-0 self-end justify-center pb-0.5`,c?`mr-2.5 w-9`:`mr-2 w-6`),"data-assistant-contact-avatar-rail":``,children:(0,$.jsx)(Vt,{name:o?.id||r.fromAssistantID||e.id,avatarSeed:o?.avatarSeed??(r.fromAssistantID?void 0:e.avatarSeed),size:c?32:24,label:l,working:n?!!(o?.working||o?.activeContactTurn):void 0,showWorkingDot:!1,followPointer:!1})}):null,(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:t.rows.map(({message:t,index:r})=>{let i=`${J}:${In(t)}`,o=r>0?q[r-1]:null,l=q[r+1],d=Ce.get(t.messageID),f=d!==void 0,_=f?(0,$.jsx)(`div`,{className:`flex w-full justify-center px-4 py-4`,"data-assistant-contact-time":``,children:(0,$.jsx)(`time`,{dateTime:new Date(d).toISOString(),className:`text-[11px] font-normal leading-4 tabular-nums text-muted-foreground/70`,children:Ve(d)})}):null,v=t.role===`user`,y=t.role===`peer`,b=e=>e&&!Fn(e)&&e.role===t.role&&e.turnID===t.turnID&&e.fromAssistantID===t.fromAssistantID,x=!!(!f&&b(o)),S=!!(l&&!Ce.has(l.messageID)&&b(l)),C=t.role===`assistant`&&!f&&o?.role===`assistant`&&o.turnID===t.turnID,w=y?g(t.fromAssistantID,t.fromAssistantName):m,T=zt.get(t.messageID),E=Ke.get(t.turnID),D=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`),O=(e,t)=>v?(0,$.jsx)(mt,{failedTurn:n?T:void 0,retryDisabled:Y,onRetry:xt,children:e},t):e;return t.status===`error`||D?(0,$.jsxs)(Q.Fragment,{children:[_,(0,$.jsxs)(`div`,{"data-message-id":t.messageID,"data-assistant-contact-error":``,className:I(`relative px-1`,!f&&`mt-3`),children:[(0,$.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap text-center text-[11px] font-normal leading-4 text-muted-foreground [overflow-wrap:anywhere]`,children:t.text||E?.error||a(`assistants.contact.sendFailed`)}),p?.messageID===t.messageID?(0,$.jsx)(Ye,{assistantID:e.id,position:p},`${s}:${e.id}:${p.generation}:${p.ordinal}`):null]})]},i):(0,$.jsxs)(Q.Fragment,{children:[_,(0,$.jsx)(ze.div,{"data-message-id":t.messageID,initial:Fe&&r>Pe&&t.messageID!==rt.current?{opacity:0,y:4}:!1,animate:{opacity:1,y:0},transition:{duration:Ae?0:.18,ease:`easeOut`},className:I(`flex w-full`,v?`justify-end`:`justify-start`,f?`mt-0`:x?`mt-2`:`mt-4 first:mt-0`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":T?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!C?``:void 0,children:(0,$.jsxs)(`div`,{className:I(`relative flex min-w-0 flex-col gap-2`,v?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[y?(0,$.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:a(`assistants.contact.peer.from`,{name:w})}):null,t.parts.map((r,o)=>{if(r.type===`card`&&r.cardType===`session`)return(0,$.jsx)(Je,{card:r},`${i}:card:${o}:${JSON.stringify([r.target??null,r.directory,r.sessionID])}`);if(r.type===`card`&&r.cardType===`assistant`)return(0,$.jsx)(Ht,{card:r,assistant:u.data?.assistants.find(e=>e.id===r.assistantID),active:n},`${i}:card:${o}`);if(r.type===`card`&&r.cardType===`schedule`)return(0,$.jsx)(Xt,{card:r,task:ye.get(r.projectID)?.get(r.taskID)},`${i}:card:${o}`);if(r.type===`file`)return O((0,$.jsx)(ft,{assistantID:e.id,part:r,onShowPopup:de},`${i}:file:${o}`),`${i}:file:${o}`);if(r.type===`text`&&Pn(r.text))return null;if(r.type===`text`&&(r.text.trim()||t.status===`streaming`)){let e=!v,s=e&&/^!\[(?:\\.|[^\]\\\n])*\]\(\s*(?:<[^>\n]+>|[^\s()]+)(?:\s+"[^"\n]*")?\s*\)$/.test(r.text.trim());return O((0,$.jsx)(ht,{label:y?a(`assistants.contact.peer.aria`,{name:w}):void 0,outgoing:v,joinedBefore:x,joinedAfter:S,createdAt:t.createdAt,time:He.format(t.createdAt),mobile:c,media:s,colors:v?h:void 0,hidden:n&&at?.scope===J&&at.messageID===t.messageID,children:e?(0,$.jsx)(ve,{content:r.text,messageId:i,isAnimated:!1,isStreaming:t.status===`streaming`,variant:`assistant`,enableFileReferences:!1,onShowPopup:de,className:`w-full min-w-0 [overflow-wrap:anywhere]`}):r.text},`${i}:text:${o}`),`${i}:text:${o}`)}return null}),p?.messageID===t.messageID?(0,$.jsx)(Ye,{assistantID:e.id,position:p},`${s}:${e.id}:${p.generation}:${p.ordinal}`):null]})})]},i)})})]},`${J}:${t.key}`)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 left-[var(--contact-avatar-gutter)] flex h-10 items-center`,"data-assistant-contact-status-slot":``,children:!Y&&at?.scope!==J&&(Ue||X)?(0,$.jsxs)(ze.div,{role:`status`,"aria-label":a(`assistants.contact.processing`),initial:!Ae&&{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:Ae?0:.18,ease:`easeOut`},className:`relative inline-flex h-9 origin-bottom-left items-center gap-1 rounded-[1.35rem] bg-[var(--surface-muted)] px-4 text-muted-foreground/70`,"data-assistant-contact-processing":``,children:[(0,$.jsx)(`div`,{className:I(`absolute -left-[var(--contact-avatar-gutter)] top-0.5 flex justify-center`,c?`w-9`:`w-6`),"data-assistant-contact-processing-avatar":``,children:(0,$.jsx)(Vt,{name:e.id,avatarSeed:e.avatarSeed,size:c?32:24,label:m,working:n?X:void 0,showWorkingDot:!1,followPointer:!1})}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.45s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.22s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-duration:1.4s] motion-reduce:animate-none`})]}):null})]})]}),(0,$.jsxs)(`footer`,{ref:Xe,className:`relative z-10 shrink-0 bg-transparent pt-1`,"data-assistant-contact-composer":``,children:[A?(0,$.jsx)(`div`,{className:`chat-input-column mb-2`,children:(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:A})}):null,(0,$.jsx)(`form`,{className:I(`relative w-full pt-1.5 pb-4`,c&&`bottom-safe-area yuri-mobile-composer`),onSubmit:e=>{e.preventDefault(),vt()},onDragOver:pt,onDrop:_t,children:(0,$.jsx)(`div`,{className:`relative overflow-visible`,"data-contact-composer-column":``,children:(0,$.jsx)(ot,{active:n,layout:`inline`,value:_,attachments:y,pending:Y,isMobile:c,placeholder:a(`assistants.contact.placeholder`,{name:m}),sendLabel:a(`assistants.contact.send`),addFilesLabel:a(`assistants.contact.addFiles`),removeAttachmentLabel:a(`assistants.contact.removeAttachment`),fileAccept:`*/*`,onChange:e=>v(e),onVoiceSend:e=>{vt(e)},onSubmit:()=>{vt()},onAddFiles:e=>{ut(e)},onRemoveAttachment:t=>{Y||(S.current.delete(`${e.id}:${t}`),b(e=>e.filter(e=>e.id!==t)))},onPaste:dt,onDragOver:pt,onDrop:_t,className:I(`relative z-10`,c&&`yuri-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":a(`assistants.contact.placeholder`,{name:m})}},`${s}:${e.id}`)})})]}),te.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Nn,{popup:te,onOpenChange:R,isMobile:c})}):null]})};export{Bt as i,en as n,Vt as r,Ln as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RemoteAssistantSessionCard-CE-B_FHL.js","assets/vendor-base-ui-fom6orB6.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-D5BntRmA.js","assets/vendor-tanstack-react-query-ChSd65dm.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/useMobileNavigationStore-Dlt-Ip-3.js","assets/runtime-auth-mjIpsk3N.js","assets/reasoning-projection-client-BEhVknv9.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtime-fetch-DKZOpfzo.js","assets/platform-wF65ZFgV.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-zustand-CNn3HHhT.js","assets/gitApiHttp-BEMPJCIG.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/safeStorage-DTOhKN0V.js","assets/client-CgAFd1ew.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-8bssUUT3.js","assets/runtime-file-resource-DnhWnndu.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-B8s-Rcd-.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/useUIStore-CYex4rbF.js","assets/useMobileHtmlPreviewStore-DUquFMmd.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-Y-KPX915.js","assets/i18n-OsFhnlRH.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-Dj5cSf8B.js","assets/tour-CMXP3Kif.js","assets/useAssistantUIStore-CphyXHEY.js","assets/input-store-DRTu4uZc.js","assets/remoteProjectQueries-8giIAvzL.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/remoteSessionReference-BODrh2wf.js","assets/openRemoteProjectSession-DkaBkopU.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./platform-wF65ZFgV.js";import{ot as n,st as r}from"./vendor-base-ui-fom6orB6.js";import{n as i}from"./vendor-react-D5BntRmA.js";import{r as a}from"./vendor-reactuses-core-B8s-Rcd-.js";import{o}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as s}from"./useUIStore-CYex4rbF.js";import{r as c}from"./vendor-sonner-Y-KPX915.js";import{t as l}from"./i18n-OsFhnlRH.js";import{Ct as u,K as d,Rn as f,Zn as p,vi as m}from"./useMobileNavigationStore-Dlt-Ip-3.js";import{n as h}from"./Icon-C6CNZZkk.js";import{a as g,c as _,o as v,t as y}from"./sessionLookup-BnWJnI1i.js";var b=e(r(),1),x=i(),S=n();function C(e){let t=(0,x.c)(6),{value:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,S.jsx)(h,{name:`brain`,weight:`medium`,className:`size-3.5 shrink-0`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,S.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),t[1]=n,t[2]=i);let a;return t[3]!==i||t[4]!==n?(a=(0,S.jsxs)(`p`,{"data-contact-card-model":``,className:`flex min-w-0 flex-1 items-center gap-1.5 text-[0.75em] leading-4 text-muted-foreground`,title:n,children:[r,i]}),t[3]=i,t[4]=n,t[5]=a):a=t[5],a}var w=b.createContext(null),T=[`grid h-[calc(148px*var(--padding-scale,1))] w-[19rem] min-w-0 max-w-full shrink-0 grid-rows-[calc(40px*var(--padding-scale,1))_calc(20px*var(--padding-scale,1))_calc(20px*var(--padding-scale,1))_calc(48px*var(--padding-scale,1))] content-start cursor-pointer rounded-[var(--contact-bubble-radius,1.125rem)] bg-[var(--assistant-panel-background,var(--surface-muted))]`,`px-4 py-2.5 text-left typography-ui-label transition-colors duration-150 motion-reduce:transition-none`,`hover:bg-[color-mix(in_srgb,var(--assistant-panel-background,var(--surface-muted))_94%,black)]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),E=T,D=T,O=`row-start-1 mb-2 flex h-8 min-w-0 items-center gap-2`,k=`row-start-2 min-w-0 self-start truncate font-medium leading-5 text-foreground`,A=`row-start-4 flex h-12 min-w-0 flex-col justify-center`;function j(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var M=b.lazy(()=>o(()=>import(`./RemoteAssistantSessionCard-CE-B_FHL.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]))),N=(e,t)=>t===`cancelled`?t:e===`busy`||e===`retry`?e:t===`error`||t===`question`||t===`complete`||t===`busy`||t===`retry`?t:e===`idle`?`complete`:t===`idle`?t:t||`busy`,P=e=>e===`unknown`?`remoteProjects.unknown`:e===`cancelled`?`assistants.contact.card.session.status.cancelled`:e===`busy`?`assistants.contact.card.session.status.busy`:e===`retry`?`assistants.contact.card.session.status.retry`:e===`idle`?`assistants.contact.card.session.status.idle`:e===`complete`?`assistants.contact.card.session.status.complete`:e===`error`?`assistants.contact.card.session.status.error`:e===`question`?`assistants.contact.card.session.status.question`:null,F=e=>e===`busy`?`text-[var(--status-info)]`:e===`retry`||e===`question`?`text-[var(--status-warning)]`:e===`error`?`text-[var(--status-error)]`:e===`idle`||e===`complete`?`text-[var(--status-success)]`:`text-muted-foreground`,I=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,L=e=>{let t=(0,x.c)(12),{card:n}=e,r;t[0]===n.sessionID?r=t[1]:(r=e=>e.activeSessions.find(e=>e.id===n.sessionID)??e.archivedSessions.find(e=>e.id===n.sessionID)??null,t[0]=n.sessionID,t[1]=r);let i=m(r),a=d(n.sessionID),o;t[2]!==n.directory||t[3]!==i?.directory?(o=i?.directory?.trim()||n.directory,t[2]=n.directory,t[3]=i?.directory,t[4]=o):o=t[4];let s=p(o),c=i??void 0,l=a?.type,u;t[5]===s.data?.current?u=t[6]:(u=s.data?.current?.trim()||null,t[5]=s.data?.current,t[6]=u);let f;return t[7]!==n||t[8]!==c||t[9]!==l||t[10]!==u?(f=(0,S.jsx)(z,{card:n,liveSession:c,liveType:l,branch:u}),t[7]=n,t[8]=c,t[9]=l,t[10]=u,t[11]=f):f=t[11],f},R=e=>{let t=(0,x.c)(2),{card:n}=e,r;return t[0]===n?r=t[1]:(r=n.target?(0,S.jsx)(b.Suspense,{fallback:(0,S.jsx)(z,{card:n,branch:null}),children:(0,S.jsx)(M,{card:n})}):(0,S.jsx)(L,{card:n}),t[0]=n,t[1]=r),r};function z({card:e,liveSession:n,liveType:r,branch:i}){let{t:d}=l(),p=!!(_()&&!t()),m=(typeof n?.title==`string`&&n.title.trim()?n.title.trim():null)||e.title||d(`assistants.contact.card.session.untitled`),x=e.target?r===`idle`?`complete`:r===`busy`||r===`retry`?r:[`complete`,`error`,`cancelled`].includes(e.status??``)?e.status:`unknown`:N(r,e.status),T=P(x),E=typeof n?.directory==`string`&&n.directory.trim()?n.directory.trim():e.directory,A=I(E),M=v(n),L=x===`complete`||x===`idle`?g(n):null,R=b.useContext(w),z=a(()=>{if(e.target){if(R)return R({sessionId:e.sessionID,directory:e.directory,target:e.target});o(async()=>{let{openAssistantRemoteSession:e}=await import(`./remoteSessionReference-BODrh2wf.js`);return{openAssistantRemoteSession:e}},__vite__mapDeps([46,23,2,7,9,10,8,11,12,13,1,3,5,4,24,25,26,27,28,29,17,6,14,15,16,18,19,20,21,22,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,47])).then(({openAssistantRemoteSession:t})=>t(e,p)).catch(()=>c.error(d(`remoteProjects.host-unavailable`)));return}let t=y(e.sessionID)?.directory||e.directory;if(R)return R({sessionId:e.sessionID,directory:t});u(e.sessionID,t,{phoneShell:p,switchToChat:!0}),p||s.getState().setActiveMainTab(`chat`)}),B=a(e=>{j(e,z)});return(0,S.jsxs)(`article`,{className:D,role:`button`,tabIndex:0,"aria-label":d(`assistants.contact.card.session.aria`,{title:m}),"data-assistant-contact-card":`session`,onClick:z,onKeyDown:B,children:[(0,S.jsxs)(`div`,{className:O,children:[(0,S.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[0.8em] leading-4 text-muted-foreground`,children:[(0,S.jsx)(h,{name:`chat-thread`,weight:`medium`,className:`size-4 shrink-0`}),(0,S.jsx)(`span`,{className:`truncate`,children:d(`assistants.contact.card.session.label`)})]}),T?(0,S.jsxs)(`span`,{"data-assistant-session-status":``,className:f(`ml-auto inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[0.75em] leading-4`,F(x)),children:[(0,S.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}),d(T)]}):null]}),(0,S.jsx)(`h3`,{className:k,title:m,children:m}),(0,S.jsxs)(`div`,{"data-contact-session-details":``,className:`row-start-3 row-end-5 flex min-w-0 flex-col gap-1.5 py-1`,children:[(0,S.jsxs)(`div`,{"data-contact-session-project":``,className:`flex h-4 min-w-0 flex-none items-center gap-2 text-[0.8em] leading-4`,children:[(0,S.jsxs)(`p`,{className:f(`flex min-w-0 items-center gap-1.5 text-foreground`,i&&`max-w-[45%] shrink-0`),title:E,children:[(0,S.jsx)(h,{name:`folder`,weight:`medium`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,S.jsx)(`span`,{className:`min-w-0 truncate`,children:A})]}),i?(0,S.jsxs)(`p`,{"data-contact-session-branch":``,className:`flex min-w-0 items-center gap-1 text-muted-foreground`,title:i,children:[(0,S.jsx)(h,{name:`git-branch`,weight:`medium`,className:`size-3 shrink-0`}),(0,S.jsx)(`span`,{className:`min-w-0 truncate`,children:i})]}):null]}),L?(0,S.jsxs)(`p`,{"data-contact-session-changes":``,className:`flex h-4 min-w-0 flex-none items-center gap-1.5 overflow-hidden whitespace-nowrap text-[0.8em] leading-4 text-muted-foreground tabular-nums`,children:[(0,S.jsx)(h,{name:`code`,weight:`medium`,className:`size-3.5 shrink-0`}),L.additions===void 0?null:(0,S.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,L.additions]}),L.deletions===void 0?null:(0,S.jsxs)(`span`,{className:`text-[var(--status-error)]`,children:[`−`,L.deletions]}),L.files===void 0?null:(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:L.files===1?d(`assistants.contact.card.session.changes.filesSingle`,{count:L.files}):d(`assistants.contact.card.session.changes.filesPlural`,{count:L.files})})]}):null,(0,S.jsxs)(`div`,{"data-contact-session-bottom":``,className:`mt-auto flex h-4 min-w-0 flex-none items-center gap-2`,children:[M?(0,S.jsx)(C,{value:M}):null,(0,S.jsx)(h,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`})]})]})]})}export{O as a,w as c,A as i,C as l,z as n,k as o,E as r,j as s,R as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/rolldown-runtime-hePW80VL.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r,o as i}from"./runtime-switch-BMjl5Y5W.js";import{n as a}from"./runtime-fetch-DKZOpfzo.js";import{B as o,I as s,P as c,R as l,V as u,Z as d,_ as f,f as p,h as m,n as h,t as g,z as _}from"./platform-wF65ZFgV.js";import{t as v}from"./runtimeAPIRegistry-C2VogTny.js";import{a as y,i as b,r as x}from"./vendor-zustand-CNn3HHhT.js";import{c as S,it as C,l as w,ot as T,st as E}from"./vendor-base-ui-fom6orB6.js";import{Ft as D,St as O,Ut as k}from"./gitApiHttp-BEMPJCIG.js";import{i as A,t as j}from"./safeStorage-DTOhKN0V.js";import{n as M}from"./client-CgAFd1ew.js";import{n as N}from"./vendor-react-D5BntRmA.js";import{n as P,o as F,s as ee,u as I}from"./vendor-tanstack-react-query-ChSd65dm.js";import{G as L,J as R,U as te,q as z}from"./runtime-file-resource-DnhWnndu.js";import{r as ne}from"./vendor-reactuses-core-B8s-Rcd-.js";import{o as B}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as V}from"./useUIStore-CYex4rbF.js";import{o as re}from"./useMobileHtmlPreviewStore-DUquFMmd.js";import{a as H,t as ie}from"./types-fkNzcMt6.js";import{B as U,E as ae,F as W,G as oe,K as se,R as ce,U as le,V as ue,W as de,X as fe,Y as pe,Z as me,a as he,f as ge,g as _e,ht as ve,j as ye,l as be,lt as xe,mt as Se,pt as Ce,st as G,tt as we}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{c as Te,o as K,r as Ee}from"./vendor-codemirror-lang-angular-Cm7vBE3E.js";import{n as De,r as Oe}from"./vendor-codemirror-lang-json-DowyFczU.js";import{n as ke}from"./vendor-codemirror-lang-markdown-npWBZIoE.js";import{n as Ae}from"./vendor-codemirror-lang-python-OPRdU26g.js";import{O as je}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{n as Me,t as Ne}from"./i18n-OsFhnlRH.js";import{Bn as Pe,Ia as Fe,In as q,Ln as Ie,Ma as Le,Qt as Re,Rn as J,Si as Y,Ui as ze,Va as Be,Xi as Ve,_a as He,ci as Ue,da as We,er as Ge,hi as Ke,p as qe,vi as Je,yt as Ye}from"./useMobileNavigationStore-Dlt-Ip-3.js";import{t as Xe}from"./AgentAvatar-B9ucI2MO.js";import{n as Ze}from"./useThemeSystem-D2YBbLma.js";import{n as X}from"./Icon-C6CNZZkk.js";import{a as Qe,n as $e,o as et,r as tt,t as nt}from"./dialog-CDfUL86v.js";import{a as rt,c as it,g as at,n as ot,r as st,t as ct,u as lt}from"./gitApi-6bjyfJ0P.js";import{t as ut}from"./input-Dc9Few6S.js";import{i as dt,n as ft,t as pt}from"./tooltip-IVmealjG.js";import{At as mt,B as ht,Dt as gt,E as _t,Ft as vt,G as yt,H as bt,K as xt,M as St,Mt as Ct,Ot as wt,Q as Tt,R as Et,U as Dt,W as Ot,h as kt,j as At,jt,k as Mt,kt as Nt,n as Pt,q as Ft,z as It,zt as Lt}from"./pwa-CUF8fchS.js";import{r as Rt,t as zt}from"./device-C8ZHblkr.js";import{n as Bt}from"./MarkdownRenderer-DrXbG9Y5.js";import{t as Vt}from"./MobileResizableSheet-Cn4FFye8.js";import{d as Ht}from"./select-RfWO-Q8r.js";import{n as Ut}from"./textarea-7J-b5mR2.js";import{a as Wt,c as Gt,h as Kt,m as qt,n as Jt,r as Yt,t as Xt}from"./projectMeta-CX7xsn7U.js";import{r as Zt}from"./markdown-worker-oBGEB9Eg.js";import{c as Qt,i as $t,o as en}from"./mcpQueries-D-c3h-8F.js";import{c as tn,f as nn,p as rn,s as an}from"./usePluginsStore-GVUi9ssB.js";import{n as on,r as sn,t as cn}from"./collapsible-Bt9trgB2.js";import{a as ln,d as un,o as dn,s as fn}from"./vendor-codemirror-commands-5saeUOVY.js";import{a as pn,c as mn,i as hn,l as gn,o as _n,r as vn,s as yn}from"./vendor-codemirror-search-hZY-L2l8.js";import{n as bn,t as xn}from"./vendor-replit-codemirror-vim-BmQmU1lR.js";import{t as Sn}from"./vendor-codemirror-language-data-B3pLWvv-.js";var Cn=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],wn=e=>[...Cn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],Z=N(),Q=T();function Tn(e){let t=(0,Z.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Q.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var $=e(E(),1),En=$.forwardRef((e,t)=>{let n=(0,Z.c)(11),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=J(`peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o={width:`36px`,height:`20px`,minWidth:`36px`,minHeight:`20px`},n[5]=o):o=n[5];let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(S,{className:J(`pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0`),style:{width:`16px`,height:`16px`,minWidth:`16px`,minHeight:`16px`}}),n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==t||n[9]!==a?(c=(0,Q.jsx)(w,{className:a,style:o,...i,ref:t,children:s}),n[7]=i,n[8]=t,n[9]=a,n[10]=c):c=n[10],c});En.displayName=`Switch`;var Dn={},On=(e,t=n())=>JSON.stringify([t,$t(e)]),kn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},An=e=>{let t=$t(e);return t?M.getScopedApiClient(t):M.getApiClient()},jn=e=>e?{location:{directory:e}}:void 0,Mn=new Map,Nn=(e,t)=>JSON.stringify([r(),On(t),e]),Pn=async(e,t,n)=>{let r=(await e.mcp.list(jn(n))).data.find(e=>e.name===t)?.integrationID;if(!r)throw Error(`MCP server "${t}" has no authentication integration`);return(await e.integration.get({integrationID:r,...jn(n)})).data},Fn=e=>$t(e===void 0?O.getState().currentDirectory:e),In=y()(x((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=On(Fn(e));return t().diagnosticsByDirectory[n]??Dn},clearDiagnostic:(t,n,r)=>{let i=On(Fn(n),r);e(e=>({diagnosticsByDirectory:kn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=Fn(r),a=n(),o=On(i,a),s=An(i);try{await s.mcp.connect({server:t,...jn(i)})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:r}}}})),n}await Qt(z,i,a),e(e=>({diagnosticsByDirectory:kn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=Fn(r),a=n(),o=On(i,a);await An(i).mcp.disconnect({server:t,...jn(i)}),await Qt(z,i,a),e(e=>({diagnosticsByDirectory:kn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=Fn(t),r=Nn(e,n),i=An(n),a=await Pn(i,e,n),o=a.methods.find(e=>e.type===`oauth`);if(!o)throw Error(`MCP server "${e}" has no OAuth method`);if(r!==Nn(e,n))throw Error(`MCP authorization runtime changed`);let s=Mn.get(r);if(s&&(await i.integration.oauth.cancel({integrationID:s.integrationID,attemptID:s.attempt.attemptID,...jn(n)}),Mn.delete(r)),r!==Nn(e,n))throw Error(`MCP authorization runtime changed`);let{data:c}=await i.integration.oauth.connect({integrationID:a.id,methodID:o.id,...jn(n)});if(r!==Nn(e,n))throw Error(`MCP authorization runtime changed`);for(let[e,t]of Mn)t.attempt.time.expires<=Date.now()&&Mn.delete(e);return Mn.set(r,{integrationID:a.id,attempt:c}),c},authStatus:async(e,t)=>{let n=Fn(t),r=Nn(e,n),i=Mn.get(r);if(!i)throw Error(`MCP authorization attempt not found`);let{data:a}=await An(n).integration.oauth.status({integrationID:i.integrationID,attemptID:i.attempt.attemptID,...jn(n)});if(r!==Nn(e,n))throw Error(`MCP authorization runtime changed`);return a.status!==`pending`&&Mn.get(r)===i&&Mn.delete(r),a},completeAuth:async(e,t,r)=>{let i=Fn(r),a=n(),o=Nn(e,i),s=Mn.get(o);if(!s||s.attempt.mode!==`code`)throw Error(`MCP authorization requires the browser callback`);if(!t.trim())throw Error(`MCP authorization code is empty`);if(await An(i).integration.oauth.complete({integrationID:s.integrationID,attemptID:s.attempt.attemptID,code:t.trim(),...jn(i)}),Mn.get(o)===s&&Mn.delete(o),o!==Nn(e,i))throw Error(`MCP authorization runtime changed`);await Qt(z,i,a)},clearAuth:async(e,t)=>{let r=Fn(t),i=n(),a=Nn(e,r),o=An(r),s=await Pn(o,e,r);if(a!==Nn(e,r))throw Error(`MCP authorization runtime changed`);let c=Mn.get(a);c&&(await o.integration.oauth.cancel({integrationID:c.integrationID,attemptID:c.attempt.attemptID,...jn(r)}),Mn.delete(a));let l=new Set(s.connections.flatMap(e=>e.type===`credential`?[e.id]:[]));for(let t of l){if(a!==Nn(e,r))throw Error(`MCP authorization runtime changed`);await o.credential.remove({credentialID:t})}if(a!==Nn(e,r))throw Error(`MCP authorization runtime changed`);await Qt(z,r,i)},testConnection:async(t,r)=>{let i=Fn(r),a=n(),o=On(i,a),s=An(i),c=en(z,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...jn(i)})}catch(n){l=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:l??`Connection failed`}}}}))}let d=(await Qt(z,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...jn(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await Qt(z,i,a)}return l||e(e=>({diagnosticsByDirectory:kn(e.diagnosticsByDirectory,o,t)})),{status:f??en(z,i,a)[t],error:l,warning:u}}}))),Ln=`https://yuri-updates.xiaobe.top/v1/update/check`,Rn=`https://yuri-origin.xiaobe.top/v1/update/check`,zn=`https://github.com/yee94/yuri/releases/latest`,Bn=`https://github.com/yee94/yuri/releases`,Vn=`https://testflight.apple.com/join/pN5SSHeg`,Hn=1e4;function Un(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function Wn(e,t){let n=Un(e),r=Un(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function Gn(){return[Ln,Rn]}function Kn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function qn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Jn(e,t,n,r){try{if(h())try{let{CapacitorHttp:r}=await B(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([0,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,url:typeof o.url==`string`?o.url:e,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,url:i.url,json:()=>i.json()}}catch{return null}}function Yn(e,t){return e===`ios`?Vn:`${Bn}/download/v${t}/app-release.apk`}function Xn(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=Wn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Bn}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():Yn(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function Zn(e,t,n,r){let i=await Jn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(qn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Xn(a,t.currentVersion,t.platform)}async function Qn(e,t,n,r){let i=await Jn(zn,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:zn,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=Wn(s,e),l=`${Bn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:Yn(t,s)}}async function $n(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=Gn(),a=r()+Hn;for(let[t,o]of i.entries()){let s=Kn(a,i.length-t+1,r);if(s===null)break;let c=await Zn(o,e,s,n);if(c)return c}let o=Kn(a,1,r);if(o!==null){let r=await Qn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function er(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=zt();return e}catch{return`unknown`}}function tr(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function nr(){let e=g();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function rr(e){let t=V.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,er()),n.set(`arch`,tr()),n.set(`platform`,nr()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,c()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function ir(e,t){let n=t??`unknown`;try{let r=rr(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let o=await a(`/api/yuri/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function ar(){return h()?`mobile`:s()?`desktop`:l()?`vscode`:_()?`web`:null}var or={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,downloadError:null,downloadVersion:null,downloadChannel:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null},sr=`yuri-client-update-download`,cr=e=>typeof e==`string`&&/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(e);function lr(){try{let e=JSON.parse(A().getItem(sr)??`null`);return!e||e.runtimeType!==ar()||![`desktop`,`mobile`].includes(e.runtimeType)||!cr(e.version)||![null,`stable`,`beta`].includes(e.channel)?{}:{runtimeType:e.runtimeType,downloadVersion:e.version,downloadChannel:e.channel,downloadError:`update_interrupted`}}catch{return{}}}function ur(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};if(e.primaryAction===`apply_ota`&&e.ota.bundle)return e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}};if(e.primaryAction===`install_native_required`){if(!e.native.version?.trim()||!e.native.installUrl?.trim())throw Error(`Native update required, but the update service supplied no complete installation target`);return{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}}return{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var dr=0,fr=y()((e,t)=>({...or,...lr(),checkForUpdates:async()=>{let n=ar();if(!n)return null;let r=++dr;e({checking:!0,error:null,runtimeType:n});try{let i=null,a=null;if(n===`desktop`){let n=V.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await m(n);if(r!==dr||V.getState().otaChannelOverride!==n)return null;let a=i?.downloaded===!0,o=!a&&i?.downloading===!0;return e({checking:!1,available:i?.available??!1,downloaded:a,...a?{downloading:!1,progress:null,downloadError:null}:o?{downloading:!0,progress:i?.progress??null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:a?`pending_restart`:o?`downloading`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await ir(`web`),a=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await ir(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await H()??`unknown`,r=h()?v()?.mobileUpdates:void 0,o=V.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==o;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let a=await r.checkForOtaUpdate(o===`beta`||o===`stable`?{channelOverride:o}:void 0),s=ur(a,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==a.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:a.nextCheckInSec,otaDecision:a,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:o,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),a.nextCheckInSec}catch(t){if(!(t instanceof ie)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:o}),null}}return i=await $n({currentVersion:n,platform:nr()===`ios`?`ios`:`android`,deviceClass:er(),arch:tr(),reportUsage:V.getState().reportUsage}),a=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(i){return r===dr&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async n=>{n?.resume===!0&&!t().info&&await t().checkForUpdates();let{available:r,runtimeType:i,otaDecision:a,downloading:o,downloaded:s}=t();if(o||s)return;let c=V.getState().otaChannelOverride,l=n?.resume===!0,u=l?t().downloadVersion:t().info?.version;if(l&&(t().downloadChannel!==c||u!==t().info?.version)){e({downloadError:`update_plan_changed`,error:`update_plan_changed`});return}if(i===`mobile`&&a?.primaryAction===`apply_ota`&&a.ota.bundle){if(o||s)return;let t=v()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,downloadError:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,downloadError:null,downloadVersion:u??null,downloadChannel:c,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(a.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,downloadError:null,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,downloadError:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(i!==`desktop`||!r)){e({downloading:!0,error:null,downloadError:null,downloadVersion:u??null,downloadChannel:c,progress:null});try{let n=V.getState().otaChannelOverride,r=await m(n);if(n!==V.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(u&&r?.version!==u)throw Error(`update_plan_changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await f(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,downloadError:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!s())return()=>{};let n=[],r=await o(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null,downloadError:null})});r&&n.push(r);let i=await u(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null,downloadError:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=v()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await d())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,downloadError:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{let n=t();n.otaPhase===`pending_restart`||n.downloading||n.downloadError||e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(or)}}));fr.subscribe((e,t)=>{if(e.downloading===t.downloading&&e.downloaded===t.downloaded&&e.downloadError===t.downloadError&&e.downloadVersion===t.downloadVersion&&e.downloadChannel===t.downloadChannel)return;let n=A();(e.downloading||e.downloadError)&&!e.downloaded&&cr(e.downloadVersion)?n.setItem(sr,JSON.stringify({version:e.downloadVersion,channel:e.downloadChannel,runtimeType:e.runtimeType})):n.removeItem(sr)});var pr=8e3,mr=e=>!!(e&&![`succeeded`,`failed`].includes(e.status));function hr(e,t){if(e!==n()||t!==r())throw Error(`Stale update runtime`)}var gr=(e=n(),t=r(),i)=>({queryKey:[e,`host-update`,t,i??`current`],queryFn:async({signal:n})=>{hr(e,t);let r=new AbortController,o=()=>r.abort();n.addEventListener(`abort`,o,{once:!0});let s;try{return await Promise.race([(async()=>{let n=await a(`/api/system/update${i?`?channel=${i}`:``}`,{headers:{Accept:`application/json`},signal:r.signal});if([404,501].includes(n.status))throw Error(`host_update_unsupported`);let o=await n.json();if(hr(e,t),!n.ok&&n.status!==502||typeof o.serverId!=`string`||typeof o.supported!=`boolean`||![`cli`,`electron`].includes(o.host))throw Error(`Host update check failed`);return o})(),new Promise((e,t)=>{s=setTimeout(()=>{r.abort(),t(Error(`host_update_timeout`))},pr)})])}finally{s!==void 0&&clearTimeout(s),n.removeEventListener(`abort`,o)}},staleTime:6e4,retry:!1}),_r=(e=n(),t=r(),i)=>z.getQueryData(gr(e,t,i).queryKey),vr=(e=n(),t=r(),i)=>{let a=_r(e,t,i);return z.fetchQuery({...gr(e,t,i),staleTime:a?.checkError||mr(a?.operation)?0:6e4})},yr=(e=n(),t=r(),i)=>z.fetchQuery({...gr(e,t,i),staleTime:0}),br=(e,t,n)=>{let r=(0,Z.c)(6),i;r[0]!==n||r[1]!==t||r[2]!==e?(i=gr(e,t,n),r[0]=n,r[1]=t,r[2]=e,r[3]=i):i=r[3];let a;return r[4]===i?a=r[5]:(a={...i,refetchInterval:Cr,refetchIntervalInBackground:!1},r[4]=i,r[5]=a),ee(a)};async function xr(e,t,n){if(hr(t,n),!e.update)throw Error(`No update plan`);let r=await a(`/api/system/update`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({version:e.update.version,channel:e.channel,planId:e.update.planId,allowDowngrade:e.update.rollback===!0})});if(hr(t,n),!r.ok)throw Error(`Host update was not accepted`);let i=await r.json();if(typeof i.operation?.id!=`string`)throw Error(`Invalid update operation`);return i.operation}async function Sr(e,t,n){hr(t,n);let r=await yr(t,n,e.channel);hr(t,n);let i=r.operation;if(i?.id===e.id&&i.version===e.version&&i.channel===e.channel&&i.kind===e.kind&&(mr(i)||i.status===`succeeded`&&r.currentVersion===e.version))return z.setQueryData(gr(t,n).queryKey,r),i;if(r.checkError||r.update?.version!==e.version||r.update.kind!==e.kind)throw Error(`update_plan_changed`);let a=await xr(r,t,n);return hr(t,n),z.setQueryData(gr(t,n).queryKey,e=>({...e??r,operation:a})),a}function Cr(e){return mr(e.state.data?.operation)?2e3:e.state.error?.message===`host_update_unsupported`?!1:e.state.error?15e3:3e5}function wr(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(Me(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function Tr(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function Er(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function Dr(e,t){let n=e.split(`.`).map(e=>Number.parseInt(e,10)),r=t.split(`.`).map(e=>Number.parseInt(e,10));for(let e=0;e<3;e+=1){let t=Number.isFinite(n[e])?n[e]:0,i=Number.isFinite(r[e])?r[e]:0;if(t!==i)return i-t}return 0}function Or(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.map((t,r)=>{let i=n[r+1]?.start??e.length;return{version:t.version,date:t.date,start:t.start,end:i,raw:e.slice(t.start,i).trim()}})}function kr(e){let t=(0,Z.c)(67),{open:n,onOpenChange:r,model:i,onAction:a}=e,{t:o}=Ne(),[s,c]=(0,$.useState)(!1),l=ne(jr),u;t[0]===l?u=t[1]:(u=e=>{let t=e.target.closest(`a`);t?.href&&(e.preventDefault(),e.stopPropagation(),l(t.href))},t[0]=l,t[1]=u);let d=ne(u),f;t[2]===i.fallbackCommand?f=t[3]:(f=async()=>{i.fallbackCommand&&(await ze(i.fallbackCommand)).ok&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=i.fallbackCommand,t[3]=f);let p=ne(f),m;if(t[4]!==i.body||t[5]!==o){bb0:{let e=i.body?.trim();if(!e){m=null;break bb0}let n=Or(e);if(!n.length){m={kind:`raw`,title:o(`updateDialog.changelog.title`),content:Er(e)};break bb0}let r;t[7]===o?r=t[8]:(r=o(`updateDialog.changelog.title`),t[7]=o,t[8]=r),m={kind:`sections`,title:r,sections:[...n].sort(Ar).map(t=>({version:t.version,dateLabel:wr(t.date),content:Er(Tr(t.raw)||e)}))}}t[4]=i.body,t[5]=o,t[6]=m}else m=t[6];let h=m,g=i.dismissible===!1?void 0:r,_=i.stableLayout&&`h-[min(38rem,calc(100dvh-2rem))] overflow-hidden transition-[opacity,transform,filter]`,v;t[9]===_?v=t[10]:(v=J(`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,_),t[9]=_,t[10]=v);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(X,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),t[11]=y):y=t[11];let b;t[12]===i.title?b=t[13]:(b=(0,Q.jsxs)(et,{className:`flex items-center gap-2`,children:[y,(0,Q.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.title})]}),t[12]=i.title,t[13]=b);let x;t[14]!==i.currentVersion||t[15]!==i.methodLabel||t[16]!==i.version?(x=(i.currentVersion||i.version)&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[i.currentVersion&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/75`,children:i.currentVersion}),i.currentVersion&&i.version&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),i.version&&(0,Q.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:i.version}),i.methodLabel&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,i.methodLabel]})]}),t[14]=i.currentVersion,t[15]=i.methodLabel,t[16]=i.version,t[17]=x):x=t[17];let S;t[18]===i.description?S=t[19]:(S=i.description&&(0,Q.jsx)(tt,{className:`mt-2`,children:i.description}),t[18]=i.description,t[19]=S);let C;t[20]!==S||t[21]!==b||t[22]!==x?(C=(0,Q.jsxs)(`div`,{className:`mb-3 shrink-0 pr-8 sm:mb-4`,children:[b,x,S]}),t[20]=S,t[21]=b,t[22]=x,t[23]=C):C=t[23];let w=i.stableLayout?`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto`:`space-y-3 sm:space-y-4`,T;t[24]===i.message?T=t[25]:(T=i.message&&(0,Q.jsx)(`p`,{role:`status`,className:`typography-ui-label text-muted-foreground`,children:i.message}),t[24]=i.message,t[25]=T);let E;t[26]===i.warning?E=t[27]:(E=i.warning&&(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:i.warning}),t[26]=i.warning,t[27]=E);let D;t[28]!==h||t[29]!==d||t[30]!==i.hideChangelog||t[31]!==i.stableLayout?(D=h&&!i.hideChangelog&&(0,Q.jsxs)(`section`,{className:J(`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,i.stableLayout&&`flex min-h-0 flex-1 flex-col`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Q.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:h.title})]}),(0,Q.jsx)(Ut,{className:i.stableLayout?`p-0`:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,outerClassName:i.stableLayout?`flex-1`:void 0,fillContainer:!!i.stableLayout,children:h.kind===`raw`?(0,Q.jsx)(`div`,{className:`break-words px-3.5 py-2 text-[13px] leading-[1.65] text-foreground sm:px-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_.markdown-content>:first-child]:!mt-0 [&_.markdown-content>:first-child>:first-child]:!mt-0 [&_.markdown-content>:last-child]:!mb-0 [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:d,children:(0,Q.jsx)(Bt,{content:h.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:h.sections.map(e=>(0,Q.jsxs)(`div`,{className:`px-3.5 py-2 sm:px-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Q.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Q.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:d,children:(0,Q.jsx)(Bt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),t[28]=h,t[29]=d,t[30]=i.hideChangelog,t[31]=i.stableLayout,t[32]=D):D=t[32];let O;t[33]!==s||t[34]!==p||t[35]!==i.fallbackCommand||t[36]!==o?(O=i.fallbackCommand&&(0,Q.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Q.jsx)(X,{name:`terminal`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:o(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Q.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:i.fallbackCommand}),(0,Q.jsx)(`button`,{onClick:p,className:J(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,s&&`text-[var(--status-success)]`),title:o(s?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:(0,Q.jsx)(X,{name:s?`check`:`clipboard`,className:`h-4 w-4`})})]})]}),t[33]=s,t[34]=p,t[35]=i.fallbackCommand,t[36]=o,t[37]=O):O=t[37];let k;t[38]!==i.stableLayout||t[39]!==i.status?(k=i.status&&(0,Q.jsxs)(`div`,{role:`status`,className:J(`space-y-2`,i.stableLayout&&`min-h-9 shrink-0`),children:[(0,Q.jsxs)(`div`,{className:`flex h-5 items-center justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium text-muted-foreground sm:text-[13px]`,children:[i.status.kind===`activity`&&(0,Q.jsx)(X,{name:`loader`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--primary-base)]`}),(0,Q.jsx)(`span`,{className:`truncate`,title:i.status.label,children:i.status.label})]}),i.status.progress!=null&&(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[Math.round(i.status.progress),`%`]})]}),(0,Q.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:i.status.progress==null?(0,Q.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-[var(--primary-base)]/60`}):(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-[width] duration-500`,style:{width:`${i.status.progress}%`}})}),i.status.detail&&(0,Q.jsx)(`p`,{className:`text-xs leading-4 text-muted-foreground`,children:i.status.detail})]}),t[38]=i.stableLayout,t[39]=i.status,t[40]=k):k=t[40];let A;t[41]===i.error?A=t[42]:(A=i.error&&(0,Q.jsx)(`div`,{role:`alert`,className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Q.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:i.error})}),t[41]=i.error,t[42]=A);let j;t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O||t[48]!==k||t[49]!==A?(j=(0,Q.jsxs)(`div`,{className:w,children:[T,E,D,O,k,A]}),t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k,t[49]=A,t[50]=j):j=t[50];let M;t[51]===i.notice?M=t[52]:(M=i.notice&&(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Q.jsx)(X,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:i.notice})]}),t[51]=i.notice,t[52]=M);let N;t[53]!==i.actions||t[54]!==i.releaseLink||t[55]!==a?(N=(i.releaseLink||i.actions.length>0)&&(0,Q.jsxs)(`div`,{className:`mt-4 flex shrink-0 items-center justify-between gap-4`,children:[i.releaseLink&&(0,Q.jsxs)(`a`,{href:i.releaseLink.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),i.releaseLink.label]}),(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-nowrap items-center justify-end gap-2`,children:i.actions.map(e=>(0,Q.jsxs)(q,{onClick:()=>a(e.id),disabled:e.disabled,variant:e.variant??`default`,size:`default`,className:`min-w-0 shrink`,title:e.label,children:[e.icon&&(0,Q.jsx)(X,{name:e.icon,className:J(`h-4 w-4`,e.loading&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))})]}),t[53]=i.actions,t[54]=i.releaseLink,t[55]=a,t[56]=N):N=t[56];let P;t[57]!==C||t[58]!==j||t[59]!==M||t[60]!==N||t[61]!==v?(P=(0,Q.jsxs)($e,{className:v,showCloseButton:!0,children:[C,j,M,N]}),t[57]=C,t[58]=j,t[59]=M,t[60]=N,t[61]=v,t[62]=P):P=t[62];let F;return t[63]!==n||t[64]!==P||t[65]!==g?(F=(0,Q.jsx)(nt,{open:n,onOpenChange:g,children:P}),t[63]=n,t[64]=P,t[65]=g,t[66]=F):F=t[66],F}function Ar(e,t){return Dr(e.version,t.version)}function jr(e){re(e)}var Mr=`https://github.com/yee94/yuri/releases`,Nr=2e3,Pr=6e5,Fr=e=>e.transport===n()&&e.generation===r();async function Ir(e,t){try{if(!Fr(t))return{success:!1};let n=await vr(t.transport,t.generation);return!Fr(t)||!e||!n.supported||n.update?.version!==e||n.update.rollback?{success:!1}:(await xr(n,t.transport,t.generation),{success:!0,autoRestart:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function Lr(e,t,n=Math.ceil(Pr/Nr),r=Nr){for(let i=0;i<n;i++){if(!Fr(t))return!1;try{let n=await yr(t.transport,t.generation);if(n.operation?.status===`failed`)return!1;if(n.currentVersion===e&&n.operation?.status===`succeeded`&&Fr(t))return!0}catch{}await new Promise(e=>setTimeout(e,r))}return!1}var Rr=e=>{let t=(0,Z.c)(107),{open:i,onOpenChange:a,info:o,downloading:s,downloaded:c,progress:l,error:u,onDownload:d,onRestart:f,runtimeType:p}=e,m=p===void 0?`desktop`:p,{t:h}=Ne(),[g,_]=(0,$.useState)(`idle`),[v,y]=(0,$.useState)(null),b=fr(zr),x=o?.releaseUrl||(o?.version?`${Mr}/tag/v${o.version}`:Mr),S=o?.downloadUrl,C=m===`web`,w=m===`mobile`,T=w&&o?.manualUpdate===!0&&!!S,E=w&&o?.inAppApply===!0,D=m===`desktop`&&o?.manualUpdate===!0,O=g!==`idle`&&g!==`error`,k=w?S:x,A;t[0]!==c||t[1]!==E||t[2]!==a?(A=e=>{!e&&E&&c&&fr.getState().dismiss(),a(e)},t[0]=c,t[1]=E,t[2]=a,t[3]=A):A=t[3];let j=ne(A),M,N;t[4]===i?(M=t[5],N=t[6]):(M=()=>{i||(_(`idle`),y(null))},N=[i],t[4]=i,t[5]=M,t[6]=N),(0,$.useEffect)(M,N);let P;t[7]!==o?.version||t[8]!==h?(P=async()=>{let e={transport:n(),generation:r()};_(`updating`),y(null);let t=await Ir(o?.version,e);if(!Fr(e))return;if(!t.success){_(`error`),y(t.error||h(`updateDialog.error.updateFailed`));return}t.autoRestart&&(_(`restarting`),await new Promise(Br)),_(`reconnecting`);let i=await Lr(o?.version,e);Fr(e)&&(i?window.location.reload():(_(`error`),y(h(`updateDialog.error.takingLonger`))))},t[7]=o?.version,t[8]=h,t[9]=P):P=t[9];let F=ne(P),ee;t[10]!==F||t[11]!==w||t[12]!==d||t[13]!==a||t[14]!==f||t[15]!==S||t[16]!==x?(ee=e=>{bb107:switch(e){case`download`:d();break bb107;case`restart`:f();break bb107;case`later`:fr.getState().dismiss(),a(!1);break bb107;case`open-external`:{let e=w?S:x;e&&re(e);break bb107}case`web-update`:F()}},t[10]=F,t[11]=w,t[12]=d,t[13]=a,t[14]=f,t[15]=S,t[16]=x,t[17]=ee):ee=t[17];let I=ne(ee),L;if(t[18]!==c||t[19]!==s||t[20]!==E||t[21]!==D||t[22]!==w||t[23]!==C||t[24]!==O||t[25]!==T||t[26]!==h){if(L=[],!C&&(!w||E)){if(!D&&!c&&!s){let e;t[28]!==E||t[29]!==h?(e=h(E?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`),t[28]=E,t[29]=h,t[30]=e):e=t[30];let n;t[31]===e?n=t[32]:(n={id:`download`,icon:`download`,label:e},t[31]=e,t[32]=n),L.push(n)}if(D&&!c&&!s){let e;t[33]===h?e=t[34]:(e=h(`updateDialog.actions.openMobileUpdate`),t[33]=h,t[34]=e);let n;t[35]===e?n=t[36]:(n={id:`open-external`,icon:`external-link`,label:e},t[35]=e,t[36]=n),L.push(n)}if(s){let e;t[37]===h?e=t[38]:(e=h(`updateDialog.status.downloading`),t[37]=h,t[38]=e);let n;t[39]===e?n=t[40]:(n={id:`downloading`,icon:`loader`,loading:!0,disabled:!0,label:e},t[39]=e,t[40]=n),L.push(n)}if(c){if(E){let e;t[41]===h?e=t[42]:(e=h(`updateDialog.actions.later`),t[41]=h,t[42]=e);let n;t[43]===e?n=t[44]:(n={id:`later`,variant:`ghost`,label:e},t[43]=e,t[44]=n),L.push(n)}let e;t[45]===h?e=t[46]:(e=h(`updateDialog.actions.restartToUpdate`),t[45]=h,t[46]=e);let n;t[47]===e?n=t[48]:(n={id:`restart`,icon:`restart`,label:e},t[47]=e,t[48]=n),L.push(n)}}if(w&&!E&&T){let e;t[49]===h?e=t[50]:(e=h(`updateDialog.actions.openMobileUpdate`),t[49]=h,t[50]=e);let n;t[51]===e?n=t[52]:(n={id:`open-external`,icon:`external-link`,label:e},t[51]=e,t[52]=n),L.push(n)}if(C){let e;t[53]!==O||t[54]!==h?(e=O?{id:`updating`,icon:`loader`,loading:!0,disabled:!0,label:h(`updateDialog.status.updating`)}:{id:`web-update`,icon:`download`,label:h(`updateDialog.actions.updateNow`)},t[53]=O,t[54]=h,t[55]=e):e=t[55],L.push(e)}t[18]=c,t[19]=s,t[20]=E,t[21]=D,t[22]=w,t[23]=C,t[24]=O,t[25]=T,t[26]=h,t[27]=L}else L=t[27];let R;t[56]!==h||t[57]!==g?(R=h(g===`restarting`||g===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`),t[56]=h,t[57]=g,t[58]=R):R=t[58];let te=o?.currentVersion,z=o?.version,B=o?.body,V=!O,H=u||v,ie=C&&g===`error`?o?.updateCommand||`yuri update`:void 0,U;t[59]!==c||t[60]!==E||t[61]!==b||t[62]!==h?(U=E&&c&&b?h(`updateDialog.status.otaBundleReused`):void 0,t[59]=c,t[60]=E,t[61]=b,t[62]=h,t[63]=U):U=t[63];let ae;t[64]!==w||t[65]!==k||t[66]!==T?(ae=(!w||T)&&k?{url:k,label:`GitHub`}:void 0,t[64]=w,t[65]=k,t[66]=T,t[67]=ae):ae=t[67];let W;if(t[68]!==L||t[69]!==s||t[70]!==E||t[71]!==w||t[72]!==C||t[73]!==O||t[74]!==l||t[75]!==h||t[76]!==B||t[77]!==V||t[78]!==H||t[79]!==ie||t[80]!==U||t[81]!==ae||t[82]!==R||t[83]!==te||t[84]!==z||t[85]!==g){if(W={title:R,currentVersion:te,version:z,body:B,hideChangelog:O,dismissible:V,error:H,fallbackCommand:ie,notice:U,releaseLink:ae,actions:L},C&&O){let e;t[87]!==h||t[88]!==g?(e=h(g===`updating`?`updateDialog.status.installingUpdate`:g===`restarting`?`updateDialog.status.serverRestarting`:`updateDialog.status.waitingForServer`),t[87]=h,t[88]=g,t[89]=e):e=t[89];let n;t[90]===h?n=t[91]:(n=h(`updateDialog.status.autoReloadHint`),t[90]=h,t[91]=n);let r;t[92]!==e||t[93]!==n?(r={kind:`activity`,label:e,detail:n},t[92]=e,t[93]=n,t[94]=r):r=t[94],W.status=r}if(!C&&(!w||E)&&s){let e;t[95]===h?e=t[96]:(e=h(`updateDialog.status.downloadingPayload`),t[95]=h,t[96]=e);let n;t[97]===l?n=t[98]:(n=l?.total?Math.round(l.downloaded/l.total*100):0,t[97]=l,t[98]=n);let r;t[99]!==e||t[100]!==n?(r={kind:`download`,label:e,progress:n},t[99]=e,t[100]=n,t[101]=r):r=t[101],W.status=r}t[68]=L,t[69]=s,t[70]=E,t[71]=w,t[72]=C,t[73]=O,t[74]=l,t[75]=h,t[76]=B,t[77]=V,t[78]=H,t[79]=ie,t[80]=U,t[81]=ae,t[82]=R,t[83]=te,t[84]=z,t[85]=g,t[86]=W}else W=t[86];let oe;return t[102]!==I||t[103]!==j||t[104]!==W||t[105]!==i?(oe=(0,Q.jsx)(kr,{open:i,onOpenChange:j,model:W,onAction:I}),t[102]=I,t[103]=j,t[104]=W,t[105]=i,t[106]=oe):oe=t[106],oe};function zr(e){return e.otaDownloadSkipped}function Br(e){return setTimeout(e,2e3)}function Vr(e,t){return e===`checking`?5:e===`downloading`?5+Math.min(Math.max(t??0,0),100)*.75:e===`installing`?85:e===`restarting`?95:100}function Hr(e,t,n){let r=e?.operation,i=e?.update,a=i??(r&&t.updateDetails&&r.planId===t.updateDetails.planId&&r.version===t.updateDetails.version?t.updateDetails:void 0),o=mr(r),s=e?.supported===!1||t.failure===`unsupported`,c={title:n(`settings.yuri.about.hostUpdate.title`),stableLayout:!0,description:n(`settings.yuri.about.hostUpdate.description`),currentVersion:e?.currentVersion??t.versionFallback,version:i?.version??r?.version,body:a||r?a?.releaseNotes||n(`settings.yuri.about.hostUpdate.noNotes`):void 0,warning:!o&&i?.rollback?n(`settings.yuri.about.hostUpdate.downgrade`):void 0,actions:o||t.submitting||t.completed||!i?[]:[{id:`confirm`,icon:`download`,label:n(`settings.yuri.about.hostUpdate.confirm`),disabled:!e?.supported||!!t.failure||!!t.checking}]};return o&&r?c.status={kind:r.status===`downloading`?`download`:`activity`,label:n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.hostUpdate.status.${r.status}`),progress:Vr(r.status,r.progress)}:t.completed&&!i?c.status={kind:`download`,label:n(`settings.yuri.about.hostUpdate.status.succeeded`),progress:100}:t.submitting?c.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`),progress:0}:t.checking===`initial`?c.status={kind:`activity`,label:n(`settings.yuri.about.state.checking`)}:s?c.message=n(`settings.yuri.about.hostUpdate.unsupported`):t.failure?c.error=n(t.failure===`disconnected`?`settings.yuri.about.hostUpdate.reconnecting`:`settings.yuri.about.toast.checkFailed`):!i&&e?.supported&&(c.message=r?.status===`succeeded`?n(`settings.yuri.about.hostUpdate.status.succeeded`):n(`settings.yuri.about.toast.latestVersion`)),r?.status===`failed`&&(c.error=n(`settings.yuri.about.hostUpdate.status.failed`)),c}function Ur(){let e=(0,Z.c)(7),{t:i}=Ne(),a=$.useSyncExternalStore(t,n,n),o=$.useSyncExternalStore(t,r,r),s=`${a}:${o}`,c;e[0]===i?c=e[1]:(c=i(`settings.yuri.about.state.unknown`),e[0]=i,e[1]=c);let l;return e[2]!==o||e[3]!==s||e[4]!==c||e[5]!==a?(l=(0,Q.jsx)(Wr,{transport:a,generation:o,version:c},s),e[2]=o,e[3]=s,e[4]=c,e[5]=a,e[6]=l):l=e[6],l}function Wr({version:e,transport:t,generation:i,itemId:a,channel:o}){let{t:s}=Ne(),c=I(),[l,u]=$.useState(!1),d=V(e=>e.otaChannelOverride),f=o??d??void 0,p=br(t,i,f),m=p.data,h=m?.operation,g=mr(h),_=JSON.stringify([t,i,f??`current`]),[v,y]=$.useState(null);m?.update&&(v?.scope!==_||v.update!==m.update)&&y({scope:_,update:m.update});let b=P({mutationFn:({plan:e})=>xr(e,t,i),onSuccess:(e,a)=>{t===n()&&i===r()&&c.setQueryData(gr(t,i,a.channel).queryKey,t=>t&&{...t,operation:e})},onSettled:(e,a,o)=>{t===n()&&i===r()&&c.invalidateQueries({queryKey:gr(t,i,o.channel).queryKey,exact:!0})}}),[x,S]=$.useState(null);l&&g&&h&&h.id!==x&&S(h.id);let C=h?.status===`succeeded`&&h.id===x,w=s(`settings.yuri.about.hostUpdate.status.succeeded`);$.useEffect(()=>{!C||p.isError||t!==n()||i!==r()||(S(null),u(!1),Y.success(w,{id:`host-update:${t}:${i}:${x}`}))},[C,p.isError,t,i,x,w]);let T=$.useRef(null),E=ne(()=>_),D=ne(async()=>{if(g){u(!0),p.refetch({cancelRefetch:!1});return}if(T.current===_)return;let e=_;T.current=e;try{let a=await p.refetch({cancelRefetch:!1});if(e!==E()||t!==n()||i!==r())return;if(a.isError||!a.data||a.data.checkError){a.error?.message===`host_update_unsupported`?Y.info(s(`settings.yuri.about.hostUpdate.unsupported`)):Y.error(s(`settings.yuri.about.toast.checkFailed`));return}mr(a.data.operation)?u(!0):a.data.supported?a.data.update?u(!0):(u(!1),Y.success(s(`settings.yuri.about.toast.latestVersion`))):Y.info(s(`settings.yuri.about.hostUpdate.unsupported`))}finally{T.current===e&&(T.current=null)}}),O=m?.supported===!1||!g&&p.error?.message===`host_update_unsupported`,k=p.isError||!!m?.checkError,A=b.isError&&b.variables?.channel===f,j=Hr(m,{versionFallback:e,checking:p.isPending?`initial`:p.isFetching?`refresh`:!1,submitting:b.isPending,failure:O?`unsupported`:p.isError&&(g||A)?`disconnected`:k||A?`check`:null,completed:C,updateDetails:v?.scope===_?v.update:void 0},s),M=ne(e=>{e===`confirm`&&m?.update&&b.mutate({plan:m,channel:f})});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,"data-settings-item":a,children:[(0,Q.jsxs)(`span`,{className:`relative typography-ui-label font-mono text-foreground text-right`,children:[m?.currentVersion??e,m?.update&&!g&&(0,Q.jsx)(`span`,{"aria-label":s(`settings.yuri.about.hostUpdate.available`),className:`absolute -right-1.5 -top-0.5 size-1.5 rounded-full bg-[var(--status-error)]`})]}),(0,Q.jsx)(q,{type:`button`,size:`icon`,variant:`ghost`,onClick:D,disabled:p.isFetching&&!g,"aria-label":s(`settings.yuri.about.hostUpdate.title`),title:s(`settings.yuri.about.hostUpdate.title`),children:(0,Q.jsx)(X,{name:g||p.isFetching?`loader`:m?.update?`download`:`refresh`,className:g||p.isFetching?`size-4 animate-spin`:`size-4`})})]}),(0,Q.jsx)(kr,{open:l,onOpenChange:u,model:j,onAction:M})]})}var Gr=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e),Kr=e=>{let t=e.replace(/\\/g,`/`),n=[],[r,...i]=t.split(`/`);for(let e of i)if(e!==``&&e!==`.`){if(e===`..`){n.pop();continue}n.push(e)}return`${/^[A-Za-z]:$/.test(r)?`${r.toUpperCase()}/`:`/`}${n.join(`/`)}`},qr=e=>Kr(`${e.replace(/\\/g,`/`)}/..`),Jr=e=>{try{let t=decodeURIComponent(new URL(e).pathname);return/^\/[A-Za-z]:\//.test(t)?t.slice(1):t}catch{return null}};function Yr(e,t){if(e.startsWith(`file://`)){let t=Jr(e);return t?{kind:`local`,path:Kr(t)}:null}return e.startsWith(`./`)||e.startsWith(`../`)?t?{kind:`local`,path:Kr(`${qr(t)}/${e}`)}:null:Gr(e)?{kind:`local`,path:Kr(e)}:{kind:`package`,target:e}}function Xr(e){return e?{kind:`local`,path:Kr(e)}:null}var Zr=(e,t)=>{if(e.kind===`package`)return t.source.kind===`package`&&t.source.target===e.target;if(t.source.kind!==`local`)return!1;let n=Kr(t.source.path);return n===e.path||n.startsWith(`${e.path}/`)};function Qr(e,t){return t.filter(t=>Zr(e,t))}function $r(e){for(let t of e)if(t.state.kind===`active`&&t.source.kind===`package`&&t.source.version?.trim())return t.source.version.trim();return null}function ei(e){let t=e.find(e=>e.state.kind===`failed`);if(t&&t.state.kind===`failed`)return{kind:`failed`,error:t.state.error,ref:t.state.ref};let n=e[0];return n?{kind:`active`,version:n.source.kind===`package`?n.source.version:null}:{kind:`notReported`}}function ti(e){let t=e.flatMap(e=>e.source.kind===`package`?[e.source]:[]);return t.some(e=>e.updating)?`updating`:t.some(e=>e.outdated)?`available`:`none`}function ni(){let e=(0,Z.c)(5),t=tn(),n=an(),r=t.data?.entries,i=t.data?.files,a=n.data,o;bb0:{if(!a){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],o=t;break bb0}let t;if(e[1]!==r||e[2]!==i||e[3]!==a){t=[];let n=(e,n,r)=>{if(!r)return;let i=ei(Qr(r,a));i.kind===`failed`&&t.push({id:e,label:n,error:i.error})};for(let e of r??[])n(e.id,e.spec,Yr(e.spec,e.sourcePath));for(let e of i??[])n(e.id,e.fileName,Xr(e.absolutePath));e[1]=r,e[2]=i,e[3]=a,e[4]=t}else t=e[4];o=t}return o}function ri(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var ii={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function ai(e,t){let n=ii[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function oi(e){return ii[e]??[]}function si(e){return[...e].sort((e,t)=>e.order-t.order)}function ci(e,t){let n=new Map;for(let r of Object.keys(e)){let e=ai(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function li(e,t,n){let r=new Map;for(let i of e){let e=ai(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function ui(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var di=(e,t=``,n=!1)=>F({queryKey:R.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await a(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let i=await r.json();if(!i||!Array.isArray(i.sources)||!i.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>L(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return i}}),fi=6e4,pi=0,mi=0,hi,gi=0,_i=0,vi=0,yi=new Map,bi=e=>{let t=Cn.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):fi,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||t.includes(e))):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{magpieUsageUrl:typeof e?.magpieUsageUrl==`string`?e.magpieUsageUrl:``,magpieHiddenProviders:Array.isArray(e?.magpieHiddenProviders)?e.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`)):[],autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},xi=async()=>{let e=v()?.settings;if(e)try{let t=(await e.load())?.settings;return bi(t??null)}catch{}if(!l()){let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return bi(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:fi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Cn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Si=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return L(n)&&r.push(n),r},Ci=async(e,t)=>{let n=mi;yi.set(e,(yi.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await z.fetchQuery({queryKey:R.quota(e),queryFn:({signal:t})=>te(e,t),staleTime:0,retry:!1});if(n!==mi)return{providerId:e,stale:!0};if(!L(r))throw Error(`Invalid quota response`);return t(t=>({results:Si(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===mi?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===mi){let n=(yi.get(e)??1)-1;n>0?yi.set(e,n):yi.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},wi=()=>{hi=void 0,gi+=1,mi+=1,pi+=1,yi.clear(),Ti.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},Ti=y()(x((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:fi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Cn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=mi;try{let n=await xi();if(t!==mi)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++pi;e({isLoading:!0,error:null});let r=Cn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>Ci(t,e))),t().fetchMagpieQuotas(!0)]);if(n===pi){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await Ci(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=mi,i=O.getState().currentDirectory,a=t().magpieUsageUrl,o=JSON.stringify([i,a]);hi!==o&&(hi=o,gi+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let s=gi,c=++_i;try{let{sources:o,incomplete:l}=await z.fetchQuery(di(i,a,n));if(r!==mi||s!==gi||c<vi||i!==O.getState().currentDirectory||a!==t().magpieUsageUrl)return;vi=c,e(e=>{let t=new Map(o.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(l){let n=new Set(o.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...o.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:o,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==mi||s!==gi||c<vi||i!==O.getState().currentDirectory||a!==t().magpieUsageUrl)return;vi=c,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),D({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),D({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=ui(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),D({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),Ei=()=>{let e=(0,Z.c)(11),t=O(Di),n=Ti(Oi),r=Ti(ki),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],$.useEffect(i,a);let o=Ti(Ai),s=Ti(ji),c=Ti(Mi),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),$.useEffect(l,u)};function Di(e){return e.currentDirectory}function Oi(e){return e.magpieUsageUrl}function ki(e){return e.fetchMagpieQuotas}function Ai(e){return e.autoRefresh}function ji(e){return e.refreshIntervalMs}function Mi(e){return e.fetchAllQuotas}var Ni=e(C(),1),Pi=e=>{let t=(0,Z.c)(217),{providerId:n,modelId:r,variant:i,onChange:a,className:o,allowedProviderIds:s,allowedModelIdsByProvider:c,placeholder:l,tooltipsEnabled:u,dropdownPortalToBody:d,showIcon:f,providers:p}=e,m=u===void 0||u,h=d!==void 0&&d,g=f===void 0||f,{t:_}=Ne(),{isReady:v,isUnavailable:y}=bt(),b=Ve(Fi),x=p??b,S=Ve(Ii),C=V(Li),w=V(Ri),T=V(zi),E=V(Bi),D=V(Vi),O=V(Hi),k;t[0]!==r||t[1]!==n?(k={currentProviderID:n,currentModelID:r},t[0]=r,t[1]=n,t[2]=k):k=t[2];let{favoriteModelsList:A,recentModelsList:j}=qt(k),{isMobile:M}=Rt(),N=C||M,[P,F]=$.useState(!1),[ee,I]=$.useState(!1),L;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{F(!0),Ve.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=L):L=t[3];let R=ne(L),te;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{I(e),e&&Ve.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=te):te=t[4];let z=ne(te),[B,re]=$.useState(``),[H,ie]=$.useState(null),U=i!==void 0,ae;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{F(!1),I(!1),re(``),ie(null)},t[5]=ae):ae=t[5];let W=ae,oe;t[6]===x?oe=t[7]:(oe=e=>{let t=x.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID);return t?.variants?Object.keys(t.variants):[]},t[6]=x,t[7]=oe);let se=oe,ce;t[8]!==D||t[9]!==se||t[10]!==r||t[11]!==a||t[12]!==n||t[13]!==i||t[14]!==U?(ce=e=>{let t=se(e),o=e.providerID===n&&e.modelID===r,s=e.variant!==void 0&&t.includes(e.variant)?e.variant:void 0,c=o&&i&&t.includes(i)?i:s??``;a(e.providerID,e.modelID,U?c:void 0),D(e.providerID,e.modelID,U&&c||void 0),W()},t[8]=D,t[9]=se,t[10]=r,t[11]=a,t[12]=n,t[13]=i,t[14]=U,t[15]=ce):ce=t[15];let le=ce,ue;t[16]!==a||t[17]!==U?(ue=()=>{a(``,``,U?``:void 0),W()},t[16]=a,t[17]=U,t[18]=ue):ue=t[18];let de=ue,fe;t[19]!==D||t[20]!==a||t[21]!==H?(fe=e=>{H&&(a(H.providerID,H.modelID,e),D(H.providerID,H.modelID,e||void 0),W())},t[19]=D,t[20]=a,t[21]=H,t[22]=fe):fe=t[22];let pe=fe,me;t[23]===_?me=t[24]:(me=_(`settings.agents.modelSelector.searchPlaceholder`),t[23]=_,t[24]=me);let he;t[25]===_?he=t[26]:(he=_(`settings.agents.modelSelector.state.noModelsFound`),t[25]=_,t[26]=he);let ge;t[27]===_?ge=t[28]:(ge=_(`settings.agents.modelSelector.section.favorites`),t[27]=_,t[28]=ge);let _e;t[29]===_?_e=t[30]:(_e=_(`settings.agents.modelSelector.section.recent`),t[29]=_,t[30]=_e);let ve;t[31]===_?ve=t[32]:(ve=_(`settings.agents.modelSelector.keyboardHints`),t[31]=_,t[32]=ve);let ye;t[33]!==l||t[34]!==_?(ye=l||_(`settings.agents.modelSelector.notSelected`),t[33]=l,t[34]=_,t[35]=ye):ye=t[35];let be;t[36]===_?be=t[37]:(be=_(`settings.agents.modelSelector.actions.favorite`),t[36]=_,t[37]=be);let xe;t[38]===_?xe=t[39]:(xe=_(`settings.agents.modelSelector.actions.unfavorite`),t[38]=_,t[39]=xe);let Se;t[40]===_?Se=t[41]:(Se=_(`chat.modelControls.provider`),t[40]=_,t[41]=Se);let Ce;t[42]===_?Ce=t[43]:(Ce=_(`chat.modelControls.capabilities`),t[42]=_,t[43]=Ce);let G;t[44]===_?G=t[45]:(G=_(`chat.modelControls.capability.toolCalling`),t[44]=_,t[45]=G);let we;t[46]===_?we=t[47]:(we=_(`chat.modelControls.capability.reasoning`),t[46]=_,t[47]=we);let Te;t[48]===_?Te=t[49]:(Te=_(`chat.modelControls.modality.image`),t[48]=_,t[49]=Te);let K;t[50]===_?K=t[51]:(K=_(`chat.modelControls.modality.video`),t[50]=_,t[51]=K);let Ee;t[52]===_?Ee=t[53]:(Ee=_(`chat.modelControls.modality.audio`),t[52]=_,t[53]=Ee);let De;t[54]===_?De=t[55]:(De=_(`chat.modelControls.costPerMillion`),t[54]=_,t[55]=De);let Oe;t[56]===_?Oe=t[57]:(Oe=_(`chat.modelControls.costInput`),t[56]=_,t[57]=Oe);let ke;t[58]===_?ke=t[59]:(ke=_(`chat.modelControls.costOutput`),t[58]=_,t[59]=ke);let Ae;t[60]!==me||t[61]!==he||t[62]!==ge||t[63]!==_e||t[64]!==ve||t[65]!==ye||t[66]!==be||t[67]!==xe||t[68]!==Se||t[69]!==Ce||t[70]!==G||t[71]!==we||t[72]!==Te||t[73]!==K||t[74]!==Ee||t[75]!==De||t[76]!==Oe||t[77]!==ke?(Ae={searchPlaceholder:me,noResults:he,favorites:ge,recent:_e,keyboardHint:ve,notSelected:ye,favorite:be,unfavorite:xe,provider:Se,capabilities:Ce,capabilityToolCalling:G,capabilityReasoning:we,modalityImage:Te,modalityVideo:K,modalityAudio:Ee,costPerMillion:De,costInput:Oe,costOutput:ke},t[60]=me,t[61]=he,t[62]=ge,t[63]=_e,t[64]=ve,t[65]=ye,t[66]=be,t[67]=xe,t[68]=Se,t[69]=Ce,t[70]=G,t[71]=we,t[72]=Te,t[73]=K,t[74]=Ee,t[75]=De,t[76]=Oe,t[77]=ke,t[78]=Ae):Ae=t[78];let je=Ae,Me;t[79]!==r||t[80]!==n?(Me=n&&r?{providerID:n,modelID:r}:null,t[79]=r,t[80]=n,t[81]=Me):Me=t[81];let Pe=Me,Fe;t[82]!==r||t[83]!==l||t[84]!==n||t[85]!==_?(Fe=n&&r?`${n}/${r}`:l||_(`settings.agents.modelSelector.notSelected`),t[82]=r,t[83]=l,t[84]=n,t[85]=_,t[86]=Fe):Fe=t[86];let q=Fe,Ie;t[87]!==_||t[88]!==i||t[89]!==U?(Ie=U?i||_(`chat.modelControls.default`):null,t[87]=_,t[88]=i,t[89]=U,t[90]=Ie):Ie=t[90];let Le=Ie,Re;t[91]!==r||t[92]!==n||t[93]!==i||t[94]!==U?(Re=(e,t)=>{if(!(!U||e!==n||t!==r))return i||void 0},t[91]=r,t[92]=n,t[93]=i,t[94]=U,t[95]=Re):Re=t[95];let Y=Re,ze;t[96]!==D||t[97]!==a||t[98]!==U?(ze=(e,t,n)=>{a(e,t,U?n??``:void 0),D(e,t,U&&n||void 0),W()},t[96]=D,t[97]=a,t[98]=U,t[99]=ze):ze=t[99];let Be=ze,He;t[100]!==se||t[101]!==_||t[102]!==i||t[103]!==U?(He=(e,t)=>{let n=se(e);if(!U||n.length===0)return null;let r=e.variant!==void 0&&n.includes(e.variant)?e.variant:void 0,a=t.isSelected?i:r??``;return(0,Q.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-0.5 rounded-md px-1.5 py-0.5 typography-micro font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),ie(e)},"aria-label":_(`chat.modelControls.showThinkingModes`),children:[(0,Q.jsx)(`span`,{className:`max-w-24 truncate`,children:a||_(`chat.modelControls.default`)}),(0,Q.jsx)(X,{name:`arrow-right-s`,className:`size-3.5`})]})},t[100]=se,t[101]=_,t[102]=i,t[103]=U,t[104]=He):He=t[104];let Ue=He,We=N?`max-h-none flex-1`:void 0,Ge=m&&(N?P:ee),Ke;t[105]===E?Ke=t[106]:(Ke=e=>E(e.providerID,e.modelID),t[105]=E,t[106]=Ke);let qe;t[107]!==r||t[108]!==n||t[109]!==T||t[110]!==i?(qe=e=>T(e.providerID,e.modelID,e.providerID===n&&e.modelID===r?i||void 0:e.variant),t[107]=r,t[108]=n,t[109]=T,t[110]=i,t[111]=qe):qe=t[111];let Je;t[112]!==c||t[113]!==s||t[114]!==A||t[115]!==S||t[116]!==le||t[117]!==de||t[118]!==w||t[119]!==je||t[120]!==O||t[121]!==x||t[122]!==j||t[123]!==Ue||t[124]!==B||t[125]!==Pe||t[126]!==We||t[127]!==Ge||t[128]!==Ke||t[129]!==qe?(Je=(0,Q.jsx)(Kt,{providers:x,providerOrder:O,favoriteModels:A,recentModels:j,getMetadata:S,searchQuery:B,onSearchQueryChange:re,onSelect:le,labels:je,selectedModel:Pe,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,includeNotSelected:!0,onSelectNone:de,onEscape:W,maxHeightClassName:We,tooltipsEnabled:Ge,isFavorite:Ke,onToggleFavorite:qe,renderRowEnd:Ue}),t[112]=c,t[113]=s,t[114]=A,t[115]=S,t[116]=le,t[117]=de,t[118]=w,t[119]=je,t[120]=O,t[121]=x,t[122]=j,t[123]=Ue,t[124]=B,t[125]=Pe,t[126]=We,t[127]=Ge,t[128]=Ke,t[129]=qe,t[130]=Je):Je=t[130];let Ye=Je,Xe;t[131]!==se||t[132]!==H?(Xe=H?se(H):[],t[131]=se,t[132]=H,t[133]=Xe):Xe=t[133];let Ze=Xe,Qe;bb0:{if(!H){Qe=``;break bb0}if(H.providerID===n&&H.modelID===r){Qe=i||``;break bb0}Qe=H.variant!==void 0&&Ze.includes(H.variant)?H.variant:``}let $e=Qe,et;t[134]!==pe||t[135]!==_||t[136]!==H||t[137]!==$e||t[138]!==Ze?(et=H?(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-h-11 items-center gap-2 border-b border-border/40 px-3 text-left typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,onClick:()=>ie(null),"aria-label":_(`header.actions.backAria`),children:[(0,Q.jsx)(X,{name:`arrow-left`,className:`size-4`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:H.modelID})]}),(0,Q.jsx)(`div`,{className:`space-y-1 p-2`,role:`listbox`,"aria-label":_(`chat.modelControls.thinking`),children:[``,...Ze].map(e=>{let t=$e===e;return(0,Q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:J(`flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left typography-ui-label transition-colors`,t?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),onClick:()=>pe(e),children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e||_(`chat.modelControls.default`)}),t?(0,Q.jsx)(X,{name:`check`,className:`size-4 shrink-0`}):null]},e||`__default`)})})]}):null,t[134]=pe,t[135]=_,t[136]=H,t[137]=$e,t[138]=Ze,t[139]=et):et=t[139];let tt=et||Ye;if(N){let e=v?R:void 0,a=!v,l=!v&&`opacity-60 cursor-not-allowed`,u;t[140]!==o||t[141]!==l?(u=J(`flex w-full items-center justify-between gap-2 rounded-lg border border-border/40 bg-[var(--surface-elevated)] px-2 py-1.5 text-left`,l,o),t[140]=o,t[141]=l,t[142]=u):u=t[142];let d;t[143]!==v||t[144]!==y||t[145]!==r||t[146]!==n||t[147]!==g||t[148]!==_?(d=v?g&&(n||r)?(0,Q.jsx)(Ht,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):g?(0,Q.jsx)(X,{name:`pencil-ai`,className:`h-3 w-3 text-muted-foreground`}):null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[143]=v,t[144]=y,t[145]=r,t[146]=n,t[147]=g,t[148]=_,t[149]=d):d=t[149];let f;t[150]!==v||t[151]!==q?(f=v?(0,Q.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:q}):null,t[150]=v,t[151]=q,t[152]=f):f=t[152];let p;t[153]!==v||t[154]!==Le?(p=v&&Le?(0,Q.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Le}):null,t[153]=v,t[154]=Le,t[155]=p):p=t[155];let m;t[156]!==d||t[157]!==f||t[158]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[d,f,p]}),t[156]=d,t[157]=f,t[158]=p,t[159]=m):m=t[159];let h;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`}),t[160]=h):h=t[160];let b;t[161]!==e||t[162]!==a||t[163]!==u||t[164]!==m?(b=(0,Q.jsxs)(`button`,{type:`button`,onClick:e,disabled:a,className:u,children:[m,h]}),t[161]=e,t[162]=a,t[163]=u,t[164]=m,t[165]=b):b=t[165];let C;t[166]!==A||t[167]!==r||t[168]!==n||t[169]!==j||t[170]!==T||t[171]!==i?(C=(e,t)=>T(e,t,e===n&&t===r?i||void 0:A.find(n=>n.providerID===e&&n.modelID===t)?.variant??j.find(n=>n.providerID===e&&n.modelID===t)?.variant),t[166]=A,t[167]=r,t[168]=n,t[169]=j,t[170]=T,t[171]=i,t[172]=C):C=t[172];let D;t[173]!==c||t[174]!==s||t[175]!==A||t[176]!==S||t[177]!==Be||t[178]!==w||t[179]!==E||t[180]!==P||t[181]!==r||t[182]!==n||t[183]!==O||t[184]!==x||t[185]!==j||t[186]!==Y||t[187]!==C||t[188]!==U?(D=(0,Q.jsx)(Dt,{open:P,onClose:W,selectedProviderID:n,selectedModelID:r,resolveSelectedVariant:Y,onSelect:Be,providers:x,favoriteModels:A,recentModels:j,getMetadata:S,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,providerOrder:O,variantSelectionEnabled:U,isFavorite:E,onToggleFavorite:C}),t[173]=c,t[174]=s,t[175]=A,t[176]=S,t[177]=Be,t[178]=w,t[179]=E,t[180]=P,t[181]=r,t[182]=n,t[183]=O,t[184]=x,t[185]=j,t[186]=Y,t[187]=C,t[188]=U,t[189]=D):D=t[189];let k;return t[190]!==b||t[191]!==D?(k=(0,Q.jsxs)(Q.Fragment,{children:[b,D]}),t[190]=b,t[191]=D,t[192]=k):k=t[192],k}let nt=v&&ee,rt=v?z:void 0,it=!v&&`opacity-60 cursor-not-allowed`,at;t[193]!==o||t[194]!==it?(at=J(`border-input data-[placeholder]:text-muted-foreground flex min-w-0 items-center justify-between gap-2 rounded-lg border bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover data-[popup-open]:bg-interactive-active h-6 w-fit`,it,o),t[193]=o,t[194]=it,t[195]=at):at=t[195];let ot;t[196]!==v||t[197]!==y||t[198]!==r||t[199]!==n||t[200]!==g||t[201]!==_||t[202]!==q||t[203]!==Le?(ot=v?(0,Q.jsxs)(Q.Fragment,{children:[g?n||r?(0,Q.jsx)(Ht,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):(0,Q.jsx)(X,{name:`pencil-ai`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):null,(0,Q.jsx)(`span`,{className:`typography-ui-label min-w-0 flex-1 truncate text-left font-normal text-foreground`,children:q}),Le?(0,Q.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Le}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-nowrap text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[196]=v,t[197]=y,t[198]=r,t[199]=n,t[200]=g,t[201]=_,t[202]=q,t[203]=Le,t[204]=ot):ot=t[204];let st;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(st=(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`}),t[205]=st):st=t[205];let ct;t[206]!==at||t[207]!==ot?(ct=(0,Q.jsx)(Tt,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:at,children:[ot,st]})}),t[206]=at,t[207]=ot,t[208]=ct):ct=t[208];let lt;t[209]!==h||t[210]!==tt?(lt=(0,Q.jsx)(xt,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:h,children:tt}),t[209]=h,t[210]=tt,t[211]=lt):lt=t[211];let ut;return t[212]!==nt||t[213]!==rt||t[214]!==ct||t[215]!==lt?(ut=(0,Q.jsxs)(yt,{open:nt,onOpenChange:rt,children:[ct,lt]}),t[212]=nt,t[213]=rt,t[214]=ct,t[215]=lt,t[216]=ut):ut=t[216],ut};function Fi(e){return e.providers}function Ii(e){return e.getModelMetadata}function Li(e){return e.isMobile}function Ri(e){return e.hiddenModels}function zi(e){return e.toggleFavoriteModel}function Bi(e){return e.isFavoriteModel}function Vi(e){return e.addRecentModel}function Hi(e){return e.providerOrder}var Ui=e=>{let t=(0,Z.c)(41),{agentName:n,onChange:r,className:i,filter:a,dropdownPortalToBody:o,showIcon:s,agents:c}=e,l=o!==void 0&&o,u=s===void 0||s,{t:d}=Ne(),{isReady:f,isUnavailable:p}=bt(),m=Ve(Wi),h=He(Gi),g=Ve(Ki),{data:_}=Le(),v;t[0]===_?v=t[1]:(v=_===void 0?[]:_,t[0]=_,t[1]=v);let y=v,b;bb0:{if(c){b=c;break bb0}if(Array.isArray(m)&&m.length>0){b=m;break bb0}b=y}let x=b,S;if(t[2]!==a||t[3]!==x){let e=We(x);S=a?e.filter(a):e,t[2]=a,t[3]=x,t[4]=S}else S=t[4];let C=S,w=V(qi),{isMobile:T}=Rt(),E=w||T,[D,O]=$.useState(!1),k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{O(!0),Ve.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:mobilePanel`})},t[5]=k):k=t[5];let A=ne(k),j=ne(Ji),M=$.useId(),N,P;t[6]!==c||t[7]!==h||t[8]!==g||t[9]!==x.length?(N=()=>{c||x.length>0||(g(),h())},P=[c,x.length,g,h],t[6]=c,t[7]=h,t[8]=g,t[9]=x.length,t[10]=N,t[11]=P):(N=t[10],P=t[11]),$.useEffect(N,P);let F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>O(!1),t[12]=F):F=t[12];let ee=F,I;t[13]===r?I=t[14]:(I=e=>{r(e)},t[13]=r,t[14]=I);let L=I,R;t[15]!==n||t[16]!==C||t[17]!==L||t[18]!==E||t[19]!==D||t[20]!==M||t[21]!==d?(R=()=>E?(0,Q.jsx)(Vt,{id:`mobile-agent-selector-sheet-${M}`,open:D,onOpenChange:e=>{e||ee()},ariaLabel:d(`settings.commands.agentSelector.title`),closeAriaLabel:d(`mobile.surface.closeAria`),resizeAriaLabel:d(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Q.jsxs)(Ut,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`flex flex-col gap-1 overscroll-contain`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:J(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,n?`text-foreground`:`bg-primary/10 text-primary`),onClick:()=>{L(``),ee()},children:[(0,Q.jsx)(Xe,{name:`default`,size:16}),(0,Q.jsx)(`span`,{className:J(`min-w-0 typography-meta`,n?`text-muted-foreground`:`font-medium`),children:d(`settings.commands.agentSelector.notSelected`)}),!n&&(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary`})]}),C.map(e=>{let t=e.name===n;return(0,Q.jsxs)(`button`,{type:`button`,className:J(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-start gap-x-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,t?`bg-primary/10 text-primary`:`text-foreground`),onClick:()=>{L(e.name),ee()},children:[(0,Q.jsx)(Xe,{name:e.name,size:16,className:`mt-1.5`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`typography-meta font-medium`,children:e.name}),e.description&&(0,Q.jsx)(`span`,{className:`mt-0.5 block whitespace-normal break-words typography-micro text-muted-foreground`,children:e.description})]}),t&&(0,Q.jsx)(`div`,{className:`mt-2 h-2 w-2 rounded-full bg-primary`})]},e.name)})]})}):null,t[15]=n,t[16]=C,t[17]=L,t[18]=E,t[19]=D,t[20]=M,t[21]=d,t[22]=R):R=t[22];let te=R,z;t[23]!==n||t[24]!==C||t[25]!==i||t[26]!==l||t[27]!==L||t[28]!==j||t[29]!==E||t[30]!==f||t[31]!==p||t[32]!==A||t[33]!==u||t[34]!==d?(z=E?(0,Q.jsxs)(`button`,{type:`button`,onClick:f?A:void 0,disabled:!f,className:J(`flex w-full items-center justify-between gap-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,!f&&`opacity-60 cursor-not-allowed`,i),children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:f?(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(Xe,{name:n||`default`,size:14}):null,(0,Q.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:n||d(`settings.commands.agentSelector.selectAgentPlaceholder`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]})}),(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3 text-muted-foreground`})]}):f?(0,Q.jsxs)(yt,{onOpenChange:j,children:[(0,Q.jsx)(Tt,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:J(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 cursor-pointer hover:bg-interactive-hover/30 h-6 w-fit`,i),children:[u?(0,Q.jsx)(Xe,{name:n||`default`,size:14}):null,(0,Q.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap`,children:n||d(`settings.commands.agentSelector.notSelected`)}),(0,Q.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`})]})}),(0,Q.jsxs)(xt,{className:`max-w-[300px]`,portalToBody:l,children:[(0,Q.jsxs)(Ft,{className:`typography-meta`,onSelect:()=>L(``),children:[(0,Q.jsx)(Xe,{name:`default`,size:14}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:d(`settings.commands.agentSelector.notSelected`)})]}),C.map(e=>(0,Q.jsxs)(Ft,{className:`typography-meta`,onSelect:()=>L(e.name),children:[(0,Q.jsx)(Xe,{name:e.name,size:14}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.name))]})]}):(0,Q.jsxs)(`div`,{className:J(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 h-6 w-fit opacity-60`,i),children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-3 w-3 animate-spin text-muted-foreground flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]}),t[23]=n,t[24]=C,t[25]=i,t[26]=l,t[27]=L,t[28]=j,t[29]=E,t[30]=f,t[31]=p,t[32]=A,t[33]=u,t[34]=d,t[35]=z):z=t[35];let B;t[36]===te?B=t[37]:(B=te(),t[36]=te,t[37]=B);let re;return t[38]!==z||t[39]!==B?(re=(0,Q.jsxs)(Q.Fragment,{children:[z,B]}),t[38]=z,t[39]=B,t[40]=re):re=t[40],re};function Wi(e){return e.agents}function Gi(e){return e.loadAgents}function Ki(e){return e.loadAgents}function qi(e){return e.isMobile}function Ji(e){e&&Ve.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var Yi=`/mcp/oauth/callback`,Xi=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},Zi=e=>{let t=$i(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},Qi=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},$i=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Xi(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},ea=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,ta=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=xn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return ea(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function na(e){return e?[bn(),we.of(ta),se()]:[]}var ra={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},ia={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function aa(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(ra)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(ia)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var oa=new WeakMap;function sa(e,t){let n=hn(e.state);if(!n.valid)return oa.delete(e),0;let r=oa.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return oa.set(e,{query:n,doc:e.state.doc,total:a}),a}function ca(e){let t=hn(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function la(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=sa(t,n),o=a===0?0:ca(t);i.textContent=a===0?``:`${o}/${a}`}var ua=new G,da=new G,fa=new G,pa=new G,ma=new G,ha=new G,ga=new G,_a=(e=>e)(mn.filter(e=>e.run!==pn)),va=ae,ya=_n,ba=vn,xa=class extends oe{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`yuri-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},Sa=(e,t)=>!e||e.length===0?[]:ve.define({create(n){let r=new Ce,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,ue.widget({widget:new xa(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>le.decorations.from(e)}),Ca=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return de.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new Ce;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,ue.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function wa({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=$.useRef(null),h=$.useRef(null),g=$.useRef(e),_=$.useRef(t),v=$.useRef(s),y=$.useRef(c),b=$.useRef(f),x=$.useRef(l),S=$.useRef(p),C=$.useRef(new Map),[w,T]=$.useState([]),E=$.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=$.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return $.useEffect(()=>{g.current=e},[e]),$.useEffect(()=>{_.current=t},[t]),$.useEffect(()=>{v.current=s,y.current=c},[s,c]),$.useEffect(()=>{b.current=f},[f]),$.useEffect(()=>{x.current=l,E(l)},[l,E]),$.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=xe.create({doc:g.current,extensions:[...e?[le.cspNonce.of(e)]:[],pe({fixed:!0}),ua.of(me(a)),dn(),ye.of(` `),ga.of(na(p)),fe.of([un,...ln,...fn]),le.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=gn(e.startState),n=gn(e.state);t!==n&&b.current?.(n);let r=!hn(e.startState).eq(hn(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&la(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),da.of(le.editable.of(!i)),fa.of(n??[]),pa.of(Ca(o)),ma.of(Sa(l,C.current)),ha.of(u?[yn({top:!0}),fe.of(_a)]:[])]});return h.current=new le({state:t,parent:m.current}),va(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),$.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[ua.reconfigure(me(a)),da.reconfigure(le.editable.of(!i)),fa.reconfigure(n??[]),pa.reconfigure(Ca(o)),ma.reconfigure(Sa(l,C.current)),ha.reconfigure(u?[yn({top:!0}),fe.of(_a)]:[])]}),va(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),$.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:ga.reconfigure(na(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(ya(e),requestAnimationFrame(()=>{aa(e.dom),la(e.dom,e,!0)})):ba(e))},[d,u]),$.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),va(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:m,className:J(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,Ni.createPortal)(e.content,e.container,e.id))]})}var Ta=ge.define(je),Ea=Oe.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Da(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return Ta;case`json`:case`jsonc`:case`json5`:return De().language;case`js`:case`javascript`:return K().language;case`jsx`:return K({jsx:!0}).language;case`ts`:case`typescript`:return K({typescript:!0}).language;case`tsx`:return K({typescript:!0,jsx:!0}).language;case`html`:return Ee().language;case`css`:return Te().language;case`py`:case`python`:return Ae().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return ke().language;case`heex`:case`eex`:case`leex`:return Ee().language;default:return be.matchLanguageName(Sn,t,!0)}}var Oa=e=>e.split(`/`).pop()?.toLowerCase()??``,ka=e=>{let t=Oa(e);return t?be.matchFilename(Sn,t):null},Aa=()=>W(he.define([{tag:[U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],fontWeight:`600`},{tag:U.strong,fontWeight:`600`},{tag:U.emphasis,fontStyle:`italic`},{tag:U.strikethrough,textDecoration:`line-through`},{tag:[U.link,U.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:U.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:U.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:U.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:U.heading,color:`var(--markdown-heading1, currentColor)`}]));function ja(e){let t=e.toLowerCase();switch(Oa(t)){case`makefile`:case`gnumakefile`:return Ta}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return K({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return K({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[De(),Ea];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return De();case`css`:case`scss`:case`sass`:case`less`:return Te();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return Ee();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[ke({codeLanguages:Da}),Aa()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return Ta;case`py`:case`pyw`:case`pyi`:return Ae();default:return null}}async function Ma(e){let t=ka(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function Na(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=le.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-foldPlaceholder":{backgroundColor:e.colors.surface.muted,color:e.colors.surface.foreground,borderColor:e.colors.interactive.border},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=he.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],class:`cm-comment`},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],class:`cm-keyword`},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],class:`cm-operator`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],class:`cm-punctuation`},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],class:`cm-string`},{tag:U.escape,class:`cm-string-2`},{tag:[U.number,U.bool,U.atom,U.null,U.self],class:`cm-number`},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],class:`cm-builtin`},{tag:U.definition(U.variableName),class:`cm-def`},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],class:`cm-variable`},{tag:U.propertyName,class:`cm-property`},{tag:U.attributeName,class:`cm-attribute`},{tag:[U.className,U.typeName,U.namespace],class:`cm-variable-3`},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],class:`cm-tag`},{tag:U.link,class:`cm-link`},{tag:[U.heading,U.heading1,U.heading2,U.heading3,U.heading4,U.heading5,U.heading6],class:`cm-keyword`}]),l=he.define([{tag:[U.comment,U.docComment,U.meta,U.documentMeta],color:e.colors.syntax.base.comment},{tag:[U.keyword,U.controlKeyword,U.moduleKeyword,U.definitionKeyword,U.modifier],color:e.colors.syntax.base.keyword},{tag:[U.operatorKeyword,U.operator,U.derefOperator,U.updateOperator,U.definitionOperator,U.typeOperator,U.controlOperator,U.logicOperator,U.bitwiseOperator,U.arithmeticOperator,U.compareOperator],color:e.colors.syntax.base.operator},{tag:[U.string,U.regexp,U.attributeValue,U.special(U.string),U.monospace],color:e.colors.syntax.base.string},{tag:U.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[U.number,U.bool,U.atom,U.null,U.self],color:e.colors.syntax.base.number},{tag:[U.function(U.variableName),U.function(U.definition(U.variableName)),U.function(U.propertyName),U.standard(U.variableName),U.special(U.variableName)],color:e.colors.syntax.base.function},{tag:U.definition(U.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[U.variableName,U.local(U.variableName),U.constant(U.variableName),U.literal],color:e.colors.syntax.base.variable},{tag:U.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:U.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[U.className,U.typeName,U.namespace],color:e.colors.syntax.base.type},{tag:[U.tagName,U.labelName,U.annotation,U.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:U.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[U.punctuation,U.separator,U.bracket,U.paren,U.brace,U.squareBracket,U.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,W(_e,{fallback:!0}),W(ce),W(c),W(l)]}var Pa=180,Fa=Se.define(),Ia=1,La=2,Ra=4,za=new Map,Ba=(e,t)=>{let n=`${e}|${t}`,r=za.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Ia&&(i+=`font-style:italic;`),t&La&&(i+=`font-weight:bold;`),t&Ra&&(i+=`text-decoration:underline;`);let a=ue.mark({attributes:{style:i}});return za.set(n,a),a},Va=(e,t)=>{let n=new Ce,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,Ba(t,r)))}}return n.finish()},Ha=ve.define({create(){return ue.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Fa)&&(n=e.value);return n},provide:e=>le.decorations.from(e)}),Ua=e=>de.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},Pa)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Zt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:Fa.of(Va(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),Wa=e=>[Ha,Ua(e)],Ga=e=>{let t=(0,Z.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Q.jsx)(X,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(X,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Q.jsx)(dt,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Q.jsx)(ft,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Q.jsxs)(pt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Ka=y()(x(b((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await it(),isLoading:!1}),!0}catch(t){return console.error(`Failed to load git identity profiles:`,t),e({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{let t=await lt();return t&&t.userName&&t.userEmail?e({globalIdentity:{id:`global`,name:`Global Identity`,userName:t.userName,userEmail:t.userEmail,authType:t.sshCommand?`ssh`:void 0,sshKey:t.sshCommand?t.sshCommand.replace(`ssh -i `,``):null,color:`info`,icon:`house`}}):e({globalIdentity:null}),!0}catch(t){return console.error(`Failed to load global git identity:`,t),e({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{return e({discoveredCredentials:await rt()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=v()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await a(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await D({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await ot(n),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to create git identity profile:`,e),!1}},updateProfile:async(e,n)=>{try{let r=t().profiles.find(t=>t.id===e);if(!r)throw Error(`Profile not found`);let i={...r,...n};return await at(e,i),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to update git identity profile:`,e),!1}},deleteProfile:async n=>{try{return await st(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:j(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=Ka);var qa=e=>{let t=(0,Z.c)(27),{title:n,settingsItem:r,children:i,collapsible:a,count:o}=e,s=a!==void 0&&a,[c,l]=$.useState(!1);if(s){let e;t[0]===n?e=t[1]:(e=(0,Q.jsx)(`span`,{className:`typography-ui-label min-w-0 truncate`,children:n}),t[0]=n,t[1]=e);let a;t[2]===o?a=t[3]:(a=o===void 0?null:(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums`,children:o}),t[2]=o,t[3]=a);let s=c?`arrow-down-s`:`arrow-right-s`,u;t[4]===s?u=t[5]:(u=(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center`,children:(0,Q.jsx)(X,{name:s,className:`size-4`})}),t[4]=s,t[5]=u);let d;t[6]!==a||t[7]!==u?(d=(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-muted-foreground`,children:[a,u]}),t[6]=a,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==e||t[10]!==d?(f=(0,Q.jsx)(`div`,{className:`yuri-settings-group-row flex items-center gap-2`,children:(0,Q.jsxs)(sn,{className:`min-w-0 flex-1 gap-2 p-0 hover:bg-transparent focus-visible:ring-[var(--interactive-focus-ring)]`,children:[e,d]})}),t[9]=e,t[10]=d,t[11]=f):f=t[11];let p;t[12]===i?p=t[13]:(p=(0,Q.jsx)(on,{keepMounted:!0,children:(0,Q.jsx)(`div`,{className:`yuri-settings-group-row`,children:i})}),t[12]=i,t[13]=p);let m;t[14]!==f||t[15]!==p?(m=(0,Q.jsxs)(nn,{children:[f,p]}),t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;return t[17]!==c||t[18]!==r||t[19]!==m?(h=(0,Q.jsx)(cn,{open:c,onOpenChange:l,"data-settings-item":r,children:m}),t[17]=c,t[18]=r,t[19]=m,t[20]=h):h=t[20],h}let u;t[21]===i?u=t[22]:(u=(0,Q.jsx)(`div`,{className:`yuri-settings-group-row`,children:i}),t[21]=i,t[22]=u);let d;return t[23]!==r||t[24]!==u||t[25]!==n?(d=(0,Q.jsx)(nn,{label:n,itemId:r,children:u}),t[23]=r,t[24]=u,t[25]=n,t[26]=d):d=t[26],d},Ja=({projectRef:e=null,collapsible:t=!1})=>{let{t:n}=Ne(),{isMobile:r,isTablet:i}=Rt(),a=r||i,o=Be(e=>e.getActiveProject()),s=e?.path??o?.path??null,c=qe(e=>e.getWorktreeMetadata),l=Ye(),u=O(e=>e.homeDirectory),[d,f]=$.useState(null),[p,m]=$.useState([]),[h,g]=$.useState(!1),_=$.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!o?.id||!s?null:{id:o.id,path:s},[o?.id,s,e?.id,e?.path]),v=$.useCallback(async()=>{if(!(!_||d===!1))try{let e=await Gt(_);m(e)}catch{}},[_,d]);$.useEffect(()=>{if(!s)return;let e=!1;return f(null),(async()=>{try{let t=await ct(s);if(e)return;f(t)}catch{}})(),()=>{e=!0}},[s]),$.useEffect(()=>{if(!_){m([]),g(!1);return}if(d===!1){m([]),g(!1);return}let e=!1;return g(!0),m([]),(async()=>{try{let t=await Gt(_);if(e)return;m(t)}catch{}finally{e||g(!1)}})(),()=>{e=!0}},[_,d]);let y=$.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=l.filter(e=>{let r=c(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...Je.getState().activeSessions,...Je.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},s=o(i),u=new Set,d=[...r,...s].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));Ge.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[l,c]),b=$.useMemo(()=>l.map(e=>e.id).join(`,`),[l]);return $.useEffect(()=>{d&&s&&v()},[b,d,s,v]),s?d===!1?(0,Q.jsx)(qa,{title:n(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Q.jsx)(qa,{title:n(`settings.yuri.worktrees.list.title`),settingsItem:`projects.worktree`,collapsible:t,count:h?void 0:p.length,children:h?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.list.loading`)}):p.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:n(`settings.yuri.worktrees.list.empty`)}):(0,Q.jsx)(`div`,{className:`w-full space-y-1`,children:p.map(e=>(0,Q.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||n(`settings.yuri.worktrees.list.detachedHead`)})}),(0,Q.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:Pe(e.path,u)})]}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>y(e),className:J(`text-muted-foreground transition-opacity focus-visible:opacity-100`,a?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":n(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Q.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})}):(0,Q.jsx)(qa,{title:n(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.state.selectProject`)})})},Ya=e=>{let t=(0,Z.c)(127),{form:n}=e,{t:r}=Ne(),{currentTheme:i}=Ze(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?Jt[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let ee;t[4]===r?ee=t[5]:(ee=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=ee);let I;t[6]===r?I=t[7]:(I=r(`settings.projects.page.field.projectName`),t[6]=r,t[7]=I);let L;t[8]!==a||t[9]!==F||t[10]!==ee||t[11]!==I?(L=(0,Q.jsx)(ut,{value:a,onChange:F,placeholder:ee,"aria-label":I}),t[8]=a,t[9]=F,t[10]=ee,t[11]=I,t[12]=L):L=t[12];let R;t[13]!==P||t[14]!==L?(R=(0,Q.jsx)(rn,{label:P,itemId:`projects.name`,children:L}),t[13]=P,t[14]=L,t[15]=R):R=t[15];let te;t[16]===r?te=t[17]:(te=r(`settings.yuri.defaults.field.defaultModel`),t[16]=r,t[17]=te);let z=p.providerId,ne=p.modelId,B;t[18]===r?B=t[19]:(B=r(`settings.yuri.defaults.option.default`),t[18]=r,t[19]=B);let V;t[20]!==m||t[21]!==p.modelId||t[22]!==p.providerId||t[23]!==B?(V=(0,Q.jsx)(Pi,{providerId:z,modelId:ne,onChange:m,className:`yuri-settings-inline-value`,placeholder:B,showIcon:!1}),t[20]=m,t[21]=p.modelId,t[22]=p.providerId,t[23]=B,t[24]=V):V=t[24];let re;t[25]!==V||t[26]!==te?(re=(0,Q.jsx)(rn,{label:te,itemId:`projects.default-model`,children:V}),t[25]=V,t[26]=te,t[27]=re):re=t[27];let H;t[28]===r?H=t[29]:(H=r(`settings.projects.page.field.accentColor`),t[28]=r,t[29]=H);let ie;t[30]===u?ie=t[31]:(ie=()=>u(null),t[30]=u,t[31]=ie);let U=l===null,ae;t[32]===r?ae=t[33]:(ae=r(`settings.projects.page.field.none`),t[32]=r,t[33]=ae);let W;t[34]===r?W=t[35]:(W=r(`settings.projects.page.field.none`),t[34]=r,t[35]=W);let oe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Q.jsx)(X,{name:`close`,className:`size-4 text-muted-foreground`}),t[36]=oe):oe=t[36];let se;t[37]!==ie||t[38]!==U||t[39]!==ae||t[40]!==W?(se=(0,Q.jsx)(q,{type:`button`,variant:`chip`,size:`icon`,onClick:ie,"aria-pressed":U,"aria-label":ae,title:W,children:oe}),t[37]=ie,t[38]=U,t[39]=ae,t[40]=W,t[41]=se):se=t[41];let ce;t[42]!==l||t[43]!==u?(ce=Xt.map(e=>(0,Q.jsx)(q,{type:`button`,variant:`chip`,size:`icon`,onClick:()=>u(e.key),"aria-pressed":l===e.key,"aria-label":e.label,title:e.label,children:(0,Q.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full`,style:{backgroundColor:e.cssVar},children:l===e.key?(0,Q.jsx)(X,{name:`check`,className:`size-3 text-foreground`}):null})},e.key)),t[42]=l,t[43]=u,t[44]=ce):ce=t[44];let le;t[45]!==se||t[46]!==ce?(le=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-2`,children:[se,ce]}),t[45]=se,t[46]=ce,t[47]=le):le=t[47];let ue;t[48]!==H||t[49]!==le?(ue=(0,Q.jsx)(rn,{label:H,itemId:`projects.accent-color`,footer:le,children:null}),t[48]=H,t[49]=le,t[50]=ue):ue=t[50];let de;t[51]===r?de=t[52]:(de=r(`settings.projects.page.field.projectIcon`),t[51]=r,t[52]=de);let fe;t[53]===O?fe=t[54]:(fe=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[53]=O,t[54]=fe);let pe;t[55]!==D||t[56]!==fe?(pe=(0,Q.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:fe}),t[55]=D,t[56]=fe,t[57]=pe):pe=t[57];let me;t[58]===c?me=t[59]:(me=()=>c(null),t[58]=c,t[59]=me);let he=s===null,ge;t[60]===r?ge=t[61]:(ge=r(`settings.projects.page.field.none`),t[60]=r,t[61]=ge);let _e;t[62]===r?_e=t[63]:(_e=r(`settings.projects.page.field.none`),t[62]=r,t[63]=_e);let ve;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[64]=ve):ve=t[64];let ye;t[65]!==me||t[66]!==he||t[67]!==ge||t[68]!==_e?(ye=(0,Q.jsx)(q,{type:`button`,variant:`chip`,size:`icon`,onClick:me,"aria-pressed":he,"aria-label":ge,title:_e,children:ve}),t[65]=me,t[66]=he,t[67]=ge,t[68]=_e,t[69]=ye):ye=t[69];let be;t[70]!==N||t[71]!==s||t[72]!==c?(be=Yt.map(e=>{let t=e.Icon;return(0,Q.jsx)(q,{type:`button`,variant:`chip`,size:`icon`,onClick:()=>c(e.key),"aria-pressed":s===e.key,"aria-label":e.label,title:e.label,children:(0,Q.jsx)(X,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[70]=N,t[71]=s,t[72]=c,t[73]=be):be=t[73];let xe;t[74]!==ye||t[75]!==be?(xe=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[ye,be]}),t[74]=ye,t[75]=be,t[76]=xe):xe=t[76];let Se;t[77]!==j||t[78]!==i||t[79]!==w||t[80]!==S||t[81]!==d||t[82]!==b||t[83]!==M||t[84]!==x||t[85]!==E?(Se=w&&E&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Q.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Q.jsx)(Wt,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})}),t[77]=j,t[78]=i,t[79]=w,t[80]=S,t[81]=d,t[82]=b,t[83]=M,t[84]=x,t[85]=E,t[86]=Se):Se=t[86];let Ce;t[87]!==w||t[88]!==d||t[89]!==f||t[90]!==r?(Ce=w&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Q.jsx)(ut,{value:d??``,onChange:e=>f(e.target.value),"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Q.jsx)(q,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>f(null),"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Q.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[87]=w,t[88]=d,t[89]=f,t[90]=r,t[91]=Ce):Ce=t[91];let G;t[92]!==D||t[93]!==A||t[94]!==C||t[95]!==_||t[96]!==h||t[97]!==r?(G=!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{size:`xs`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Q.jsx)(q,{size:`xs`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[92]=D,t[93]=A,t[94]=C,t[95]=_,t[96]=h,t[97]=r,t[98]=G):G=t[98];let we;t[99]!==k||t[100]!==T||t[101]!==g||t[102]!==r?(we=T&&(0,Q.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[99]=k,t[100]=T,t[101]=g,t[102]=r,t[103]=we):we=t[103];let Te;t[104]!==g||t[105]!==v||t[106]!==y||t[107]!==r?(Te=v&&(0,Q.jsx)(q,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[104]=g,t[105]=v,t[106]=y,t[107]=r,t[108]=Te):Te=t[108];let K;t[109]!==G||t[110]!==we||t[111]!==Te?(K=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[G,we,Te]}),t[109]=G,t[110]=we,t[111]=Te,t[112]=K):K=t[112];let Ee;t[113]!==pe||t[114]!==xe||t[115]!==Se||t[116]!==Ce||t[117]!==K?(Ee=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col items-start gap-2 pt-2`,children:[pe,xe,Se,Ce,K]}),t[113]=pe,t[114]=xe,t[115]=Se,t[116]=Ce,t[117]=K,t[118]=Ee):Ee=t[118];let De;t[119]!==de||t[120]!==Ee?(De=(0,Q.jsx)(rn,{label:de,itemId:`projects.icon`,footer:Ee,children:null}),t[119]=de,t[120]=Ee,t[121]=De):De=t[121];let Oe;return t[122]!==re||t[123]!==ue||t[124]!==De||t[125]!==R?(Oe=(0,Q.jsxs)(nn,{children:[R,re,ue,De]}),t[122]=re,t[123]=ue,t[124]=De,t[125]=R,t[126]=Oe):Oe=t[126],Oe},Xa=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Za=e=>{if(!e)return null;let t=e.trim();return t&&Xa.test(t)?t.toLowerCase():null},Qa=e=>{let{t}=Ne(),n=Be(e=>e.uploadProjectIcon),r=Be(e=>e.removeProjectIcon),i=Be(e=>e.discoverProjectIcon),a=Be(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=$.useState(``),[c,l]=$.useState(null),[u,d]=$.useState(null),[f,p]=$.useState(null),[m,h]=$.useState(void 0),[g,_]=$.useState(!1),[v,y]=$.useState(!1),[b,x]=$.useState(!1),[S,C]=$.useState(!1),[w,T]=$.useState(null),[E,D]=$.useState(null),[O,k]=$.useState(!1),A=$.useRef(null),j=$.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;$.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),$.useEffect(()=>()=>{j()},[j]);let N=$.useMemo(()=>Fe(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),ee=e?.iconImage?.source===`custom`,I=P&&!S||F,L=I,R=!!(e&&P&&!S),te=!O&&(F||R),z=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),ne=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),B=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),V=$.useCallback(()=>{!e||!L||v||(F&&j(),C(!!P),k(!1))},[j,F,L,P,v,e]),re=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){Y.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){Y.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}Y.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),H=$.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return Y.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||Y.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return Y.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||Y.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:Za(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return $.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:ne,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:ee,effectiveHasImageIcon:I,hasRemovableImageIcon:L,showStoredImagePreview:R,showImagePreview:te,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:B,handleRemoveImageIcon:V,handleDiscoverIcon:re,hasChanges:z,prepareSaveData:H,currentIconImage:a,project:e}},$a=450,eo=(e,t)=>{let{t:n}=Ne(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=$.useRef(!1);$.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{Y.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},$a);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},to=e=>{let t=(0,Z.c)(22),{project:n,onIdentitySave:r,compact:i}=e,a=i!==void 0&&i,{t:o}=Ne(),s=Qa(n),c;bb0:{if(!n){c=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],c=e}let l=c;if(eo(s,r),!n||!l)return null;let u;t[3]!==n.path||t[4]!==o?(u=n.path.split(/[\\/]/).filter(Boolean).at(-1)??o(`settings.projects.page.title.default`),t[3]=n.path,t[4]=o,t[5]=u):u=t[5];let d=u,f;t[6]===d?f=t[7]:(f=(0,Q.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:d}),t[6]=d,t[7]=f);let p;t[8]===n.path?p=t[9]:(p=(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[8]=n.path,t[9]=p);let m;t[10]!==f||t[11]!==p?(m=(0,Q.jsxs)(`div`,{className:`min-w-0 pr-6`,children:[f,p]}),t[10]=f,t[11]=p,t[12]=m):m=t[12];let h;t[13]===s?h=t[14]:(h=(0,Q.jsx)(Ya,{form:s}),t[13]=s,t[14]=h);let g;t[15]!==a||t[16]!==l?(g=(0,Q.jsx)(Ja,{projectRef:l,collapsible:a}),t[15]=a,t[16]=l,t[17]=g):g=t[17];let _;return t[18]!==m||t[19]!==h||t[20]!==g?(_=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[m,h,g]}),t[18]=m,t[19]=h,t[20]=g,t[21]=_):_=t[21],_},no=(e,t)=>t.updatedAtMs-e.updatedAtMs,ro=y((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([jt(),vt()]),i={};for(let e of r.sort(no))i[e.id]=e;t().listenerReady||await Lt(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await mt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await vt(),n={};for(let e of t.sort(no))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await Ct({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=gt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Nt(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await wt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await Nt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),io=e=>{let t=(0,Z.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=_t(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=St(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=J(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Q.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Q.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Q.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},ao=e=>{let t=(0,Z.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=Ne(),s;t[0]===n.status?s=t[1]:(s=At(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=J(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.wait`,{duration:Mt(n.remainingSeconds)})}):(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Q.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=J(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:Mt(n.remainingSeconds)})]}):(0,Q.jsxs)(`span`,{title:f,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Q.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},oo=e=>e instanceof Error&&e.name===`CancelledError`,so=y(()=>({setStatus:e=>ht(z,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await z.cancelQueries({queryKey:R.github.auth(r),exact:!0});try{return await It(z,e,r)}catch(e){if(oo(e))return Et(z,r);throw e}}})),co={displayMode:`browser`,installed:!1,browserTab:!0},lo=new Set,uo=co,fo=!1,po,mo=()=>{let e=Pt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},ho=()=>(!fo&&typeof window<`u`&&(uo=mo(),fo=!0),uo),go=()=>{let e=mo();fo=!0,e.displayMode!==uo.displayMode&&(uo=e,lo.forEach(e=>e()))},_o=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,go):typeof t.addListener==`function`&&t.addListener(go);return window.addEventListener(`appinstalled`,go),window.addEventListener(`focus`,go),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,go):typeof t.removeListener==`function`&&t.removeListener(go);window.removeEventListener(`appinstalled`,go),window.removeEventListener(`focus`,go)}},vo=e=>(lo.add(e),po??=_o(),go(),()=>{lo.delete(e),lo.size===0&&(po?.(),po=void 0)}),yo=()=>$.useSyncExternalStore(vo,ho,bo);function bo(){return co}var xo=`Yuri`,So=y()(b(e=>({sidebarBrandName:xo,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:k(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=xo),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=xo),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=xo),n}}));typeof window<`u`&&t(e=>{i(e)&&So.persist.rehydrate()});var Co=(e,t)=>e?t.kind===e.kind?t.projectRoot.length===e.projectRoot.length?t.projectId.localeCompare(e.projectId)<0:t.projectRoot.length>e.projectRoot.length:t.kind===`project`:!0,wo=(e,t,n)=>{Co(e.get(t),n)&&e.set(t,n)},To=e=>{let t=e;return p(t.directory)??p(t.project?.worktree)},Eo=e=>{if(e===`/`||/^[A-Z]:$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:t===0?`/`:t===2&&/^[A-Z]:\//.test(e)?e.slice(0,2):e.slice(0,t)},Do=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=p(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),wo(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=p(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=p(e.path);t&&wo(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=Eo(n)}for(let e of t)s.set(e,i);return i},m=(e,t,n)=>{for(let r of e){let e=f(To(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return m(e,l,d),m(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},Oo=`__other__`;function ko(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Ao({mode:e=`dialog`}){let{t}=Ne(),{isMobile:n,isTablet:r,hasTouchInput:i}=Rt(),a=n||r||i,o=e===`page`,s=V(e=>e.isArchivedSessionsDialogOpen),c=V(e=>e.setArchivedSessionsDialogOpen),u=o||s,d=Be(e=>e.projects),f=Je(e=>e.archivedSessions),p=qe(e=>e.setCurrentSession),m=V(e=>e.setSettingsDialogOpen),[h,g]=$.useState(!1),[_,v]=$.useState(null),[y,b]=$.useState(null);$.useEffect(()=>{if(!u){v(null),b(null);return}let e=!1;return g(!0),Ue().catch(()=>{e||Y.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[u,t]);let x=$.useMemo(()=>{let e=Do([],d.map(e=>({id:e.id,normalizedPath:e.path})),new Map,l(),f),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>ko(t)-ko(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=f.filter(e=>!r.has(e.id)).sort((e,t)=>ko(t)-ko(e));i.length>0&&n.set(Oo,i);let a=[];for(let e of d){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let o=n.get(Oo);return o&&o.length>0&&a.push({projectId:Oo,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[f,d,t]),S=f.length,C=_?x.find(e=>e.projectId===_)??null:null,w=$.useCallback(async e=>{b(e.id);try{await Re(e.id)?Y.success(t(`settings.yuri.archivedSessions.toast.restored`)):Y.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=$.useCallback(e=>{let t=Ke(e);p(e.id,t),c(!1),m(!1)},[p,c,m]),E=C?C.label:t(`settings.yuri.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),O=(0,Q.jsxs)(`div`,{className:`yuri-picker-list space-y-3`,children:[C?(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>v(null),children:[(0,Q.jsx)(X,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,h?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Q.jsx)(`div`,{className:`yuri-picker-empty rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Q.jsx)(`div`,{className:`yuri-picker-rows space-y-1.5`,children:C.sessions.map(e=>{let n=Ke(e),r=ko(e),i=y===e.id;return(0,Q.jsxs)(`div`,{className:`yuri-picker-row flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`yuri-picker-label typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Q.jsxs)(`div`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:[r>0?kt(r):null,r>0&&n?` · `:null,n?Pe(n):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Q.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Q.jsxs)(q,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Q.jsx)(X,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(X,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Q.jsx)(`div`,{className:`yuri-picker-empty rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Q.jsx)(`div`,{className:`yuri-picker-rows space-y-1.5`,children:x.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>v(e.projectId),className:J(`yuri-picker-row flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Q.jsx)(X,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`yuri-picker-label typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Q.jsx)(`div`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:Pe(e.path)}):null]}),(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!h&&S>0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Q.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),O]}):a?(0,Q.jsx)(Ot,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:O}):(0,Q.jsx)(nt,{open:s,onOpenChange:c,children:(0,Q.jsxs)($e,{presentation:`picker`,children:[(0,Q.jsx)(Qe,{className:`yuri-picker-header`,children:(0,Q.jsx)(et,{className:`yuri-picker-title truncate`,children:E})}),O]})})}function jo(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Ao,{mode:`dialog`}),e[0]=t):t=e[0],t}var Mo=48;function No({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,$.useRef)(null),a=(0,$.useRef)(null),o=(0,$.useRef)(null),s=(0,$.useRef)(null),c=(0,$.useRef)(null),l=ne(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/Mo)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--yuri-mobile-title-collapse`,r.toFixed(4)))}),u=ne(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,$.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.yuri-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`header`,{ref:i,className:J(`yuri-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-inner`,children:[(0,Q.jsxs)(`div`,{className:`yuri-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Q.jsx)(`p`,{className:`yuri-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Q.jsx)(`h1`,{className:`yuri-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),(0,Q.jsx)(`div`,{className:`yuri-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n})]})}),(0,Q.jsx)(`div`,{className:`yuri-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}function Po(e){let t=(0,Z.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({asChild:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?Ie:`div`,o;t[4]===n?o=t[5]:(o=J(`yuri-mobile-floating-surface`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Q.jsx)(a,{className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function Fo(e){let t=(0,Z.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({as:o,children:n,className:r,variant:s,surfaceProps:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o===void 0?`div`:o,l=s===void 0?`actions`:s,u;t[7]===r?u=t[8]:(u=J(`yuri-mobile-floating-bottom-bar-frame`,r),t[7]=r,t[8]=u);let d=l===`navigation`?`yuri-mobile-floating-bottom-bar-navigation`:`yuri-mobile-floating-bottom-bar-actions`,f;t[9]===d?f=t[10]:(f=J(`yuri-mobile-floating-bottom-bar`,d),t[9]=d,t[10]=f);let p;t[11]!==n||t[12]!==a||t[13]!==f?(p=(0,Q.jsx)(Po,{...a,className:f,children:n}),t[11]=n,t[12]=a,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==i||t[17]!==u||t[18]!==p?(m=(0,Q.jsx)(c,{className:u,...i,children:p}),t[15]=c,t[16]=i,t[17]=u,t[18]=p,t[19]=m):m=t[19],m}function Io(e){let t=(0,Z.c)(17),{title:n,children:r,surface:i,scrollsWithPage:a,showHeader:o,trailing:s,className:c,surfaceClassName:l,surfaceAriaLabel:u}=e,d=i===void 0||i,f=a!==void 0&&a,p=o===void 0||o,m=f&&`yuri-mobile-tab-page-flow`,h=!p&&`gap-0`,g;t[0]!==c||t[1]!==m||t[2]!==h?(g=J(`yuri-mobile-tab-page`,m,h,c),t[0]=c,t[1]=m,t[2]=h,t[3]=g):g=t[3];let _;t[4]!==p||t[5]!==n||t[6]!==s?(_=p?(0,Q.jsx)(No,{title:n,trailing:s}):null,t[4]=p,t[5]=n,t[6]=s,t[7]=_):_=t[7];let v;t[8]!==r||t[9]!==d||t[10]!==u||t[11]!==l?(v=d?(0,Q.jsx)(Po,{className:J(`yuri-mobile-tab-page-surface`,l),"aria-label":u,children:r}):(0,Q.jsx)(`div`,{className:J(`yuri-mobile-tab-page-content`,l),"aria-label":u,children:r}),t[8]=r,t[9]=d,t[10]=u,t[11]=l,t[12]=v):v=t[12];let y;return t[13]!==g||t[14]!==_||t[15]!==v?(y=(0,Q.jsxs)(`div`,{className:g,children:[_,v]}),t[13]=g,t[14]=_,t[15]=v,t[16]=y):y=t[16],y}function Lo(e){let t=(0,Z.c)(12),{label:n,children:r,className:i,cardClassName:a,ariaLabel:o}=e,s;t[0]!==a||t[1]!==i?(s=J(`yuri-mobile-labeled-surface-group`,a,i),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=(0,Q.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group-label`,children:n}),t[3]=n,t[4]=c);let l;t[5]===r?l=t[6]:(l=r?(0,Q.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group-content`,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,Q.jsxs)(`section`,{className:s,"aria-label":o,children:[c,l]}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}export{Cn as $,Ti as A,$r as B,Yi as C,Pi as D,Ui as E,si as F,Rr as G,ti as H,ni as I,Sr as J,gr as K,Yr as L,ri as M,ci as N,wi as O,li as P,Tn as Q,Qr as R,wa as S,Qi as T,Ur as U,ei as V,Wr as W,In as X,fr as Y,En as Z,Ga as _,No as a,ja as b,Do as c,so as d,wn as et,ao as f,Ka as g,to as h,Io as i,oi as j,Ei as k,So as l,ro as m,Po as n,jo as o,io as p,mr as q,Lo as r,Ao as s,Fo as t,yo as u,Wa as v,Zi as w,Ma as x,Na as y,Xr as z};