@yuriai/web 0.2.37 → 0.2.38-beta.3

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 (138) hide show
  1. package/dist/assets/{AgentAvatar-Dpot7DG_.js → AgentAvatar-CAC4rKO_.js} +1 -1
  2. package/dist/assets/{AssistantContactStatus-DBUeAOcC.js → AssistantContactStatus-Co_TnYMc.js} +3 -3
  3. package/dist/assets/{AssistantUnreadBadge-uMPRfRqu.js → AssistantUnreadBadge-DqJFhaNg.js} +1 -1
  4. package/dist/assets/AssistantView-D6fdLgFj.js +1 -0
  5. package/dist/assets/{DiagramView-D317a0U8.js → DiagramView-tx4upWOs.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-DlU4WRpc.js → FadeInOnReveal--aVey7kZ.js} +1 -1
  7. package/dist/assets/{GuiPluginSurface-DHMppLxf.js → GuiPluginSurface-Bd3v_5A8.js} +1 -1
  8. package/dist/assets/{GuiPluginWindow-CWP-ZcJj.js → GuiPluginWindow-fy3lT5ns.js} +1 -1
  9. package/dist/assets/{Icon-3udlHlix.js → Icon-h0JiZMjp.js} +1 -1
  10. package/dist/assets/{ImageLoadingPlaceholder-D2CKCkHe.js → ImageLoadingPlaceholder-A2tjfBfo.js} +1 -1
  11. package/dist/assets/{LoadingImage-CzTb95Cn.js → LoadingImage-C4DsIEui.js} +1 -1
  12. package/dist/assets/MarkdownRenderer-BfAZBFzv.js +2 -0
  13. package/dist/assets/{MarkdownRendererImpl-Dfj5yBQH.js → MarkdownRendererImpl-MYwBFYBA.js} +2 -2
  14. package/dist/assets/MarkstreamRendererImpl-13XA9vlX.js +3 -0
  15. package/dist/assets/{MobileDetailNavigation-D6pHFCLd.js → MobileDetailNavigation-UU1cGYp2.js} +1 -1
  16. package/dist/assets/{MobileResizableSheet-B9lJQT-Q.js → MobileResizableSheet-nUZzBOmQ.js} +1 -1
  17. package/dist/assets/{MobileShareBridge-BJDkko0y.js → MobileShareBridge-IWtj1SYy.js} +2 -2
  18. package/dist/assets/MobileTabPageHeader-Diplic-W.js +2 -0
  19. package/dist/assets/{MultiRunWindow-C4sUyQMj.js → MultiRunWindow-CHdpFi_v.js} +1 -1
  20. package/dist/assets/{OnboardingScreen-tF0G9FoO.js → OnboardingScreen-CeQxPD6C.js} +1 -1
  21. package/dist/assets/{OverlayScrollbar-BhUMMoCN.js → OverlayScrollbar-DMbq1jNO.js} +1 -1
  22. package/dist/assets/SettingsView-CxHpCSsu.js +29 -0
  23. package/dist/assets/{SettingsWindow-Cl_MVXqd.js → SettingsWindow-DEEHLurG.js} +1 -1
  24. package/dist/assets/{SetupTourDialog-BGvxww7E.js → SetupTourDialog-5w42fqYN.js} +1 -1
  25. package/dist/assets/{TerminalView-DCVU9yPv.js → TerminalView-DAx8JZmn.js} +1 -1
  26. package/dist/assets/ToolOutputDialog-CoKt-9rk.js +10 -0
  27. package/dist/assets/{VoiceSettings-C3KZYlyP.js → VoiceSettings-BFCJ8d-d.js} +1 -1
  28. package/dist/assets/{YuriLogo-CMoJ3Apd.js → YuriLogo-BFawEKZ2.js} +1 -1
  29. package/dist/assets/{YuriWordmark-DiB7p_ho.js → YuriWordmark-CJ8qJ14A.js} +1 -1
  30. package/dist/assets/{appThemeRegistry-axRbeIwY.js → appThemeRegistry-CbyMACnN.js} +1 -1
  31. package/dist/assets/{appearance--vFosLNi.js → appearance-DFsI3pnP.js} +1 -1
  32. package/dist/assets/{assistant-attachment-cache-B7NHgRWA.js → assistant-attachment-cache-C-SlEpSB.js} +1 -1
  33. package/dist/assets/{bootstrap-CH0Mo2ok.js → bootstrap-BzeQds0D.js} +3 -3
  34. package/dist/assets/{capgoAdapter-C8QhPFlX.js → capgoAdapter-C1AUTwaK.js} +1 -1
  35. package/dist/assets/{checkbox-C641Uk-q.js → checkbox-DR7tyhFb.js} +1 -1
  36. package/dist/assets/{collapsible-YNp0uGvK.js → collapsible-C8DgipZf.js} +1 -1
  37. package/dist/assets/{context-menu-BHe5nbZ0.js → context-menu-BfLJgbjE.js} +1 -1
  38. package/dist/assets/{desktop-DLxQTjzu.js → desktop-Brp3xDpd.js} +1 -1
  39. package/dist/assets/{desktopHosts-Dk0D5ATF.js → desktopHosts-qQ2Rz26_.js} +1 -1
  40. package/dist/assets/{desktopRelayRestore-COTsQw8C.js → desktopRelayRestore-DifJHAur.js} +1 -1
  41. package/dist/assets/{device-BGox1QjM.js → device-Db_TcRdX.js} +1 -1
  42. package/dist/assets/{diagram-DZJvm12J.js → diagram-0lT2w7uS.js} +1 -1
  43. package/dist/assets/{dialog-So-nuji1.js → dialog-Kz0pw-SO.js} +1 -1
  44. package/dist/assets/{es-BC7jaA0J.js → es-CrVDn7XV.js} +1 -1
  45. package/dist/assets/{fileMentionTouchSelection-CcBab6jA.js → fileMentionTouchSelection-BhQqAWYa.js} +1 -1
  46. package/dist/assets/{fileQueries-BBcsALlC.js → fileQueries-BaEKb7SZ.js} +1 -1
  47. package/dist/assets/fileReferenceActions-D06_lyuL.js +1 -0
  48. package/dist/assets/{fr-BIvcfHvS.js → fr-CCwt5AOu.js} +1 -1
  49. package/dist/assets/{gitApi-CXUPuRTB.js → gitApi-CWUhy6kY.js} +1 -1
  50. package/dist/assets/{gui-CJjEj3l4.js → gui-CFdPKvfq.js} +1 -1
  51. package/dist/assets/{historyImportQueries-MpkoiK56.js → historyImportQueries-BrhVXQhP.js} +1 -1
  52. package/dist/assets/host-D_6AN-1g.js +1 -0
  53. package/dist/assets/{image-loading-2ppAWcFZ.js → image-loading-D1DfK_bJ.js} +1 -1
  54. package/dist/assets/{input-BK1Dm9vD.js → input-Baq2dV0C.js} +1 -1
  55. package/dist/assets/{insertionBoundaries-DQRAPE-y.js → insertionBoundaries-Bfzw2QQw.js} +1 -1
  56. package/dist/assets/{ja-Dx_d9fYc.js → ja-BfwjUNPc.js} +1 -1
  57. package/dist/assets/{ko-CLQ_FtRR.js → ko-CZQZFkal.js} +1 -1
  58. package/dist/assets/{main-CM26G9n0.js → main-CeqfStCn.js} +2 -2
  59. package/dist/assets/main-c0X9U5aG.js +169 -0
  60. package/dist/assets/{markdownHeightCache-DMZ5GgoP.js → markdownHeightCache-BEb1XAlf.js} +1 -1
  61. package/dist/assets/{mcpQueries-BFbulSUU.js → mcpQueries-DtBlC0VK.js} +1 -1
  62. package/dist/assets/miniChat-TSOpbP39.js +2 -0
  63. package/dist/assets/mobile-W2QaGheB.js +2 -0
  64. package/dist/assets/{mobileBackNavigation-D3-dwiiY.js → mobileBackNavigation-Dy-OW7DB.js} +1 -1
  65. package/dist/assets/{multirun-CEyNjbIS.js → multirun-O7LH-36l.js} +1 -1
  66. package/dist/assets/{native-config-stLNU1o7.js → native-config-CGAqvpqz.js} +1 -1
  67. package/dist/assets/{pl-BkPum7Gu.js → pl-B6C3vXqv.js} +1 -1
  68. package/dist/assets/{platform-h8km2dnF.js → platform-Dids8J9D.js} +1 -1
  69. package/dist/assets/projectMeta-B2LbasoM.js +1 -0
  70. package/dist/assets/{pt-BR-DfT7YLHn.js → pt-BR-BUDTNopP.js} +1 -1
  71. package/dist/assets/pwa-BHki-tGS.js +2 -0
  72. package/dist/assets/{queue-abort-optimistic-BZd3gflI.js → queue-abort-optimistic-DaJr8CmG.js} +1 -1
  73. package/dist/assets/{readiness-Djew2NvN.js → readiness-DqfcV8R2.js} +1 -1
  74. package/dist/assets/renderElectronMiniChatApp-Dlt2LoM5.js +2 -0
  75. package/dist/assets/{renderMobileApp-D4aaygxO.js → renderMobileApp-BqUbrWSg.js} +4 -4
  76. package/dist/assets/runtime-auth-Bh3htXtG.js +1 -0
  77. package/dist/assets/runtime-fetch-9B8F_rKW.js +1 -0
  78. package/dist/assets/{runtime-file-download-Bz4NbKDi.js → runtime-file-download-D4WGSMk-.js} +1 -1
  79. package/dist/assets/{runtime-file-resource-Btl3euLf.js → runtime-file-resource-tDTBpJT_.js} +1 -1
  80. package/dist/assets/{runtime-switch-DEZ1K7qW.js → runtime-switch-ibQIZnws.js} +1 -1
  81. package/dist/assets/{runtimeConfig-D4pEnoIh.js → runtimeConfig-k2t218IT.js} +1 -1
  82. package/dist/assets/{runtimeEndpointReset-DvSz9Dmf.js → runtimeEndpointReset-_8oYno9l.js} +6 -6
  83. package/dist/assets/{scheduledTaskNavigation-BhsMoXS3.js → scheduledTaskNavigation-C8tBjNoP.js} +1 -1
  84. package/dist/assets/{select-IPdYq29J.js → select-DV9UcboH.js} +1 -1
  85. package/dist/assets/{sessionLookup-7Ux2A4fS.js → sessionLookup-BBH2jvTL.js} +1 -1
  86. package/dist/assets/{sortable-tabs-strip-pQbSLRMg.js → sortable-tabs-strip-M-5RVko_.js} +1 -1
  87. package/dist/assets/{speechSettingsQueries-Cl_-LtPL.js → speechSettingsQueries-C4eOkV7q.js} +1 -1
  88. package/dist/assets/src-Bc4Nf__6.css +2 -0
  89. package/dist/assets/{store-BKKodkCp.js → store-Myt_Fv8d.js} +2 -2
  90. package/dist/assets/{terminalApi-D2kNkPrJ.js → terminalApi-BXf0a2VZ.js} +1 -1
  91. package/dist/assets/{textarea-DSOIfiVX.js → textarea-DWw42WmZ.js} +1 -1
  92. package/dist/assets/{tooltip-BuZUnYeV.js → tooltip-CxneNjeR.js} +1 -1
  93. package/dist/assets/types-hxNDOWGs.js +2 -0
  94. package/dist/assets/{uk-DgzBKB1K.js → uk-Ct9y1Y2t.js} +1 -1
  95. package/dist/assets/{useAppFontEffects-Cjtcc4Sq.js → useAppFontEffects-C9muit_c.js} +60 -60
  96. package/dist/assets/{useAssistantUIStore-Jmh6rESU.js → useAssistantUIStore-CVSFSgJV.js} +1 -1
  97. package/dist/assets/useDesktopWindowControlsLayout-3SlaV4G-.js +1 -0
  98. package/dist/assets/{useDictation-BafHajO_.js → useDictation-CgUBTlk5.js} +1 -1
  99. package/dist/assets/{useEffectiveDirectory-AQOtdYdf.js → useEffectiveDirectory-Dn3Z6Sbz.js} +1 -1
  100. package/dist/assets/{useFontPreferences-OCLG7Btz.js → useFontPreferences-DqBoLHp6.js} +1 -1
  101. package/dist/assets/{useMobileNavigationStore-l2L-r3RJ.js → useMobileNavigationStore-ywElU2fl.js} +8 -8
  102. package/dist/assets/{usePluginsStore-DaZr5OE_.js → usePluginsStore-BD47b67P.js} +1 -1
  103. package/dist/assets/{useStreamingTextThrottle-C1Dm4frL.js → useStreamingTextThrottle-BDPkHk3Z.js} +1 -1
  104. package/dist/assets/{useUIStore-DPo791La.js → useUIStore-BsCfUWQw.js} +1 -1
  105. package/dist/assets/{useWorkerHighlightedLines-DhJbTxdK.js → useWorkerHighlightedLines-D9HhL0-T.js} +1 -1
  106. package/dist/assets/{zh-CN-DTKScxtm.js → zh-CN-BegPizz4.js} +1 -1
  107. package/dist/assets/{zh-TW-JOn8l2o2.js → zh-TW-4xftqQQG.js} +1 -1
  108. package/dist/index.html +19 -19
  109. package/dist/mini-chat.html +19 -19
  110. package/dist/mobile.html +19 -19
  111. package/package.json +1 -1
  112. package/server/lib/gui-customization/DOCUMENTATION.md +2 -0
  113. package/server/lib/gui-customization/skill/SKILL.md +1 -1
  114. package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
  115. package/server/lib/gui-customization/skill/references/gui-api.md +1 -1
  116. package/server/lib/gui-customization/skill/references/icons.md +35 -8
  117. package/server/lib/relay/DOCUMENTATION.md +5 -0
  118. package/server/lib/ui-auth/DOCUMENTATION.md +7 -0
  119. package/server/lib/ui-auth/ui-auth.test.js +25 -0
  120. package/dist/assets/AssistantView-9v8wufOH.js +0 -1
  121. package/dist/assets/MarkdownRenderer-C1KveBTm.js +0 -2
  122. package/dist/assets/MarkstreamRendererImpl-DBWfVjRS.js +0 -3
  123. package/dist/assets/MobileTabPageHeader-BdZ4z7qY.js +0 -2
  124. package/dist/assets/SettingsView-Dk2vpPHM.js +0 -29
  125. package/dist/assets/ToolOutputDialog-BSNWZM5u.js +0 -10
  126. package/dist/assets/fileReferenceActions-DRECILCs.js +0 -1
  127. package/dist/assets/host-CzMYcPbz.js +0 -1
  128. package/dist/assets/main-BVl-5tBj.js +0 -169
  129. package/dist/assets/miniChat-CD9Pz0ZW.js +0 -2
  130. package/dist/assets/mobile-B3bArIND.js +0 -2
  131. package/dist/assets/projectMeta-2FoNc0nP.js +0 -1
  132. package/dist/assets/pwa-CCJwn58X.js +0 -2
  133. package/dist/assets/renderElectronMiniChatApp-DdvkzG1o.js +0 -2
  134. package/dist/assets/runtime-auth-DBn9yahL.js +0 -1
  135. package/dist/assets/runtime-fetch-D0YWp3FJ.js +0 -1
  136. package/dist/assets/src-BHDTEDdR.css +0 -2
  137. package/dist/assets/types-DAssRFbW.js +0 -2
  138. package/dist/assets/useDesktopWindowControlsLayout-BJx2ijlY.js +0 -1
@@ -1 +1 @@
1
- import{a as e}from"./vendor-zustand-vDaAPGfl.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{a as t,n}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as r,t as i}from"./platform-h8km2dnF.js";import{r as a}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{s as o}from"./useMobileNavigationStore-l2L-r3RJ.js";import{t as s}from"./agentColors-DWSbQXy2.js";import{t as c}from"./rasterizePng-056Poix7.js";var l=`yuri.iosNativeUi`,u=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(l)===`1`}catch{return!1}},d=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(l,`1`):window.localStorage.removeItem(l)}catch{}},f=e(e=>({enabled:u(),setEnabled:t=>{d(t),e({enabled:t})}})),p=()=>f.getState().enabled,m=()=>f(te),ee=()=>r()&&i()===`ios`;function te(e){return e.enabled}var h=5,g=Math.ceil(h/2);function _(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t>>>0}function ne(e){let t=Array.from({length:h},()=>Array.from({length:h},()=>!1));if(!e)return t;let n=_(e);for(let e=0;e<h;e++)for(let r=0;r<g;r++){let i=(n&1)==1;n>>>=1,t[e][r]=i,t[e][4-r]=i}return t}var re=`yuri-native-ios-composer`,v=`--yuri-native-composer-height`,y=`--yuri-native-composer-accessory`,b=33554432,x=`YuriComposer`,S=`#22c55e`,C=32,w=()=>({open:!1,highlightedIndex:0,query:``,highlightColor:``,rows:[]}),T=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:S,agentIdenticon:Array.from({length:25},()=>0),agentIcon:``,suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:w()}),ie=t(x),ae=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function oe(e){return typeof window>`u`?!1:ae({isCapacitor:r(),platform:i(),pluginAvailable:n.isPluginAvailable(x),isMobile:e,nativeUiEnabled:p()})}var se=e=>e.classList.contains(`dark`)?`dark`:`light`,ce=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},le=(e,t)=>{if(!(t>0)){e.style.removeProperty(v);return}e.style.setProperty(v,`${Math.round(t)}px`)},ue=(e,t)=>{if(!(t>0)){e.style.removeProperty(y);return}e.style.setProperty(y,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(re,t),t||(e.style.removeProperty(v),e.style.removeProperty(y))},de=e=>ne(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return S;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,S),S;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},fe=e=>k(s(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.agentIcon===t.agentIcon&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.query===t.query&&e.highlightColor===t.highlightColor&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),F=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},I=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),L=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),R=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},z=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},B=e=>{let t=z(e?.selectionStart);if(t===null)return null;let n=z(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},V=e=>z(e?.index)??0,pe=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},me=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},he=e=>e.replacedText!==null&&e.incoming===e.replacedText,ge=e=>setTimeout(e,0),_e=e=>{e.applyDocument(e.text),ge(e.submit)},H=(e,t)=>e===t,ve=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,H),a(`modelLabel`,H),a(`modelVariantLabel`,H),a(`modelIcon`,H),a(`canSend`,H),a(`canAbort`,H),a(`attachmentCount`,H),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,H),a(`attachAria`,H),a(`attachTitle`,H),a(`attachPhotosLabel`,H),a(`attachFilesLabel`,H),a(`attachCancelLabel`,H),a(`sendAria`,H),a(`queueAria`,H),a(`stopAria`,H),a(`modelAria`,H),a(`agentAria`,H),a(`agentLabel`,H),a(`agentColor`,H),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`agentIcon`,H),a(`suppressed`,H),a(`showScrollToBottom`,H),a(`scrollAria`,H),a(`autocomplete`,j),Object.keys(i).length===0?null:i},ye=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},be=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},xe=(e,t=b)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=be(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},U=80,Se=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=U,e.height=U;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,U,U),r.drawImage(n,0,0,U,U);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),Ce=e=>c(e,C),W=()=>ie,G=((e=W)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,B(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,xe(t),ye(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=R(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,ce(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,V(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(T()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c();let r=s||t>0;t=0,s=!1,o=!1,i=null,E(n,!1),r&&e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),we=()=>t(`YuriNavigation`),K=e=>e?.kind===`chat`||e?.kind===`draft`,q=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Te=(e,t)=>K(e)&&!K(t),Ee=(e=G)=>{q(o.getState().secondary)&&e.conceal()},De=(e=G)=>{let t=o.subscribe((t,n)=>{Te(n.secondary,t.secondary)&&e.conceal()}),r=[],i=!1;return n.getPlatform()===`ios`&&(async()=>{let t=we(),n=await t.addListener(`backStarted`,()=>{q(o.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(i){n.remove(),a.remove();return}r=[n,a]})(),()=>{i=!0,t();for(let e of r)e.remove();r=[]}},Oe=e=>/^#[0-9a-fA-F]{6}$/.test(e),ke=e=>/^#[0-9a-fA-F]{8}$/.test(e),Ae=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?Oe(e)?`${e}${t}`:ke(e)?`${e.slice(0,7)}${t}`:e:e,J=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,je=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>J(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},Y=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=J(a.diffAddedBackground,r.successBackground),s=J(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":J(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":Ae(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":J(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":J(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":J(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":J(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":J(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":J(a.diffRemoved,r.error),"terminal.ansiGreen":J(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":J(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":J(e.colors.primary.foreground,t.background),"badge.foreground":J(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":J(e.colors.primary.foreground,t.background)}};function Me(e){return{name:e.metadata.name,type:e.metadata.variant,colors:Y(e),tokenColors:je(e)}}var Ne=e=>/^#[0-9a-fA-F]{8}$/.test(e),X=e=>Ne(e)?e.slice(0,7):e;function Pe(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Z=new Map,Q=new Set,Fe=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?X(n):void 0,a=r?X(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return Pe({...e,name:t,fg:a,bg:i,settings:o},t)},Ie=e=>Me(e),$=e=>{let t=Z.get(e.metadata.id);if(t)return t;let n=Fe(Ie(e),e.metadata.id);return Z.set(e.metadata.id,n),n},Le=e=>{let t=e.metadata.id;if(Q.has(t))return;let n=$(e);a(t,async()=>n),Q.add(t)};export{p as A,Ce as C,E as D,me as E,f as M,he as O,Se as S,k as T,F as _,G as a,se as b,le as c,ve as d,oe as f,j as g,_e as h,Ee as i,m as j,ee as k,L as l,W as m,$ as n,v as o,w as p,De as r,ue as s,Le as t,I as u,A as v,pe as w,de as x,fe as y};
1
+ import{a as e}from"./vendor-zustand-vDaAPGfl.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{a as t,n}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as r,t as i}from"./platform-Dids8J9D.js";import{r as a}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{s as o}from"./useMobileNavigationStore-ywElU2fl.js";import{t as s}from"./agentColors-DWSbQXy2.js";import{t as c}from"./rasterizePng-056Poix7.js";var l=`yuri.iosNativeUi`,u=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(l)===`1`}catch{return!1}},d=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(l,`1`):window.localStorage.removeItem(l)}catch{}},f=e(e=>({enabled:u(),setEnabled:t=>{d(t),e({enabled:t})}})),p=()=>f.getState().enabled,m=()=>f(te),ee=()=>r()&&i()===`ios`;function te(e){return e.enabled}var h=5,g=Math.ceil(h/2);function _(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t>>>0}function ne(e){let t=Array.from({length:h},()=>Array.from({length:h},()=>!1));if(!e)return t;let n=_(e);for(let e=0;e<h;e++)for(let r=0;r<g;r++){let i=(n&1)==1;n>>>=1,t[e][r]=i,t[e][4-r]=i}return t}var re=`yuri-native-ios-composer`,v=`--yuri-native-composer-height`,y=`--yuri-native-composer-accessory`,b=33554432,x=`YuriComposer`,S=`#22c55e`,C=32,w=()=>({open:!1,highlightedIndex:0,query:``,highlightColor:``,rows:[]}),T=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:S,agentIdenticon:Array.from({length:25},()=>0),agentIcon:``,suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:w()}),ie=t(x),ae=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function oe(e){return typeof window>`u`?!1:ae({isCapacitor:r(),platform:i(),pluginAvailable:n.isPluginAvailable(x),isMobile:e,nativeUiEnabled:p()})}var se=e=>e.classList.contains(`dark`)?`dark`:`light`,ce=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},le=(e,t)=>{if(!(t>0)){e.style.removeProperty(v);return}e.style.setProperty(v,`${Math.round(t)}px`)},ue=(e,t)=>{if(!(t>0)){e.style.removeProperty(y);return}e.style.setProperty(y,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(re,t),t||(e.style.removeProperty(v),e.style.removeProperty(y))},de=e=>ne(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return S;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,S),S;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},fe=e=>k(s(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.agentIcon===t.agentIcon&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.query===t.query&&e.highlightColor===t.highlightColor&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),F=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},I=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),L=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),R=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},z=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},B=e=>{let t=z(e?.selectionStart);if(t===null)return null;let n=z(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},V=e=>z(e?.index)??0,pe=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},me=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},he=e=>e.replacedText!==null&&e.incoming===e.replacedText,ge=e=>setTimeout(e,0),_e=e=>{e.applyDocument(e.text),ge(e.submit)},H=(e,t)=>e===t,ve=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,H),a(`modelLabel`,H),a(`modelVariantLabel`,H),a(`modelIcon`,H),a(`canSend`,H),a(`canAbort`,H),a(`attachmentCount`,H),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,H),a(`attachAria`,H),a(`attachTitle`,H),a(`attachPhotosLabel`,H),a(`attachFilesLabel`,H),a(`attachCancelLabel`,H),a(`sendAria`,H),a(`queueAria`,H),a(`stopAria`,H),a(`modelAria`,H),a(`agentAria`,H),a(`agentLabel`,H),a(`agentColor`,H),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`agentIcon`,H),a(`suppressed`,H),a(`showScrollToBottom`,H),a(`scrollAria`,H),a(`autocomplete`,j),Object.keys(i).length===0?null:i},ye=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},be=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},xe=(e,t=b)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=be(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},U=80,Se=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=U,e.height=U;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,U,U),r.drawImage(n,0,0,U,U);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),Ce=e=>c(e,C),W=()=>ie,G=((e=W)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,B(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,xe(t),ye(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=R(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,ce(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,V(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(T()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c();let r=s||t>0;t=0,s=!1,o=!1,i=null,E(n,!1),r&&e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),we=()=>t(`YuriNavigation`),K=e=>e?.kind===`chat`||e?.kind===`draft`,q=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Te=(e,t)=>K(e)&&!K(t),Ee=(e=G)=>{q(o.getState().secondary)&&e.conceal()},De=(e=G)=>{let t=o.subscribe((t,n)=>{Te(n.secondary,t.secondary)&&e.conceal()}),r=[],i=!1;return n.getPlatform()===`ios`&&(async()=>{let t=we(),n=await t.addListener(`backStarted`,()=>{q(o.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(i){n.remove(),a.remove();return}r=[n,a]})(),()=>{i=!0,t();for(let e of r)e.remove();r=[]}},Oe=e=>/^#[0-9a-fA-F]{6}$/.test(e),ke=e=>/^#[0-9a-fA-F]{8}$/.test(e),Ae=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?Oe(e)?`${e}${t}`:ke(e)?`${e.slice(0,7)}${t}`:e:e,J=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,je=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>J(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},Y=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=J(a.diffAddedBackground,r.successBackground),s=J(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":J(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":Ae(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":J(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":J(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":J(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":J(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":J(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":J(a.diffRemoved,r.error),"terminal.ansiGreen":J(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":J(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":J(e.colors.primary.foreground,t.background),"badge.foreground":J(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":J(e.colors.primary.foreground,t.background)}};function Me(e){return{name:e.metadata.name,type:e.metadata.variant,colors:Y(e),tokenColors:je(e)}}var Ne=e=>/^#[0-9a-fA-F]{8}$/.test(e),X=e=>Ne(e)?e.slice(0,7):e;function Pe(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Z=new Map,Q=new Set,Fe=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?X(n):void 0,a=r?X(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return Pe({...e,name:t,fg:a,bg:i,settings:o},t)},Ie=e=>Me(e),$=e=>{let t=Z.get(e.metadata.id);if(t)return t;let n=Fe(Ie(e),e.metadata.id);return Z.set(e.metadata.id,n),n},Le=e=>{let t=e.metadata.id;if(Q.has(t))return;let n=$(e);a(t,async()=>n),Q.add(t)};export{p as A,Ce as C,E as D,me as E,f as M,he as O,Se as S,k as T,F as _,G as a,se as b,le as c,ve as d,oe as f,j as g,_e as h,Ee as i,m as j,ee as k,L as l,W as m,$ as n,v as o,w as p,De as r,ue as s,Le as t,I as u,A as v,pe as w,de as x,fe as y};
@@ -1 +1 @@
1
- import{r as e}from"./themes-BgDJcxRc.js";import{t}from"./theme-validation-BGYdrOu7.js";var n=`yuri.file-icon`,r=`http://www.w3.org/2000/svg`,i=new Set([`svg`,`g`,`path`,`rect`,`circle`,`ellipse`,`line`,`polyline`,`polygon`,`defs`,`linearGradient`,`radialGradient`,`stop`,`clipPath`,`mask`,`use`,`title`,`desc`]),a=e=>e.trim().replace(/^\./,``).toLowerCase();function o(e,t){if(typeof e!=`string`)throw Error(`GUI file icon requires SVG text`);let n=t.get(e);if(n)return n;if(e.length>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);let a=new TextEncoder().encode(e).byteLength;if(a>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);if(!/^\s*<svg[\s>]/.test(e)||/<!|<\?/.test(e))throw Error(`Invalid GUI file icon SVG`);let o=new DOMParser().parseFromString(e,`image/svg+xml`),s=o.documentElement;if(s?.localName!==`svg`||s.namespaceURI!==r||o.querySelector(`parsererror`))throw Error(`Invalid GUI file icon SVG`);for(let e of[s,...s.querySelectorAll(`*`)]){if(e.namespaceURI!==r||!i.has(e.localName))throw Error(`Unsupported GUI file icon SVG element`);for(let t of e.attributes){let e=t.name.toLowerCase(),n=t.value.trim();if(e.startsWith(`on`)||e===`style`||e===`xml:base`||n.includes(`\\`)||Array.from(n).some(e=>e.charCodeAt(0)<32)||(e===`href`||e.endsWith(`:href`))&&!/^#[\w.-]+$/.test(n)||/url\s*\(/i.test(n)&&!/^url\(\s*#[\w.-]+\s*\)$/.test(n))throw Error(`Unsupported GUI file icon SVG reference or attribute`)}}let c={source:e,bytes:a,uri:`data:image/svg+xml,${encodeURIComponent(e)}`};return t.set(e,c),c}function s(e){return o(e,new Map).uri}var c=class{plugins=new Map;index=new Map;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});get(e,t){if(t?.isDirectory)return;let n=e.split(/[\\/]/).at(-1)??``,r=t?.extension??(n.includes(`.`)?n.slice(n.lastIndexOf(`.`)+1):``),i=this.index.get(a(r));return t?.themeVariant===`light`?i?.light.uri:i?.dark.uri}replace(e,t){if(t.length>64)throw Error(`GUI file icon per-plugin limit exceeded`);if(!t.length){this.remove(e);return}let n=new Map;for(let t of this.plugins.get(e)??[])for(let e of[t.dark,t.light])n.set(e.source,e);let r=new Set,i=t.map(e=>{if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||r.has(e.id))throw Error(`Invalid or duplicate GUI file icon id`);if(r.add(e.id),!(`extensions`in e)||!Array.isArray(e.extensions)||!e.extensions.length||e.extensions.length>64)throw Error(`GUI file icon requires 1–64 extensions`);let t=e.extensions.map(e=>{if(typeof e!=`string`)throw Error(`Invalid GUI file icon extension`);let t=a(e);if(!/^[a-z0-9][a-z0-9_+-]{0,63}$/.test(t))throw Error(`Invalid GUI file icon extension`);return t}),i=o(`svg`in e?e.svg:void 0,n),s=`lightSvg`in e&&e.lightSvg!==void 0?o(e.lightSvg,n):i;return{id:e.id,extensions:[...new Set(t)],dark:i,light:s}}),s=i.length,c=i.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0);for(let[t,n]of this.plugins)t!==e&&(s+=n.length,c+=n.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0));if(s>512||c>8388608)throw Error(`GUI file icon total limit exceeded`);this.plugins.set(e,i),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map;for(let t of this.plugins.values())for(let n of t)for(let t of n.extensions)e.set(t,n);let t=e.size!==this.index.size||[...e].some(([e,t])=>{let n=this.index.get(e);return n?.dark.uri!==t.dark.uri||n?.light.uri!==t.light.uri});if(this.index=e,t)for(let e of this.listeners)e()}},l=`yuri.theme`,u=`yuri.branding`,d=Object.freeze({themes:[],branding:[]}),f=(e,t)=>JSON.stringify([e,t]);function p(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Expected an appearance object`);return e}function m(e,t){if(t===void 0)return e;if(!t||typeof t!=`object`||Array.isArray(t))return t;let n={...p(e??{})};for(let[e,r]of Object.entries(t)){if([`__proto__`,`prototype`,`constructor`].includes(e))throw Error(`Invalid appearance property`);n[e]=m(n[e],r)}return n}function h(e,t){let n=e=>{if(!Object.values(p(e)).every(e=>typeof e==`string`))throw Error(`Theme tokens must be strings`)};for(let[t,r]of Object.entries(e))if(t===`syntax`)for(let[e,t]of Object.entries(p(r)))e===`languages`?Object.values(p(t)).forEach(n):n(t);else if(t===`tools`||t===`toast`)for(let e of Object.values(p(r)))typeof e!=`string`&&n(e);else if(t===`buttons`||t===`badges`)Object.values(p(r)).forEach(n);else if(t===`charts`){if(!Object.values(p(r)).every(e=>typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`)))throw Error(`Invalid chart colors`)}else if(t===`a11y`){if(!Object.values(p(r)).every(e=>typeof e==`string`||typeof e==`boolean`))throw Error(`Invalid accessibility tokens`)}else n(r);t!==void 0&&Object.values(p(t)).forEach(n)}function g(e){if(typeof e!=`string`||e.length>2097152||!/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Dock icons require an inline PNG data URL, at most 2 MiB`);return e}var _=class{plugins=new Map;order=[];snapshot=d;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;setOrder(e){e.length===this.order.length&&e.every((e,t)=>e===this.order[t])||(this.order=[...e],this.plugins.size&&this.publish())}replace(n,r,i,a){if(r.length>16||i.length>8)throw Error(`Appearance contribution limit exceeded`);if(!r.length&&!i.length){this.remove(n);return}let o=JSON.stringify([r,i,a]);if(this.plugins.get(n)?.signature===o)return;let c=new TextEncoder().encode(o).byteLength;if(c>8388608)throw Error(`Appearance resources exceed 8 MiB`);let l=new Set,u=(e,t)=>{let r=p(e);if(typeof r.id!=`string`||!r.id.trim()||r.id.length>128||typeof r.title!=`string`||!r.title.trim()||r.title.length>128||l.has(`${t}:${r.id}`))throw Error(`Invalid or duplicate appearance id/title`);return l.add(`${t}:${r.id}`),{value:r,key:f(n,r.id),title:r.title}},d=r.map(n=>{let{value:r,key:i,title:a}=u(n,`theme`);if(r.variant!==`light`&&r.variant!==`dark`)throw Error(`Invalid theme variant`);if(new TextEncoder().encode(JSON.stringify(r)).byteLength>65536)throw Error(`Theme exceeds 64 KiB`);let o=e(r.variant===`dark`),s={...o,metadata:{...o.metadata,id:`gui:${i}`,name:a,variant:r.variant},colors:m(o.colors,r.colors),config:m(o.config,r.config)};if(!t(s))throw Error(`Invalid plugin theme colors`);return h(s.colors,s.config),structuredClone(s)}),_=i.map(e=>{let{value:t,key:r,title:i}=u(e,`brand`);if(t.logo===void 0&&t.dockIcon===void 0)throw Error(`Branding requires a logo or Dock icon`);let o=t.logo===void 0?void 0:p(t.logo),c=t.dockIcon===void 0?void 0:p(t.dockIcon),l=o?s(o.svg):void 0,d=c?g(c.png):void 0;return Object.freeze({key:r,pluginId:n,title:i,native:a,logo:l?{dark:l,light:o?.lightSvg===void 0?l:s(o.lightSvg)}:void 0,dockIcon:d?{dark:d,light:c?.lightPng===void 0?d:g(c.lightPng)}:void 0})}),v=[...this.plugins].filter(([e])=>e!==n).map(([,e])=>e);if(d.length+v.reduce((e,t)=>e+t.themes.length,0)>128||_.length+v.reduce((e,t)=>e+t.branding.length,0)>64||c+v.reduce((e,t)=>e+t.bytes,0)>16777216)throw Error(`Window appearance catalog limit exceeded`);this.plugins.set(n,{themes:d,branding:_,signature:o,bytes:c}),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map(this.order.map((e,t)=>[e,t])),t=[...this.plugins].sort(([t],[n])=>(e.get(t)??-1)-(e.get(n)??-1)).map(([,e])=>e);this.snapshot=t.length?{themes:t.flatMap(e=>e.themes).reverse(),branding:t.flatMap(e=>e.branding).reverse()}:d;for(let e of this.listeners)e()}};export{n as a,_ as i,u as n,c as o,l as r,d as t};
1
+ import{r as e}from"./themes-BgDJcxRc.js";import{t}from"./theme-validation-BGYdrOu7.js";var n=`yuri.file-icon`,r=`http://www.w3.org/2000/svg`,i=new Set([`svg`,`g`,`path`,`rect`,`circle`,`ellipse`,`line`,`polyline`,`polygon`,`defs`,`linearGradient`,`radialGradient`,`stop`,`clipPath`,`mask`,`use`,`title`,`desc`]),a=e=>e.trim().replace(/^\./,``).toLowerCase();function o(e,t){if(typeof e!=`string`)throw Error(`GUI file icon requires SVG text`);let n=t.get(e);if(n)return n;if(e.length>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);let a=new TextEncoder().encode(e).byteLength;if(a>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);if(!/^\s*<svg[\s>]/.test(e)||/<!|<\?/.test(e))throw Error(`Invalid GUI file icon SVG`);let o=new DOMParser().parseFromString(e,`image/svg+xml`),s=o.documentElement;if(s?.localName!==`svg`||s.namespaceURI!==r||o.querySelector(`parsererror`))throw Error(`Invalid GUI file icon SVG`);for(let e of[s,...s.querySelectorAll(`*`)]){if(e.namespaceURI!==r||!i.has(e.localName))throw Error(`Unsupported GUI file icon SVG element`);for(let t of e.attributes){let e=t.name.toLowerCase(),n=t.value.trim();if(e.startsWith(`on`)||e===`style`||e===`xml:base`||n.includes(`\\`)||Array.from(n).some(e=>e.charCodeAt(0)<32)||(e===`href`||e.endsWith(`:href`))&&!/^#[\w.-]+$/.test(n)||/url\s*\(/i.test(n)&&!/^url\(\s*#[\w.-]+\s*\)$/.test(n))throw Error(`Unsupported GUI file icon SVG reference or attribute`)}}let c={source:e,bytes:a,uri:`data:image/svg+xml,${encodeURIComponent(e)}`};return t.set(e,c),c}function s(e){return o(e,new Map).uri}var c=class{plugins=new Map;index=new Map;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});get(e,t){if(t?.isDirectory)return;let n=e.split(/[\\/]/).at(-1)??``,r=t?.extension??(n.includes(`.`)?n.slice(n.lastIndexOf(`.`)+1):``),i=this.index.get(a(r));return t?.themeVariant===`light`?i?.light.uri:i?.dark.uri}replace(e,t){if(t.length>64)throw Error(`GUI file icon per-plugin limit exceeded`);if(!t.length){this.remove(e);return}let n=new Map;for(let t of this.plugins.get(e)??[])for(let e of[t.dark,t.light])n.set(e.source,e);let r=new Set,i=t.map(e=>{if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||r.has(e.id))throw Error(`Invalid or duplicate GUI file icon id`);if(r.add(e.id),!(`extensions`in e)||!Array.isArray(e.extensions)||!e.extensions.length||e.extensions.length>64)throw Error(`GUI file icon requires 1–64 extensions`);let t=e.extensions.map(e=>{if(typeof e!=`string`)throw Error(`Invalid GUI file icon extension`);let t=a(e);if(!/^[a-z0-9][a-z0-9_+-]{0,63}$/.test(t))throw Error(`Invalid GUI file icon extension`);return t}),i=o(`svg`in e?e.svg:void 0,n),s=`lightSvg`in e&&e.lightSvg!==void 0?o(e.lightSvg,n):i;return{id:e.id,extensions:[...new Set(t)],dark:i,light:s}}),s=i.length,c=i.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0);for(let[t,n]of this.plugins)t!==e&&(s+=n.length,c+=n.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0));if(s>512||c>8388608)throw Error(`GUI file icon total limit exceeded`);this.plugins.set(e,i),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map;for(let t of this.plugins.values())for(let n of t)for(let t of n.extensions)e.set(t,n);let t=e.size!==this.index.size||[...e].some(([e,t])=>{let n=this.index.get(e);return n?.dark.uri!==t.dark.uri||n?.light.uri!==t.light.uri});if(this.index=e,t)for(let e of this.listeners)e()}},l=`yuri.theme`,u=`yuri.branding`,d=Object.freeze({themes:[],branding:[]}),f=(e,t)=>JSON.stringify([e,t]);function p(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Expected an appearance object`);return e}function m(e,t){if(t===void 0)return e;if(!t||typeof t!=`object`||Array.isArray(t))return t;let n={...p(e??{})};for(let[e,r]of Object.entries(t)){if([`__proto__`,`prototype`,`constructor`].includes(e))throw Error(`Invalid appearance property`);n[e]=m(n[e],r)}return n}function h(e,t){let n=e=>{if(!Object.values(p(e)).every(e=>typeof e==`string`))throw Error(`Theme tokens must be strings`)};for(let[t,r]of Object.entries(e))if(t===`syntax`)for(let[e,t]of Object.entries(p(r)))e===`languages`?Object.values(p(t)).forEach(n):n(t);else if(t===`tools`||t===`toast`)for(let e of Object.values(p(r)))typeof e!=`string`&&n(e);else if(t===`buttons`||t===`badges`)Object.values(p(r)).forEach(n);else if(t===`charts`){if(!Object.values(p(r)).every(e=>typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`)))throw Error(`Invalid chart colors`)}else if(t===`a11y`){if(!Object.values(p(r)).every(e=>typeof e==`string`||typeof e==`boolean`))throw Error(`Invalid accessibility tokens`)}else n(r);t!==void 0&&Object.values(p(t)).forEach(n)}function g(e){if(typeof e!=`string`||e.length>2097152||!/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Dock icons require an inline PNG data URL, at most 2 MiB`);return e}var _=class{plugins=new Map;order=[];snapshot=d;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;setOrder(e){e.length===this.order.length&&e.every((e,t)=>e===this.order[t])||(this.order=[...e],this.plugins.size&&this.publish())}replace(n,r,i,a){if(r.length>16||i.length>8)throw Error(`Appearance contribution limit exceeded`);if(!r.length&&!i.length){this.remove(n);return}let o=JSON.stringify([r,i,a]);if(this.plugins.get(n)?.signature===o)return;let c=new TextEncoder().encode(o).byteLength;if(c>8388608)throw Error(`Appearance resources exceed 8 MiB`);let l=new Set,u=(e,t)=>{let r=p(e);if(typeof r.id!=`string`||!r.id.trim()||r.id.length>128||typeof r.title!=`string`||!r.title.trim()||r.title.length>128||l.has(`${t}:${r.id}`))throw Error(`Invalid or duplicate appearance id/title`);return l.add(`${t}:${r.id}`),{value:r,key:f(n,r.id),title:r.title}},d=r.map(n=>{let{value:r,key:i,title:a}=u(n,`theme`);if(r.variant!==`light`&&r.variant!==`dark`)throw Error(`Invalid theme variant`);if(new TextEncoder().encode(JSON.stringify(r)).byteLength>65536)throw Error(`Theme exceeds 64 KiB`);let o=e(r.variant===`dark`),s={...o,metadata:{...o.metadata,id:`gui:${i}`,name:a,variant:r.variant},colors:m(o.colors,r.colors),config:m(o.config,r.config)};if(!t(s))throw Error(`Invalid plugin theme colors`);return h(s.colors,s.config),structuredClone(s)}),_=i.map(e=>{let{value:t,key:r,title:i}=u(e,`brand`);if(t.logo===void 0&&t.dockIcon===void 0)throw Error(`Branding requires a logo or Dock icon`);let o=t.logo===void 0?void 0:p(t.logo),c=t.dockIcon===void 0?void 0:p(t.dockIcon),l=o?s(o.svg):void 0,d=c?g(c.png):void 0;return Object.freeze({key:r,pluginId:n,title:i,native:a,logo:l?{dark:l,light:o?.lightSvg===void 0?l:s(o.lightSvg)}:void 0,dockIcon:d?{dark:d,light:c?.lightPng===void 0?d:g(c.lightPng)}:void 0})}),v=[...this.plugins].filter(([e])=>e!==n).map(([,e])=>e);if(d.length+v.reduce((e,t)=>e+t.themes.length,0)>128||_.length+v.reduce((e,t)=>e+t.branding.length,0)>64||c+v.reduce((e,t)=>e+t.bytes,0)>16777216)throw Error(`Window appearance catalog limit exceeded`);this.plugins.set(n,{themes:d,branding:_,signature:o,bytes:c}),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map(this.order.map((e,t)=>[e,t])),t=[...this.plugins].sort(([t],[n])=>(e.get(t)??-1)-(e.get(n)??-1)).map(([,e])=>e);this.snapshot=t.length?{themes:t.flatMap(e=>e.themes).reverse(),branding:t.flatMap(e=>e.branding).reverse()}:d;for(let e of this.listeners)e()}};export{n as a,_ as i,u as n,c as o,l as r,s,d as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,d as r,s as i}from"./runtime-auth-DBn9yahL.js";import{c as a,i as o}from"./runtime-switch-DEZ1K7qW.js";import{n as s}from"./runtime-fetch-D0YWp3FJ.js";import{d as c,g as l,h as u,i as d,l as f,m as p,n as m,p as h,u as g}from"./runtime-file-resource-Btl3euLf.js";var _=26214400,v=class extends Error{status;code;constructor(e,t,n=`Failed to upload assistant attachment`){super(n),this.name=`AssistantAttachmentUploadError`,this.status=e,this.code=t}},y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),b=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),x=async e=>{let t;if(e instanceof ArrayBuffer)t=e;else if(ArrayBuffer.isView(e)){let n=e;t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=await e.arrayBuffer();return b(await crypto.subtle.digest(`SHA-256`,t))},S=e=>typeof e==`string`?e.split(`;`)[0]?.trim().toLowerCase():``,C=e=>{if(!Number.isSafeInteger(e)||e<0)throw new v(0,`rejected`,`Invalid attachment size`);if(e>26214400)throw new v(413,`too-large`)},w=(e,t,n={})=>{if(!y(e))throw new v(0,`integrity`,`Attachment response was not a JSON object`);if(e.type!==`file`)throw new v(0,`integrity`,`Attachment response type must be file`);let r=typeof e.attachmentID==`string`?e.attachmentID.trim():``,i=typeof e.sha256==`string`?e.sha256.trim().toLowerCase():``,a=typeof e.size==`number`&&Number.isSafeInteger(e.size)?e.size:NaN,o=S(typeof e.mime==`string`?e.mime:``),s=typeof e.filename==`string`&&e.filename.trim()?e.filename.trim():void 0;if(!r)throw new v(0,`integrity`,`Attachment response missing attachmentID`);if(!/^[a-f0-9]{64}$/i.test(i))throw new v(0,`integrity`,`Attachment response missing sha256`);if(!Number.isSafeInteger(a)||a<0)throw new v(0,`integrity`,`Attachment response missing size`);if(!o)throw new v(0,`integrity`,`Attachment response missing mime`);if((n.enforceUploadLimit===!0||t)&&C(a),t){if(i!==t.sha256.toLowerCase())throw new v(0,`integrity`,`Attachment SHA-256 mismatch`);if(a!==t.size)throw new v(0,`integrity`,`Attachment size mismatch`);if(o!==t.mime)throw new v(0,`integrity`,`Attachment mime mismatch`)}return{type:`file`,attachmentID:r,sha256:i,size:a,mime:o,...s?{filename:s}:{}}},T=async(e,t,n,r)=>{let i=m(),a=typeof e==`string`?e.trim():``,o=typeof n==`string`?n.trim():``;if(!a||!o)throw new v(0,`rejected`,`assistantID and uploadID are required`);if(!(t instanceof Blob))throw new v(0,`rejected`,`file must be a File or Blob`);let c=S(t.type||t.type)||`application/octet-stream`,l=t.type===c?t:new Blob([t],{type:c});C(l.size);let u=await x(l),d=typeof t.name==`string`&&t.name.trim()?t.name.trim():void 0,f;try{f=await s(`/api/yuri/assistants/${encodeURIComponent(a)}/contact/attachments/${encodeURIComponent(o)}`,{method:`PUT`,headers:{"Content-Type":c,"X-Content-SHA256":u,"X-Content-Size":String(l.size),...d?{"X-Attachment-Filename":encodeURIComponent(d)}:{}},body:l,signal:r})}catch{throw new v(0,`unavailable`)}if(f.status===204||f.status===205)throw new v(f.status,`integrity`,`Attachment upload returned empty status`);if(f.status===413)throw new v(413,`too-large`);if(!f.ok)throw new v(f.status,f.status>=500||f.status===0?`unavailable`:`rejected`);let p=f.headers.get(`content-type`)?.toLowerCase()??``;if(p.includes(`text/html`)||p.includes(`text/plain`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);let h;try{let e=await f.text();if(!e.trim())throw new v(f.status,`integrity`,`Attachment upload returned empty body`);if(!p.includes(`application/json`)&&!e.trim().startsWith(`{`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);h=JSON.parse(e)}catch(e){throw e instanceof v?e:new v(f.status,`integrity`,`Attachment upload response was not valid JSON`)}let g=w(h,{sha256:u,size:l.size,mime:c});return await i(l,u),g},E=e=>{try{return w(e,void 0,{enforceUploadLimit:!1}),!0}catch{return!1}},D=e({clearAssistantAttachmentCacheAll:()=>G,clearAssistantAttachmentCacheForBearer:()=>W,clearAssistantAttachmentCacheScope:()=>U,getAssistantAttachmentBlob:()=>J,getAssistantAttachmentDisplay:()=>Y,resolveAssistantAttachmentCacheScope:()=>R}),O=g,k=class extends Error{status;code;constructor(e,t,n=`Assistant attachment cache error`){super(n),this.status=e,this.code=t,this.name=`AssistantAttachmentCacheError`}},A=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``),j=0,M,N,P=!1,F=new Map,I=new Map,L=new Set,R=async(e={})=>{let t=e.transportIdentity??o(),r=e.authGeneration??i(),a=(e.bearer??n()).trim();return{transportIdentity:t,authGeneration:r,authScope:a?`b:${await A(a)}`:`m:${r}`,authScopeKind:a?`bearer-hash`:`memory-ephemeral`}},z=e=>`assistant:${e.transportIdentity}:${e.authScope}`,B=e=>`assistant-auth:${e}`,V=()=>{j++;for(let e of L)e.abort();L.clear();for(let e of I.values())e.controller.abort(),e.url&&p(e.url);I.clear();for(let e of F.values()){for(let t=0;t<e.refs;t++)h(e.url);p(e.url)}F.clear()},H=()=>{if(!P&&globalThis.indexedDB){P=!0;for(let e of[`yuri-assistant-attachments`,`openchamber-assistant-attachments`,`openchambery-assistant-attachments`])try{globalThis.indexedDB.deleteDatabase(e)}catch{}}M||=a(V),N||=t(e=>{V(),e.reason!==`endpoint-switch`&&d(e.previousBearerDigest?B(`b:${e.previousBearerDigest}`):void 0)})},U=async(e,t=`scope-cleared`)=>{let n=typeof e==`object`?e:await R();V(),await d(z(n))},W=async(e,t=`forget-bearer`)=>{if(!e.trim())return;let n=B(`b:${await A(e.trim())}`);V(),await d(n)},G=async(e=`cleared`)=>{V(),await d()},K=(e,t,n)=>{if(!e.trim()||!E(t))throw new k(0,`rejected`);if(t.size>n)throw new k(413,`too-large`)},q=async(e,t,n,a)=>{H(),K(e,t,n),a?.throwIfAborted();let o=j,c=await R();if(o!==j)throw new k(0,`stale`);let l=new AbortController,u=()=>l.abort(a?.reason);a?.addEventListener(`abort`,u,{once:!0}),L.add(l);let d;try{a?.throwIfAborted();let u=await f({identity:`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,sha256:t.sha256.toLowerCase(),size:t.size,mime:t.mime,filename:t.filename,persistent:c.authScopeKind===`bearer-hash`,tags:[z(c),B(c.authScope)],signal:l.signal,maxBytes:n,load:async n=>{let a=await s(`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,{method:`GET`,cache:`no-store`,signal:n});if(a.status===401||a.status===403)throw d=new k(a.status,`unauthorized`),await U(c,`unauthorized`),i()===c.authGeneration&&r(),new k(a.status,`unauthorized`);if(!a.ok)throw new k(a.status,a.status===413?`too-large`:a.status>=500?`unavailable`:`rejected`);return a}});if(o!==j)throw new k(0,`stale`);return u}catch(e){throw d||(e instanceof k?e:o===j?l.signal.aborted?new k(0,`aborted`):/descriptor limit|streaming destination/i.test(String(e))?new k(413,`too-large`):new k(0,/fingerprint|size|changed|truncated/i.test(String(e))?`integrity`:`unavailable`):new k(0,`stale`))}finally{L.delete(l),a?.removeEventListener(`abort`,u)}},J=(e,t,n={})=>q(e,t,_,n.signal),Y=async(e,t,n={})=>{H(),K(e,t,O),n.signal?.throwIfAborted();let r=j,i=await R(),a=JSON.stringify([z(i),e,t.attachmentID,t.sha256]),o=e=>{if(r!==j||!c(e)||!u(e))throw p(e),new k(0,`stale`);let t=F.get(a)?.url===e?F.get(a):{url:e,refs:0};t.refs++,F.set(a,t);let n=!1;return{url:e,release:()=>{n||(n=!0,F.get(a)===t&&(h(e),--t.refs===0&&(F.delete(a),p(e))))}}},s=F.get(a);if(s&&c(s.url))return o(s.url);let d=I.get(a);if(!d){let n=new AbortController,i={controller:n,refs:0,promise:Promise.resolve(``)};i.promise=q(e,t,O,n.signal).then(e=>l(e,n.signal,{mimeType:t.mime||e.type})).then(e=>{if(i.url=e,r!==j||n.signal.aborted||i.refs===0)throw p(e),new k(0,`stale`);return e}).catch(e=>{throw I.get(a)===i&&I.delete(a),e}),d=i,I.set(a,d)}let f=d;return f.refs++,new Promise((e,t)=>{let r=!1,i=e=>{--f.refs===0&&(e&&f.controller.abort(),I.get(a)===f&&I.delete(a),e&&f.url&&!F.has(a)&&p(f.url))},s=()=>{r||(r=!0,i(!0),t(new k(0,`aborted`)))};n.signal?.addEventListener(`abort`,s,{once:!0}),n.signal?.aborted&&s(),f.promise.then(a=>{if(n.signal?.removeEventListener(`abort`,s),!r){r=!0;try{e(o(a))}catch(e){t(e)}i(!1)}},e=>{n.signal?.removeEventListener(`abort`,s),!r&&(r=!0,i(!1),t(e))})})};export{T as i,J as n,Y as r,D as t};
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,d as r,s as i}from"./runtime-auth-Bh3htXtG.js";import{c as a,i as o}from"./runtime-switch-ibQIZnws.js";import{n as s}from"./runtime-fetch-9B8F_rKW.js";import{d as c,g as l,h as u,i as d,l as f,m as p,n as m,p as h,u as g}from"./runtime-file-resource-tDTBpJT_.js";var _=26214400,v=class extends Error{status;code;constructor(e,t,n=`Failed to upload assistant attachment`){super(n),this.name=`AssistantAttachmentUploadError`,this.status=e,this.code=t}},y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),b=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),x=async e=>{let t;if(e instanceof ArrayBuffer)t=e;else if(ArrayBuffer.isView(e)){let n=e;t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=await e.arrayBuffer();return b(await crypto.subtle.digest(`SHA-256`,t))},S=e=>typeof e==`string`?e.split(`;`)[0]?.trim().toLowerCase():``,C=e=>{if(!Number.isSafeInteger(e)||e<0)throw new v(0,`rejected`,`Invalid attachment size`);if(e>26214400)throw new v(413,`too-large`)},w=(e,t,n={})=>{if(!y(e))throw new v(0,`integrity`,`Attachment response was not a JSON object`);if(e.type!==`file`)throw new v(0,`integrity`,`Attachment response type must be file`);let r=typeof e.attachmentID==`string`?e.attachmentID.trim():``,i=typeof e.sha256==`string`?e.sha256.trim().toLowerCase():``,a=typeof e.size==`number`&&Number.isSafeInteger(e.size)?e.size:NaN,o=S(typeof e.mime==`string`?e.mime:``),s=typeof e.filename==`string`&&e.filename.trim()?e.filename.trim():void 0;if(!r)throw new v(0,`integrity`,`Attachment response missing attachmentID`);if(!/^[a-f0-9]{64}$/i.test(i))throw new v(0,`integrity`,`Attachment response missing sha256`);if(!Number.isSafeInteger(a)||a<0)throw new v(0,`integrity`,`Attachment response missing size`);if(!o)throw new v(0,`integrity`,`Attachment response missing mime`);if((n.enforceUploadLimit===!0||t)&&C(a),t){if(i!==t.sha256.toLowerCase())throw new v(0,`integrity`,`Attachment SHA-256 mismatch`);if(a!==t.size)throw new v(0,`integrity`,`Attachment size mismatch`);if(o!==t.mime)throw new v(0,`integrity`,`Attachment mime mismatch`)}return{type:`file`,attachmentID:r,sha256:i,size:a,mime:o,...s?{filename:s}:{}}},T=async(e,t,n,r)=>{let i=m(),a=typeof e==`string`?e.trim():``,o=typeof n==`string`?n.trim():``;if(!a||!o)throw new v(0,`rejected`,`assistantID and uploadID are required`);if(!(t instanceof Blob))throw new v(0,`rejected`,`file must be a File or Blob`);let c=S(t.type||t.type)||`application/octet-stream`,l=t.type===c?t:new Blob([t],{type:c});C(l.size);let u=await x(l),d=typeof t.name==`string`&&t.name.trim()?t.name.trim():void 0,f;try{f=await s(`/api/yuri/assistants/${encodeURIComponent(a)}/contact/attachments/${encodeURIComponent(o)}`,{method:`PUT`,headers:{"Content-Type":c,"X-Content-SHA256":u,"X-Content-Size":String(l.size),...d?{"X-Attachment-Filename":encodeURIComponent(d)}:{}},body:l,signal:r})}catch{throw new v(0,`unavailable`)}if(f.status===204||f.status===205)throw new v(f.status,`integrity`,`Attachment upload returned empty status`);if(f.status===413)throw new v(413,`too-large`);if(!f.ok)throw new v(f.status,f.status>=500||f.status===0?`unavailable`:`rejected`);let p=f.headers.get(`content-type`)?.toLowerCase()??``;if(p.includes(`text/html`)||p.includes(`text/plain`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);let h;try{let e=await f.text();if(!e.trim())throw new v(f.status,`integrity`,`Attachment upload returned empty body`);if(!p.includes(`application/json`)&&!e.trim().startsWith(`{`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);h=JSON.parse(e)}catch(e){throw e instanceof v?e:new v(f.status,`integrity`,`Attachment upload response was not valid JSON`)}let g=w(h,{sha256:u,size:l.size,mime:c});return await i(l,u),g},E=e=>{try{return w(e,void 0,{enforceUploadLimit:!1}),!0}catch{return!1}},D=e({clearAssistantAttachmentCacheAll:()=>G,clearAssistantAttachmentCacheForBearer:()=>W,clearAssistantAttachmentCacheScope:()=>U,getAssistantAttachmentBlob:()=>J,getAssistantAttachmentDisplay:()=>Y,resolveAssistantAttachmentCacheScope:()=>R}),O=g,k=class extends Error{status;code;constructor(e,t,n=`Assistant attachment cache error`){super(n),this.status=e,this.code=t,this.name=`AssistantAttachmentCacheError`}},A=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``),j=0,M,N,P=!1,F=new Map,I=new Map,L=new Set,R=async(e={})=>{let t=e.transportIdentity??o(),r=e.authGeneration??i(),a=(e.bearer??n()).trim();return{transportIdentity:t,authGeneration:r,authScope:a?`b:${await A(a)}`:`m:${r}`,authScopeKind:a?`bearer-hash`:`memory-ephemeral`}},z=e=>`assistant:${e.transportIdentity}:${e.authScope}`,B=e=>`assistant-auth:${e}`,V=()=>{j++;for(let e of L)e.abort();L.clear();for(let e of I.values())e.controller.abort(),e.url&&p(e.url);I.clear();for(let e of F.values()){for(let t=0;t<e.refs;t++)h(e.url);p(e.url)}F.clear()},H=()=>{if(!P&&globalThis.indexedDB){P=!0;for(let e of[`yuri-assistant-attachments`,`openchamber-assistant-attachments`,`openchambery-assistant-attachments`])try{globalThis.indexedDB.deleteDatabase(e)}catch{}}M||=a(V),N||=t(e=>{V(),e.reason!==`endpoint-switch`&&d(e.previousBearerDigest?B(`b:${e.previousBearerDigest}`):void 0)})},U=async(e,t=`scope-cleared`)=>{let n=typeof e==`object`?e:await R();V(),await d(z(n))},W=async(e,t=`forget-bearer`)=>{if(!e.trim())return;let n=B(`b:${await A(e.trim())}`);V(),await d(n)},G=async(e=`cleared`)=>{V(),await d()},K=(e,t,n)=>{if(!e.trim()||!E(t))throw new k(0,`rejected`);if(t.size>n)throw new k(413,`too-large`)},q=async(e,t,n,a)=>{H(),K(e,t,n),a?.throwIfAborted();let o=j,c=await R();if(o!==j)throw new k(0,`stale`);let l=new AbortController,u=()=>l.abort(a?.reason);a?.addEventListener(`abort`,u,{once:!0}),L.add(l);let d;try{a?.throwIfAborted();let u=await f({identity:`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,sha256:t.sha256.toLowerCase(),size:t.size,mime:t.mime,filename:t.filename,persistent:c.authScopeKind===`bearer-hash`,tags:[z(c),B(c.authScope)],signal:l.signal,maxBytes:n,load:async n=>{let a=await s(`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,{method:`GET`,cache:`no-store`,signal:n});if(a.status===401||a.status===403)throw d=new k(a.status,`unauthorized`),await U(c,`unauthorized`),i()===c.authGeneration&&r(),new k(a.status,`unauthorized`);if(!a.ok)throw new k(a.status,a.status===413?`too-large`:a.status>=500?`unavailable`:`rejected`);return a}});if(o!==j)throw new k(0,`stale`);return u}catch(e){throw d||(e instanceof k?e:o===j?l.signal.aborted?new k(0,`aborted`):/descriptor limit|streaming destination/i.test(String(e))?new k(413,`too-large`):new k(0,/fingerprint|size|changed|truncated/i.test(String(e))?`integrity`:`unavailable`):new k(0,`stale`))}finally{L.delete(l),a?.removeEventListener(`abort`,u)}},J=(e,t,n={})=>q(e,t,_,n.signal),Y=async(e,t,n={})=>{H(),K(e,t,O),n.signal?.throwIfAborted();let r=j,i=await R(),a=JSON.stringify([z(i),e,t.attachmentID,t.sha256]),o=e=>{if(r!==j||!c(e)||!u(e))throw p(e),new k(0,`stale`);let t=F.get(a)?.url===e?F.get(a):{url:e,refs:0};t.refs++,F.set(a,t);let n=!1;return{url:e,release:()=>{n||(n=!0,F.get(a)===t&&(h(e),--t.refs===0&&(F.delete(a),p(e))))}}},s=F.get(a);if(s&&c(s.url))return o(s.url);let d=I.get(a);if(!d){let n=new AbortController,i={controller:n,refs:0,promise:Promise.resolve(``)};i.promise=q(e,t,O,n.signal).then(e=>l(e,n.signal,{mimeType:t.mime||e.type})).then(e=>{if(i.url=e,r!==j||n.signal.aborted||i.refs===0)throw p(e),new k(0,`stale`);return e}).catch(e=>{throw I.get(a)===i&&I.delete(a),e}),d=i,I.set(a,d)}let f=d;return f.refs++,new Promise((e,t)=>{let r=!1,i=e=>{--f.refs===0&&(e&&f.controller.abort(),I.get(a)===f&&I.delete(a),e&&f.url&&!F.has(a)&&p(f.url))},s=()=>{r||(r=!0,i(!0),t(new k(0,`aborted`)))};n.signal?.addEventListener(`abort`,s,{once:!0}),n.signal?.aborted&&s(),f.promise.then(a=>{if(n.signal?.removeEventListener(`abort`,s),!r){r=!0;try{e(o(a))}catch(e){t(e)}i(!1)}},e=>{n.signal?.removeEventListener(`abort`,s),!r&&(r=!0,i(!1),t(e))})})};export{T as i,J as n,Y as r,D as t};