@yuriai/web 0.2.32-beta.4 → 0.2.32-beta.6

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 (171) hide show
  1. package/README.md +18 -0
  2. package/dist/assets/{AgentAvatar-DG1RbFtI.js → AgentAvatar-BPGtFSJl.js} +1 -1
  3. package/dist/assets/AssistantContactStatus-aUqr2ugb.js +3 -0
  4. package/dist/assets/{AssistantUnreadBadge-ByetyaWn.js → AssistantUnreadBadge-DrGzknrO.js} +1 -1
  5. package/dist/assets/{AssistantView-CHt3RWEC.js → AssistantView-GTh6h8B4.js} +1 -1
  6. package/dist/assets/{DiagramView-DReVW5q9.js → DiagramView-CLxCIzOU.js} +1 -1
  7. package/dist/assets/{FadeInOnReveal-Bmxvkrf4.js → FadeInOnReveal-DoQ1DHcy.js} +1 -1
  8. package/dist/assets/{GuiPluginSurface-CIeyIzIp.js → GuiPluginSurface-Cnyb0Yg6.js} +1 -1
  9. package/dist/assets/{GuiPluginWindow-CwP_vUoC.js → GuiPluginWindow-CWjwMY19.js} +1 -1
  10. package/dist/assets/Icon-wD7peplo.js +1 -0
  11. package/dist/assets/{ImageLoadingPlaceholder-DlosWH_9.js → ImageLoadingPlaceholder-cfSg1uO0.js} +1 -1
  12. package/dist/assets/{LoadingImage-D9r0ukc0.js → LoadingImage-DTlBKb0t.js} +1 -1
  13. package/dist/assets/{MarkdownRenderer-D-0KHpNl.js → MarkdownRenderer-QhegFBTR.js} +2 -2
  14. package/dist/assets/{MarkdownRendererImpl-BEUnj4i_.js → MarkdownRendererImpl-rflXjuIs.js} +1 -1
  15. package/dist/assets/{MarkstreamRendererImpl-BufiC_bA.js → MarkstreamRendererImpl-DGuW5ssC.js} +1 -1
  16. package/dist/assets/{MobileDetailNavigation-32DAi6Mg.js → MobileDetailNavigation-DpEvfH1k.js} +1 -1
  17. package/dist/assets/{MobileResizableSheet-vAenroLZ.js → MobileResizableSheet-3pSxhm6y.js} +1 -1
  18. package/dist/assets/{MobileShareBridge-DukFTkwu.js → MobileShareBridge-DiIVhlyc.js} +1 -1
  19. package/dist/assets/MobileTabPageHeader-eWPfDPR9.js +2 -0
  20. package/dist/assets/{MultiRunWindow-B2e-JjFb.js → MultiRunWindow-ByORgIWm.js} +1 -1
  21. package/dist/assets/{OnboardingScreen-DNlK3zfZ.js → OnboardingScreen-De74T2ws.js} +1 -1
  22. package/dist/assets/{OverlayScrollbar-W17unuIx.js → OverlayScrollbar-C1VJiQk-.js} +1 -1
  23. package/dist/assets/{SettingsView-DXhstV_y.js → SettingsView-H9vzfUh1.js} +12 -12
  24. package/dist/assets/{SettingsWindow-D1BRJCx_.js → SettingsWindow-CdUQZdrH.js} +1 -1
  25. package/dist/assets/SetupTourDialog-DJQC2v_9.js +1 -0
  26. package/dist/assets/SetupTourDialog-DrL_4ODI.css +1 -0
  27. package/dist/assets/{TerminalView-B_jqEx8P.js → TerminalView-X8tMXHjR.js} +1 -1
  28. package/dist/assets/{ToolOutputDialog-BgwsFo9W.js → ToolOutputDialog-DzAxB4FS.js} +1 -1
  29. package/dist/assets/{VoiceSettings-DXHfWAgl.js → VoiceSettings-CnYY2qY_.js} +2 -2
  30. package/dist/assets/{YuriLogo-XH6UGXtF.js → YuriLogo-kLl6rb2d.js} +1 -1
  31. package/dist/assets/YuriWordmark-DHYo0FlR.js +1 -0
  32. package/dist/assets/{appThemeRegistry-ChXTWoVW.js → appThemeRegistry-DIjRw0x6.js} +1 -1
  33. package/dist/assets/{button-CyJvQsp5.js → button-DSfiaJr4.js} +1 -1
  34. package/dist/assets/{capgoAdapter-BAvjN_Nh.js → capgoAdapter-cbndHe7B.js} +1 -1
  35. package/dist/assets/checkbox-cWs92MsM.js +1 -0
  36. package/dist/assets/{collapsible-CXjDO6DW.js → collapsible-AUQp4jpe.js} +1 -1
  37. package/dist/assets/{context-menu-BajfnPcW.js → context-menu-DwQvyFO2.js} +1 -1
  38. package/dist/assets/{diagram-_Js3imTf.js → diagram-BTa5MQro.js} +1 -1
  39. package/dist/assets/{dialog-Bapd6e10.js → dialog-gWs6IrfL.js} +1 -1
  40. package/dist/assets/{es-CBhZ80Z7.js → es-mX3KOqnq.js} +1 -1
  41. package/dist/assets/{fileMentionTouchSelection-BqGxOZhB.js → fileMentionTouchSelection-plcnc8He.js} +1 -1
  42. package/dist/assets/{fr-D9s0sHDF.js → fr-DpWAkfly.js} +1 -1
  43. package/dist/assets/{gitApi-DtXTuozL.js → gitApi-B9CzBfkU.js} +1 -1
  44. package/dist/assets/historyImportQueries-DXif2xV2.js +1 -0
  45. package/dist/assets/host-z9PU8q1e.js +1 -0
  46. package/dist/assets/{input-SCAHBeSU.js → input-D2qPeIPD.js} +1 -1
  47. package/dist/assets/insertionBoundaries-mB_fOUPv.js +1 -0
  48. package/dist/assets/{ja-BXQ3ox8H.js → ja-BBtK3t8l.js} +1 -1
  49. package/dist/assets/{ko-DlUti1wK.js → ko-Cwp3wC4W.js} +1 -1
  50. package/dist/assets/main-GmcShJwn.js +169 -0
  51. package/dist/assets/main-PMsuxOz8.js +2 -0
  52. package/dist/assets/{markdownHeightCache-B3MTnGA8.js → markdownHeightCache-Cinxvo8I.js} +1 -1
  53. package/dist/assets/{mcpQueries-0BYnsVR6.js → mcpQueries-D4D9YExA.js} +1 -1
  54. package/dist/assets/miniChat-D6sCXrvt.js +2 -0
  55. package/dist/assets/mobile-BT_KeI5P.js +2 -0
  56. package/dist/assets/{mobileBackNavigation-C1Ow2avo.js → mobileBackNavigation-uUEjrscy.js} +1 -1
  57. package/dist/assets/multirun-T_ppFdUy.js +3 -0
  58. package/dist/assets/{native-config-DQIb-3qU.js → native-config-BuFjRBaY.js} +1 -1
  59. package/dist/assets/{pl-B7LIbV2C.js → pl-Ccedjy5w.js} +1 -1
  60. package/dist/assets/{projectMeta-CSiZ4I85.js → projectMeta-FCtpvvba.js} +1 -1
  61. package/dist/assets/{pt-BR-DyusczdZ.js → pt-BR-M2O45bRx.js} +1 -1
  62. package/dist/assets/{pwa-Cm-jO8eR.js → pwa-CT5wGYKz.js} +1 -1
  63. package/dist/assets/{queue-abort-optimistic-CxF6bGXx.js → queue-abort-optimistic-Dqb0K-4o.js} +1 -1
  64. package/dist/assets/react-a6PrrNTm.js +1 -0
  65. package/dist/assets/{readiness-CDywb9dh.js → readiness-B2YFCzzO.js} +1 -1
  66. package/dist/assets/{renderElectronMiniChatApp-CiVeccip.js → renderElectronMiniChatApp-oHllm8xZ.js} +2 -2
  67. package/dist/assets/{renderMobileApp-B9-hpVnc.js → renderMobileApp-BHHmg4QP.js} +7 -7
  68. package/dist/assets/{runtimeConfig-Rthccc9z.js → runtimeConfig-7V2FCxSF.js} +1 -1
  69. package/dist/assets/runtimeEndpointReset-RgJe46-h.js +149 -0
  70. package/dist/assets/{select-BCLecCtX.js → select-BOlDxL_9.js} +1 -1
  71. package/dist/assets/sessionLookup-Fwx-W5l-.js +1 -0
  72. package/dist/assets/{sortable-tabs-strip-D474PwS8.js → sortable-tabs-strip-CtkfOIVC.js} +1 -1
  73. package/dist/assets/{speechSettingsQueries-alV0B1bP.js → speechSettingsQueries-BjBvcUMN.js} +1 -1
  74. package/dist/assets/src-C5Lsul_L.css +2 -0
  75. package/dist/assets/{store-Diaywtmi.js → store-BMijqCTE.js} +3 -3
  76. package/dist/assets/{textarea-CWQIq-Mn.js → textarea-Cspgldlr.js} +1 -1
  77. package/dist/assets/{tooltip-D3WmiZ7G.js → tooltip-DBb-UCMU.js} +1 -1
  78. package/dist/assets/tour-DzjTres6.js +1 -0
  79. package/dist/assets/{types-_2Igbjc0.js → types-C1fTHpjE.js} +1 -1
  80. package/dist/assets/{uk-BrwM67Dh.js → uk-skNzlwtr.js} +1 -1
  81. package/dist/assets/{useAppFontEffects-B1n0YPn0.js → useAppFontEffects-BIioYkKK.js} +54 -54
  82. package/dist/assets/useDesktopWindowControlsLayout-BO0Lolpp.js +1 -0
  83. package/dist/assets/{useDictation-C-waWdAq.js → useDictation-CwZ6a6i7.js} +1 -1
  84. package/dist/assets/{useEffectiveDirectory-CvDy8Tyu.js → useEffectiveDirectory-Bqgyt9OS.js} +1 -1
  85. package/dist/assets/{useMobileNavigationStore-BHAEAnfr.js → useMobileNavigationStore-BGHhBg7N.js} +13 -13
  86. package/dist/assets/{usePluginsStore-DvvZ8a3q.js → usePluginsStore-DT2-z09d.js} +1 -1
  87. package/dist/assets/{useWorkerHighlightedLines-DUpdltuG.js → useWorkerHighlightedLines-B8ypYliw.js} +1 -1
  88. package/dist/assets/{zh-CN-D9NAFloZ.js → zh-CN-KsbHpHjS.js} +1 -1
  89. package/dist/assets/{zh-TW-tuUKOuhs.js → zh-TW-SdNEiQ7a.js} +1 -1
  90. package/dist/index.html +6 -6
  91. package/dist/mini-chat.html +6 -6
  92. package/dist/mobile.html +6 -6
  93. package/package.json +1 -1
  94. package/server/index.js +2 -0
  95. package/server/lib/client-auth/pairing.js +2 -0
  96. package/server/lib/client-auth/pairing.test.js +29 -0
  97. package/server/lib/content-search/DOCUMENTATION.md +9 -0
  98. package/server/lib/content-search/routes.js +18 -1
  99. package/server/lib/content-search/routes.test.js +21 -0
  100. package/server/lib/content-search/runtime.js +7 -3
  101. package/server/lib/content-search/runtime.test.js +26 -0
  102. package/server/lib/gui-customization/DOCUMENTATION.md +21 -1
  103. package/server/lib/gui-customization/session-skill.js +2 -2
  104. package/server/lib/gui-customization/session-skill.test.js +3 -1
  105. package/server/lib/gui-customization/skill/SKILL.md +5 -1
  106. package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
  107. package/server/lib/gui-customization/skill/references/gui-api.md +4 -1
  108. package/server/lib/gui-customization/skill/references/icons.md +134 -0
  109. package/server/lib/gui-customization/skill/references/plugin-styles.md +112 -0
  110. package/server/lib/gui-customization/skill/references/ui-surfaces.md +2 -0
  111. package/server/lib/gui-customization/skill/references/work-status.md +110 -0
  112. package/server/lib/history-import/AGENT_CONNECT_LICENSE +21 -0
  113. package/server/lib/history-import/DOCUMENTATION.md +214 -0
  114. package/server/lib/history-import/dev-proxy.integration.test.js +56 -0
  115. package/server/lib/history-import/events.js +322 -0
  116. package/server/lib/history-import/events.test.js +110 -0
  117. package/server/lib/history-import/installations.js +39 -0
  118. package/server/lib/history-import/installations.test.js +24 -0
  119. package/server/lib/history-import/native.js +49 -0
  120. package/server/lib/history-import/native.test.js +42 -0
  121. package/server/lib/history-import/routes.js +48 -0
  122. package/server/lib/history-import/routes.test.js +55 -0
  123. package/server/lib/history-import/service.js +374 -0
  124. package/server/lib/history-import/service.test.js +508 -0
  125. package/server/lib/history-import/settings.js +146 -0
  126. package/server/lib/history-import/settings.test.js +88 -0
  127. package/server/lib/history-import/sources.js +184 -0
  128. package/server/lib/history-import/sources.test.js +190 -0
  129. package/server/lib/history-import/sqlite.js +187 -0
  130. package/server/lib/history-import/store.js +58 -0
  131. package/server/lib/history-import/store.test.js +72 -0
  132. package/server/lib/history-import/targets.js +24 -0
  133. package/server/lib/host-update/DOCUMENTATION.md +6 -0
  134. package/server/lib/host-update/routes.test.js +1 -1
  135. package/server/lib/notifications/native-stream.relay.test.js +1 -0
  136. package/server/lib/opencode/DOCUMENTATION.md +3 -0
  137. package/server/lib/opencode/core-routes.js +1 -0
  138. package/server/lib/opencode/feature-routes-runtime.js +11 -1
  139. package/server/lib/opencode/yuri-routes.js +1 -1
  140. package/server/lib/relay/DOCUMENTATION.md +1 -1
  141. package/server/lib/relay/host-client.js +3 -1
  142. package/server/lib/relay/host-client.test.js +1 -0
  143. package/server/lib/relay/reasoning-projection.e2e.test.ts +1 -0
  144. package/server/lib/relay/relay-server.e2e.test.ts +32 -17
  145. package/server/lib/relay/service.js +2 -0
  146. package/server/lib/relay/tunnel-host.js +26 -1
  147. package/server/lib/relay/tunnel-host.test.js +27 -3
  148. package/server/lib/remote-desktop/runtime.test.js +2 -2
  149. package/server/lib/ui-auth/DOCUMENTATION.md +3 -0
  150. package/server/lib/ui-auth/ui-auth.js +27 -0
  151. package/server/lib/ui-auth/ui-auth.test.js +42 -1
  152. package/server/plugin-gui-proxy.test.js +1 -1
  153. package/dist/assets/AssistantContactStatus-TjmyQVnm.js +0 -3
  154. package/dist/assets/Icon-BOYrvHyJ.js +0 -1
  155. package/dist/assets/MobileTabPageHeader-DEXatYlp.js +0 -2
  156. package/dist/assets/SetupTourDialog-CUzqT2sw.css +0 -1
  157. package/dist/assets/SetupTourDialog-CxgLkqcj.js +0 -1
  158. package/dist/assets/YuriWordmark-Cr1vkcue.js +0 -1
  159. package/dist/assets/host-CBfSyi4l.js +0 -1
  160. package/dist/assets/insertionBoundaries-DeBppC-3.js +0 -1
  161. package/dist/assets/main-BEYE305b.js +0 -2
  162. package/dist/assets/main-CYlSqUaZ.js +0 -169
  163. package/dist/assets/miniChat-CvclLJoR.js +0 -2
  164. package/dist/assets/mobile-BU75qxb4.js +0 -2
  165. package/dist/assets/multirun-4Pn9maGs.js +0 -3
  166. package/dist/assets/react-Bwr5-XPi.js +0 -1
  167. package/dist/assets/runtimeEndpointReset-CretKGD9.js +0 -149
  168. package/dist/assets/sessionLookup-BxPSStyI.js +0 -1
  169. package/dist/assets/src-CFd7QD5V.css +0 -2
  170. package/dist/assets/tour-DeA0Ksvj.js +0 -1
  171. package/dist/assets/useDesktopWindowControlsLayout-CpYYPIUB.js +0 -1
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-BufiC_bA.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-base-ui-CzHs0bHY.js","assets/useUIStore-BerIUSLP.js","assets/runtime-switch-DEZ1K7qW.js","assets/runtime-auth-DBn9yahL.js","assets/vendor-zustand-vDaAPGfl.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-DlzBev0S.js","assets/fileQueries-C2Rs6TPz.js","assets/vendor-tanstack-react-query-B-Wpqq5J.js","assets/vendor-tanstack-query-core-Y_YoRHtC.js","assets/queryRuntime-2dx7jbt9.js","assets/runtime-fetch-D0YWp3FJ.js","assets/vendor-markstream-react-DfLaSG3W.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/vendor-reactuses-core-DWo5Wn6R.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-CyJvQsp5.js","assets/desktop-BAmoc_34.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/bootstrap-C8paoQ0j.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/runtime-ead7P81A.js","assets/store-Diaywtmi.js","assets/tour-DeA0Ksvj.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useMobileNavigationStore-BHAEAnfr.js","assets/gitApiHttp-MWsHNHuo.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/runtime-file-resource-BP4P52ry.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/platform-sEg2IOLZ.js","assets/vendor-sonner-BEHGipm5.js","assets/useAssistantUIStore-D25VqrpK.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/useThemeSystem-CNzUUkFn.js","assets/tooltip-D3WmiZ7G.js","assets/url-MRa-FtQa.js","assets/useEffectiveDirectory-CvDy8Tyu.js","assets/image-loading-DKQOYtti.js","assets/image-loading-D9Z_BASK.css","assets/LoadingImage-D9r0ukc0.js","assets/ImageLoadingPlaceholder-DlosWH_9.js","assets/markdownHeightCache-B3MTnGA8.js","assets/dualLimitLru-D8Sphgua.js","assets/MarkdownRendererImpl-BEUnj4i_.js","assets/vendor-katex-DNVSTX6g.js","assets/themes-BgDJcxRc.js","assets/FadeInOnReveal-Bmxvkrf4.js","assets/markdownTheme-CHNl6tUv.js","assets/vendor-pierre-diffs-BFiZ3IhI.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/markdown-worker-oBGEB9Eg.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/fileReferenceActions-COS3jfbf.js","assets/toolHelpers-iEHVHQ9p.js","assets/fileReferenceParser-1HHDBUum.js","assets/MarkstreamRendererImpl-EpBnVy9J.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-vDaAPGfl.js";import{ot as n,st as r}from"./vendor-base-ui-CzHs0bHY.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as o}from"./button-CyJvQsp5.js";import{t as s}from"./useEffectiveDirectory-CvDy8Tyu.js";import{i as c,n as l,t as u}from"./markdownHeightCache-B3MTnGA8.js";var d=i(),f=e(r(),1),p=`yuri:chunk-import-reload`,m=250,h=3e4,g=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function _(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function v(e){let t=_(e);return g.some(e=>e.test(t))}function y(e){return`0.2.32-beta.4:${_(e).slice(0,500)}`}function b(e){if(typeof window>`u`)return;let t=Date.now(),n=y(e),r=null;try{let e=window.sessionStorage.getItem(p);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<h)){try{window.sessionStorage.setItem(p,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:_(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function x(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!v(e)||t>=n)break;await new Promise(e=>setTimeout(e,m*(t+1)))}throw v(r)&&b(r),r}var S=e=>(0,f.lazy)(()=>x(e)),C=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),w=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},T=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},E=`yuri:markstream-react`,D=e=>w(E,e),O=t(e=>({markstreamReactEnabled:D(),setMarkstreamReactEnabled:t=>{T(E,t),e({markstreamReactEnabled:t})}})),k=null,A=()=>(k??=a(()=>import(`./MarkstreamRendererImpl-BufiC_bA.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,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,79,80])).catch(e=>{throw k=null,e}),k),j=()=>{A().catch(()=>void 0)},M=null,N=()=>(M??=a(()=>import(`./MarkdownRendererImpl-BEUnj4i_.js`).then(e=>e.n),__vite__mapDeps([56,1,4,5,24,25,2,3,6,7,8,9,10,11,12,13,14,41,57,20,21,22,23,26,27,28,29,30,16,31,32,33,34,35,36,37,38,39,40,42,43,44,45,55,46,58,48,49,50,51,59,54,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79])).catch(e=>{throw M=null,e}),M),P=()=>{N().catch(()=>void 0),D()&&j()},F=class extends f.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},I=f.createContext(!0),L=()=>f.useContext(I),R=n(),z=S(()=>N().then(e=>({default:e.MarkdownRenderer}))),B=S(()=>A().then(e=>({default:e.MarkstreamRenderer}))),V=S(()=>N().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,d.c)(15),n=O(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,R.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,d.c)(13),n=L(),r=O(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(F,{fallback:a,children:(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!C(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,d.c)(4);if(!L()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{C as a,P as i,G as n,S as o,I as r,W as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-DGuW5ssC.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-base-ui-CzHs0bHY.js","assets/useUIStore-BerIUSLP.js","assets/runtime-switch-DEZ1K7qW.js","assets/runtime-auth-DBn9yahL.js","assets/vendor-zustand-vDaAPGfl.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-DlzBev0S.js","assets/fileQueries-C2Rs6TPz.js","assets/vendor-tanstack-react-query-B-Wpqq5J.js","assets/vendor-tanstack-query-core-Y_YoRHtC.js","assets/queryRuntime-2dx7jbt9.js","assets/runtime-fetch-D0YWp3FJ.js","assets/vendor-markstream-react-DfLaSG3W.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/vendor-reactuses-core-DWo5Wn6R.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-DSfiaJr4.js","assets/desktop-BAmoc_34.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/bootstrap-C8paoQ0j.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/runtime-ead7P81A.js","assets/store-BMijqCTE.js","assets/tour-DzjTres6.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useMobileNavigationStore-BGHhBg7N.js","assets/gitApiHttp-MWsHNHuo.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/runtime-file-resource-BP4P52ry.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/platform-sEg2IOLZ.js","assets/vendor-sonner-BEHGipm5.js","assets/useAssistantUIStore-D25VqrpK.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/useThemeSystem-CNzUUkFn.js","assets/tooltip-DBb-UCMU.js","assets/url-MRa-FtQa.js","assets/useEffectiveDirectory-Bqgyt9OS.js","assets/image-loading-DKQOYtti.js","assets/image-loading-D9Z_BASK.css","assets/LoadingImage-DTlBKb0t.js","assets/ImageLoadingPlaceholder-cfSg1uO0.js","assets/markdownHeightCache-Cinxvo8I.js","assets/dualLimitLru-D8Sphgua.js","assets/MarkdownRendererImpl-rflXjuIs.js","assets/vendor-katex-DNVSTX6g.js","assets/themes-BgDJcxRc.js","assets/FadeInOnReveal-DoQ1DHcy.js","assets/markdownTheme-CHNl6tUv.js","assets/vendor-pierre-diffs-BFiZ3IhI.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/markdown-worker-oBGEB9Eg.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/fileReferenceActions-COS3jfbf.js","assets/toolHelpers-iEHVHQ9p.js","assets/fileReferenceParser-1HHDBUum.js","assets/MarkstreamRendererImpl-EpBnVy9J.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-vDaAPGfl.js";import{ot as n,st as r}from"./vendor-base-ui-CzHs0bHY.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as o}from"./button-DSfiaJr4.js";import{t as s}from"./useEffectiveDirectory-Bqgyt9OS.js";import{i as c,n as l,t as u}from"./markdownHeightCache-Cinxvo8I.js";var d=i(),f=e(r(),1),p=`yuri:chunk-import-reload`,m=250,h=3e4,g=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function _(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function v(e){let t=_(e);return g.some(e=>e.test(t))}function y(e){return`0.2.32-beta.6:${_(e).slice(0,500)}`}function b(e){if(typeof window>`u`)return;let t=Date.now(),n=y(e),r=null;try{let e=window.sessionStorage.getItem(p);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<h)){try{window.sessionStorage.setItem(p,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:_(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function x(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!v(e)||t>=n)break;await new Promise(e=>setTimeout(e,m*(t+1)))}throw v(r)&&b(r),r}var S=e=>(0,f.lazy)(()=>x(e)),C=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),w=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},T=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},E=`yuri:markstream-react`,D=e=>w(E,e),O=t(e=>({markstreamReactEnabled:D(),setMarkstreamReactEnabled:t=>{T(E,t),e({markstreamReactEnabled:t})}})),k=null,A=()=>(k??=a(()=>import(`./MarkstreamRendererImpl-DGuW5ssC.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,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,79,80])).catch(e=>{throw k=null,e}),k),j=()=>{A().catch(()=>void 0)},M=null,N=()=>(M??=a(()=>import(`./MarkdownRendererImpl-rflXjuIs.js`).then(e=>e.n),__vite__mapDeps([56,1,4,5,24,25,2,3,6,7,8,9,10,11,12,13,14,41,57,20,21,22,23,26,27,28,29,30,16,31,32,33,34,35,36,37,38,39,40,42,43,44,45,55,46,58,48,49,50,51,59,54,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79])).catch(e=>{throw M=null,e}),M),P=()=>{N().catch(()=>void 0),D()&&j()},F=class extends f.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},I=f.createContext(!0),L=()=>f.useContext(I),R=n(),z=S(()=>N().then(e=>({default:e.MarkdownRenderer}))),B=S(()=>A().then(e=>({default:e.MarkstreamRenderer}))),V=S(()=>N().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,d.c)(15),n=O(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,R.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,d.c)(13),n=L(),r=O(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(F,{fallback:a,children:(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!C(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,d.c)(4);if(!L()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{C as a,P as i,G as n,S as o,I as r,W as t};
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./runtime-switch-DEZ1K7qW.js";import{T as r}from"./desktop-BAmoc_34.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{r as o}from"./useUIStore-BerIUSLP.js";import{n as s}from"./vendor-react-DlzBev0S.js";import{u as c}from"./fileQueries-C2Rs6TPz.js";import{t as l}from"./platform-sEg2IOLZ.js";import{n as u}from"./vendor-katex-DNVSTX6g.js";import{a as d,i as f,m as p}from"./vendor-reactuses-core-DWo5Wn6R.js";import{d as m,f as h,r as g}from"./button-CyJvQsp5.js";import{Vn as _}from"./useMobileNavigationStore-BHAEAnfr.js";import{t as v}from"./dualLimitLru-D8Sphgua.js";import{t as y}from"./useThemeSystem-CNzUUkFn.js";import{r as b}from"./themes-BgDJcxRc.js";import{a as x,i as S,n as C,r as w}from"./url-MRa-FtQa.js";import{n as ee}from"./useEffectiveDirectory-CvDy8Tyu.js";import{a as T,i as E,t as D}from"./image-loading-DKQOYtti.js";import{c as O,i as k,l as te,n as ne,o as A,r as re}from"./FadeInOnReveal-Bmxvkrf4.js";import{i as ie,r as j,t as ae}from"./markdownHeightCache-B3MTnGA8.js";import{n as oe,t as M}from"./markdownTheme-CHNl6tUv.js";import{i as N,n as P,t as F}from"./markdown-worker-oBGEB9Eg.js";import{t as se}from"./vendor-morphdom-BbKiNDAu.js";import{t as I}from"./vendor-dompurify-CeJNOzik.js";import{t as L}from"./vendor-pele-C1WTNWUm.js";import{t as R}from"./vendor-marked-WVekxjAN.js";import{t as z}from"./vendor-remend-C3cXc-tf.js";import{a as B,c as ce,f as V,g as le,h as H,i as U,l as W,n as ue,o as de,p as fe,t as pe,u as me}from"./fileReferenceActions-COS3jfbf.js";var G=t(a(),1),he=s(),K=new v({maxEntries:100,maxBytes:8388608}),ge=(e,t)=>{let{surface:n,interactive:r,primary:i,status:a}=t.colors,o={bg:n.elevated,fg:n.foreground,muted:n.mutedForeground,line:r.border,surface:n.muted,"surface-alt":n.background,border:r.border,accent:i.base,critical:a.error,error:a.error,"series-1":i.base,"series-2":a.info,"series-3":a.success,"series-4":a.warning,"series-5":a.error,"series-6":i.hover??i.base,"series-7":a.infoForeground,"series-8":a.successForeground},s=JSON.stringify([o,new Date().toDateString(),e]),c=K.get(s);if(c)return c;let l;try{let{svg:t}=L(e,{fontFamily:`system-ui, sans-serif`,autoDirection:!1,links:!1,images:!1}),n=I.sanitize(t,{USE_PROFILES:{svg:!0,svgFilters:!0},RETURN_DOM_FRAGMENT:!0}).querySelector(`svg`);if(!n)throw Error(`Missing diagram SVG`);for(let[e,t]of Object.entries(o))n.style.setProperty(`--pele-${e}`,t);l={svg:n.outerHTML}}catch{l={}}return K.set(s,l,(s.length+(l.svg?.length??0))*2),l},q=`data-md-stream-fence`,J=`data-md-stream-line`,_e=`data-md-stream-src`,ve=`data-md-stream-applied`,ye=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return r;return n},be=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-md-stream-line`)),xe=(e,t)=>{let n=document.createElement(`span`);return n.setAttribute(J,String(t)),n.className=`line`,n.innerHTML=e,n},Se=(e,t)=>{let n=be(e),r=ye(n.map(e=>e.innerHTML),t);if(n.length===0&&e.childNodes.length>0&&t.length>0){e.replaceChildren();for(let n=0;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
1
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./runtime-switch-DEZ1K7qW.js";import{T as r}from"./desktop-BAmoc_34.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{r as o}from"./useUIStore-BerIUSLP.js";import{n as s}from"./vendor-react-DlzBev0S.js";import{u as c}from"./fileQueries-C2Rs6TPz.js";import{t as l}from"./platform-sEg2IOLZ.js";import{n as u}from"./vendor-katex-DNVSTX6g.js";import{a as d,i as f,m as p}from"./vendor-reactuses-core-DWo5Wn6R.js";import{d as m,f as h,r as g}from"./button-DSfiaJr4.js";import{Vn as _}from"./useMobileNavigationStore-BGHhBg7N.js";import{t as v}from"./dualLimitLru-D8Sphgua.js";import{t as y}from"./useThemeSystem-CNzUUkFn.js";import{r as b}from"./themes-BgDJcxRc.js";import{a as x,i as S,n as C,r as w}from"./url-MRa-FtQa.js";import{n as ee}from"./useEffectiveDirectory-Bqgyt9OS.js";import{a as T,i as E,t as D}from"./image-loading-DKQOYtti.js";import{c as O,i as k,l as te,n as ne,o as A,r as re}from"./FadeInOnReveal-DoQ1DHcy.js";import{i as ie,r as j,t as ae}from"./markdownHeightCache-Cinxvo8I.js";import{n as oe,t as M}from"./markdownTheme-CHNl6tUv.js";import{i as N,n as P,t as F}from"./markdown-worker-oBGEB9Eg.js";import{t as se}from"./vendor-morphdom-BbKiNDAu.js";import{t as I}from"./vendor-dompurify-CeJNOzik.js";import{t as L}from"./vendor-pele-C1WTNWUm.js";import{t as R}from"./vendor-marked-WVekxjAN.js";import{t as z}from"./vendor-remend-C3cXc-tf.js";import{a as B,c as ce,f as V,g as le,h as H,i as U,l as W,n as ue,o as de,p as fe,t as pe,u as me}from"./fileReferenceActions-COS3jfbf.js";var G=t(a(),1),he=s(),K=new v({maxEntries:100,maxBytes:8388608}),ge=(e,t)=>{let{surface:n,interactive:r,primary:i,status:a}=t.colors,o={bg:n.elevated,fg:n.foreground,muted:n.mutedForeground,line:r.border,surface:n.muted,"surface-alt":n.background,border:r.border,accent:i.base,critical:a.error,error:a.error,"series-1":i.base,"series-2":a.info,"series-3":a.success,"series-4":a.warning,"series-5":a.error,"series-6":i.hover??i.base,"series-7":a.infoForeground,"series-8":a.successForeground},s=JSON.stringify([o,new Date().toDateString(),e]),c=K.get(s);if(c)return c;let l;try{let{svg:t}=L(e,{fontFamily:`system-ui, sans-serif`,autoDirection:!1,links:!1,images:!1}),n=I.sanitize(t,{USE_PROFILES:{svg:!0,svgFilters:!0},RETURN_DOM_FRAGMENT:!0}).querySelector(`svg`);if(!n)throw Error(`Missing diagram SVG`);for(let[e,t]of Object.entries(o))n.style.setProperty(`--pele-${e}`,t);l={svg:n.outerHTML}}catch{l={}}return K.set(s,l,(s.length+(l.svg?.length??0))*2),l},q=`data-md-stream-fence`,J=`data-md-stream-line`,_e=`data-md-stream-src`,ve=`data-md-stream-applied`,ye=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return r;return n},be=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-md-stream-line`)),xe=(e,t)=>{let n=document.createElement(`span`);return n.setAttribute(J,String(t)),n.className=`line`,n.innerHTML=e,n},Se=(e,t)=>{let n=be(e),r=ye(n.map(e=>e.innerHTML),t);if(n.length===0&&e.childNodes.length>0&&t.length>0){e.replaceChildren();for(let n=0;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
2
2
  `)),e.appendChild(xe(t[n]??``,n));return{reused:0,replaced:0,added:t.length,removed:0}}let i=0;if(r<n.length&&r<t.length){let e=n[r];e&&(e.innerHTML=t[r]??``,e.setAttribute(J,String(r)),i=1)}let a=0;for(let e=n.length-1;e>=r+i;--e){let t=n[e]?.previousSibling;t?.nodeType===Node.TEXT_NODE&&t.remove(),n[e]?.remove(),a+=1}let o=0;for(let n=r+i;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
3
3
  `)),e.appendChild(xe(t[n]??``,n)),o+=1;return{reused:r,replaced:i,added:o,removed:a}},Ce=e=>{if(e.includes(`data-md-stream-fence=`))return e;let t=e.toLowerCase().lastIndexOf(`<pre`);return t<0?e:`${e.slice(0,t)}${e.slice(t).replace(/<pre\b/i,`<pre ${q}="true"`)}`},we=(e,t)=>{if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement)||e.getAttribute(`data-md-stream-fence`)!==`true`||t.getAttribute(`data-md-stream-fence`)!==`true`)return!1;let n=e.tagName===`CODE`?e:e.querySelector(`code`),r=t.tagName===`CODE`?t:t.querySelector(`code`);return n instanceof HTMLElement&&r instanceof HTMLElement&&n.setAttribute(_e,r.textContent??``),!0},Te=e=>e.getAttribute(`data-md-stream-src`)??e.textContent??``,Ee=e=>{let t=e.querySelectorAll(`pre[${q}="true"]`),n=[];return t.forEach(e=>{let t=e.querySelector(`code`);t instanceof HTMLElement&&n.push(t)}),n},De=e=>e.closest(`pre`)?.getAttribute(`data-md-lang`)||e.className.match(/language-([^\s"]+)/)?.[1]||`text`,Oe=async(e,t,n)=>{if(n?.signal?.aborted)return;let r=Ee(e);await Promise.all(r.map(async r=>{let i=Te(r);if(!i||n?.signal?.aborted||r.getAttribute(`data-md-stream-applied`)===i)return;let a=De(r);if(a===`mermaid`)return;let o=await t(i,a,n);if(!(n?.signal?.aborted||!e.contains(r)||Te(r)!==i)){if(!o){let e=be(r),t=document.createElement(`span`);Se(r,i.split(`
4
4
  `).map((n,r)=>{let i=e[r];return i?.textContent===n?i.innerHTML:(t.textContent=n,t.innerHTML)}));return}Se(r,o),r.setAttribute(ve,i),r.removeAttribute(_e)}}))},ke=`text`,Ae=/^(\d+):(\d+):(.+)$/,je={ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,vue:`vue`,svelte:`svelte`,astro:`astro`,json:`json`,jsonc:`jsonc`,json5:`json5`,jsonl:`json`,ndjson:`json`,geojson:`json`,yaml:`yaml`,yml:`yaml`,toml:`toml`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`properties`,env:`dotenv`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,styl:`stylus`,html:`html`,htm:`html`,xml:`xml`,svg:`xml`,md:`markdown`,markdown:`markdown`,mdown:`markdown`,mkd:`markdown`,mdx:`mdx`,py:`python`,pyw:`python`,pyi:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,kts:`kotlin`,swift:`swift`,scala:`scala`,c:`c`,h:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,m:`objective-c`,mm:`objective-cpp`,cs:`csharp`,fs:`fsharp`,fsx:`fsharp`,vb:`vb`,php:`php`,pl:`perl`,pm:`perl`,lua:`lua`,r:`r`,dart:`dart`,ex:`elixir`,exs:`elixir`,erl:`erlang`,hrl:`erlang`,hs:`haskell`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,groovy:`groovy`,jl:`julia`,ml:`ocaml`,mli:`ocaml`,zig:`zig`,nix:`nix`,sol:`solidity`,prisma:`prisma`,proto:`proto`,graphql:`graphql`,gql:`graphql`,sql:`sql`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,fish:`shellscript`,ps1:`powershell`,psm1:`powershell`,bat:`bat`,cmd:`bat`,tf:`terraform`,tfvars:`terraform`,hcl:`hcl`,diff:`diff`,patch:`diff`,csv:`csv`,tex:`latex`,vim:`viml`,wgsl:`wgsl`,glsl:`glsl`,wat:`wasm`,mermaid:`mermaid`,mmd:`mermaid`},Me={dockerfile:`docker`,containerfile:`docker`,makefile:`make`,gnumakefile:`make`,"cmakelists.txt":`cmake`,gemfile:`ruby`,rakefile:`ruby`,podfile:`ruby`,".env":`dotenv`,".bashrc":`shellscript`,".zshrc":`shellscript`,".profile":`shellscript`},Ne=e=>{let t=e.split(/[\\/]/).pop()?.toLowerCase()??``;if(!t)return ke;let n=Me[t];if(n)return n;let r=t.lastIndexOf(`.`);return r<=0?ke:je[t.slice(r+1)]??ke},Pe=e=>{let t=e?.trim()??``;if(!t)return{lang:ke,label:ke,reference:!1};let n=Ae.exec(t);if(!n){let e=t.toLowerCase();return{lang:e,label:e,reference:!1}}let[,r=``,i=``,a=``]=n,o=r===i?r:`${r}-${i}`;return{lang:Ne(a),label:`${a}:${o}`,reference:!0}},Fe=e=>e===` `||e===` `||e===`
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{r}from"./useUIStore-BerIUSLP.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{u as a}from"./fileQueries-C2Rs6TPz.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./vendor-markstream-react-DfLaSG3W.js";import{a as f,i as p,m}from"./vendor-reactuses-core-DWo5Wn6R.js";import{r as h}from"./button-CyJvQsp5.js";import{Vn as g}from"./useMobileNavigationStore-BHAEAnfr.js";import{t as _}from"./useThemeSystem-CNzUUkFn.js";import{i as v,n as y,t as b}from"./tooltip-D3WmiZ7G.js";import{a as x,r as S}from"./url-MRa-FtQa.js";import{n as C}from"./useEffectiveDirectory-CvDy8Tyu.js";import{o as w}from"./image-loading-DKQOYtti.js";import{t as T}from"./LoadingImage-D9r0ukc0.js";import{r as ee,t as E}from"./markdownHeightCache-B3MTnGA8.js";import{r as D,t as O}from"./MarkdownRendererImpl-BEUnj4i_.js";import{n as k}from"./fileReferenceParser-1HHDBUum.js";import{a as A,c as j,f as M,h as N,i as P,l as F,m as I,o as L,s as te,t as ne}from"./fileReferenceActions-COS3jfbf.js";var R=e(n(),1),z=`img:not([data-md-link-favicon="true"])`,B=e=>e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,V=(e,t)=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;let n=e.target;if(!(n instanceof Element))return;let r=n.closest(z);if(r instanceof HTMLImageElement&&t.onShowPopup){let n=e.currentTarget;if(!(n instanceof HTMLElement))return;let i=Array.from(n.querySelectorAll(z)).map(e=>({url:B(e),filename:e.alt||B(e)||void 0})).filter(e=>e.url),a=B(r),o=i.findIndex(e=>e.url===a);if(!a)return;e.preventDefault(),e.stopPropagation(),t.onShowPopup({open:!0,title:r.alt||a,content:``,previewSource:r,image:{url:a,...t.effectiveDirectory?{directory:t.effectiveDirectory}:{},filename:r.alt||a,gallery:i,index:o>=0?o:0}});return}if(t.fileReference){let r=n.closest(M);if(r instanceof HTMLElement){e.preventDefault(),e.stopPropagation(),L(r,t.fileReference);return}}let i=n.closest(`a[href]`);if(!(i instanceof HTMLAnchorElement))return;let a=i.getAttribute(`href`)??``;if(N(a)){e.preventDefault(),e.stopPropagation(),t.fileReference&&I(a)&&L(i,t.fileReference);return}if(!S(a))return;e.preventDefault(),e.stopPropagation();let o=(t.effectiveDirectory||``).trim();if(!g()&&o&&t.openInAppBrowser){t.openInAppBrowser(o,a);return}x(a)},re=(e,t)=>{if(e.key!==`Enter`&&e.key!==` `||!t.fileReference)return;let n=e.target;if(!(n instanceof Element))return;let r=n.closest(M);!(r instanceof HTMLElement)||r.getAttribute(`data-yuri-file-link`)!==`true`||(e.preventDefault(),e.stopPropagation(),L(r,t.fileReference))},H=i(),ie=(e,t)=>{let n=t>=2?e.slice(t-2,t):``;return(t>=1?e.charAt(t-1):``)===`:`||n===`:/`},ae=e=>{if(!e.includes(`/`)||!e.includes(`.`))return[{kind:`text`,value:e}];k.lastIndex=0;let t=[],n=0,r=k.exec(e);for(;r;){let i=r[0];if(!i||ie(e,r.index)||!I(i)){r=k.exec(e);continue}r.index>n&&t.push({kind:`text`,value:e.slice(n,r.index)}),t.push({kind:`path`,value:i}),n=r.index+i.length,r=k.exec(e)}return n===0?[{kind:`text`,value:e}]:(n<e.length&&t.push({kind:`text`,value:e.slice(n)}),t)},U=t(),W=R.createContext({enabled:!1,insideLink:!1,isMobileSurface:!1,effectiveDirectory:``,preferRuntimeEditor:!1,slots:{used:0,limit:0}}),G=e=>{let t=(0,H.c)(11),{enabled:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,content:s,children:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=g(),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u={used:0,limit:P()},t[1]=u):u=t[1];let d;t[2]!==i||t[3]!==r||t[4]!==n||t[5]!==o||t[6]!==a?(d={enabled:n,insideLink:!1,isMobileSurface:l,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,slots:u},t[2]=i,t[3]=r,t[4]=n,t[5]=o,t[6]=a,t[7]=d):d=t[7];let f=d,p;return t[8]!==c||t[9]!==f?(p=(0,U.jsx)(W.Provider,{value:f,children:c}),t[8]=c,t[9]=f,t[10]=p):p=t[10],p},K=({raw:e,referenceKind:t,children:n})=>{let r=R.useContext(W),i=A(e,r.effectiveDirectory,t),a=R.useRef(!1);r.enabled&&i&&!a.current&&r.slots.used<r.slots.limit&&(r.slots.used+=1,a.current=!0);let[o,s]=R.useState(i?te(i.resolvedPath,r.effectiveDirectory)??null:null),c=i?.resolvedPath;if(R.useEffect(()=>{if(!r.enabled||!c||!a.current)return;let e=!1;return j(c,r.effectiveDirectory).then(t=>{e||s(t)}).catch(()=>{}),()=>{e=!0}},[r.enabled,r.effectiveDirectory,c]),!i)return n??e;let l=!!(a.current&&o&&F(i.resolvedPath,o,r.isMobileSurface));return(0,U.jsx)(`span`,{"data-yuri-block-path-token":`true`,...l?{"data-yuri-file-link":`true`,"data-yuri-file-ref":e,"data-yuri-file-path":i.resolvedPath,"data-yuri-file-binary":String(o?.isBinary===!0),title:ne,...n?{}:{role:`button`,tabIndex:0}}:{},children:n??e})};function q(e){let t=(0,H.c)(12),n=R.useContext(W),r=e.node.content??``;if(!n.enabled||n.insideLink){let n;return t[0]===e?n=t[1]:(n=(0,U.jsx)(u,{...e}),t[0]=e,t[1]=n),n}let i,a;if(t[2]!==r||t[3]!==e){a=Symbol.for(`react.early_return_sentinel`);bb0:{let n=ae(r);if(n.length===1&&n[0]?.kind!==`path`){let n;t[6]===e?n=t[7]:(n=(0,U.jsx)(u,{...e}),t[6]=e,t[7]=n),a=n;break bb0}let o;t[8]===e?o=t[9]:(o=(t,n)=>t.kind===`path`?(0,U.jsx)(K,{raw:t.value},`path-${n}-${t.value}`):(0,U.jsx)(u,{...e,node:{...e.node,content:t.value}},`text-${n}`),t[8]=e,t[9]=o),i=n.map(o)}t[2]=r,t[3]=e,t[4]=i,t[5]=a}else i=t[4],a=t[5];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[10]===i?o=t[11]:(o=(0,U.jsx)(U.Fragment,{children:i}),t[10]=i,t[11]=o),o}function oe(e){let t=(0,H.c)(7),n=R.useContext(W),r=e.node.code??``;if(!n.enabled||!I(r)){let n;return t[0]===e?n=t[1]:(n=(0,U.jsx)(s,{...e}),t[0]=e,t[1]=n),n}let i;t[2]===r?i=t[3]:(i=(0,U.jsx)(K,{raw:r}),t[2]=r,t[3]=i);let a;return t[4]!==e||t[5]!==i?(a=(0,U.jsx)(s,{...e,children:i}),t[4]=e,t[5]=i,t[6]=a):a=t[6],a}function se(e){let t=(0,H.c)(20),n=R.useContext(W),r=e.node.href??``,i;t[0]!==n.enabled||t[1]!==r?(i=n.enabled&&I(r),t[0]=n.enabled,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===e?o=t[4]:(o=(0,U.jsx)(c,{...e,showTooltip:!1}),t[3]=e,t[4]=o);let s=o,l;t[5]!==n.isMobileSurface||t[6]!==r||t[7]!==s||t[8]!==e.node.title||t[9]!==e.showTooltip?(l=n.isMobileSurface||e.showTooltip===!1?s:(0,U.jsxs)(b,{children:[(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(`span`,{children:s})}),(0,U.jsx)(y,{children:e.node.title||r})]}),t[5]=n.isMobileSurface,t[6]=r,t[7]=s,t[8]=e.node.title,t[9]=e.showTooltip,t[10]=l):l=t[10];let u=l,d;t[11]===n?d=t[12]:(d={...n,insideLink:!0},t[11]=n,t[12]=d);let f;t[13]!==u||t[14]!==a||t[15]!==r?(f=a?(0,U.jsx)(K,{raw:r,referenceKind:`href`,children:u}):u,t[13]=u,t[14]=a,t[15]=r,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,U.jsx)(W.Provider,{value:d,children:f}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}var J=/^[ \t]{0,3}(`{3,}|~{3,})/,ce=e=>{if(typeof e!=`string`||e.length===0)return!1;let t=e.split(/\r?\n/,1)[0]??``;return J.test(t)},le=e=>{let t=0,n=0,r=e.match(/[`~]+/g)??[];for(let e of r)e[0]==="`"?t=Math.max(t,e.length):n=Math.max(n,e.length);return t>=3?"`".repeat(Math.max(3,t+1)):n>=3&&t===0?"```":n>=3?`~`.repeat(Math.max(3,n+1)):"```"},ue=e=>{let t=typeof e.raw==`string`?e.raw:``;if(ce(t))return t.endsWith(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{r}from"./useUIStore-BerIUSLP.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{u as a}from"./fileQueries-C2Rs6TPz.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./vendor-markstream-react-DfLaSG3W.js";import{a as f,i as p,m}from"./vendor-reactuses-core-DWo5Wn6R.js";import{r as h}from"./button-DSfiaJr4.js";import{Vn as g}from"./useMobileNavigationStore-BGHhBg7N.js";import{t as _}from"./useThemeSystem-CNzUUkFn.js";import{i as v,n as y,t as b}from"./tooltip-DBb-UCMU.js";import{a as x,r as S}from"./url-MRa-FtQa.js";import{n as C}from"./useEffectiveDirectory-Bqgyt9OS.js";import{o as w}from"./image-loading-DKQOYtti.js";import{t as T}from"./LoadingImage-DTlBKb0t.js";import{r as ee,t as E}from"./markdownHeightCache-Cinxvo8I.js";import{r as D,t as O}from"./MarkdownRendererImpl-rflXjuIs.js";import{n as k}from"./fileReferenceParser-1HHDBUum.js";import{a as A,c as j,f as M,h as N,i as P,l as F,m as I,o as L,s as te,t as ne}from"./fileReferenceActions-COS3jfbf.js";var R=e(n(),1),z=`img:not([data-md-link-favicon="true"])`,B=e=>e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,V=(e,t)=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;let n=e.target;if(!(n instanceof Element))return;let r=n.closest(z);if(r instanceof HTMLImageElement&&t.onShowPopup){let n=e.currentTarget;if(!(n instanceof HTMLElement))return;let i=Array.from(n.querySelectorAll(z)).map(e=>({url:B(e),filename:e.alt||B(e)||void 0})).filter(e=>e.url),a=B(r),o=i.findIndex(e=>e.url===a);if(!a)return;e.preventDefault(),e.stopPropagation(),t.onShowPopup({open:!0,title:r.alt||a,content:``,previewSource:r,image:{url:a,...t.effectiveDirectory?{directory:t.effectiveDirectory}:{},filename:r.alt||a,gallery:i,index:o>=0?o:0}});return}if(t.fileReference){let r=n.closest(M);if(r instanceof HTMLElement){e.preventDefault(),e.stopPropagation(),L(r,t.fileReference);return}}let i=n.closest(`a[href]`);if(!(i instanceof HTMLAnchorElement))return;let a=i.getAttribute(`href`)??``;if(N(a)){e.preventDefault(),e.stopPropagation(),t.fileReference&&I(a)&&L(i,t.fileReference);return}if(!S(a))return;e.preventDefault(),e.stopPropagation();let o=(t.effectiveDirectory||``).trim();if(!g()&&o&&t.openInAppBrowser){t.openInAppBrowser(o,a);return}x(a)},re=(e,t)=>{if(e.key!==`Enter`&&e.key!==` `||!t.fileReference)return;let n=e.target;if(!(n instanceof Element))return;let r=n.closest(M);!(r instanceof HTMLElement)||r.getAttribute(`data-yuri-file-link`)!==`true`||(e.preventDefault(),e.stopPropagation(),L(r,t.fileReference))},H=i(),ie=(e,t)=>{let n=t>=2?e.slice(t-2,t):``;return(t>=1?e.charAt(t-1):``)===`:`||n===`:/`},ae=e=>{if(!e.includes(`/`)||!e.includes(`.`))return[{kind:`text`,value:e}];k.lastIndex=0;let t=[],n=0,r=k.exec(e);for(;r;){let i=r[0];if(!i||ie(e,r.index)||!I(i)){r=k.exec(e);continue}r.index>n&&t.push({kind:`text`,value:e.slice(n,r.index)}),t.push({kind:`path`,value:i}),n=r.index+i.length,r=k.exec(e)}return n===0?[{kind:`text`,value:e}]:(n<e.length&&t.push({kind:`text`,value:e.slice(n)}),t)},U=t(),W=R.createContext({enabled:!1,insideLink:!1,isMobileSurface:!1,effectiveDirectory:``,preferRuntimeEditor:!1,slots:{used:0,limit:0}}),G=e=>{let t=(0,H.c)(11),{enabled:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,content:s,children:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=g(),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u={used:0,limit:P()},t[1]=u):u=t[1];let d;t[2]!==i||t[3]!==r||t[4]!==n||t[5]!==o||t[6]!==a?(d={enabled:n,insideLink:!1,isMobileSurface:l,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,slots:u},t[2]=i,t[3]=r,t[4]=n,t[5]=o,t[6]=a,t[7]=d):d=t[7];let f=d,p;return t[8]!==c||t[9]!==f?(p=(0,U.jsx)(W.Provider,{value:f,children:c}),t[8]=c,t[9]=f,t[10]=p):p=t[10],p},K=({raw:e,referenceKind:t,children:n})=>{let r=R.useContext(W),i=A(e,r.effectiveDirectory,t),a=R.useRef(!1);r.enabled&&i&&!a.current&&r.slots.used<r.slots.limit&&(r.slots.used+=1,a.current=!0);let[o,s]=R.useState(i?te(i.resolvedPath,r.effectiveDirectory)??null:null),c=i?.resolvedPath;if(R.useEffect(()=>{if(!r.enabled||!c||!a.current)return;let e=!1;return j(c,r.effectiveDirectory).then(t=>{e||s(t)}).catch(()=>{}),()=>{e=!0}},[r.enabled,r.effectiveDirectory,c]),!i)return n??e;let l=!!(a.current&&o&&F(i.resolvedPath,o,r.isMobileSurface));return(0,U.jsx)(`span`,{"data-yuri-block-path-token":`true`,...l?{"data-yuri-file-link":`true`,"data-yuri-file-ref":e,"data-yuri-file-path":i.resolvedPath,"data-yuri-file-binary":String(o?.isBinary===!0),title:ne,...n?{}:{role:`button`,tabIndex:0}}:{},children:n??e})};function q(e){let t=(0,H.c)(12),n=R.useContext(W),r=e.node.content??``;if(!n.enabled||n.insideLink){let n;return t[0]===e?n=t[1]:(n=(0,U.jsx)(u,{...e}),t[0]=e,t[1]=n),n}let i,a;if(t[2]!==r||t[3]!==e){a=Symbol.for(`react.early_return_sentinel`);bb0:{let n=ae(r);if(n.length===1&&n[0]?.kind!==`path`){let n;t[6]===e?n=t[7]:(n=(0,U.jsx)(u,{...e}),t[6]=e,t[7]=n),a=n;break bb0}let o;t[8]===e?o=t[9]:(o=(t,n)=>t.kind===`path`?(0,U.jsx)(K,{raw:t.value},`path-${n}-${t.value}`):(0,U.jsx)(u,{...e,node:{...e.node,content:t.value}},`text-${n}`),t[8]=e,t[9]=o),i=n.map(o)}t[2]=r,t[3]=e,t[4]=i,t[5]=a}else i=t[4],a=t[5];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[10]===i?o=t[11]:(o=(0,U.jsx)(U.Fragment,{children:i}),t[10]=i,t[11]=o),o}function oe(e){let t=(0,H.c)(7),n=R.useContext(W),r=e.node.code??``;if(!n.enabled||!I(r)){let n;return t[0]===e?n=t[1]:(n=(0,U.jsx)(s,{...e}),t[0]=e,t[1]=n),n}let i;t[2]===r?i=t[3]:(i=(0,U.jsx)(K,{raw:r}),t[2]=r,t[3]=i);let a;return t[4]!==e||t[5]!==i?(a=(0,U.jsx)(s,{...e,children:i}),t[4]=e,t[5]=i,t[6]=a):a=t[6],a}function se(e){let t=(0,H.c)(20),n=R.useContext(W),r=e.node.href??``,i;t[0]!==n.enabled||t[1]!==r?(i=n.enabled&&I(r),t[0]=n.enabled,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===e?o=t[4]:(o=(0,U.jsx)(c,{...e,showTooltip:!1}),t[3]=e,t[4]=o);let s=o,l;t[5]!==n.isMobileSurface||t[6]!==r||t[7]!==s||t[8]!==e.node.title||t[9]!==e.showTooltip?(l=n.isMobileSurface||e.showTooltip===!1?s:(0,U.jsxs)(b,{children:[(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(`span`,{children:s})}),(0,U.jsx)(y,{children:e.node.title||r})]}),t[5]=n.isMobileSurface,t[6]=r,t[7]=s,t[8]=e.node.title,t[9]=e.showTooltip,t[10]=l):l=t[10];let u=l,d;t[11]===n?d=t[12]:(d={...n,insideLink:!0},t[11]=n,t[12]=d);let f;t[13]!==u||t[14]!==a||t[15]!==r?(f=a?(0,U.jsx)(K,{raw:r,referenceKind:`href`,children:u}):u,t[13]=u,t[14]=a,t[15]=r,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,U.jsx)(W.Provider,{value:d,children:f}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}var J=/^[ \t]{0,3}(`{3,}|~{3,})/,ce=e=>{if(typeof e!=`string`||e.length===0)return!1;let t=e.split(/\r?\n/,1)[0]??``;return J.test(t)},le=e=>{let t=0,n=0,r=e.match(/[`~]+/g)??[];for(let e of r)e[0]==="`"?t=Math.max(t,e.length):n=Math.max(n,e.length);return t>=3?"`".repeat(Math.max(3,t+1)):n>=3&&t===0?"```":n>=3?`~`.repeat(Math.max(3,n+1)):"```"},ue=e=>{let t=typeof e.raw==`string`?e.raw:``;if(ce(t))return t.endsWith(`
2
2
  `)?t:`${t}\n`;let n=(e.language??``).trim(),r=e.code??``,i=le(r),a=r.endsWith(`
3
3
  `)?r:`${r}\n`;return e.loading?`${i}${n}\n${a}`:`${i}${n}\n${a}${i}\n`},de=e=>{let t=e.partId?`part-${e.partId}`:`body`,n=e.indexKey!==void 0&&e.indexKey!==null&&String(e.indexKey).length>0?String(e.indexKey):e.language&&e.language.length>0?e.language:`code`;return`${e.messageId}:${t}:code:${n}`},Y=R.createContext({messageId:`markstream`,isStreaming:!1,disableStreamAnimation:!1,variant:`assistant`,enableFileReferences:!0}),X=()=>R.useContext(Y);function fe(e,t){let n=5381;for(let e=0;e<t.length;e+=1)n=Math.imul(n,33)^t.charCodeAt(e);return`${e}:${(n>>>0).toString(36)}:${t.length}`}function Z(e){let t=(0,H.c)(7),n;if(t[0]!==e.indexKey||t[1]!==e.node.code||t[2]!==e.node.language){let r=(e.node.language??``).trim().toLowerCase()||`diagram`;n=e.indexKey??fe(r,e.node.code??``),t[0]=e.indexKey,t[1]=e.node.code,t[2]=e.node.language,t[3]=n}else n=t[3];let r=n,i;return t[4]!==r||t[5]!==e?(i=(0,U.jsx)(Q,{...e,indexKey:r}),t[4]=r,t[5]=e,t[6]=i):i=t[6],i}function Q(e){let t=(0,H.c)(21),n=X(),r=e.node.language??``,i=e.node.code??``,a=e.node.raw??``,o=e.node.loading===!0||e.loading===!0,s;t[0]!==i||t[1]!==r||t[2]!==o||t[3]!==a?(s=ue({type:`code_block`,language:r,code:i,raw:a,loading:o}),t[0]=i,t[1]=r,t[2]=o,t[3]=a,t[4]=s):s=t[4];let c=s,l=n.isStreaming||e.loading===!0||e.node.loading===!0,u=n.part?.id,d;t[5]!==n.messageId||t[6]!==e.indexKey||t[7]!==e.node.language||t[8]!==u?(d=de({messageId:n.messageId,partId:u,indexKey:e.indexKey,language:e.node.language}),t[5]=n.messageId,t[6]=e.indexKey,t[7]=e.node.language,t[8]=u,t[9]=d):d=t[9];let f=d,p=n.enableFileReferences&&!l,m;t[10]!==c||t[11]!==n.disableStreamAnimation||t[12]!==n.onShowPopup||t[13]!==n.variant||t[14]!==f||t[15]!==l||t[16]!==p?(m=(0,U.jsx)(O,{content:c,messageId:f,isAnimated:!1,skipFadeIn:!0,isStreaming:l,disableStreamAnimation:n.disableStreamAnimation,variant:n.variant,onShowPopup:n.onShowPopup,enableFileReferences:p}),t[10]=c,t[11]=n.disableStreamAnimation,t[12]=n.onShowPopup,t[13]=n.variant,t[14]=f,t[15]=l,t[16]=p,t[17]=m):m=t[17];let h;return t[18]!==f||t[19]!==m?(h=(0,U.jsx)(`div`,{className:`yuri-markstream-code-host min-w-0 w-full`,"data-yuri-markstream-code":`markdown-impl`,"data-yuri-markstream-code-id":f,children:m}),t[18]=f,t[19]=m,t[20]=h):h=t[20],h}function pe(e){let t=(0,H.c)(9),{node:n}=e,r=C()??``,i=w(n.src,r),{onShowPopup:a}=X(),o=p(me),s=i.source||void 0,c=n.title??void 0,l=a?`button`:void 0,u=a?0:void 0,d=a?o:void 0,f;return t[0]!==n.alt||t[1]!==n.src||t[2]!==i.error||t[3]!==s||t[4]!==c||t[5]!==l||t[6]!==u||t[7]!==d?(f=(0,U.jsx)(T,{contentFrame:!0,src:s,resourceError:i.error,"data-md-image-source":n.src,alt:n.alt,title:c,className:`rounded-lg`,role:l,tabIndex:u,onKeyDown:d}),t[0]=n.alt,t[1]=n.src,t[2]=i.error,t[3]=s,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f):f=t[8],f}function me(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.currentTarget.click())}function he(e){let t=(0,H.c)(4);if(e.node.type===`code_block`){let n=e,r;return t[0]===n?r=t[1]:(r=(0,U.jsx)(Q,{...n}),t[0]=n,t[1]=r),r}let n=e,r;return t[2]===n?r=t[3]:(r=(0,U.jsx)(pe,{...n}),t[2]=n,t[3]=r),r}var $=!1;function ge(e){return e.node?.type===`code_block`?R.createElement(Q,e):R.createElement(q,e)}var _e=()=>{$||($=!0,o({text:ge,inline_code:oe,link:se,image:he,code_block:l(Q,`block`),mermaid:l(Z,`block`),d2:l(Z,`block`),d2lang:l(Z,`block`),infographic:l(Z,`block`)}))},ve={maxLiveNodes:0,liveNodeBuffer:0,batchRendering:!1,deferNodesUntilVisible:!1,viewportPriority:!1,smoothStreaming:!1,typewriter:!1,fade:!1};_e();var ye=e=>(e.inline.ruler.at(`math`,(e,t)=>{let n=e.src.slice(e.pos),r=D(n),i=n.startsWith(`\\(`)?/^\\\(([\s\S]+?)\\\)/.exec(n):null,a=r?.raw??i?.[0],o=r?.text??i?.[1];if(!a||!o)return!1;if(!t){let t=e.push(`math_inline`,`math`,0);t.content=o,t.markup=r?r.display?`$$`:`$`:`\\(\\)`}return e.pos+=a.length,!0}),e),be=e=>e===`tool`?`markdown-content markdown-tool yuri-markstream-host`:e===`reasoning`?`markdown-content markdown-reasoning yuri-markstream-host`:`markdown-content leading-relaxed yuri-markstream-host`,xe=R.memo(({content:e,part:t,messageId:n,className:i,isStreaming:o=!1,disableStreamAnimation:s=!1,variant:c=`assistant`,onShowPopup:l,enableFileReferences:u=!0})=>{let g=_()?.currentTheme.metadata.variant===`dark`,{editor:v,runtime:y}=a(),b=C()??``,x=R.useRef(null),S=t?.id?`yuri-ms-${t.id}`:`yuri-ms-${n}`,w=E(e,`markstream:${c}`),T=!o,D=u&&!o,O=D?{effectiveDirectory:b,editor:v,preferRuntimeEditor:y.isVSCode,onShowPopup:l}:void 0,k=R.useMemo(()=>({messageId:n,part:t,isStreaming:o,disableStreamAnimation:s,variant:c,onShowPopup:l,enableFileReferences:u}),[n,t,o,s,c,l,u]),A=R.useRef(T);A.current=T;let j=R.useRef(w);j.current=w;let M=p(e=>{if(!A.current)return;let t=e[0];if(!t)return;let n=t.borderBoxSize?.[0],r=n?n.blockSize:t.contentRect.height,i=n?n.inlineSize:t.contentRect.width;ee(j.current,r,i)});m(x,M);let N=p((e,t)=>{r.getState().openContextBrowser(e,t)}),P=p(e=>{V(e,{onShowPopup:l,fileReference:O,effectiveDirectory:b,openInAppBrowser:N})}),F=p(e=>{re(e,{fileReference:O})});return f(`click`,P,x),f(`keydown`,F,x),(0,U.jsx)(`div`,{ref:x,className:h(`relative break-words w-full min-w-0`,be(c),i),"data-markdown-ready":`true`,"data-markdown-hydration":`ready`,"data-yuri-markdown-engine":`markstream`,"data-yuri-markstream-virtual":`off`,children:(0,U.jsx)(Y.Provider,{value:k,children:(0,U.jsx)(G,{enabled:D,effectiveDirectory:b,editor:v,preferRuntimeEditor:y.isVSCode,onShowPopup:l,content:e,children:(0,U.jsx)(d,{content:e,customMarkdownIt:ye,customId:S,final:!o,isDark:g,codeBlockStream:o,...ve})})})})},(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id);export{xe as MarkstreamRenderer};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{n as r}from"./runtime-fetch-D0YWp3FJ.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{n as o}from"./vendor-react-DlzBev0S.js";import{s}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as c}from"./queryRuntime-2dx7jbt9.js";import{r as l,t as u}from"./button-CyJvQsp5.js";import{i as d}from"./store-Diaywtmi.js";import{ja as f,ka as p}from"./useMobileNavigationStore-BHAEAnfr.js";import{n as m}from"./Icon-BOYrvHyJ.js";var h=e(a(),1),g=o(),_=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},v=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},y=class extends _{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},b=(e,t=200)=>{throw new _(`invalid_${e}_response`,t,e)},x=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:b(t),S=(e,t)=>typeof e==`string`?e:b(t),C=(e,t)=>e===null||typeof e==`string`?e:b(t),w=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:b(t),T=(e,t)=>e===null?null:w(e,t),E=(e,t)=>typeof e==`boolean`?e:b(t),D=(e,t,n)=>t.includes(e)?e:b(n),O=e=>{let t=x(e,`capability`);return{supported:E(t.supported,`capability`),enabled:E(t.enabled,`capability`),revision:w(t.revision,`capability`),serverInstanceID:C(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&E(t.sharingAvailable,`capability`)}},k=e=>{if(e==null)return null;let t=x(e,`assistant`);return{turnID:S(t.turnID,`assistant`),messageID:S(t.messageID,`assistant`),status:D(t.status,[`queued`,`running`],`assistant`),admittedAt:w(t.admittedAt,`assistant`)}},A=e=>{if(e==null)return null;let t=x(e,`assistant_preview`),n=w(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?b(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:w(t.createdAt,`assistant_preview`)},messageID:S(t.messageID,`assistant_preview`),ordinal:n,role:D(t.role,[`user`,`assistant`],`assistant_preview`),text:S(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:D(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},j=e=>{let t=w(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:b(`assistant_read`)},M=e=>{let t=x(e,`assistant_read`);return{generation:j(t.generation),ordinal:j(t.ordinal),messageID:S(t.messageID,`assistant_read`)}},N=e=>({unreadCount:e.unreadCount===void 0?0:j(e.unreadCount),readWatermark:e.readWatermark==null?null:M(e.readWatermark),readTip:e.readTip==null?null:M(e.readTip)}),P=e=>{let t=x(e,`assistant_read`);return{assistantID:S(t.assistantID,`assistant_read`),changed:E(t.changed,`assistant_read`),unreadCount:j(t.unreadCount),readWatermark:M(t.readWatermark),readTip:M(t.readTip),revision:j(t.revision)}},F=e=>{let t=x(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>S(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:w(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return b(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>S(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:k(t.activeContactTurn),o=t.working===void 0?a!=null:E(t.working,`assistant`);return{...N(t),pinnedAt:t.pinnedAt===void 0?void 0:T(t.pinnedAt,`assistant`),latestMessagePreview:A(t.latestMessagePreview),id:S(t.id,`assistant`),avatarSeed:S(t.avatarSeed??t.id,`assistant`),revision:w(t.revision,`assistant`),enabled:E(t.enabled,`assistant`),name:S(t.name,`assistant`),defaultPrompt:S(t.defaultPrompt,`assistant`),workspacePath:C(t.workspacePath,`assistant`),effectiveWorkspacePath:S(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:C(t.managedWorkspacePath??null,`assistant`),providerID:S(t.providerID,`assistant`),modelID:S(t.modelID,`assistant`),agent:C(t.agent,`assistant`),variant:C(t.variant??null,`assistant`),mode:D(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:C(t.sessionID,`assistant`),sessionGeneration:w(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:T(t.createdAt,`assistant`),updatedAt:w(t.updatedAt,`assistant`),tombstoneAt:T(t.tombstoneAt,`assistant`)}},I=e=>{let t=x(e,`snapshot`);return{revision:w(t.revision,`snapshot`),enabled:E(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(F):b(`snapshot`)}},L=e=>{let t=x(e,`binding`);return{sessionID:C(t.sessionID,`binding`),directory:S(t.directory,`binding`),sessionGeneration:w(t.sessionGeneration,`binding`)}},R=e=>{let t=x(e,`message_admission`);if(t.admitted!==!0)return b(`message_admission`);let n=t.revision===void 0||t.revision===null?null:w(t.revision,`message_admission`);return{binding:L(t.binding),messageID:S(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},z=e=>{let t=x(e,`share_operation`);return{operationID:S(t.operationID,`share_operation`),assistantID:S(t.assistantID,`share_operation`),sessionID:C(t.sessionID,`share_operation`),messageID:C(t.messageID,`share_operation`),state:D(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:S(t.phase,`share_operation`),attempt:w(t.attempt,`share_operation`),leaseExpiresAt:T(t.leaseExpiresAt,`share_operation`),errorCode:C(t.errorCode,`share_operation`)}},B=e=>{let t=x(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:S(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:S(t.filename,`assistant_contact_part`),n=S(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return b(`assistant_contact_part`);if(i){let r=w(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?b(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:S(t.attachmentID,`assistant_contact_part`),sha256:S(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:S(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:b(`assistant_contact_part`)}if(t.type===`card`){let e=D(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);return e===`session`?{type:`card`,cardType:`session`,sessionID:S(t.sessionID,`assistant_contact_part`),directory:S(t.directory,`assistant_contact_part`),title:C(t.title??null,`assistant_contact_part`),status:C(t.status??null,`assistant_contact_part`),branch:C(t.branch??null,`assistant_contact_part`)}:e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:S(t.assistantID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),providerID:S(t.providerID,`assistant_contact_part`),modelID:S(t.modelID,`assistant_contact_part`),mode:D(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:S(t.taskID,`assistant_contact_part`),projectID:S(t.projectID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),kind:C(t.kind??null,`assistant_contact_part`),time:C(t.time??null,`assistant_contact_part`),timezone:C(t.timezone??null,`assistant_contact_part`),prompt:C(t.prompt??null,`assistant_contact_part`),...t.cron===void 0?{}:{cron:C(t.cron,`assistant_contact_part`)},...t.date===void 0?{}:{date:C(t.date,`assistant_contact_part`)},...t.times===void 0?{}:{times:t.times===null?null:Array.isArray(t.times)?t.times.map(e=>S(e,`assistant_contact_part`)):b(`assistant_contact_part`)},...t.weekdays===void 0?{}:{weekdays:t.weekdays===null?null:Array.isArray(t.weekdays)?t.weekdays.map(e=>{let t=w(e,`assistant_contact_part`);return Number.isInteger(t)&&t>=0&&t<=6?t:b(`assistant_contact_part`)}):b(`assistant_contact_part`)}}}return b(`assistant_contact_part`)},ee=e=>{let t=x(e,`assistant_contact`),n=C(t.nextCursor,`assistant_contact`),r=E(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return b(`assistant_contact`);let i=w(t.generation,`assistant_contact`),a=w(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?b(`assistant_contact`):{messages:t.messages.map(e=>{let t=x(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return b(`assistant_contact_message`);let n=t.parts.map(B);return{messageID:S(t.messageID,`assistant_contact_message`),assistantID:S(t.assistantID,`assistant_contact_message`),role:D(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:S(t.turnID,`assistant_contact_message`),bubbleIndex:w(t.bubbleIndex,`assistant_contact_message`),createdAt:w(t.createdAt,`assistant_contact_message`),ordinal:w(t.ordinal,`assistant_contact_message`),status:S(t.status,`assistant_contact_message`),fromAssistantID:C(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:C(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},te=e=>{let t=x(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=x(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:x(t.task,`assistant_scheduled_task_live`);return{assistantID:S(t.assistantID,`assistant_scheduled_task`),projectID:S(t.projectID,`assistant_scheduled_task`),taskID:S(t.taskID,`assistant_scheduled_task`),createdAt:w(t.createdAt,`assistant_scheduled_task`),projectPath:C(t.projectPath??null,`assistant_scheduled_task`),projectLabel:C(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:b(`assistant_scheduled_tasks`)},V=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},H=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},U=e=>e===null||typeof e==`string`,ne=e=>e===null||typeof e==`number`&&Number.isFinite(e),re=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,ie=e=>e===null||re(e),ae=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&U(t.sessionId)&&U(t.directory)&&U(t.error)&&re(t.startedAt)&&ie(t.finishedAt)&&ne(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},oe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(ae)||!U(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},se=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/yuri/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await V(a,`Failed to load scheduled task history`));return oe(await a.json().catch(()=>null))},ce=async({signal:e}={})=>{let t=await r(`/api/yuri/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await V(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},le=async(e,t)=>{let n=H(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await V(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},ue=async(e,t)=>{let n=H(e),i=H(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await V(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},de=async(e,t)=>{let n=H(e),i=H(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await V(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},fe=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,pe=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`yuri.settle.`)&&!t.startsWith(`oc.settle.`)},me=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(pe)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&fe({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},he=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),ge=e=>!!(e&&e.generation>=0),_e=(e,t)=>fe({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),W=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(_e)},ve=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},ye=e=>e.map(e=>e.messageID),be=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},xe=e=>new Set(e),Se=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Ce=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),we=e=>({ordinal:e.ordinal,messageID:e.messageID}),Te=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>fe(we(e),we(r))<0),...t]},Ee=(e,t)=>{let n=e??he(),r=ge(n),i=[...t.messages].sort(_e),a=ye(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=Te(n.messages,i,t.complete);else{let e=ve(i);c=W(n.messages.filter(t=>t.ordinal<e),W(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=xe(a),d=l.length>0&&be(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},De=(e,t)=>{if(!ge(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=W(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},Oe=(e,t,n)=>{if(!ge(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=W(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&Se(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=ye(t.messages),c=e.gapTargetIDs??[],l=xe(c);return c.length>0&&be(s,l)||t.complete||!t.nextCursor?Ce({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},G={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},K=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new _(e,n.status,void 0,t)}return i},q=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),J=(e,r)=>{if(t()!==e||n()!==r)throw new _(`runtime_stale`,409)},ke=(e,t,r)=>{c.setQueryData(G.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),c.invalidateQueries({queryKey:G.snapshot(r)}),c.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},Ae=(e,t)=>{c.setQueryData(G.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),c.invalidateQueries({queryKey:G.snapshot(t)})},je=2500,Me=15e3,Ne=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Pe=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?je:Me}return Ne(e)?je:Me},Y=(e=t())=>({queryKey:G.snapshot(e),queryFn:async({signal:e})=>I(await K(`/api/yuri/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Pe(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),X=new Map,Fe=e=>{let r=X.get(e);if(r)r.count+=1;else{let r=n(),i=!1,a=!1,o=!1,s=()=>!i&&t()===e&&n()===r,l=async()=>{if(o=!0,!a){a=!0;try{do o=!1,c.getQueryCache().find({queryKey:G.snapshot(e),exact:!0})?.state.fetchStatus===`fetching`&&(o=!0),await c.invalidateQueries({queryKey:G.snapshot(e),exact:!0},{cancelRefetch:!1});while(o&&s())}finally{a=!1}}},u=f(t=>{if(!s())return;let n=c.getQueryData(G.snapshot(e));(t.type===`event-stream-ready`||t.type===`contact-turn-start`||t.type===`contact-turn-end`||t.type===`assistants-changed`&&(!n||t.revision>n.revision))&&l()});X.set(e,{count:1,dispose:()=>{i=!0,u()}})}return()=>{let t=X.get(e);t&&--t.count===0&&(t.dispose(),X.delete(e))}},Ie=e=>{let n=(0,g.c)(7),r,i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),i=s,r=Y(a),n[0]=r,n[1]=i,n[2]=a):(r=n[0],i=n[1],a=n[2]);let o;n[3]===e?o=n[4]:(o={...r,select:e},n[3]=e,n[4]=o);let c=i(o),l,u;return n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>Fe(a),u=[a],n[5]=l,n[6]=u):(l=n[5],u=n[6]),h.useEffect(l,u),c},Le=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Re=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:Le},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??0},ze=e=>e.enabled&&Ne(e),Be=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:ze},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??!1},Ve=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/yuri/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},He=async(e,t,n)=>ee(await K(Ve(e,t),n?{signal:n}:{})),Ue=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,Z=new Map,We=new Map,Q=e=>e.join(``),Ge=async(e,t,n,r,i)=>{let a=Q(t),o=We.get(a);if(o)return o;let s=(async()=>{let a=c.getQueryData(t)??n,o=0,s=!1,l=!1,u=a.gapRequestIDs?[...a.gapRequestIDs]:null,d=a.gapCursor;for(;a.hasMessageGap&&a.gapCursor&&o<5&&!i?.aborted;){J(r.transport,r.runtimeGeneration),o+=1;let n=a.gapCursor;try{let o=await He(e,{limit:20,before:n},i);J(r.transport,r.runtimeGeneration);let l=c.getQueryData(t)??a;if(o.generation!==l.generation){a=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(a=Oe(l,o,u?{requestIDs:u,cursor:d}:void 0),c.setQueryData(t,a),!f)break;if(!a.hasMessageGap){s=!0;break}if(a.gapCursor&&a.gapCursor!==n)s=!0;else break}catch(e){if(i?.aborted||v(e))break;l=!0,a=c.getQueryData(t)??a;break}}return{view:c.getQueryData(t)??a,failed:l,progressed:s}})();We.set(a,s);try{return await s}finally{We.get(a)===s&&We.delete(a)}},Ke=(e,r=t(),i=n(),a={})=>({queryKey:G.contact(e,r,i),queryFn:async({signal:t})=>{J(r,i),await p(),J(r,i);let n=G.contact(e,r,i),a=c.getQueryData(n),o=await He(e,{limit:20},t);J(r,i);let s=Ee(c.getQueryData(n)??a??null,o);c.setQueryData(n,s);let l=Q(n);if(s.hasMessageGap&&s.gapCursor){Z.delete(l);let a=await Ge(e,n,s,{transport:r,runtimeGeneration:i},t);s=a.view,(a.failed||a.view.hasMessageGap&&!a.progressed)&&a.view.gapCursor&&Z.set(l,a.view.gapCursor)}else Z.delete(l);J(r,i);let u=c.getQueryData(n)??s;return a&&Ue(a,u)?a:u},retry:2,staleTime:0,refetchInterval:()=>a.reconcileInForeground?Pe(c.getQueryData(G.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),qe=(e,r=!0)=>{let i=t(),a=n(),[o,l]=h.useState(!1),[u,d]=h.useState(null),[p,m]=h.useState(!1),g=h.useRef(null),_=h.useRef(null),y=h.useRef(null),b=h.useRef(null),x=h.useRef({assistantID:e,transport:i,runtimeGeneration:a,enabled:r});x.current={assistantID:e,transport:i,runtimeGeneration:a,enabled:r};let S=s({...Ke(e,i,a,{reconcileInForeground:!0}),enabled:r&&!!e});h.useEffect(()=>{!r||!e||c.invalidateQueries({queryKey:G.snapshot(i),exact:!0},{cancelRefetch:!1})},[e,r,a,i]),h.useEffect(()=>f(n=>{t()===i&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||c.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}))}),[e,a,i]),h.useEffect(()=>{let t=Q(G.contact(e,i,a));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,g.current=null,_.current=null,Z.delete(t)}},[e,i,a,r]);let C=S.data,w=G.contact(e,i,a),T=async()=>{if(!e||!r)return;if(g.current)return g.current;let t=c.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;d(null),l(!0);let n=new AbortController;b.current?.abort(),b.current=n;let o={transport:i,runtimeGeneration:a,assistantID:e,cursor:t.olderCursor},s=(async()=>{try{J(o.transport,o.runtimeGeneration);let e=await He(o.assistantID,{limit:20,before:o.cursor},n.signal);if(n.signal.aborted||(J(o.transport,o.runtimeGeneration),x.current.assistantID!==o.assistantID||x.current.transport!==o.transport||x.current.runtimeGeneration!==o.runtimeGeneration))return;let r=c.getQueryData(w)??t;if(e.generation!==r.generation)return;c.setQueryData(w,De(r,e))}catch(e){if(n.signal.aborted||v(e))return;let t=e instanceof Error?e:Error(String(e));throw d(t),t}finally{b.current===n&&(b.current=null),l(!1),g.current=null}})();return g.current=s,s},E=async(t=`explicit`)=>{if(!e||!r)return;if(_.current)return _.current;let n=c.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let o=Q(w);if(t===`auto`&&Z.get(o)===n.gapCursor)return;t===`explicit`&&Z.delete(o),m(!0);let s=new AbortController;y.current?.abort(),y.current=s;let l={transport:i,runtimeGeneration:a,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{J(l.transport,l.runtimeGeneration);let e=await Ge(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},s.signal);if(s.signal.aborted)return;if(J(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&Z.set(o,e.view.gapCursor);return}e.view.hasMessageGap||Z.delete(o)}catch(e){if(s.signal.aborted||v(e))return;throw Z.set(o,l.cursor),e}finally{y.current===s&&(y.current=null),m(!1),_.current=null}})();return _.current=u,u};return h.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||p)return;let t=Q(w);Z.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,p,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:o,previousPageError:u,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:p,retryMessageGap:()=>E(`explicit`)}},Je=async(e,r)=>{let i=t(),a=n();await p(),J(i,a);let o=await He(e,{messageID:r,limit:1});if(J(i,a),!o.messages.some(e=>e.messageID===r&&e.role===`user`))return null;c.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}),c.invalidateQueries({queryKey:G.snapshot(i),exact:!0});let s=c.getQueryData(G.snapshot(i));return{admitted:!0,messageID:r,revision:o.revision??s?.revision??null}},Ye=(e,r=t(),i=n())=>({queryKey:G.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{J(r,i);let n=te(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return J(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof _&&t.status===404)&&e<2}),Xe=(e,r)=>{let i=(0,g.c)(6),a=r===void 0||r,o,c;if(i[0]!==e){let r=t(),a=n();c=s,o=Ye(e,r,a),i[0]=e,i[1]=o,i[2]=c}else o=i[1],c=i[2];let l=a&&!!e,u;return i[3]!==o||i[4]!==l?(u={...o,enabled:l},i[3]=o,i[4]=l,i[5]=u):u=i[5],c(u)},Ze=(e=t())=>({queryKey:G.globalScheduledTasks(e),queryFn:ce,refetchOnMount:`always`}),Qe=e=>{let t=(0,g.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Ze(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),s(i)},$e=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),et=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Ze(i),select:$e,staleTime:0,refetchInterval:yt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,l;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>f(e=>{t()===i&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&c.invalidateQueries({queryKey:Ze(i).queryKey,exact:!0})}),l=[i],e[3]=o,e[4]=l):(o=e[3],l=e[4]),h.useEffect(o,l),a.data===!0},tt=(e,r=t())=>{c.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},nt=(e=t())=>({queryKey:G.capability(e),queryFn:()=>gt(),retry:!1}),rt=()=>{let e=(0,g.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=nt(),e[0]=t):t=e[0],s(t)},it=(e=c,n=t())=>e.getQueryData(G.snapshot(n)),at=(e=c,n=t())=>e.fetchQuery(Y(n)),ot=async(e=c)=>{let r=t(),i=n();await e.invalidateQueries({queryKey:G.snapshot(r),exact:!0}),J(r,i);let a=await e.fetchQuery(Y(r));return J(r,i),a},st=15e3,ct=e=>{throw e instanceof _?e:v(e)?new _(`admission_timeout`,408):e},lt=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(st);try{let t=R(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/messages`,{...q(`POST`,{messageID:r,parts:s,language:d.getState().locale}),signal:c}));return J(a,o),ke(e,t.binding,a),tt(e,a),t}catch(e){return ct(e)}},ut=async(e,r,i,a,o)=>{let s=t(),c=n(),l=z(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/share`,q(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return J(s,c),l},dt=async(e,r=t(),i=n())=>{J(r,i);let a=z(await K(`/api/yuri/assistants/share-operations/${encodeURIComponent(e)}`));return J(r,i),a},ft=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)J(r,i),await new Promise(e=>setTimeout(e,750)),a=await dt(a.operationID,r,i);if(J(r,i),a.state===`completed`)return a;throw a.state===`failed`?new y(a.errorCode??`share_failed`,400,a):new y(`share_unresolved`,408,a)},pt=async e=>{let n=t(),r=F(await K(`/api/yuri/assistants`,q(`POST`,{...e,language:d.getState().locale})));return Ae(r,n),r},mt=async(e,r)=>{let i=t(),a=n(),o=F(await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`PATCH`,{...r,expectedRevision:e.revision})));return J(i,a),r.pinned===void 0?Ae(o,i):(await c.cancelQueries({queryKey:G.snapshot(i),exact:!0}),J(i,a),await c.fetchQuery(Y(i)),J(i,a)),o},ht=async e=>{await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`DELETE`,{expectedRevision:e.revision})),await c.invalidateQueries({queryKey:G.snapshot(t())})},gt=async()=>O(await K(`/api/yuri/assistants/capability`)),_t=async(e,r)=>{let i=t(),a=n(),o=M(r);try{let t=P(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/contact/read`,{...q(`POST`,o),signal:AbortSignal.timeout(15e3)}));if(J(i,a),t.assistantID!==e)throw new _(`invalid_assistant_read_response`,200);return t}finally{t()===i&&n()===a&&c.invalidateQueries({queryKey:G.snapshot(i),exact:!0})}},vt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(J(i,a),_t(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function yt(e){return e.state.data&&$e(e.state.data)?2500:15e3}var $=i();function bt(e){let t=(0,g.c)(33),{title:n,subtitle:r,backAriaLabel:i,onBack:a,backDisabled:o,actions:s,trailing:c,sticky:d,overlay:f,elevated:p,collapsible:h}=e,_=o!==void 0&&o,v;t[0]===s?v=t[1]:(v=s===void 0?[]:s,t[0]=s,t[1]=v);let y=v,b=d!==void 0&&d,x=f!==void 0&&f,S=p!==void 0&&p,C=h!==void 0&&h,w=Array.isArray(c)?c.filter(Boolean).length:+!!c,T=S||y.some(St),E=C?`true`:void 0,D=b&&`yuri-mobile-detail-navigation-sticky`,O=x&&`absolute inset-x-0 top-0`,k=T?`z-[60]`:x?`z-30`:void 0,A;t[2]!==O||t[3]!==k||t[4]!==D?(A=l(`yuri-mobile-detail-navigation relative shrink-0 pt-[max(0.25rem,var(--yuri-safe-area-top,0px))]`,D,O,k),t[2]=O,t[3]=k,t[4]=D,t[5]=A):A=t[5];let j=y.length+w>1?`grid-cols-[2.75rem_minmax(0,1fr)_auto]`:`grid-cols-[2.75rem_minmax(0,1fr)_2.75rem]`,M;t[6]===j?M=t[7]:(M=l(`yuri-mobile-detail-navigation-content grid items-center gap-1 px-4`,j),t[6]=j,t[7]=M);let N;t[8]!==i||t[9]!==_||t[10]!==a?(N=a?(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`justify-self-start`,onClick:a,disabled:_,"aria-label":i,children:(0,$.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}):(0,$.jsx)(`span`,{"aria-hidden":`true`}),t[8]=i,t[9]=_,t[10]=a,t[11]=N):N=t[11];let P;t[12]===n?P=t[13]:(P=(0,$.jsx)(`div`,{className:`yuri-mobile-detail-title w-full truncate typography-ui-label font-medium text-foreground`,children:n}),t[12]=n,t[13]=P);let F;t[14]===r?F=t[15]:(F=r?(0,$.jsx)(`div`,{className:`yuri-mobile-detail-subtitle w-full truncate text-muted-foreground`,"aria-live":`polite`,children:r}):null,t[14]=r,t[15]=F);let I;t[16]!==P||t[17]!==F?(I=(0,$.jsxs)(`div`,{className:`flex w-full max-w-72 min-w-0 flex-col items-center justify-center justify-self-center px-1`,children:[P,F]}),t[16]=P,t[17]=F,t[18]=I):I=t[18];let L;t[19]===y?L=t[20]:(L=y.map(xt),t[19]=y,t[20]=L);let R;t[21]!==L||t[22]!==c?(R=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[c,L]}),t[21]=L,t[22]=c,t[23]=R):R=t[23];let z;t[24]!==M||t[25]!==N||t[26]!==I||t[27]!==R?(z=(0,$.jsxs)(`div`,{className:M,children:[N,I,R]}),t[24]=M,t[25]=N,t[26]=I,t[27]=R,t[28]=z):z=t[28];let B;return t[29]!==A||t[30]!==z||t[31]!==E?(B=(0,$.jsx)(`header`,{"data-yuri-collapsible-header":E,className:A,children:z}),t[29]=A,t[30]=z,t[31]=E,t[32]=B):B=t[32],B}function xt(e,t){return(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:l(e.elevated&&`relative z-[60]`),onClick:e.onClick,disabled:e.disabled,"aria-label":e.ariaLabel,"aria-expanded":e.pressed,title:e.title,children:(0,$.jsx)(m,{name:e.icon,className:`size-5`})},`${e.icon}:${t}`)}function St(e){return e.elevated}export{le as A,ft as C,ce as D,ue as E,y as M,v as N,se as O,et as S,pe as T,Xe as _,ht as a,Be as b,ot as c,it as d,lt as f,qe as g,rt as h,pt as i,_ as j,de as k,vt as l,mt as m,Ke as n,at as o,ut as p,Je as r,gt as s,bt as t,_t as u,Ie as v,me as w,Qe as x,Re as y};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{n as r}from"./runtime-fetch-D0YWp3FJ.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{n as o}from"./vendor-react-DlzBev0S.js";import{s}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as c}from"./queryRuntime-2dx7jbt9.js";import{r as l,t as u}from"./button-DSfiaJr4.js";import{i as d}from"./store-BMijqCTE.js";import{Aa as f,Ma as p}from"./useMobileNavigationStore-BGHhBg7N.js";import{n as m}from"./Icon-wD7peplo.js";var h=e(a(),1),g=o(),_=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},v=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},y=class extends _{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},b=(e,t=200)=>{throw new _(`invalid_${e}_response`,t,e)},x=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:b(t),S=(e,t)=>typeof e==`string`?e:b(t),C=(e,t)=>e===null||typeof e==`string`?e:b(t),w=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:b(t),T=(e,t)=>e===null?null:w(e,t),E=(e,t)=>typeof e==`boolean`?e:b(t),D=(e,t,n)=>t.includes(e)?e:b(n),O=e=>{let t=x(e,`capability`);return{supported:E(t.supported,`capability`),enabled:E(t.enabled,`capability`),revision:w(t.revision,`capability`),serverInstanceID:C(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&E(t.sharingAvailable,`capability`)}},k=e=>{if(e==null)return null;let t=x(e,`assistant`);return{turnID:S(t.turnID,`assistant`),messageID:S(t.messageID,`assistant`),status:D(t.status,[`queued`,`running`],`assistant`),admittedAt:w(t.admittedAt,`assistant`)}},A=e=>{if(e==null)return null;let t=x(e,`assistant_preview`),n=w(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?b(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:w(t.createdAt,`assistant_preview`)},messageID:S(t.messageID,`assistant_preview`),ordinal:n,role:D(t.role,[`user`,`assistant`],`assistant_preview`),text:S(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:D(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},j=e=>{let t=w(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:b(`assistant_read`)},M=e=>{let t=x(e,`assistant_read`);return{generation:j(t.generation),ordinal:j(t.ordinal),messageID:S(t.messageID,`assistant_read`)}},N=e=>({unreadCount:e.unreadCount===void 0?0:j(e.unreadCount),readWatermark:e.readWatermark==null?null:M(e.readWatermark),readTip:e.readTip==null?null:M(e.readTip)}),P=e=>{let t=x(e,`assistant_read`);return{assistantID:S(t.assistantID,`assistant_read`),changed:E(t.changed,`assistant_read`),unreadCount:j(t.unreadCount),readWatermark:M(t.readWatermark),readTip:M(t.readTip),revision:j(t.revision)}},F=e=>{let t=x(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>S(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:w(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return b(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>S(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:k(t.activeContactTurn),o=t.working===void 0?a!=null:E(t.working,`assistant`);return{...N(t),pinnedAt:t.pinnedAt===void 0?void 0:T(t.pinnedAt,`assistant`),latestMessagePreview:A(t.latestMessagePreview),id:S(t.id,`assistant`),avatarSeed:S(t.avatarSeed??t.id,`assistant`),revision:w(t.revision,`assistant`),enabled:E(t.enabled,`assistant`),name:S(t.name,`assistant`),defaultPrompt:S(t.defaultPrompt,`assistant`),workspacePath:C(t.workspacePath,`assistant`),effectiveWorkspacePath:S(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:C(t.managedWorkspacePath??null,`assistant`),providerID:S(t.providerID,`assistant`),modelID:S(t.modelID,`assistant`),agent:C(t.agent,`assistant`),variant:C(t.variant??null,`assistant`),mode:D(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:C(t.sessionID,`assistant`),sessionGeneration:w(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:T(t.createdAt,`assistant`),updatedAt:w(t.updatedAt,`assistant`),tombstoneAt:T(t.tombstoneAt,`assistant`)}},I=e=>{let t=x(e,`snapshot`);return{revision:w(t.revision,`snapshot`),enabled:E(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(F):b(`snapshot`)}},L=e=>{let t=x(e,`binding`);return{sessionID:C(t.sessionID,`binding`),directory:S(t.directory,`binding`),sessionGeneration:w(t.sessionGeneration,`binding`)}},R=e=>{let t=x(e,`message_admission`);if(t.admitted!==!0)return b(`message_admission`);let n=t.revision===void 0||t.revision===null?null:w(t.revision,`message_admission`);return{binding:L(t.binding),messageID:S(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},z=e=>{let t=x(e,`share_operation`);return{operationID:S(t.operationID,`share_operation`),assistantID:S(t.assistantID,`share_operation`),sessionID:C(t.sessionID,`share_operation`),messageID:C(t.messageID,`share_operation`),state:D(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:S(t.phase,`share_operation`),attempt:w(t.attempt,`share_operation`),leaseExpiresAt:T(t.leaseExpiresAt,`share_operation`),errorCode:C(t.errorCode,`share_operation`)}},B=e=>{let t=x(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:S(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:S(t.filename,`assistant_contact_part`),n=S(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return b(`assistant_contact_part`);if(i){let r=w(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?b(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:S(t.attachmentID,`assistant_contact_part`),sha256:S(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:S(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:b(`assistant_contact_part`)}if(t.type===`card`){let e=D(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);return e===`session`?{type:`card`,cardType:`session`,sessionID:S(t.sessionID,`assistant_contact_part`),directory:S(t.directory,`assistant_contact_part`),title:C(t.title??null,`assistant_contact_part`),status:C(t.status??null,`assistant_contact_part`),branch:C(t.branch??null,`assistant_contact_part`)}:e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:S(t.assistantID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),providerID:S(t.providerID,`assistant_contact_part`),modelID:S(t.modelID,`assistant_contact_part`),mode:D(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:S(t.taskID,`assistant_contact_part`),projectID:S(t.projectID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),kind:C(t.kind??null,`assistant_contact_part`),time:C(t.time??null,`assistant_contact_part`),timezone:C(t.timezone??null,`assistant_contact_part`),prompt:C(t.prompt??null,`assistant_contact_part`),...t.cron===void 0?{}:{cron:C(t.cron,`assistant_contact_part`)},...t.date===void 0?{}:{date:C(t.date,`assistant_contact_part`)},...t.times===void 0?{}:{times:t.times===null?null:Array.isArray(t.times)?t.times.map(e=>S(e,`assistant_contact_part`)):b(`assistant_contact_part`)},...t.weekdays===void 0?{}:{weekdays:t.weekdays===null?null:Array.isArray(t.weekdays)?t.weekdays.map(e=>{let t=w(e,`assistant_contact_part`);return Number.isInteger(t)&&t>=0&&t<=6?t:b(`assistant_contact_part`)}):b(`assistant_contact_part`)}}}return b(`assistant_contact_part`)},ee=e=>{let t=x(e,`assistant_contact`),n=C(t.nextCursor,`assistant_contact`),r=E(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return b(`assistant_contact`);let i=w(t.generation,`assistant_contact`),a=w(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?b(`assistant_contact`):{messages:t.messages.map(e=>{let t=x(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return b(`assistant_contact_message`);let n=t.parts.map(B);return{messageID:S(t.messageID,`assistant_contact_message`),assistantID:S(t.assistantID,`assistant_contact_message`),role:D(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:S(t.turnID,`assistant_contact_message`),bubbleIndex:w(t.bubbleIndex,`assistant_contact_message`),createdAt:w(t.createdAt,`assistant_contact_message`),ordinal:w(t.ordinal,`assistant_contact_message`),status:S(t.status,`assistant_contact_message`),fromAssistantID:C(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:C(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},te=e=>{let t=x(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=x(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:x(t.task,`assistant_scheduled_task_live`);return{assistantID:S(t.assistantID,`assistant_scheduled_task`),projectID:S(t.projectID,`assistant_scheduled_task`),taskID:S(t.taskID,`assistant_scheduled_task`),createdAt:w(t.createdAt,`assistant_scheduled_task`),projectPath:C(t.projectPath??null,`assistant_scheduled_task`),projectLabel:C(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:b(`assistant_scheduled_tasks`)},V=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},H=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},U=e=>e===null||typeof e==`string`,ne=e=>e===null||typeof e==`number`&&Number.isFinite(e),re=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,ie=e=>e===null||re(e),ae=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&U(t.sessionId)&&U(t.directory)&&U(t.error)&&re(t.startedAt)&&ie(t.finishedAt)&&ne(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},oe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(ae)||!U(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},se=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/yuri/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await V(a,`Failed to load scheduled task history`));return oe(await a.json().catch(()=>null))},ce=async({signal:e}={})=>{let t=await r(`/api/yuri/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await V(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},le=async(e,t)=>{let n=H(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await V(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},ue=async(e,t)=>{let n=H(e),i=H(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await V(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},de=async(e,t)=>{let n=H(e),i=H(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await V(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},fe=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,pe=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`yuri.settle.`)&&!t.startsWith(`oc.settle.`)},me=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(pe)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&fe({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},he=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),ge=e=>!!(e&&e.generation>=0),_e=(e,t)=>fe({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),W=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(_e)},ve=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},ye=e=>e.map(e=>e.messageID),be=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},xe=e=>new Set(e),Se=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Ce=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),we=e=>({ordinal:e.ordinal,messageID:e.messageID}),Te=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>fe(we(e),we(r))<0),...t]},Ee=(e,t)=>{let n=e??he(),r=ge(n),i=[...t.messages].sort(_e),a=ye(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=Te(n.messages,i,t.complete);else{let e=ve(i);c=W(n.messages.filter(t=>t.ordinal<e),W(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=xe(a),d=l.length>0&&be(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},De=(e,t)=>{if(!ge(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=W(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},Oe=(e,t,n)=>{if(!ge(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=W(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&Se(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=ye(t.messages),c=e.gapTargetIDs??[],l=xe(c);return c.length>0&&be(s,l)||t.complete||!t.nextCursor?Ce({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},G={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},K=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new _(e,n.status,void 0,t)}return i},q=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),J=(e,r)=>{if(t()!==e||n()!==r)throw new _(`runtime_stale`,409)},ke=(e,t,r)=>{c.setQueryData(G.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),c.invalidateQueries({queryKey:G.snapshot(r)}),c.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},Ae=(e,t)=>{c.setQueryData(G.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),c.invalidateQueries({queryKey:G.snapshot(t)})},je=2500,Me=15e3,Ne=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Pe=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?je:Me}return Ne(e)?je:Me},Y=(e=t())=>({queryKey:G.snapshot(e),queryFn:async({signal:e})=>I(await K(`/api/yuri/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Pe(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),X=new Map,Fe=e=>{let r=X.get(e);if(r)r.count+=1;else{let r=n(),i=!1,a=!1,o=!1,s=()=>!i&&t()===e&&n()===r,l=async()=>{if(o=!0,!a){a=!0;try{do o=!1,c.getQueryCache().find({queryKey:G.snapshot(e),exact:!0})?.state.fetchStatus===`fetching`&&(o=!0),await c.invalidateQueries({queryKey:G.snapshot(e),exact:!0},{cancelRefetch:!1});while(o&&s())}finally{a=!1}}},u=p(t=>{if(!s())return;let n=c.getQueryData(G.snapshot(e));(t.type===`event-stream-ready`||t.type===`contact-turn-start`||t.type===`contact-turn-end`||t.type===`assistants-changed`&&(!n||t.revision>n.revision))&&l()});X.set(e,{count:1,dispose:()=>{i=!0,u()}})}return()=>{let t=X.get(e);t&&--t.count===0&&(t.dispose(),X.delete(e))}},Ie=e=>{let n=(0,g.c)(7),r,i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),i=s,r=Y(a),n[0]=r,n[1]=i,n[2]=a):(r=n[0],i=n[1],a=n[2]);let o;n[3]===e?o=n[4]:(o={...r,select:e},n[3]=e,n[4]=o);let c=i(o),l,u;return n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>Fe(a),u=[a],n[5]=l,n[6]=u):(l=n[5],u=n[6]),h.useEffect(l,u),c},Le=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Re=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:Le},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??0},ze=e=>e.enabled&&Ne(e),Be=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:ze},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??!1},Ve=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/yuri/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},He=async(e,t,n)=>ee(await K(Ve(e,t),n?{signal:n}:{})),Ue=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,Z=new Map,We=new Map,Q=e=>e.join(``),Ge=async(e,t,n,r,i)=>{let a=Q(t),o=We.get(a);if(o)return o;let s=(async()=>{let a=c.getQueryData(t)??n,o=0,s=!1,l=!1,u=a.gapRequestIDs?[...a.gapRequestIDs]:null,d=a.gapCursor;for(;a.hasMessageGap&&a.gapCursor&&o<5&&!i?.aborted;){J(r.transport,r.runtimeGeneration),o+=1;let n=a.gapCursor;try{let o=await He(e,{limit:20,before:n},i);J(r.transport,r.runtimeGeneration);let l=c.getQueryData(t)??a;if(o.generation!==l.generation){a=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(a=Oe(l,o,u?{requestIDs:u,cursor:d}:void 0),c.setQueryData(t,a),!f)break;if(!a.hasMessageGap){s=!0;break}if(a.gapCursor&&a.gapCursor!==n)s=!0;else break}catch(e){if(i?.aborted||v(e))break;l=!0,a=c.getQueryData(t)??a;break}}return{view:c.getQueryData(t)??a,failed:l,progressed:s}})();We.set(a,s);try{return await s}finally{We.get(a)===s&&We.delete(a)}},Ke=(e,r=t(),i=n(),a={})=>({queryKey:G.contact(e,r,i),queryFn:async({signal:t})=>{J(r,i),await f(),J(r,i);let n=G.contact(e,r,i),a=c.getQueryData(n),o=await He(e,{limit:20},t);J(r,i);let s=Ee(c.getQueryData(n)??a??null,o);c.setQueryData(n,s);let l=Q(n);if(s.hasMessageGap&&s.gapCursor){Z.delete(l);let a=await Ge(e,n,s,{transport:r,runtimeGeneration:i},t);s=a.view,(a.failed||a.view.hasMessageGap&&!a.progressed)&&a.view.gapCursor&&Z.set(l,a.view.gapCursor)}else Z.delete(l);J(r,i);let u=c.getQueryData(n)??s;return a&&Ue(a,u)?a:u},retry:2,staleTime:0,refetchInterval:()=>a.reconcileInForeground?Pe(c.getQueryData(G.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),qe=(e,r=!0)=>{let i=t(),a=n(),[o,l]=h.useState(!1),[u,d]=h.useState(null),[f,m]=h.useState(!1),g=h.useRef(null),_=h.useRef(null),y=h.useRef(null),b=h.useRef(null),x=h.useRef({assistantID:e,transport:i,runtimeGeneration:a,enabled:r});x.current={assistantID:e,transport:i,runtimeGeneration:a,enabled:r};let S=s({...Ke(e,i,a,{reconcileInForeground:!0}),enabled:r&&!!e});h.useEffect(()=>{!r||!e||c.invalidateQueries({queryKey:G.snapshot(i),exact:!0},{cancelRefetch:!1})},[e,r,a,i]),h.useEffect(()=>p(n=>{t()===i&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||c.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}))}),[e,a,i]),h.useEffect(()=>{let t=Q(G.contact(e,i,a));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,g.current=null,_.current=null,Z.delete(t)}},[e,i,a,r]);let C=S.data,w=G.contact(e,i,a),T=async()=>{if(!e||!r)return;if(g.current)return g.current;let t=c.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;d(null),l(!0);let n=new AbortController;b.current?.abort(),b.current=n;let o={transport:i,runtimeGeneration:a,assistantID:e,cursor:t.olderCursor},s=(async()=>{try{J(o.transport,o.runtimeGeneration);let e=await He(o.assistantID,{limit:20,before:o.cursor},n.signal);if(n.signal.aborted||(J(o.transport,o.runtimeGeneration),x.current.assistantID!==o.assistantID||x.current.transport!==o.transport||x.current.runtimeGeneration!==o.runtimeGeneration))return;let r=c.getQueryData(w)??t;if(e.generation!==r.generation)return;c.setQueryData(w,De(r,e))}catch(e){if(n.signal.aborted||v(e))return;let t=e instanceof Error?e:Error(String(e));throw d(t),t}finally{b.current===n&&(b.current=null),l(!1),g.current=null}})();return g.current=s,s},E=async(t=`explicit`)=>{if(!e||!r)return;if(_.current)return _.current;let n=c.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let o=Q(w);if(t===`auto`&&Z.get(o)===n.gapCursor)return;t===`explicit`&&Z.delete(o),m(!0);let s=new AbortController;y.current?.abort(),y.current=s;let l={transport:i,runtimeGeneration:a,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{J(l.transport,l.runtimeGeneration);let e=await Ge(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},s.signal);if(s.signal.aborted)return;if(J(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&Z.set(o,e.view.gapCursor);return}e.view.hasMessageGap||Z.delete(o)}catch(e){if(s.signal.aborted||v(e))return;throw Z.set(o,l.cursor),e}finally{y.current===s&&(y.current=null),m(!1),_.current=null}})();return _.current=u,u};return h.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||f)return;let t=Q(w);Z.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,f,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:o,previousPageError:u,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:f,retryMessageGap:()=>E(`explicit`)}},Je=async(e,r)=>{let i=t(),a=n();await f(),J(i,a);let o=await He(e,{messageID:r,limit:1});if(J(i,a),!o.messages.some(e=>e.messageID===r&&e.role===`user`))return null;c.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}),c.invalidateQueries({queryKey:G.snapshot(i),exact:!0});let s=c.getQueryData(G.snapshot(i));return{admitted:!0,messageID:r,revision:o.revision??s?.revision??null}},Ye=(e,r=t(),i=n())=>({queryKey:G.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{J(r,i);let n=te(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return J(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof _&&t.status===404)&&e<2}),Xe=(e,r)=>{let i=(0,g.c)(6),a=r===void 0||r,o,c;if(i[0]!==e){let r=t(),a=n();c=s,o=Ye(e,r,a),i[0]=e,i[1]=o,i[2]=c}else o=i[1],c=i[2];let l=a&&!!e,u;return i[3]!==o||i[4]!==l?(u={...o,enabled:l},i[3]=o,i[4]=l,i[5]=u):u=i[5],c(u)},Ze=(e=t())=>({queryKey:G.globalScheduledTasks(e),queryFn:ce,refetchOnMount:`always`}),Qe=e=>{let t=(0,g.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Ze(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),s(i)},$e=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),et=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Ze(i),select:$e,staleTime:0,refetchInterval:yt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,l;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>p(e=>{t()===i&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&c.invalidateQueries({queryKey:Ze(i).queryKey,exact:!0})}),l=[i],e[3]=o,e[4]=l):(o=e[3],l=e[4]),h.useEffect(o,l),a.data===!0},tt=(e,r=t())=>{c.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},nt=(e=t())=>({queryKey:G.capability(e),queryFn:()=>gt(),retry:!1}),rt=()=>{let e=(0,g.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=nt(),e[0]=t):t=e[0],s(t)},it=(e=c,n=t())=>e.getQueryData(G.snapshot(n)),at=(e=c,n=t())=>e.fetchQuery(Y(n)),ot=async(e=c)=>{let r=t(),i=n();await e.invalidateQueries({queryKey:G.snapshot(r),exact:!0}),J(r,i);let a=await e.fetchQuery(Y(r));return J(r,i),a},st=15e3,ct=e=>{throw e instanceof _?e:v(e)?new _(`admission_timeout`,408):e},lt=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(st);try{let t=R(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/messages`,{...q(`POST`,{messageID:r,parts:s,language:d.getState().locale}),signal:c}));return J(a,o),ke(e,t.binding,a),tt(e,a),t}catch(e){return ct(e)}},ut=async(e,r,i,a,o)=>{let s=t(),c=n(),l=z(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/share`,q(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return J(s,c),l},dt=async(e,r=t(),i=n())=>{J(r,i);let a=z(await K(`/api/yuri/assistants/share-operations/${encodeURIComponent(e)}`));return J(r,i),a},ft=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)J(r,i),await new Promise(e=>setTimeout(e,750)),a=await dt(a.operationID,r,i);if(J(r,i),a.state===`completed`)return a;throw a.state===`failed`?new y(a.errorCode??`share_failed`,400,a):new y(`share_unresolved`,408,a)},pt=async e=>{let n=t(),r=F(await K(`/api/yuri/assistants`,q(`POST`,{...e,language:d.getState().locale})));return Ae(r,n),r},mt=async(e,r)=>{let i=t(),a=n(),o=F(await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`PATCH`,{...r,expectedRevision:e.revision})));return J(i,a),r.pinned===void 0?Ae(o,i):(await c.cancelQueries({queryKey:G.snapshot(i),exact:!0}),J(i,a),await c.fetchQuery(Y(i)),J(i,a)),o},ht=async e=>{await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`DELETE`,{expectedRevision:e.revision})),await c.invalidateQueries({queryKey:G.snapshot(t())})},gt=async()=>O(await K(`/api/yuri/assistants/capability`)),_t=async(e,r)=>{let i=t(),a=n(),o=M(r);try{let t=P(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/contact/read`,{...q(`POST`,o),signal:AbortSignal.timeout(15e3)}));if(J(i,a),t.assistantID!==e)throw new _(`invalid_assistant_read_response`,200);return t}finally{t()===i&&n()===a&&c.invalidateQueries({queryKey:G.snapshot(i),exact:!0})}},vt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(J(i,a),_t(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function yt(e){return e.state.data&&$e(e.state.data)?2500:15e3}var $=i();function bt(e){let t=(0,g.c)(33),{title:n,subtitle:r,backAriaLabel:i,onBack:a,backDisabled:o,actions:s,trailing:c,sticky:d,overlay:f,elevated:p,collapsible:h}=e,_=o!==void 0&&o,v;t[0]===s?v=t[1]:(v=s===void 0?[]:s,t[0]=s,t[1]=v);let y=v,b=d!==void 0&&d,x=f!==void 0&&f,S=p!==void 0&&p,C=h!==void 0&&h,w=Array.isArray(c)?c.filter(Boolean).length:+!!c,T=S||y.some(St),E=C?`true`:void 0,D=b&&`yuri-mobile-detail-navigation-sticky`,O=x&&`absolute inset-x-0 top-0`,k=T?`z-[60]`:x?`z-30`:void 0,A;t[2]!==O||t[3]!==k||t[4]!==D?(A=l(`yuri-mobile-detail-navigation relative shrink-0 pt-[max(0.25rem,var(--yuri-safe-area-top,0px))]`,D,O,k),t[2]=O,t[3]=k,t[4]=D,t[5]=A):A=t[5];let j=y.length+w>1?`grid-cols-[2.75rem_minmax(0,1fr)_auto]`:`grid-cols-[2.75rem_minmax(0,1fr)_2.75rem]`,M;t[6]===j?M=t[7]:(M=l(`yuri-mobile-detail-navigation-content grid items-center gap-1 px-4`,j),t[6]=j,t[7]=M);let N;t[8]!==i||t[9]!==_||t[10]!==a?(N=a?(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`justify-self-start`,onClick:a,disabled:_,"aria-label":i,children:(0,$.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}):(0,$.jsx)(`span`,{"aria-hidden":`true`}),t[8]=i,t[9]=_,t[10]=a,t[11]=N):N=t[11];let P;t[12]===n?P=t[13]:(P=(0,$.jsx)(`div`,{className:`yuri-mobile-detail-title w-full truncate typography-ui-label font-medium text-foreground`,children:n}),t[12]=n,t[13]=P);let F;t[14]===r?F=t[15]:(F=r?(0,$.jsx)(`div`,{className:`yuri-mobile-detail-subtitle w-full truncate text-muted-foreground`,"aria-live":`polite`,children:r}):null,t[14]=r,t[15]=F);let I;t[16]!==P||t[17]!==F?(I=(0,$.jsxs)(`div`,{className:`flex w-full max-w-72 min-w-0 flex-col items-center justify-center justify-self-center px-1`,children:[P,F]}),t[16]=P,t[17]=F,t[18]=I):I=t[18];let L;t[19]===y?L=t[20]:(L=y.map(xt),t[19]=y,t[20]=L);let R;t[21]!==L||t[22]!==c?(R=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[c,L]}),t[21]=L,t[22]=c,t[23]=R):R=t[23];let z;t[24]!==M||t[25]!==N||t[26]!==I||t[27]!==R?(z=(0,$.jsxs)(`div`,{className:M,children:[N,I,R]}),t[24]=M,t[25]=N,t[26]=I,t[27]=R,t[28]=z):z=t[28];let B;return t[29]!==A||t[30]!==z||t[31]!==E?(B=(0,$.jsx)(`header`,{"data-yuri-collapsible-header":E,className:A,children:z}),t[29]=A,t[30]=z,t[31]=E,t[32]=B):B=t[32],B}function xt(e,t){return(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:l(e.elevated&&`relative z-[60]`),onClick:e.onClick,disabled:e.disabled,"aria-label":e.ariaLabel,"aria-expanded":e.pressed,title:e.title,children:(0,$.jsx)(m,{name:e.icon,className:`size-5`})},`${e.icon}:${t}`)}function St(e){return e.elevated}export{le as A,ft as C,ce as D,ue as E,y as M,v as N,se as O,et as S,pe as T,Xe as _,ht as a,Be as b,ot as c,it as d,lt as f,qe as g,rt as h,pt as i,_ as j,de as k,vt as l,mt as m,Ke as n,at as o,ut as p,Je as r,gt as s,bt as t,_t as u,Ie as v,me as w,Qe as x,Re as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{at as t,ot as n,st as r}from"./vendor-base-ui-CzHs0bHY.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{i as a}from"./vendor-reactuses-core-DWo5Wn6R.js";import{r as o,t as s}from"./button-CyJvQsp5.js";import{a as c,c as l}from"./vendor-framer-motion-DDMKlXiP.js";import{n as u}from"./Icon-BOYrvHyJ.js";import{t as d}from"./MobileWindowStack-DGLdgoGr.js";var f=e(r(),1),p=i(),m=n(),h=e(t(),1),g=0,_=()=>{g=Date.now()+800},v=()=>Date.now()<g;function y(e){let t=(0,p.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`flex cursor-ns-resize touch-none justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,m.jsx)(`div`,{className:`pointer-events-none h-1.5 w-11 rounded-full bg-[var(--interactive-border)]`}),t[5]=a):a=t[5];let s;return t[6]!==r||t[7]!==i?(s=(0,m.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=s):s=t[8],s}var b=100,x=.35;function S(e,t,n){let r=e.at(-1),i=e.at(-2);for(r&&i&&Math.abs(t-r.height)>2&&(t-r.height)*(r.height-i.height)<0&&e.splice(0,e.length-1),e.push({height:t,time:n});e.length>2&&(e.length>16||e[1].time<n-b);)e.shift()}function C(e,t){let n=e.at(-1);if(!n||t-n.time>=b)return 0;let r=e.find(e=>e.time>=t-b);return!r||n.time<=r.time?0:Math.max(-4,Math.min(4,(n.height-r.height)/Math.max(1,t-r.time)))}function w(e,t,n,r,i){let a=Math.abs(r)>=x&&Math.abs(i)>=8,o=n+(a?r*180:0),s=e.reduce((e,t)=>Math.abs(t.height-o)<Math.abs(e.height-o)?t:e),c=e.find(e=>e.id===t)??s;return!a||Math.abs(s.height-c.height)>1?s.id:[...e].sort((e,t)=>r>0?e.height-t.height:t.height-e.height).find(e=>r>0?e.height>c.height+1:e.height<c.height-1)?.id??s.id}function T(e,t,n){let r=e<t?t:e>n?n:e,i=e-r;return r+Math.sign(i)*48*(1-1/(1+Math.abs(i)*.55/48))}function E(e){let t=(0,p.c)(82),{surfaceRef:n,initialPoint:r,getPoints:i,minimumHeight:o,onRelease:s,onCommit:u,renderMode:d}=e,m=d===void 0?`height`:d,[h,g]=(0,f.useState)(r),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),x=(0,f.useRef)(r),E=(0,f.useRef)(null),A=(0,f.useRef)(null),j=(0,f.useRef)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(!1),P=(0,f.useRef)(null),F;t[0]===n?F=t[1]:(F=()=>{let e=n.current;if(!e)return 0;if(!P.current)return e.getBoundingClientRect().height;let t=parseFloat(getComputedStyle(e).translate.split(` `)[1])||0;return P.current.layoutHeight-t},t[0]=n,t[1]=F);let I=a(F),L;t[2]===n?L=t[3]:(L=e=>{let t=n.current;t&&(P.current?t.style.translate=`0 ${P.current.layoutHeight-e}px`:t.style.height=`${e}px`)},t[2]=n,t[3]=L);let R=a(L),z;t[4]!==m||t[5]!==n||t[6]!==R?(z=(e,t)=>{let r=n.current;if(r){if(m===`translate`&&!P.current){let e=Math.max(...t.map(k))+144,{maxHeight:n,position:i,bottom:a,left:o,right:s}=r.style;P.current={layoutHeight:e,styles:{maxHeight:n,position:i,bottom:a,left:o,right:s}},Object.assign(r.style,{position:`absolute`,bottom:`0px`,left:`0px`,right:`0px`}),r.style.maxHeight=`none`,r.style.height=`${e}px`}r.setAttribute(`data-height-snap-active`,``),r.style.willChange=P.current?`translate`:`height`,R(e)}},t[4]=m,t[5]=n,t[6]=R,t[7]=z):z=t[7];let ae=a(z),B;t[8]===n?B=t[9]:(B=()=>{let e=n.current;e&&(P.current&&(e.style.translate=``,Object.assign(e.style,P.current.styles),e.style.height=``),e.style.willChange=``,e.removeAttribute(`data-height-snap-active`)),P.current=null},t[8]=n,t[9]=B);let V=a(B),H;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{A.current!==null&&cancelAnimationFrame(A.current),A.current=null,j.current=null,M.current?.cancel(),M.current=null},t[10]=H):H=t[10];let U=a(H),W;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{let e=E.current;E.current=null,e?.handle.hasPointerCapture?.(e.pointerId)&&e.handle.releasePointerCapture(e.pointerId)},t[11]=W):W=t[11];let G=a(W),oe;t[12]!==U||t[13]!==V||t[14]!==i||t[15]!==u||t[16]!==ae||t[17]!==I||t[18]!==G||t[19]!==n||t[20]!==R?(oe=(e,t,r,a)=>{let o=r===void 0||r,s=a===void 0?0:a,d=n.current;if(!d)return;let f=t??I();U(),R(f);let p=i(),m=p.find(t=>t.id===e);if(!m)return;if(ae(f,p),G(),v(!1),b(!1),x.current=e,g(e),R(m.height),u?.(e),!o||Math.abs(f-m.height)<1||typeof d.animate!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){V();return}b(!0);let h=P.current?.layoutHeight,_=m.height-f,y=c([d],h===void 0?{height:[`${f}px`,`${m.height}px`]}:{translate:[`0 ${h-f}px`,`0 ${h-m.height}px`]},{type:l,stiffness:576,damping:48,mass:1,velocity:s*1e3*100/_,restDelta:20/Math.abs(_),restSpeed:500/Math.abs(_)});M.current=y,y.finished.catch(O).then(()=>{M.current===y&&(M.current=null,V(),b(!1))})},t[12]=U,t[13]=V,t[14]=i,t[15]=u,t[16]=ae,t[17]=I,t[18]=G,t[19]=n,t[20]=R,t[21]=oe):oe=t[21];let K=a(oe),se;t[22]!==U||t[23]!==i||t[24]!==o||t[25]!==ae||t[26]!==I||t[27]!==n||t[28]!==R?(se=e=>{if(E.current||!e.isPrimary||e.pointerType===`mouse`&&e.button!==0||!n.current)return;let t=I();U(),R(t);let r=i();r.length&&(b(!1),E.current={pointerId:e.pointerId,startY:e.clientY,height:t,point:x.current,points:r,handle:e.currentTarget,minimum:o??Math.min(...r.map(ie)),maximum:Math.max(...r.map(re)),samples:[{height:t,time:e.timeStamp}]},N.current=!1,ae(t,r),v(!0),e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault())},t[22]=U,t[23]=i,t[24]=o,t[25]=ae,t[26]=I,t[27]=n,t[28]=R,t[29]=se):se=t[29];let ce=a(se),le;t[30]!==m||t[31]!==R?(le=e=>{let t=E.current;if(!t||t.pointerId!==e.pointerId)return;let n=t.startY-e.clientY;Math.abs(n)>3&&(N.current=!0),S(t.samples,t.height+n,e.timeStamp);let r=T(t.height+n,t.minimum,t.maximum);j.current=m===`height`?Math.max(t.minimum,r):r,A.current===null&&(A.current=requestAnimationFrame(()=>{A.current=null,j.current!==null&&R(j.current)})),e.preventDefault()},t[30]=m,t[31]=R,t[32]=le):le=t[32];let ue=a(le),de;t[33]!==U||t[34]!==s||t[35]!==I||t[36]!==G||t[37]!==K||t[38]!==n?(de=(e,t)=>{let r=E.current;if(!r||r.pointerId!==e.pointerId)return;let i=j.current??I(),a=r.height+r.startY-e.clientY;t||S(r.samples,a,e.timeStamp);let o=t?0:C(r.samples,e.timeStamp);if(G(),!t&&N.current&&s?.(i,o,r.height))U(),v(!1),n.current&&(n.current.style.willChange=``);else{let e=t||!N.current?r.point:w(r.points,r.point,i,o,a-r.height);K(e,i,!0,o)}e.preventDefault()},t[33]=U,t[34]=s,t[35]=I,t[36]=G,t[37]=K,t[38]=n,t[39]=de):de=t[39];let q=a(de),fe;t[40]!==i||t[41]!==K?(fe=e=>{let t=[...i()].sort(ne),n=t.find(e=>e.id===x.current);if(!n)return;let r=e>0?t.find(e=>e.height>n.height+1):t.sort(te).find(e=>e.height<n.height-1);r&&K(r.id)},t[40]=i,t[41]=K,t[42]=fe):fe=t[42];let J=a(fe),pe;t[43]!==i||t[44]!==K||t[45]!==J?(pe=()=>{if(N.current){N.current=!1;return}let e=[...i()].sort(ee);x.current===e.at(-1)?.id?K(e[0].id):J(1)},t[43]=i,t[44]=K,t[45]=J,t[46]=pe):pe=t[46];let me=a(pe),Y;t[47]!==i||t[48]!==me||t[49]!==K||t[50]!==J?(Y=e=>{if(![`ArrowUp`,`ArrowDown`,`Home`,`End`,`Enter`,` `].includes(e.key))return;e.preventDefault();let t=[...i()].sort(D);t.length&&(e.key===`ArrowUp`?J(1):e.key===`ArrowDown`?J(-1):e.key===`Home`?K(t.at(-1).id):e.key===`End`?K(t[0].id):me())},t[47]=i,t[48]=me,t[49]=K,t[50]=J,t[51]=Y):Y=t[51];let X=a(Y),he;t[52]!==U||t[53]!==V||t[54]!==r||t[55]!==G||t[56]!==n?(he=()=>{U(),G(),V(),x.current=r,g(r),v(!1),b(!1),N.current=!1,n.current&&(n.current.style.height=``,n.current.style.willChange=``)},t[52]=U,t[53]=V,t[54]=r,t[55]=G,t[56]=n,t[57]=he):he=t[57];let Z=a(he),Q,ge;t[58]!==U||t[59]!==V||t[60]!==G?(Q=()=>()=>{U(),G(),V()},ge=[U,G,V],t[58]=U,t[59]=V,t[60]=G,t[61]=Q,t[62]=ge):(Q=t[61],ge=t[62]),(0,f.useLayoutEffect)(Q,ge);let $;t[63]===q?$=t[64]:($=e=>q(e,!1),t[63]=q,t[64]=$);let _e=a($),ve;t[65]===q?ve=t[66]:(ve=e=>q(e,!0),t[65]=q,t[66]=ve);let ye=a(ve),be;t[67]===q?be=t[68]:(be=e=>q(e,!0),t[67]=q,t[68]=be);let xe=a(be),Se;return t[69]!==_||t[70]!==me||t[71]!==X||t[72]!==ce||t[73]!==ue||t[74]!==Z||t[75]!==K||t[76]!==y||t[77]!==h||t[78]!==_e||t[79]!==ye||t[80]!==xe?(Se={snapPoint:h,dragging:_,settling:y,settleAt:K,reset:Z,handlePointerDown:ce,handlePointerMove:ue,handlePointerUp:_e,handlePointerCancel:ye,handleLostPointerCapture:xe,handleClick:me,handleKeyDown:X},t[69]=_,t[70]=me,t[71]=X,t[72]=ce,t[73]=ue,t[74]=Z,t[75]=K,t[76]=y,t[77]=h,t[78]=_e,t[79]=ye,t[80]=xe,t[81]=Se):Se=t[81],Se}function D(e,t){return e.height-t.height}function ee(e,t){return e.height-t.height}function te(e,t){return t.height-e.height}function ne(e,t){return e.height-t.height}function re(e){return e.height}function ie(e){return e.height}function O(){}function k(e){return e.height}var A=.72,j=.98,M=64,N=()=>Math.max(1,window.innerHeight),P=(e,t)=>{let n=Math.max(1,e)*A;return t==null||!Number.isFinite(t)?n:Math.min(n,Math.max(0,t))},F=e=>{let t=(0,p.c)(20),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{initialSnapPoint:r,fitContent:i,onDismiss:o,dismissThresholdPx:s}=n,c=r===void 0?A:r,l=i!==void 0&&i,u=s===void 0?M:s,d=f.useRef(null),m=f.useRef(null),h=f.useRef(c),g=o?0:void 0,_;t[2]===l?_=t[3]:(_=()=>{let e=N(),t=d.current?.parentElement?.clientHeight||e;return l&&h.current===.72&&d.current&&!d.current.hasAttribute(`data-height-snap-active`)&&(m.current=P(e,d.current.getBoundingClientRect().height)),[{id:A,height:Math.min(t,P(e,l?m.current:void 0))},{id:j,height:Math.min(t,e*j)}]},t[2]=l,t[3]=_);let v;t[4]!==u||t[5]!==l||t[6]!==o?(v=(e,t,n)=>{let r=d.current?.parentElement?.clientHeight||N(),i=Math.min(r,P(N(),l?m.current:void 0)),a=t<-.55&&n<=i+1&&e<i-8;return!o||!a&&e>i-u?!1:(o(),!0)},t[4]=u,t[5]=l,t[6]=o,t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{h.current=e},t[8]=y):y=t[8];let b;t[9]!==c||t[10]!==g||t[11]!==_||t[12]!==v?(b={surfaceRef:d,initialPoint:c,renderMode:`translate`,minimumHeight:g,getPoints:_,onRelease:v,onCommit:y},t[9]=c,t[10]=g,t[11]=_,t[12]=v,t[13]=b):b=t[13];let x=E(b),S;t[14]!==x||t[15]!==c?(S=()=>{m.current=null,h.current=c,x.reset()},t[14]=x,t[15]=c,t[16]=S):S=t[16];let C=a(S),w;return t[17]!==x||t[18]!==C?(w={...x,surfaceRef:d,reset:C},t[17]=x,t[18]=C,t[19]=w):w=t[19],w},I=e=>{let t=(0,p.c)(12),{controller:n,ariaLabel:r}=e,i;t[0]===n.snapPoint?i=t[1]:(i=Math.round(n.snapPoint*100),t[0]=n.snapPoint,t[1]=i);let a;return t[2]!==r||t[3]!==n.handleClick||t[4]!==n.handleKeyDown||t[5]!==n.handleLostPointerCapture||t[6]!==n.handlePointerCancel||t[7]!==n.handlePointerDown||t[8]!==n.handlePointerMove||t[9]!==n.handlePointerUp||t[10]!==i?(a=(0,m.jsx)(y,{"data-mobile-sheet-snap-handle":!0,role:`separator`,tabIndex:0,"aria-label":r,"aria-orientation":`horizontal`,"aria-valuemin":A*100,"aria-valuemax":j*100,"aria-valuenow":i,className:`flex min-h-8 cursor-ns-resize touch-none justify-center pt-2.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onPointerDown:n.handlePointerDown,onPointerMove:n.handlePointerMove,onPointerUp:n.handlePointerUp,onPointerCancel:n.handlePointerCancel,onLostPointerCapture:n.handleLostPointerCapture,onClick:n.handleClick,onKeyDown:n.handleKeyDown}),t[2]=r,t[3]=n.handleClick,t[4]=n.handleKeyDown,t[5]=n.handleLostPointerCapture,t[6]=n.handlePointerCancel,t[7]=n.handlePointerDown,t[8]=n.handlePointerMove,t[9]=n.handlePointerUp,t[10]=i,t[11]=a):a=t[11],a},L=new WeakMap;function R(e){L.set(e.currentTarget,!0)}function z(e){if(L.delete(e.currentTarget))return!0;if(e.detail!==0)return!1;if(typeof document>`u`)return!0;let t=document.activeElement,n=e.currentTarget;return n instanceof Node&&t instanceof Node&&n.contains(t)}function ae(e){e.target===e.currentTarget&&R(e)}function B(e){return e.target===e.currentTarget&&z(e)}var V=(0,f.createContext)(!0),H=(e,t)=>{let n=`flex min-h-0 flex-col bg-background shadow-none`;if(e===`page`)return`${n} h-full w-full`;let r=`${n} pwa-overlay-panel`;return t===`top`?`${r} mx-auto mb-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-b-xl border-x border-b border-border/50`:t===`left`?`${r} h-full w-[min(86vw,24rem)] rounded-r-xl border-r border-y border-border/50`:t===`right`?`${r} ml-auto h-full w-[min(86vw,24rem)] rounded-l-xl border-l border-y border-border/50`:`${r} mx-auto mt-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-t-2xl border-x border-t border-border/50 pb-[max(0.5rem,var(--yuri-app-bottom-safe,0px),var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px)))]`},U=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),W=(e,t)=>{let n=U(t),r=`${(1-n)*100}%`;return{progress:n,scrimOpacity:n,surfaceOpacity:n,surfaceTransform:e===`left`?`translate3d(-${r}, 0, 0)`:e===`right`?`translate3d(${r}, 0, 0)`:e===`top`?`translate3d(0, -${r}, 0)`:`translate3d(0, ${r}, 0)`}},G=(e,t)=>{let n=U(t);return e===`present`?n:1-n},oe=(e,t)=>e===`present`?+(t===`commit`):t===`commit`?0:1,K=e=>+!!e,se=`mobile-sessions`,ce=new Map,le=e=>ce.get(e)??null,ue=(e,t)=>(ce.set(e,t),()=>{ce.get(e)===t&&ce.delete(e)}),de=`.overlay-scrollbar-container`,q=1,fe=e=>e===`left`||e===`right`?`x`:`y`,J=e=>e===`bottom`||e===`right`?1:-1,pe=(e,t,n)=>{let r=fe(e)===`x`?t:n;return Math.max(0,r*J(e))},me=(e,t,n,r,i)=>{let a=pe(e,t,n),o=Math.abs(fe(e)===`x`?n:t);return Math.hypot(t,n)>r&&a>0&&o<a*i},Y=(e,t)=>Math.min(1,Math.max(0,e/Math.max(1,t))),X=(e,t,n,r)=>Math.min(r,Math.max(n,e*t)),he=(e,t,n,r,i)=>e>=n||e>=i&&t>=r,Z=(e,t,n,r,i)=>t!==0&&n>0?t*i/n:r>80?0:e,Q=(e,t,n=q)=>{if(t===`bottom`)return e.scrollTop<=n;if(t===`top`)return e.scrollTop>=e.scrollHeight-e.clientHeight-n;if(e.matches?.(`:dir(rtl)`)){let r=e.scrollWidth-e.clientWidth;return t===`right`?Math.abs(e.scrollLeft)<=n:Math.abs(e.scrollLeft)>=r-n}return t===`right`?e.scrollLeft<=n:e.scrollLeft>=e.scrollWidth-e.clientWidth-n},ge=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=e.item(n);if(r?.identifier===t)return r}return null},$=(e,t)=>{let n=window.getComputedStyle(e),r=fe(t),i=r===`x`?n.overflowX:n.overflowY,a=r===`x`?e.scrollWidth:e.scrollHeight,o=r===`x`?e.clientWidth:e.clientHeight;return(i===`auto`||i===`scroll`||i===`overlay`)&&a>o},_e=(e,t,n,r)=>{let i=t instanceof Element?t:null,a=i instanceof HTMLElement?i:i?.parentElement??null;for(;a&&e.contains(a);){if($(a,n))return a;if(a===e)break;a=a.parentElement}let o=i?.closest(r)??null;return o&&e.contains(o)&&$(o,n)?o:null},ve=e=>{let t=f.useRef(e),n=f.useRef(null),r=f.useRef(null);return t.current=e,f.useCallback(e=>{if(n.current?.(),n.current=null,!e)return;let i=()=>{let e=r.current;r.current=null,e?.active&&e.controller?.finish(`cancel`)},a=(e,t,n)=>{let r=fe(e.edge)===`x`?t.clientX:t.clientY,i=n-e.lastTime,a=r-e.lastPrimary;e.velocity=Z(e.velocity,a,i,n-e.lastVelocityTime,J(e.edge)),a!==0&&i>0&&(e.lastVelocityTime=n),e.lastPrimary=r,e.lastTime=n,e.distance=pe(e.edge,t.clientX-e.startX,t.clientY-e.startY)},o=n=>{i();let a=t.current;if(a.disabled||n.touches.length!==1)return;let o=n.target instanceof Element?n.target:null,s=a.reservedTargetSelector?o?.closest(a.reservedTargetSelector):null;if(s&&e.contains(s)||o?.closest(`input, textarea, select, [contenteditable=""], [contenteditable="true"], [data-mobile-sheet-no-dismiss]`))return;let c=n.touches[0],l=_e(e,n.target,a.edge,a.scrollContainerSelector??de);if(l&&!Q(l,a.edge))return;let u=e.getBoundingClientRect(),d=fe(a.edge)===`x`?u.width||window.innerWidth:u.height||window.innerHeight;r.current={edge:a.edge,motionId:a.motionId,touchId:c.identifier,startX:c.clientX,startY:c.clientY,lastPrimary:fe(a.edge)===`x`?c.clientX:c.clientY,lastTime:n.timeStamp,lastVelocityTime:n.timeStamp,velocity:0,distance:0,commitDistance:X(d,a.commitDistanceRatio??.1,a.minCommitDistance??40,a.maxCommitDistance??64),motionDistance:d,intentDistance:a.intentDistance??8,maxOffAxisRatio:a.maxOffAxisRatio??1,flingVelocity:a.flingVelocity??.65,flingMinDistance:a.flingMinDistance??12,controller:null,active:!1}},s=e=>{let n=r.current;if(!n)return;if(t.current.disabled||e.touches.length!==1){i();return}let o=ge(e.touches,n.touchId);if(!o){i();return}if(a(n,o,e.timeStamp),!n.active){if(Math.hypot(o.clientX-n.startX,o.clientY-n.startY)<=n.intentDistance)return;if(!me(n.edge,o.clientX-n.startX,o.clientY-n.startY,n.intentDistance,n.maxOffAxisRatio)){r.current=null;return}let e=le(n.motionId);if(!e){r.current=null;return}if(!e.begin(`dismiss`)){r.current=null;return}n.active=!0,n.controller=e}n.controller?.update(Y(n.distance,n.motionDistance)),e.preventDefault()},c=e=>{let t=r.current;if(!t)return;let n=ge(e.changedTouches,t.touchId);if(!n){i();return}if(r.current=null,!t.active)return;a(t,n,e.timeStamp),t.controller?.update(Y(t.distance,t.motionDistance));let o=he(t.distance,t.velocity,t.commitDistance,t.flingVelocity,t.flingMinDistance);t.controller?.finish(o?`commit`:`cancel`),e.preventDefault()},l=()=>i();e.addEventListener(`touchstart`,o,{passive:!0,capture:!0}),e.addEventListener(`touchmove`,s,{passive:!1,capture:!0}),e.addEventListener(`touchend`,c,{passive:!1,capture:!0}),e.addEventListener(`touchcancel`,l,{passive:!0,capture:!0}),n.current=()=>{i(),e.removeEventListener(`touchstart`,o,!0),e.removeEventListener(`touchmove`,s,!0),e.removeEventListener(`touchend`,c,!0),e.removeEventListener(`touchcancel`,l,!0)}},[])},ye=`mobile-overlay-root`,be=200,xe=80,Se=`cubic-bezier(0.32, 0.72, 0, 1)`,Ce=`a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`,we=()=>{if(typeof document>`u`)return null;let e=document.getElementById(ye);return e||(e=document.createElement(`div`),e.id=ye,document.body.appendChild(e)),e},Te=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Ee=({id:e,open:t,onOpenChange:n,keepMounted:r=!1,presentation:i=`sheet`,edge:a=`bottom`,children:s,className:c,scrimClassName:l,surfaceClassName:u,surfaceElementRef:p,dismissGesture:g=!1,onExitComplete:_,onPreviewChange:y,ariaLabel:b})=>{let x=f.useRef(null),S=f.useRef(null),C=f.useRef(null),w=f.useRef(null),T=f.useRef(t),E=f.useRef(n),D=f.useRef(_),ee=f.useRef(y),te=f.useRef(0),ne=f.useRef(0),re=f.useRef(null),ie=f.useRef([]),O=f.useRef(null),k=f.useRef(`standard`),A=f.useRef(`present`),j=f.useRef(0),M=f.useRef(!1),N=f.useRef(t),P=f.useRef(!1),F=f.useRef(t),I=f.useRef(null),[L,R]=f.useState(t),[z,U]=f.useState(t),[se,ce]=f.useState(`standard`),[le,de]=f.useState(!1),q=se===`interactive-present`,fe=f.useSyncExternalStore(d.subscribe,d.getSnapshot,d.getSnapshot),J=z&&!q&&fe===e,pe=ve({motionId:e,edge:a,disabled:!g,...typeof g==`object`?g:{}}),me=f.useCallback(e=>{C.current=e,pe(e),typeof p==`function`?p(e):p&&typeof p==`object`&&(p.current=e)},[pe,p]),Y=f.useCallback(()=>{F.current&&(F.current=!1,U(!1),r||R(!1),D.current?.())},[r]);T.current=t,E.current=n,D.current=_,ee.current=y,f.useLayoutEffect(()=>{ee.current?.(z&&q)},[z,q]),typeof document<`u`&&!x.current&&(x.current=we());let X=f.useCallback(e=>{let t=W(a,e);te.current=t.progress,!(!S.current||!C.current)&&(S.current.style.opacity=String(t.scrimOpacity),C.current.style.transform=t.surfaceTransform,C.current.style.opacity=String(t.surfaceOpacity))},[a]),he=f.useCallback(()=>{re.current!==null&&window.cancelAnimationFrame(re.current),re.current=null},[]),Z=f.useCallback(()=>{S.current&&(S.current.style.willChange=``),C.current&&(C.current.style.willChange=``)},[]),Q=f.useCallback((e=ie.current)=>{for(let t of e)t.cancel();ie.current=[]},[]),ge=f.useCallback(()=>{he();let e=O.current;if(e){let t=e.animations[1]?.effect?.getComputedTiming().progress;X(typeof t==`number`&&Number.isFinite(t)?e.from+(e.target-e.from)*t:te.current),Q(e.animations),O.current=null}else Q();Z(),de(!1)},[X,Q,he,Z]),$=f.useCallback((e,t)=>{if(O.current?.target===e)return;ge();let n=te.current,r=S.current,i=C.current;if(de(!0),!r||!i||Te()||n===e){X(e),Z(),de(!1),t?.();return}let o=W(a,n),s=W(a,e);r.style.willChange=`opacity`,i.style.willChange=`transform, opacity`;let c=Math.max(xe,be*Math.abs(e-n)),l=[r.animate([{opacity:o.scrimOpacity},{opacity:s.scrimOpacity}],{duration:c,easing:Se,fill:`forwards`}),i.animate([{transform:o.surfaceTransform,opacity:o.surfaceOpacity},{transform:s.surfaceTransform,opacity:s.surfaceOpacity}],{duration:c,easing:Se,fill:`forwards`})];ie.current=l;let u={from:n,target:e,animations:l};O.current=u,Promise.all(l.map(e=>e.finished.catch(()=>void 0))).then(()=>{O.current===u&&(X(e),Q(l),O.current=null,Z(),de(!1),t?.())})},[X,Q,Z,a,ge]);if(f.useLayoutEffect(()=>{P.current=L,L&&X(ne.current)},[X,L]),f.useLayoutEffect(()=>{F.current=z},[z]),f.useEffect(()=>{t&&!P.current&&(ne.current=te.current,R(!0)),t&&!F.current&&(F.current=!0,U(!0)),P.current&&k.current===`standard`&&$(K(t),()=>{!T.current&&k.current===`standard`&&Y()})},[Y,t,$]),f.useLayoutEffect(()=>{!L||k.current!==`standard`||$(+!!t,()=>{!T.current&&k.current===`standard`&&Y()})},[Y,L,t,$]),f.useEffect(()=>{if(!(!z||q))return window.dispatchEvent(new Event(`yuri:mobile-overlay-opened`)),()=>{window.dispatchEvent(new Event(`yuri:mobile-overlay-closed`))}},[z,q]),f.useEffect(()=>{if(!(!z||q))return d.add({id:e,onClose:()=>E.current(!1)},document.body)},[z,e,q]),f.useEffect(()=>{if(!z||q||!J)return;let e=C.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;w.current?.focus({preventScroll:!0});let n=t=>{if(t.key===`Escape`&&d.closeTop(),t.key!==`Tab`||!e)return;let n=Array.from(e.querySelectorAll(Ce)).filter(e=>!e.closest(`[data-mobile-sheet-snap-handle]`)),r=n[0]??w.current,i=n.at(-1)??w.current;!r||!i||(t.shiftKey&&document.activeElement===r&&(t.preventDefault(),i.focus({preventScroll:!0})),!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),r.focus({preventScroll:!0})))};return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n),v()||t?.focus({preventScroll:!0})}},[z,q,J]),I.current={begin:e=>{if(e===`dismiss`&&(!F.current||k.current===`interactive-present`))return!1;ge(),j.current+=1,M.current=!0,A.current=e;let t=e===`present`?`interactive-present`:`interactive-dismiss`;return k.current=t,ce(t),de(!0),e===`present`&&(ne.current=te.current,F.current=!0,U(!0),R(!0)),!0},update:e=>{M.current&&(ne.current=G(A.current,e),re.current===null&&(re.current=window.requestAnimationFrame(()=>{re.current=null,M.current&&X(ne.current)})))},finish:e=>{if(!M.current)return;M.current=!1;let t=j.current,n=A.current,r=oe(n,e);re.current!==null&&(he(),X(ne.current)),$(r,()=>{t===j.current&&(e===`commit`&&E.current(n===`present`),n===`present`&&e===`cancel`&&!T.current&&Y(),k.current=`standard`,ce(`standard`),r===0&&Y())})},interrupt:()=>{j.current+=1,M.current=!1;let e=k.current===`interactive-present`&&!T.current;e||(k.current=`standard`,ce(`standard`)),ge(),$(K(T.current),()=>{T.current||Y(),e&&(k.current=`standard`,ce(`standard`))})}},f.useLayoutEffect(()=>{let e=N.current;N.current=t,e&&!t&&k.current!==`standard`&&I.current?.interrupt()},[t]),f.useEffect(()=>{let t=ue(e,{begin:e=>I.current?.begin(e)??!1,update:e=>I.current?.update(e),finish:e=>I.current?.finish(e),interrupt:()=>I.current?.interrupt()});return()=>{t(),he(),Q(),O.current=null,Z(),I.current=null}},[Q,he,Z,e]),!L||!x.current)return null;let _e=(0,m.jsx)(`div`,{ref:S,className:o(`yuri-mobile-window-motion yuri-keyboard-inset-surface fixed inset-0 z-[60] flex flex-col bg-[rgb(0_0_0_/_0.45)]`,le&&`yuri-mobile-window-motion-active`,!z&&!q&&`pointer-events-none invisible`,l,c),"data-mobile-overlay-active":String(z),role:q?void 0:`dialog`,"aria-label":q?void 0:b,"aria-modal":z&&J?`true`:void 0,"aria-hidden":q||!z||!J||void 0,inert:q||!z||!J||void 0,onPointerDown:ae,onClick:e=>{!z||q||!J||B(e)&&E.current(!1)},children:(0,m.jsxs)(`div`,{ref:me,className:o(`yuri-mobile-floating-shell`,H(i,a),u),"data-yuri-motion-id":e,style:{contain:`layout paint style`},onClick:e=>e.stopPropagation(),children:[(0,m.jsx)(`span`,{ref:w,tabIndex:-1,className:`sr-only`,role:`group`,"aria-label":b}),(0,m.jsx)(V.Provider,{value:J,children:s})]})});return(0,h.createPortal)(_e,x.current)},De=f.createContext(null),Oe=e=>{let t=(0,p.c)(5),{children:n}=e,r=f.useContext(De);if(!r)return null;let i;t[0]===n?i=t[1]:(i=(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,h.createPortal)(i,r),t[2]=r,t[3]=i,t[4]=a):a=t[4],a},ke=e=>{let t=(0,p.c)(47),{id:n,open:r,onOpenChange:i,title:a,leading:c,trailing:l,ariaLabel:d,closeAriaLabel:h,resizeAriaLabel:g,initiallyExpanded:_,fitContent:v,bodyClassName:y,className:b,children:x}=e,S=_!==void 0&&_,C=v!==void 0&&v,w=S?j:void 0,T;t[0]!==i||t[1]!==r?(T=r?()=>i(!1):void 0,t[0]=i,t[1]=r,t[2]=T):T=t[2];let E;t[3]!==C||t[4]!==w||t[5]!==T?(E={initialSnapPoint:w,fitContent:C,onDismiss:T},t[3]=C,t[4]=w,t[5]=T,t[6]=E):E=t[6];let D=F(E),[ee,te]=f.useState(null),ne=a!=null||c!=null||l!=null,re=D.snapPoint===j,ie=re||!C,O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O={reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},t[7]=O):O=t[7];let k=re?`h-[98dvh] max-h-[98dvh]`:C?`h-auto max-h-[72dvh]`:`h-[72dvh] max-h-[98dvh]`,A=D.surfaceRef,M=D.reset,N=ie&&`flex-1`,P;t[8]===N?P=t[9]:(P=o(`flex min-h-0 flex-col`,N),t[8]=N,t[9]=P);let L;t[10]!==g||t[11]!==D?(L=(0,m.jsx)(I,{controller:D,ariaLabel:g}),t[10]=g,t[11]=D,t[12]=L):L=t[12];let R;t[13]!==h||t[14]!==C||t[15]!==ne||t[16]!==c||t[17]!==i||t[18]!==a||t[19]!==l?(R=ne?(0,m.jsxs)(`div`,{className:C?`flex min-h-9 items-center gap-2 px-4 pb-1`:`flex min-h-10 items-center gap-2 px-4 pb-2`,children:[c?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center`,children:c}):null,(0,m.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),l?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:l}):null,(0,m.jsx)(`div`,{ref:te,className:`contents`}),(0,m.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i(!1),"aria-label":h,className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,m.jsx)(u,{name:`close`,className:`size-5`})})]}):null,t[13]=h,t[14]=C,t[15]=ne,t[16]=c,t[17]=i,t[18]=a,t[19]=l,t[20]=R):R=t[20];let z;t[21]!==L||t[22]!==R?(z=(0,m.jsxs)(`div`,{className:`shrink-0`,children:[L,R]}),t[21]=L,t[22]=R,t[23]=z):z=t[23];let ae=ie&&`flex-1`,B;t[24]!==y||t[25]!==ae?(B=o(`flex min-h-0 flex-col overflow-hidden`,ae,y),t[24]=y,t[25]=ae,t[26]=B):B=t[26];let V;t[27]!==x||t[28]!==B?(V=(0,m.jsx)(`div`,{className:B,"data-page-scroll-lock":`true`,children:x}),t[27]=x,t[28]=B,t[29]=V):V=t[29];let H;t[30]!==P||t[31]!==z||t[32]!==V?(H=(0,m.jsxs)(`div`,{className:P,children:[z,V]}),t[30]=P,t[31]=z,t[32]=V,t[33]=H):H=t[33];let U;t[34]!==d||t[35]!==b||t[36]!==n||t[37]!==i||t[38]!==r||t[39]!==D.reset||t[40]!==D.surfaceRef||t[41]!==H||t[42]!==k?(U=(0,m.jsx)(Ee,{id:n,className:b,open:r,onOpenChange:i,presentation:`sheet`,edge:`bottom`,dismissGesture:O,ariaLabel:d,surfaceClassName:k,surfaceElementRef:A,onExitComplete:M,children:H}),t[34]=d,t[35]=b,t[36]=n,t[37]=i,t[38]=r,t[39]=D.reset,t[40]=D.surfaceRef,t[41]=H,t[42]=k,t[43]=U):U=t[43];let W;return t[44]!==ee||t[45]!==U?(W=(0,m.jsx)(De.Provider,{value:ee,children:U}),t[44]=ee,t[45]=U,t[46]=W):W=t[46],W};export{_ as C,v as S,I as _,pe as a,E as b,me as c,le as d,V as f,B as g,ae as h,X as i,he as l,R as m,Oe as n,Y as o,z as p,Ee as r,Z as s,ke as t,se as u,j as v,y as x,F as y};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{at as t,ot as n,st as r}from"./vendor-base-ui-CzHs0bHY.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{i as a}from"./vendor-reactuses-core-DWo5Wn6R.js";import{r as o,t as s}from"./button-DSfiaJr4.js";import{a as c,c as l}from"./vendor-framer-motion-DDMKlXiP.js";import{n as u}from"./Icon-wD7peplo.js";import{t as d}from"./MobileWindowStack-DGLdgoGr.js";var f=e(r(),1),p=i(),m=n(),h=e(t(),1),g=0,_=()=>{g=Date.now()+800},v=()=>Date.now()<g;function y(e){let t=(0,p.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`flex cursor-ns-resize touch-none justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,m.jsx)(`div`,{className:`pointer-events-none h-1.5 w-11 rounded-full bg-[var(--interactive-border)]`}),t[5]=a):a=t[5];let s;return t[6]!==r||t[7]!==i?(s=(0,m.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=s):s=t[8],s}var b=100,x=.35;function S(e,t,n){let r=e.at(-1),i=e.at(-2);for(r&&i&&Math.abs(t-r.height)>2&&(t-r.height)*(r.height-i.height)<0&&e.splice(0,e.length-1),e.push({height:t,time:n});e.length>2&&(e.length>16||e[1].time<n-b);)e.shift()}function C(e,t){let n=e.at(-1);if(!n||t-n.time>=b)return 0;let r=e.find(e=>e.time>=t-b);return!r||n.time<=r.time?0:Math.max(-4,Math.min(4,(n.height-r.height)/Math.max(1,t-r.time)))}function w(e,t,n,r,i){let a=Math.abs(r)>=x&&Math.abs(i)>=8,o=n+(a?r*180:0),s=e.reduce((e,t)=>Math.abs(t.height-o)<Math.abs(e.height-o)?t:e),c=e.find(e=>e.id===t)??s;return!a||Math.abs(s.height-c.height)>1?s.id:[...e].sort((e,t)=>r>0?e.height-t.height:t.height-e.height).find(e=>r>0?e.height>c.height+1:e.height<c.height-1)?.id??s.id}function T(e,t,n){let r=e<t?t:e>n?n:e,i=e-r;return r+Math.sign(i)*48*(1-1/(1+Math.abs(i)*.55/48))}function E(e){let t=(0,p.c)(82),{surfaceRef:n,initialPoint:r,getPoints:i,minimumHeight:o,onRelease:s,onCommit:u,renderMode:d}=e,m=d===void 0?`height`:d,[h,g]=(0,f.useState)(r),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),x=(0,f.useRef)(r),E=(0,f.useRef)(null),A=(0,f.useRef)(null),j=(0,f.useRef)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(!1),P=(0,f.useRef)(null),F;t[0]===n?F=t[1]:(F=()=>{let e=n.current;if(!e)return 0;if(!P.current)return e.getBoundingClientRect().height;let t=parseFloat(getComputedStyle(e).translate.split(` `)[1])||0;return P.current.layoutHeight-t},t[0]=n,t[1]=F);let I=a(F),L;t[2]===n?L=t[3]:(L=e=>{let t=n.current;t&&(P.current?t.style.translate=`0 ${P.current.layoutHeight-e}px`:t.style.height=`${e}px`)},t[2]=n,t[3]=L);let R=a(L),z;t[4]!==m||t[5]!==n||t[6]!==R?(z=(e,t)=>{let r=n.current;if(r){if(m===`translate`&&!P.current){let e=Math.max(...t.map(k))+144,{maxHeight:n,position:i,bottom:a,left:o,right:s}=r.style;P.current={layoutHeight:e,styles:{maxHeight:n,position:i,bottom:a,left:o,right:s}},Object.assign(r.style,{position:`absolute`,bottom:`0px`,left:`0px`,right:`0px`}),r.style.maxHeight=`none`,r.style.height=`${e}px`}r.setAttribute(`data-height-snap-active`,``),r.style.willChange=P.current?`translate`:`height`,R(e)}},t[4]=m,t[5]=n,t[6]=R,t[7]=z):z=t[7];let ae=a(z),B;t[8]===n?B=t[9]:(B=()=>{let e=n.current;e&&(P.current&&(e.style.translate=``,Object.assign(e.style,P.current.styles),e.style.height=``),e.style.willChange=``,e.removeAttribute(`data-height-snap-active`)),P.current=null},t[8]=n,t[9]=B);let V=a(B),H;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{A.current!==null&&cancelAnimationFrame(A.current),A.current=null,j.current=null,M.current?.cancel(),M.current=null},t[10]=H):H=t[10];let U=a(H),W;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{let e=E.current;E.current=null,e?.handle.hasPointerCapture?.(e.pointerId)&&e.handle.releasePointerCapture(e.pointerId)},t[11]=W):W=t[11];let G=a(W),oe;t[12]!==U||t[13]!==V||t[14]!==i||t[15]!==u||t[16]!==ae||t[17]!==I||t[18]!==G||t[19]!==n||t[20]!==R?(oe=(e,t,r,a)=>{let o=r===void 0||r,s=a===void 0?0:a,d=n.current;if(!d)return;let f=t??I();U(),R(f);let p=i(),m=p.find(t=>t.id===e);if(!m)return;if(ae(f,p),G(),v(!1),b(!1),x.current=e,g(e),R(m.height),u?.(e),!o||Math.abs(f-m.height)<1||typeof d.animate!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){V();return}b(!0);let h=P.current?.layoutHeight,_=m.height-f,y=c([d],h===void 0?{height:[`${f}px`,`${m.height}px`]}:{translate:[`0 ${h-f}px`,`0 ${h-m.height}px`]},{type:l,stiffness:576,damping:48,mass:1,velocity:s*1e3*100/_,restDelta:20/Math.abs(_),restSpeed:500/Math.abs(_)});M.current=y,y.finished.catch(O).then(()=>{M.current===y&&(M.current=null,V(),b(!1))})},t[12]=U,t[13]=V,t[14]=i,t[15]=u,t[16]=ae,t[17]=I,t[18]=G,t[19]=n,t[20]=R,t[21]=oe):oe=t[21];let K=a(oe),se;t[22]!==U||t[23]!==i||t[24]!==o||t[25]!==ae||t[26]!==I||t[27]!==n||t[28]!==R?(se=e=>{if(E.current||!e.isPrimary||e.pointerType===`mouse`&&e.button!==0||!n.current)return;let t=I();U(),R(t);let r=i();r.length&&(b(!1),E.current={pointerId:e.pointerId,startY:e.clientY,height:t,point:x.current,points:r,handle:e.currentTarget,minimum:o??Math.min(...r.map(ie)),maximum:Math.max(...r.map(re)),samples:[{height:t,time:e.timeStamp}]},N.current=!1,ae(t,r),v(!0),e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault())},t[22]=U,t[23]=i,t[24]=o,t[25]=ae,t[26]=I,t[27]=n,t[28]=R,t[29]=se):se=t[29];let ce=a(se),le;t[30]!==m||t[31]!==R?(le=e=>{let t=E.current;if(!t||t.pointerId!==e.pointerId)return;let n=t.startY-e.clientY;Math.abs(n)>3&&(N.current=!0),S(t.samples,t.height+n,e.timeStamp);let r=T(t.height+n,t.minimum,t.maximum);j.current=m===`height`?Math.max(t.minimum,r):r,A.current===null&&(A.current=requestAnimationFrame(()=>{A.current=null,j.current!==null&&R(j.current)})),e.preventDefault()},t[30]=m,t[31]=R,t[32]=le):le=t[32];let ue=a(le),de;t[33]!==U||t[34]!==s||t[35]!==I||t[36]!==G||t[37]!==K||t[38]!==n?(de=(e,t)=>{let r=E.current;if(!r||r.pointerId!==e.pointerId)return;let i=j.current??I(),a=r.height+r.startY-e.clientY;t||S(r.samples,a,e.timeStamp);let o=t?0:C(r.samples,e.timeStamp);if(G(),!t&&N.current&&s?.(i,o,r.height))U(),v(!1),n.current&&(n.current.style.willChange=``);else{let e=t||!N.current?r.point:w(r.points,r.point,i,o,a-r.height);K(e,i,!0,o)}e.preventDefault()},t[33]=U,t[34]=s,t[35]=I,t[36]=G,t[37]=K,t[38]=n,t[39]=de):de=t[39];let q=a(de),fe;t[40]!==i||t[41]!==K?(fe=e=>{let t=[...i()].sort(ne),n=t.find(e=>e.id===x.current);if(!n)return;let r=e>0?t.find(e=>e.height>n.height+1):t.sort(te).find(e=>e.height<n.height-1);r&&K(r.id)},t[40]=i,t[41]=K,t[42]=fe):fe=t[42];let J=a(fe),pe;t[43]!==i||t[44]!==K||t[45]!==J?(pe=()=>{if(N.current){N.current=!1;return}let e=[...i()].sort(ee);x.current===e.at(-1)?.id?K(e[0].id):J(1)},t[43]=i,t[44]=K,t[45]=J,t[46]=pe):pe=t[46];let me=a(pe),Y;t[47]!==i||t[48]!==me||t[49]!==K||t[50]!==J?(Y=e=>{if(![`ArrowUp`,`ArrowDown`,`Home`,`End`,`Enter`,` `].includes(e.key))return;e.preventDefault();let t=[...i()].sort(D);t.length&&(e.key===`ArrowUp`?J(1):e.key===`ArrowDown`?J(-1):e.key===`Home`?K(t.at(-1).id):e.key===`End`?K(t[0].id):me())},t[47]=i,t[48]=me,t[49]=K,t[50]=J,t[51]=Y):Y=t[51];let X=a(Y),he;t[52]!==U||t[53]!==V||t[54]!==r||t[55]!==G||t[56]!==n?(he=()=>{U(),G(),V(),x.current=r,g(r),v(!1),b(!1),N.current=!1,n.current&&(n.current.style.height=``,n.current.style.willChange=``)},t[52]=U,t[53]=V,t[54]=r,t[55]=G,t[56]=n,t[57]=he):he=t[57];let Z=a(he),Q,ge;t[58]!==U||t[59]!==V||t[60]!==G?(Q=()=>()=>{U(),G(),V()},ge=[U,G,V],t[58]=U,t[59]=V,t[60]=G,t[61]=Q,t[62]=ge):(Q=t[61],ge=t[62]),(0,f.useLayoutEffect)(Q,ge);let $;t[63]===q?$=t[64]:($=e=>q(e,!1),t[63]=q,t[64]=$);let _e=a($),ve;t[65]===q?ve=t[66]:(ve=e=>q(e,!0),t[65]=q,t[66]=ve);let ye=a(ve),be;t[67]===q?be=t[68]:(be=e=>q(e,!0),t[67]=q,t[68]=be);let xe=a(be),Se;return t[69]!==_||t[70]!==me||t[71]!==X||t[72]!==ce||t[73]!==ue||t[74]!==Z||t[75]!==K||t[76]!==y||t[77]!==h||t[78]!==_e||t[79]!==ye||t[80]!==xe?(Se={snapPoint:h,dragging:_,settling:y,settleAt:K,reset:Z,handlePointerDown:ce,handlePointerMove:ue,handlePointerUp:_e,handlePointerCancel:ye,handleLostPointerCapture:xe,handleClick:me,handleKeyDown:X},t[69]=_,t[70]=me,t[71]=X,t[72]=ce,t[73]=ue,t[74]=Z,t[75]=K,t[76]=y,t[77]=h,t[78]=_e,t[79]=ye,t[80]=xe,t[81]=Se):Se=t[81],Se}function D(e,t){return e.height-t.height}function ee(e,t){return e.height-t.height}function te(e,t){return t.height-e.height}function ne(e,t){return e.height-t.height}function re(e){return e.height}function ie(e){return e.height}function O(){}function k(e){return e.height}var A=.72,j=.98,M=64,N=()=>Math.max(1,window.innerHeight),P=(e,t)=>{let n=Math.max(1,e)*A;return t==null||!Number.isFinite(t)?n:Math.min(n,Math.max(0,t))},F=e=>{let t=(0,p.c)(20),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{initialSnapPoint:r,fitContent:i,onDismiss:o,dismissThresholdPx:s}=n,c=r===void 0?A:r,l=i!==void 0&&i,u=s===void 0?M:s,d=f.useRef(null),m=f.useRef(null),h=f.useRef(c),g=o?0:void 0,_;t[2]===l?_=t[3]:(_=()=>{let e=N(),t=d.current?.parentElement?.clientHeight||e;return l&&h.current===.72&&d.current&&!d.current.hasAttribute(`data-height-snap-active`)&&(m.current=P(e,d.current.getBoundingClientRect().height)),[{id:A,height:Math.min(t,P(e,l?m.current:void 0))},{id:j,height:Math.min(t,e*j)}]},t[2]=l,t[3]=_);let v;t[4]!==u||t[5]!==l||t[6]!==o?(v=(e,t,n)=>{let r=d.current?.parentElement?.clientHeight||N(),i=Math.min(r,P(N(),l?m.current:void 0)),a=t<-.55&&n<=i+1&&e<i-8;return!o||!a&&e>i-u?!1:(o(),!0)},t[4]=u,t[5]=l,t[6]=o,t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{h.current=e},t[8]=y):y=t[8];let b;t[9]!==c||t[10]!==g||t[11]!==_||t[12]!==v?(b={surfaceRef:d,initialPoint:c,renderMode:`translate`,minimumHeight:g,getPoints:_,onRelease:v,onCommit:y},t[9]=c,t[10]=g,t[11]=_,t[12]=v,t[13]=b):b=t[13];let x=E(b),S;t[14]!==x||t[15]!==c?(S=()=>{m.current=null,h.current=c,x.reset()},t[14]=x,t[15]=c,t[16]=S):S=t[16];let C=a(S),w;return t[17]!==x||t[18]!==C?(w={...x,surfaceRef:d,reset:C},t[17]=x,t[18]=C,t[19]=w):w=t[19],w},I=e=>{let t=(0,p.c)(12),{controller:n,ariaLabel:r}=e,i;t[0]===n.snapPoint?i=t[1]:(i=Math.round(n.snapPoint*100),t[0]=n.snapPoint,t[1]=i);let a;return t[2]!==r||t[3]!==n.handleClick||t[4]!==n.handleKeyDown||t[5]!==n.handleLostPointerCapture||t[6]!==n.handlePointerCancel||t[7]!==n.handlePointerDown||t[8]!==n.handlePointerMove||t[9]!==n.handlePointerUp||t[10]!==i?(a=(0,m.jsx)(y,{"data-mobile-sheet-snap-handle":!0,role:`separator`,tabIndex:0,"aria-label":r,"aria-orientation":`horizontal`,"aria-valuemin":A*100,"aria-valuemax":j*100,"aria-valuenow":i,className:`flex min-h-8 cursor-ns-resize touch-none justify-center pt-2.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onPointerDown:n.handlePointerDown,onPointerMove:n.handlePointerMove,onPointerUp:n.handlePointerUp,onPointerCancel:n.handlePointerCancel,onLostPointerCapture:n.handleLostPointerCapture,onClick:n.handleClick,onKeyDown:n.handleKeyDown}),t[2]=r,t[3]=n.handleClick,t[4]=n.handleKeyDown,t[5]=n.handleLostPointerCapture,t[6]=n.handlePointerCancel,t[7]=n.handlePointerDown,t[8]=n.handlePointerMove,t[9]=n.handlePointerUp,t[10]=i,t[11]=a):a=t[11],a},L=new WeakMap;function R(e){L.set(e.currentTarget,!0)}function z(e){if(L.delete(e.currentTarget))return!0;if(e.detail!==0)return!1;if(typeof document>`u`)return!0;let t=document.activeElement,n=e.currentTarget;return n instanceof Node&&t instanceof Node&&n.contains(t)}function ae(e){e.target===e.currentTarget&&R(e)}function B(e){return e.target===e.currentTarget&&z(e)}var V=(0,f.createContext)(!0),H=(e,t)=>{let n=`flex min-h-0 flex-col bg-background shadow-none`;if(e===`page`)return`${n} h-full w-full`;let r=`${n} pwa-overlay-panel`;return t===`top`?`${r} mx-auto mb-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-b-xl border-x border-b border-border/50`:t===`left`?`${r} h-full w-[min(86vw,24rem)] rounded-r-xl border-r border-y border-border/50`:t===`right`?`${r} ml-auto h-full w-[min(86vw,24rem)] rounded-l-xl border-l border-y border-border/50`:`${r} mx-auto mt-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-t-2xl border-x border-t border-border/50 pb-[max(0.5rem,var(--yuri-app-bottom-safe,0px),var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px)))]`},U=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),W=(e,t)=>{let n=U(t),r=`${(1-n)*100}%`;return{progress:n,scrimOpacity:n,surfaceOpacity:n,surfaceTransform:e===`left`?`translate3d(-${r}, 0, 0)`:e===`right`?`translate3d(${r}, 0, 0)`:e===`top`?`translate3d(0, -${r}, 0)`:`translate3d(0, ${r}, 0)`}},G=(e,t)=>{let n=U(t);return e===`present`?n:1-n},oe=(e,t)=>e===`present`?+(t===`commit`):t===`commit`?0:1,K=e=>+!!e,se=`mobile-sessions`,ce=new Map,le=e=>ce.get(e)??null,ue=(e,t)=>(ce.set(e,t),()=>{ce.get(e)===t&&ce.delete(e)}),de=`.overlay-scrollbar-container`,q=1,fe=e=>e===`left`||e===`right`?`x`:`y`,J=e=>e===`bottom`||e===`right`?1:-1,pe=(e,t,n)=>{let r=fe(e)===`x`?t:n;return Math.max(0,r*J(e))},me=(e,t,n,r,i)=>{let a=pe(e,t,n),o=Math.abs(fe(e)===`x`?n:t);return Math.hypot(t,n)>r&&a>0&&o<a*i},Y=(e,t)=>Math.min(1,Math.max(0,e/Math.max(1,t))),X=(e,t,n,r)=>Math.min(r,Math.max(n,e*t)),he=(e,t,n,r,i)=>e>=n||e>=i&&t>=r,Z=(e,t,n,r,i)=>t!==0&&n>0?t*i/n:r>80?0:e,Q=(e,t,n=q)=>{if(t===`bottom`)return e.scrollTop<=n;if(t===`top`)return e.scrollTop>=e.scrollHeight-e.clientHeight-n;if(e.matches?.(`:dir(rtl)`)){let r=e.scrollWidth-e.clientWidth;return t===`right`?Math.abs(e.scrollLeft)<=n:Math.abs(e.scrollLeft)>=r-n}return t===`right`?e.scrollLeft<=n:e.scrollLeft>=e.scrollWidth-e.clientWidth-n},ge=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=e.item(n);if(r?.identifier===t)return r}return null},$=(e,t)=>{let n=window.getComputedStyle(e),r=fe(t),i=r===`x`?n.overflowX:n.overflowY,a=r===`x`?e.scrollWidth:e.scrollHeight,o=r===`x`?e.clientWidth:e.clientHeight;return(i===`auto`||i===`scroll`||i===`overlay`)&&a>o},_e=(e,t,n,r)=>{let i=t instanceof Element?t:null,a=i instanceof HTMLElement?i:i?.parentElement??null;for(;a&&e.contains(a);){if($(a,n))return a;if(a===e)break;a=a.parentElement}let o=i?.closest(r)??null;return o&&e.contains(o)&&$(o,n)?o:null},ve=e=>{let t=f.useRef(e),n=f.useRef(null),r=f.useRef(null);return t.current=e,f.useCallback(e=>{if(n.current?.(),n.current=null,!e)return;let i=()=>{let e=r.current;r.current=null,e?.active&&e.controller?.finish(`cancel`)},a=(e,t,n)=>{let r=fe(e.edge)===`x`?t.clientX:t.clientY,i=n-e.lastTime,a=r-e.lastPrimary;e.velocity=Z(e.velocity,a,i,n-e.lastVelocityTime,J(e.edge)),a!==0&&i>0&&(e.lastVelocityTime=n),e.lastPrimary=r,e.lastTime=n,e.distance=pe(e.edge,t.clientX-e.startX,t.clientY-e.startY)},o=n=>{i();let a=t.current;if(a.disabled||n.touches.length!==1)return;let o=n.target instanceof Element?n.target:null,s=a.reservedTargetSelector?o?.closest(a.reservedTargetSelector):null;if(s&&e.contains(s)||o?.closest(`input, textarea, select, [contenteditable=""], [contenteditable="true"], [data-mobile-sheet-no-dismiss]`))return;let c=n.touches[0],l=_e(e,n.target,a.edge,a.scrollContainerSelector??de);if(l&&!Q(l,a.edge))return;let u=e.getBoundingClientRect(),d=fe(a.edge)===`x`?u.width||window.innerWidth:u.height||window.innerHeight;r.current={edge:a.edge,motionId:a.motionId,touchId:c.identifier,startX:c.clientX,startY:c.clientY,lastPrimary:fe(a.edge)===`x`?c.clientX:c.clientY,lastTime:n.timeStamp,lastVelocityTime:n.timeStamp,velocity:0,distance:0,commitDistance:X(d,a.commitDistanceRatio??.1,a.minCommitDistance??40,a.maxCommitDistance??64),motionDistance:d,intentDistance:a.intentDistance??8,maxOffAxisRatio:a.maxOffAxisRatio??1,flingVelocity:a.flingVelocity??.65,flingMinDistance:a.flingMinDistance??12,controller:null,active:!1}},s=e=>{let n=r.current;if(!n)return;if(t.current.disabled||e.touches.length!==1){i();return}let o=ge(e.touches,n.touchId);if(!o){i();return}if(a(n,o,e.timeStamp),!n.active){if(Math.hypot(o.clientX-n.startX,o.clientY-n.startY)<=n.intentDistance)return;if(!me(n.edge,o.clientX-n.startX,o.clientY-n.startY,n.intentDistance,n.maxOffAxisRatio)){r.current=null;return}let e=le(n.motionId);if(!e){r.current=null;return}if(!e.begin(`dismiss`)){r.current=null;return}n.active=!0,n.controller=e}n.controller?.update(Y(n.distance,n.motionDistance)),e.preventDefault()},c=e=>{let t=r.current;if(!t)return;let n=ge(e.changedTouches,t.touchId);if(!n){i();return}if(r.current=null,!t.active)return;a(t,n,e.timeStamp),t.controller?.update(Y(t.distance,t.motionDistance));let o=he(t.distance,t.velocity,t.commitDistance,t.flingVelocity,t.flingMinDistance);t.controller?.finish(o?`commit`:`cancel`),e.preventDefault()},l=()=>i();e.addEventListener(`touchstart`,o,{passive:!0,capture:!0}),e.addEventListener(`touchmove`,s,{passive:!1,capture:!0}),e.addEventListener(`touchend`,c,{passive:!1,capture:!0}),e.addEventListener(`touchcancel`,l,{passive:!0,capture:!0}),n.current=()=>{i(),e.removeEventListener(`touchstart`,o,!0),e.removeEventListener(`touchmove`,s,!0),e.removeEventListener(`touchend`,c,!0),e.removeEventListener(`touchcancel`,l,!0)}},[])},ye=`mobile-overlay-root`,be=200,xe=80,Se=`cubic-bezier(0.32, 0.72, 0, 1)`,Ce=`a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`,we=()=>{if(typeof document>`u`)return null;let e=document.getElementById(ye);return e||(e=document.createElement(`div`),e.id=ye,document.body.appendChild(e)),e},Te=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Ee=({id:e,open:t,onOpenChange:n,keepMounted:r=!1,presentation:i=`sheet`,edge:a=`bottom`,children:s,className:c,scrimClassName:l,surfaceClassName:u,surfaceElementRef:p,dismissGesture:g=!1,onExitComplete:_,onPreviewChange:y,ariaLabel:b})=>{let x=f.useRef(null),S=f.useRef(null),C=f.useRef(null),w=f.useRef(null),T=f.useRef(t),E=f.useRef(n),D=f.useRef(_),ee=f.useRef(y),te=f.useRef(0),ne=f.useRef(0),re=f.useRef(null),ie=f.useRef([]),O=f.useRef(null),k=f.useRef(`standard`),A=f.useRef(`present`),j=f.useRef(0),M=f.useRef(!1),N=f.useRef(t),P=f.useRef(!1),F=f.useRef(t),I=f.useRef(null),[L,R]=f.useState(t),[z,U]=f.useState(t),[se,ce]=f.useState(`standard`),[le,de]=f.useState(!1),q=se===`interactive-present`,fe=f.useSyncExternalStore(d.subscribe,d.getSnapshot,d.getSnapshot),J=z&&!q&&fe===e,pe=ve({motionId:e,edge:a,disabled:!g,...typeof g==`object`?g:{}}),me=f.useCallback(e=>{C.current=e,pe(e),typeof p==`function`?p(e):p&&typeof p==`object`&&(p.current=e)},[pe,p]),Y=f.useCallback(()=>{F.current&&(F.current=!1,U(!1),r||R(!1),D.current?.())},[r]);T.current=t,E.current=n,D.current=_,ee.current=y,f.useLayoutEffect(()=>{ee.current?.(z&&q)},[z,q]),typeof document<`u`&&!x.current&&(x.current=we());let X=f.useCallback(e=>{let t=W(a,e);te.current=t.progress,!(!S.current||!C.current)&&(S.current.style.opacity=String(t.scrimOpacity),C.current.style.transform=t.surfaceTransform,C.current.style.opacity=String(t.surfaceOpacity))},[a]),he=f.useCallback(()=>{re.current!==null&&window.cancelAnimationFrame(re.current),re.current=null},[]),Z=f.useCallback(()=>{S.current&&(S.current.style.willChange=``),C.current&&(C.current.style.willChange=``)},[]),Q=f.useCallback((e=ie.current)=>{for(let t of e)t.cancel();ie.current=[]},[]),ge=f.useCallback(()=>{he();let e=O.current;if(e){let t=e.animations[1]?.effect?.getComputedTiming().progress;X(typeof t==`number`&&Number.isFinite(t)?e.from+(e.target-e.from)*t:te.current),Q(e.animations),O.current=null}else Q();Z(),de(!1)},[X,Q,he,Z]),$=f.useCallback((e,t)=>{if(O.current?.target===e)return;ge();let n=te.current,r=S.current,i=C.current;if(de(!0),!r||!i||Te()||n===e){X(e),Z(),de(!1),t?.();return}let o=W(a,n),s=W(a,e);r.style.willChange=`opacity`,i.style.willChange=`transform, opacity`;let c=Math.max(xe,be*Math.abs(e-n)),l=[r.animate([{opacity:o.scrimOpacity},{opacity:s.scrimOpacity}],{duration:c,easing:Se,fill:`forwards`}),i.animate([{transform:o.surfaceTransform,opacity:o.surfaceOpacity},{transform:s.surfaceTransform,opacity:s.surfaceOpacity}],{duration:c,easing:Se,fill:`forwards`})];ie.current=l;let u={from:n,target:e,animations:l};O.current=u,Promise.all(l.map(e=>e.finished.catch(()=>void 0))).then(()=>{O.current===u&&(X(e),Q(l),O.current=null,Z(),de(!1),t?.())})},[X,Q,Z,a,ge]);if(f.useLayoutEffect(()=>{P.current=L,L&&X(ne.current)},[X,L]),f.useLayoutEffect(()=>{F.current=z},[z]),f.useEffect(()=>{t&&!P.current&&(ne.current=te.current,R(!0)),t&&!F.current&&(F.current=!0,U(!0)),P.current&&k.current===`standard`&&$(K(t),()=>{!T.current&&k.current===`standard`&&Y()})},[Y,t,$]),f.useLayoutEffect(()=>{!L||k.current!==`standard`||$(+!!t,()=>{!T.current&&k.current===`standard`&&Y()})},[Y,L,t,$]),f.useEffect(()=>{if(!(!z||q))return window.dispatchEvent(new Event(`yuri:mobile-overlay-opened`)),()=>{window.dispatchEvent(new Event(`yuri:mobile-overlay-closed`))}},[z,q]),f.useEffect(()=>{if(!(!z||q))return d.add({id:e,onClose:()=>E.current(!1)},document.body)},[z,e,q]),f.useEffect(()=>{if(!z||q||!J)return;let e=C.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;w.current?.focus({preventScroll:!0});let n=t=>{if(t.key===`Escape`&&d.closeTop(),t.key!==`Tab`||!e)return;let n=Array.from(e.querySelectorAll(Ce)).filter(e=>!e.closest(`[data-mobile-sheet-snap-handle]`)),r=n[0]??w.current,i=n.at(-1)??w.current;!r||!i||(t.shiftKey&&document.activeElement===r&&(t.preventDefault(),i.focus({preventScroll:!0})),!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),r.focus({preventScroll:!0})))};return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n),v()||t?.focus({preventScroll:!0})}},[z,q,J]),I.current={begin:e=>{if(e===`dismiss`&&(!F.current||k.current===`interactive-present`))return!1;ge(),j.current+=1,M.current=!0,A.current=e;let t=e===`present`?`interactive-present`:`interactive-dismiss`;return k.current=t,ce(t),de(!0),e===`present`&&(ne.current=te.current,F.current=!0,U(!0),R(!0)),!0},update:e=>{M.current&&(ne.current=G(A.current,e),re.current===null&&(re.current=window.requestAnimationFrame(()=>{re.current=null,M.current&&X(ne.current)})))},finish:e=>{if(!M.current)return;M.current=!1;let t=j.current,n=A.current,r=oe(n,e);re.current!==null&&(he(),X(ne.current)),$(r,()=>{t===j.current&&(e===`commit`&&E.current(n===`present`),n===`present`&&e===`cancel`&&!T.current&&Y(),k.current=`standard`,ce(`standard`),r===0&&Y())})},interrupt:()=>{j.current+=1,M.current=!1;let e=k.current===`interactive-present`&&!T.current;e||(k.current=`standard`,ce(`standard`)),ge(),$(K(T.current),()=>{T.current||Y(),e&&(k.current=`standard`,ce(`standard`))})}},f.useLayoutEffect(()=>{let e=N.current;N.current=t,e&&!t&&k.current!==`standard`&&I.current?.interrupt()},[t]),f.useEffect(()=>{let t=ue(e,{begin:e=>I.current?.begin(e)??!1,update:e=>I.current?.update(e),finish:e=>I.current?.finish(e),interrupt:()=>I.current?.interrupt()});return()=>{t(),he(),Q(),O.current=null,Z(),I.current=null}},[Q,he,Z,e]),!L||!x.current)return null;let _e=(0,m.jsx)(`div`,{ref:S,className:o(`yuri-mobile-window-motion yuri-keyboard-inset-surface fixed inset-0 z-[60] flex flex-col bg-[rgb(0_0_0_/_0.45)]`,le&&`yuri-mobile-window-motion-active`,!z&&!q&&`pointer-events-none invisible`,l,c),"data-mobile-overlay-active":String(z),role:q?void 0:`dialog`,"aria-label":q?void 0:b,"aria-modal":z&&J?`true`:void 0,"aria-hidden":q||!z||!J||void 0,inert:q||!z||!J||void 0,onPointerDown:ae,onClick:e=>{!z||q||!J||B(e)&&E.current(!1)},children:(0,m.jsxs)(`div`,{ref:me,className:o(`yuri-mobile-floating-shell`,H(i,a),u),"data-yuri-motion-id":e,style:{contain:`layout paint style`},onClick:e=>e.stopPropagation(),children:[(0,m.jsx)(`span`,{ref:w,tabIndex:-1,className:`sr-only`,role:`group`,"aria-label":b}),(0,m.jsx)(V.Provider,{value:J,children:s})]})});return(0,h.createPortal)(_e,x.current)},De=f.createContext(null),Oe=e=>{let t=(0,p.c)(5),{children:n}=e,r=f.useContext(De);if(!r)return null;let i;t[0]===n?i=t[1]:(i=(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,h.createPortal)(i,r),t[2]=r,t[3]=i,t[4]=a):a=t[4],a},ke=e=>{let t=(0,p.c)(47),{id:n,open:r,onOpenChange:i,title:a,leading:c,trailing:l,ariaLabel:d,closeAriaLabel:h,resizeAriaLabel:g,initiallyExpanded:_,fitContent:v,bodyClassName:y,className:b,children:x}=e,S=_!==void 0&&_,C=v!==void 0&&v,w=S?j:void 0,T;t[0]!==i||t[1]!==r?(T=r?()=>i(!1):void 0,t[0]=i,t[1]=r,t[2]=T):T=t[2];let E;t[3]!==C||t[4]!==w||t[5]!==T?(E={initialSnapPoint:w,fitContent:C,onDismiss:T},t[3]=C,t[4]=w,t[5]=T,t[6]=E):E=t[6];let D=F(E),[ee,te]=f.useState(null),ne=a!=null||c!=null||l!=null,re=D.snapPoint===j,ie=re||!C,O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O={reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},t[7]=O):O=t[7];let k=re?`h-[98dvh] max-h-[98dvh]`:C?`h-auto max-h-[72dvh]`:`h-[72dvh] max-h-[98dvh]`,A=D.surfaceRef,M=D.reset,N=ie&&`flex-1`,P;t[8]===N?P=t[9]:(P=o(`flex min-h-0 flex-col`,N),t[8]=N,t[9]=P);let L;t[10]!==g||t[11]!==D?(L=(0,m.jsx)(I,{controller:D,ariaLabel:g}),t[10]=g,t[11]=D,t[12]=L):L=t[12];let R;t[13]!==h||t[14]!==C||t[15]!==ne||t[16]!==c||t[17]!==i||t[18]!==a||t[19]!==l?(R=ne?(0,m.jsxs)(`div`,{className:C?`flex min-h-9 items-center gap-2 px-4 pb-1`:`flex min-h-10 items-center gap-2 px-4 pb-2`,children:[c?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center`,children:c}):null,(0,m.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),l?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:l}):null,(0,m.jsx)(`div`,{ref:te,className:`contents`}),(0,m.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i(!1),"aria-label":h,className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,m.jsx)(u,{name:`close`,className:`size-5`})})]}):null,t[13]=h,t[14]=C,t[15]=ne,t[16]=c,t[17]=i,t[18]=a,t[19]=l,t[20]=R):R=t[20];let z;t[21]!==L||t[22]!==R?(z=(0,m.jsxs)(`div`,{className:`shrink-0`,children:[L,R]}),t[21]=L,t[22]=R,t[23]=z):z=t[23];let ae=ie&&`flex-1`,B;t[24]!==y||t[25]!==ae?(B=o(`flex min-h-0 flex-col overflow-hidden`,ae,y),t[24]=y,t[25]=ae,t[26]=B):B=t[26];let V;t[27]!==x||t[28]!==B?(V=(0,m.jsx)(`div`,{className:B,"data-page-scroll-lock":`true`,children:x}),t[27]=x,t[28]=B,t[29]=V):V=t[29];let H;t[30]!==P||t[31]!==z||t[32]!==V?(H=(0,m.jsxs)(`div`,{className:P,children:[z,V]}),t[30]=P,t[31]=z,t[32]=V,t[33]=H):H=t[33];let U;t[34]!==d||t[35]!==b||t[36]!==n||t[37]!==i||t[38]!==r||t[39]!==D.reset||t[40]!==D.surfaceRef||t[41]!==H||t[42]!==k?(U=(0,m.jsx)(Ee,{id:n,className:b,open:r,onOpenChange:i,presentation:`sheet`,edge:`bottom`,dismissGesture:O,ariaLabel:d,surfaceClassName:k,surfaceElementRef:A,onExitComplete:M,children:H}),t[34]=d,t[35]=b,t[36]=n,t[37]=i,t[38]=r,t[39]=D.reset,t[40]=D.surfaceRef,t[41]=H,t[42]=k,t[43]=U):U=t[43];let W;return t[44]!==ee||t[45]!==U?(W=(0,m.jsx)(De.Provider,{value:ee,children:U}),t[44]=ee,t[45]=U,t[46]=W):W=t[46],W};export{_ as C,v as S,I as _,pe as a,E as b,me as c,le as d,V as f,B as g,ae as h,X as i,he as l,R as m,Oe as n,Y as o,z as p,Ee as r,Z as s,ke as t,se as u,j as v,y as x,F as y};