@yuriai/web 0.2.35 → 0.2.36-beta.7

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 (113) hide show
  1. package/dist/assets/{AgentAvatar-DLzcNrQ0.js → AgentAvatar-D4JLZ7IL.js} +1 -1
  2. package/dist/assets/{AssistantContactStatus-9chQCNlQ.js → AssistantContactStatus-CqANenYS.js} +3 -3
  3. package/dist/assets/{AssistantUnreadBadge-DzZgExBt.js → AssistantUnreadBadge-j-O3lnH_.js} +1 -1
  4. package/dist/assets/{AssistantView-D6y9ECO7.js → AssistantView-DXibp8Nh.js} +1 -1
  5. package/dist/assets/{DiagramView-BO0AIQl-.js → DiagramView-BRW8DdSg.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-BRrU2ivL.js → FadeInOnReveal-CY1UuS2D.js} +1 -1
  7. package/dist/assets/{GuiPluginSurface-0_eilin-.js → GuiPluginSurface-BOWSgNtP.js} +1 -1
  8. package/dist/assets/{GuiPluginWindow-BykPaQeY.js → GuiPluginWindow-DlnxZgDZ.js} +1 -1
  9. package/dist/assets/{Icon-OJf0qBKf.js → Icon-D7VxRqha.js} +1 -1
  10. package/dist/assets/{ImageLoadingPlaceholder-DlQbo9CM.js → ImageLoadingPlaceholder-ClzN4oGS.js} +1 -1
  11. package/dist/assets/{LoadingImage-sZ5omN5L.js → LoadingImage-QfRXuKTy.js} +1 -1
  12. package/dist/assets/MarkdownRenderer-DjSn61IL.js +2 -0
  13. package/dist/assets/MarkdownRendererImpl-DIvSv3Rv.js +10 -0
  14. package/dist/assets/MarkstreamRendererImpl-AJvljij3.js +3 -0
  15. package/dist/assets/{MobileDetailNavigation-D107--jY.js → MobileDetailNavigation-CaO-fGvE.js} +1 -1
  16. package/dist/assets/{MobileResizableSheet-DuAi_epR.js → MobileResizableSheet-CNn25qxG.js} +1 -1
  17. package/dist/assets/{MobileShareBridge-Duya4-qV.js → MobileShareBridge-D8oRgnuW.js} +2 -2
  18. package/dist/assets/MobileTabPageHeader-CkuLCAUz.js +2 -0
  19. package/dist/assets/{MultiRunWindow-CKFLVBjQ.js → MultiRunWindow-PFfaS1N3.js} +1 -1
  20. package/dist/assets/{OnboardingScreen-CqsI0632.js → OnboardingScreen-BmAImZZZ.js} +1 -1
  21. package/dist/assets/{OverlayScrollbar-CZD1yU06.js → OverlayScrollbar-dxKlRNuH.js} +1 -1
  22. package/dist/assets/{SettingsView-By8wQ0io.js → SettingsView-Ci7GRXnm.js} +12 -12
  23. package/dist/assets/{SettingsWindow-BkYvnI4i.js → SettingsWindow-DjqjH8zU.js} +1 -1
  24. package/dist/assets/{SetupTourDialog-ER0fy_HE.js → SetupTourDialog-yJq3b29w.js} +1 -1
  25. package/dist/assets/{TerminalView-Bxwe5vPx.js → TerminalView-DsqOYj1E.js} +3 -3
  26. package/dist/assets/{ToolOutputDialog-wLULKJRN.js → ToolOutputDialog-CxlFIAQ4.js} +1 -1
  27. package/dist/assets/{VoiceSettings-BYFnku1a.js → VoiceSettings-BEtahqoU.js} +2 -2
  28. package/dist/assets/{YuriLogo-CMUoGUHc.js → YuriLogo-DADSHd1H.js} +1 -1
  29. package/dist/assets/{YuriWordmark-DHYo0FlR.js → YuriWordmark-CGDlDvEH.js} +1 -1
  30. package/dist/assets/{appThemeRegistry-z9y3dowq.js → appThemeRegistry-Bz6WZldU.js} +1 -1
  31. package/dist/assets/bootstrap-Bi91NjXG.js +3 -0
  32. package/dist/assets/{button-C-gRcs_2.js → button-B7w-b2yV.js} +1 -1
  33. package/dist/assets/{capgoAdapter-CmkP4lqS.js → capgoAdapter-BpF4euDL.js} +1 -1
  34. package/dist/assets/{checkbox-BrJBzET8.js → checkbox-DTPgJBK_.js} +1 -1
  35. package/dist/assets/{collapsible-B7esGYLd.js → collapsible-DZ4ykYM2.js} +1 -1
  36. package/dist/assets/{context-menu-DWn1nSZC.js → context-menu-BXHMb3Q-.js} +1 -1
  37. package/dist/assets/{diagram-Bnra5_6g.js → diagram-CldUPV-Z.js} +1 -1
  38. package/dist/assets/{dialog-3UseH0hM.js → dialog-gc3n4NXh.js} +1 -1
  39. package/dist/assets/{es-J7a_sZ1u.js → es-DDcXvUON.js} +1 -1
  40. package/dist/assets/{fileMentionTouchSelection-ByaQJcTS.js → fileMentionTouchSelection-CJtFYKAV.js} +1 -1
  41. package/dist/assets/{fileReferenceActions-COS3jfbf.js → fileReferenceActions-DrAZHld4.js} +1 -1
  42. package/dist/assets/{fr-BYxUMKWp.js → fr-pUULu88g.js} +2 -2
  43. package/dist/assets/{gitApi-Dw-LR3UG.js → gitApi-CJS823P8.js} +1 -1
  44. package/dist/assets/{gitApiHttp-MWsHNHuo.js → gitApiHttp-CKrsk1tw.js} +2 -2
  45. package/dist/assets/{input-CmLlZdeD.js → input-B7yPcQsA.js} +1 -1
  46. package/dist/assets/insertionBoundaries-D9Vc7ZK5.js +1 -0
  47. package/dist/assets/{ja-DCdBiJmD.js → ja-C7MjLXCG.js} +1 -1
  48. package/dist/assets/{ko-D-Nb_RJY.js → ko-U4JK9TxK.js} +1 -1
  49. package/dist/assets/{main-Dp8KQSBT.js → main-DD5kDabV.js} +2 -2
  50. package/dist/assets/{main-CRiKyn7G.js → main-Da12pxuy.js} +14 -14
  51. package/dist/assets/{markdownHeightCache-xNkQdlqi.js → markdownHeightCache-CLiBBW4n.js} +1 -1
  52. package/dist/assets/{mcpQueries-BZSAqZuN.js → mcpQueries-JrS0Bvb3.js} +1 -1
  53. package/dist/assets/{miniChat-BCW0br3M.js → miniChat-lRi18Hvu.js} +2 -2
  54. package/dist/assets/mobile-8eKyWn8a.js +2 -0
  55. package/dist/assets/{mobileBackNavigation-Bgo8TriP.js → mobileBackNavigation-BMaLnPn4.js} +1 -1
  56. package/dist/assets/multirun-Cui2oFM-.js +3 -0
  57. package/dist/assets/{native-config-ZqHOJ6fS.js → native-config-C8AlS30O.js} +1 -1
  58. package/dist/assets/{pl-AmU4w3aM.js → pl-Cy7NC-CJ.js} +1 -1
  59. package/dist/assets/projectMeta-A8jJRQk7.js +1 -0
  60. package/dist/assets/{pt-BR-BI4ft-Fj.js → pt-BR-qCU-EBEs.js} +1 -1
  61. package/dist/assets/pwa-CbR9DKyA.js +2 -0
  62. package/dist/assets/queue-abort-optimistic-B_crtkQx.js +1 -0
  63. package/dist/assets/{readiness-BYqlQeMk.js → readiness-BpeOajK9.js} +1 -1
  64. package/dist/assets/{renderElectronMiniChatApp-BJtTYEcH.js → renderElectronMiniChatApp-DqJy20-t.js} +2 -2
  65. package/dist/assets/{renderMobileApp-DYwORO8C.js → renderMobileApp-C9OxYnMu.js} +7 -7
  66. package/dist/assets/{runtimeConfig-DL4uXM0C.js → runtimeConfig-7LsY--_g.js} +1 -1
  67. package/dist/assets/{runtimeEndpointReset-C6j5YkJj.js → runtimeEndpointReset-NZMW9r3D.js} +7 -7
  68. package/dist/assets/{scheduledTaskNavigation-Cq5yavoC.js → scheduledTaskNavigation-7dD6PWMD.js} +1 -1
  69. package/dist/assets/{select-J8r9SxHt.js → select-WCptRb7Z.js} +1 -1
  70. package/dist/assets/sessionLookup-CxjYSDU2.js +1 -0
  71. package/dist/assets/{sortable-tabs-strip-CiP6RIQa.js → sortable-tabs-strip-DFKCoZZF.js} +1 -1
  72. package/dist/assets/{speechSettingsQueries-CufXiLkn.js → speechSettingsQueries-4gKyXBgi.js} +1 -1
  73. package/dist/assets/src-B_i0g2Ca.css +2 -0
  74. package/dist/assets/{store-OjrIiXCx.js → store-CVmc1U19.js} +3 -3
  75. package/dist/assets/{terminalApi-BMWW_0wH.js → terminalApi-Bo6KWljy.js} +1 -1
  76. package/dist/assets/{textarea-BHgcxJdC.js → textarea-CMVUhwQ2.js} +1 -1
  77. package/dist/assets/{tooltip-Degmpxnd.js → tooltip-L2xweVkb.js} +1 -1
  78. package/dist/assets/types-djs5o8aQ.js +2 -0
  79. package/dist/assets/{uk-CbdByxxj.js → uk-D5ulQPhM.js} +1 -1
  80. package/dist/assets/{useAppFontEffects-J3RrHTRd.js → useAppFontEffects-mxyvl0gj.js} +58 -54
  81. package/dist/assets/{useAssistantUIStore-D25VqrpK.js → useAssistantUIStore-cHle1U5H.js} +1 -1
  82. package/dist/assets/{useDesktopWindowControlsLayout-D22mutiT.js → useDesktopWindowControlsLayout-ZHw0VsJh.js} +1 -1
  83. package/dist/assets/{useDictation-DFVJpRbm.js → useDictation-DO12CgDE.js} +1 -1
  84. package/dist/assets/{useEffectiveDirectory-D1ga92jj.js → useEffectiveDirectory-B6ny9aem.js} +1 -1
  85. package/dist/assets/{useFontPreferences-CEK8G_Ps.js → useFontPreferences-D-AOjd9H.js} +1 -1
  86. package/dist/assets/useMobileNavigationStore-DRBFwjAg.js +17 -0
  87. package/dist/assets/{usePluginsStore-GuZu61OT.js → usePluginsStore-Bav6NFUH.js} +1 -1
  88. package/dist/assets/{useStreamingTextThrottle-VhgGU_te.js → useStreamingTextThrottle-DLR8xP-j.js} +1 -1
  89. package/dist/assets/useUIStore-B61bCFEM.js +1 -0
  90. package/dist/assets/{useWorkerHighlightedLines-DNj4Aa0S.js → useWorkerHighlightedLines-DdYDj9PN.js} +1 -1
  91. package/dist/assets/{vendor-marked-WVekxjAN.js → vendor-marked-S3gCOYp1.js} +1 -1
  92. package/dist/assets/{zh-CN-ufEVDbXp.js → zh-CN-C3SRM0mS.js} +1 -1
  93. package/dist/assets/{zh-TW-DTBlZ4YC.js → zh-TW-CZD-9AC2.js} +1 -1
  94. package/dist/index.html +10 -10
  95. package/dist/mini-chat.html +10 -10
  96. package/dist/mobile.html +10 -10
  97. package/package.json +1 -1
  98. package/dist/assets/MarkdownRenderer-64YkD1Ct.js +0 -2
  99. package/dist/assets/MarkdownRendererImpl-iosoqnCI.js +0 -10
  100. package/dist/assets/MarkstreamRendererImpl-BIxWqmEF.js +0 -3
  101. package/dist/assets/MobileTabPageHeader-CqhuzKJa.js +0 -2
  102. package/dist/assets/bootstrap-C8paoQ0j.js +0 -3
  103. package/dist/assets/insertionBoundaries-9KJWoqup.js +0 -1
  104. package/dist/assets/mobile-usXz8wZd.js +0 -2
  105. package/dist/assets/multirun-CflOv3TT.js +0 -3
  106. package/dist/assets/projectMeta-KP9BgEIm.js +0 -1
  107. package/dist/assets/pwa-BbBJQBpm.js +0 -2
  108. package/dist/assets/queue-abort-optimistic-BaOXtqLx.js +0 -1
  109. package/dist/assets/sessionLookup-LrqUcxJk.js +0 -1
  110. package/dist/assets/src-DHfmlFCj.css +0 -2
  111. package/dist/assets/types-DWyP764A.js +0 -2
  112. package/dist/assets/useMobileNavigationStore-BOlo2VUm.js +0 -17
  113. package/dist/assets/useUIStore-BerIUSLP.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t}from"./desktop-BAmoc_34.js";import{at as n,ot as r,st as i}from"./vendor-base-ui-CzHs0bHY.js";import{At as a}from"./gitApiHttp-CKrsk1tw.js";import{at as o,dt as s,ot as c,pt as l,ut as u}from"./bootstrap-Bi91NjXG.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{a as f,n as p}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as m,t as h}from"./platform-sEg2IOLZ.js";import{i as g,m as _}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as v,r as y,t as b}from"./button-B7w-b2yV.js";import{Ei as x,Xr as S,ei as C,ni as ee,qr as te,xi as w}from"./useMobileNavigationStore-DRBFwjAg.js";import{n as T}from"./Icon-D7VxRqha.js";import{r as E}from"./themes-BgDJcxRc.js";import{t as D}from"./MobileResizableSheet-CNn25qxG.js";import{n as ne,t as O}from"./useDictation-DO12CgDE.js";import{t as k}from"./LoadingImage-QfRXuKTy.js";import{t as A}from"./textarea-CMVUhwQ2.js";var j=e(i(),1),M=d(),N=r(),re=e(n(),1),ie=f(`YuriMedia`);function P(e){return e.platform===`android`||/Android/i.test(e.userAgent)||e.userAgentDataPlatform===`Android`}function ae(){if(typeof window>`u`)return!1;let e=navigator.userAgentData;return P({platform:h(),userAgent:navigator.userAgent||``,userAgentDataPlatform:e?.platform})}function F(){return m()&&p.getPlatform()===`android`&&p.isPluginAvailable(`YuriMedia`)}async function oe(e){if(!F())return null;let t=await ie.pickMedia({limit:e});if(t.cancelled)return[];let n=[];for(let e of t.files){let t=await fetch(p.convertFileSrc(e.path));if(!t.ok)throw Error(`Native media fetch failed (${t.status})`);let r=await t.blob();n.push(new File([r],e.name,{type:e.mimeType}))}return n}var I=`h-auto min-h-12 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 border-b border-[var(--surface-subtle)] last:border-b-0`,se=e=>{let t=(0,M.c)(38),{id:n,open:r,onOpenChange:i,onPickPhotos:a,onPickFiles:o}=e,{t:s}=v(),c;t[0]===s?c=t[1]:(c=s(`chat.chatInput.actions.addAttachment`),t[0]=s,t[1]=c);let l;t[2]===c?l=t[3]:(l=(0,N.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:c}),t[2]=c,t[3]=l);let u;t[4]===s?u=t[5]:(u=s(`chat.chatInput.actions.addAttachment`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===s?f=t[9]:(f=s(`mobile.sessions.sheet.resizeAria`),t[8]=s,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,N.jsx)(T,{name:`file-image`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[10]=p):p=t[10];let m;t[11]===s?m=t[12]:(m=s(`chat.chatInput.actions.attachPhotos`),t[11]=s,t[12]=m);let h;t[13]===m?h=t[14]:(h=(0,N.jsx)(`span`,{className:`truncate`,children:m}),t[13]=m,t[14]=h);let g;t[15]!==a||t[16]!==h?(g=(0,N.jsxs)(b,{type:`button`,variant:`ghost`,size:`lg`,className:I,"data-mobile-press-feedback":`none`,onClick:a,children:[p,h]}),t[15]=a,t[16]=h,t[17]=g):g=t[17];let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,N.jsx)(T,{name:`attachment-2`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[18]=_):_=t[18];let y;t[19]===s?y=t[20]:(y=s(`chat.chatInput.actions.attachFiles`),t[19]=s,t[20]=y);let x;t[21]===y?x=t[22]:(x=(0,N.jsx)(`span`,{className:`truncate`,children:y}),t[21]=y,t[22]=x);let S;t[23]!==o||t[24]!==x?(S=(0,N.jsxs)(b,{type:`button`,variant:`ghost`,size:`lg`,className:I,"data-mobile-press-feedback":`none`,onClick:o,children:[_,x]}),t[23]=o,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==S||t[27]!==g?(C=(0,N.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,N.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-page-scroll-lock":`true`,children:[g,S]})}),t[26]=S,t[27]=g,t[28]=C):C=t[28];let ee;return t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==C||t[33]!==l||t[34]!==u||t[35]!==d||t[36]!==f?(ee=(0,N.jsx)(D,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:u,closeAriaLabel:d,resizeAriaLabel:f,fitContent:!0,children:C}),t[29]=n,t[30]=i,t[31]=r,t[32]=C,t[33]=l,t[34]=u,t[35]=d,t[36]=f,t[37]=ee):ee=t[37],ee},L={glyph:`_glyph_1xs2e_1`,lens:`_lens_1xs2e_12`,shape:`_shape_1xs2e_21`,revolve:`_revolve_1xs2e_1`};function ce(e){let t=(0,M.c)(18),{decorative:n,size:r}=e,i=n!==void 0&&n,a=r===void 0?20:r,{t:o}=v(),s;t[0]===a?s=t[1]:(s={width:a,height:a},t[0]=a,t[1]=s);let c=i||void 0,l=i?void 0:`img`,u;t[2]!==i||t[3]!==o?(u=i?void 0:o(`common.loading`),t[2]=i,t[3]=o,t[4]=u):u=t[4];let d=`scale(${a/28})`,f;t[5]===d?f=t[6]:(f={transform:d},t[5]=d,t[6]=f);let p,m,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,N.jsx)(`span`,{className:L.shape}),p=(0,N.jsx)(`span`,{className:L.shape}),m=(0,N.jsx)(`span`,{className:L.shape}),t[7]=p,t[8]=m,t[9]=h):(p=t[7],m=t[8],h=t[9]);let g;t[10]===f?g=t[11]:(g=(0,N.jsxs)(`span`,{className:L.lens,style:f,children:[h,p,m]}),t[10]=f,t[11]=g);let _;return t[12]!==g||t[13]!==s||t[14]!==c||t[15]!==l||t[16]!==u?(_=(0,N.jsx)(`span`,{"data-dictation-loading":!0,className:L.glyph,style:s,"aria-hidden":c,role:l,"aria-label":u,children:g}),t[12]=g,t[13]=s,t[14]=c,t[15]=l,t[16]=u,t[17]=_):_=t[17],_}var R=E(!1).colors,le=`M-50 74.564 A600 600 0 0 1 147.707 22.283 A38 38 0 0 1 154.330 97.994 A524 524 0 0 0 -18.333 143.653 Z`,ue=`M450 74.564 A600 600 0 0 0 252.293 22.283 A38 38 0 0 0 245.670 97.994 A524 524 0 0 1 418.333 143.653 Z`,de={colorScheme:`light`,"--surface-background":R.surface.background,"--surface-foreground":R.surface.foreground,"--primary-base":R.primary.base,"--foreground":R.surface.background,"--interactive-hover":`color-mix(in srgb, var(--surface-background) 12%, transparent)`,"--interactive-active":`color-mix(in srgb, var(--surface-background) 20%, transparent)`,"--ring":R.interactive.focusRing,"--status-error":R.status.error};function fe(e){let t=(0,M.c)(85),{containerRef:n,disabled:r,onInsert:i,onSend:a,onRelease:o,onError:s,onHintChange:c}=e,{t:l}=v(),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(`send`),_=(0,j.useRef)(null),y=(0,j.useRef)(null),b=(0,j.useRef)(`insert`),x=(0,j.useRef)(null),S=(0,j.useId)(),C=(0,j.useId)(),te=(0,j.useId)(),w;t[0]!==i||t[1]!==a?(w=e=>b.current===`send`?a(e):i(e),t[0]=i,t[1]=a,t[2]=w):w=t[2];let T;t[3]!==s||t[4]!==w?(T={onTranscript:w,onError:s},t[3]=s,t[4]=w,t[5]=T):T=t[5];let E=O(T),{status:D,isStarting:ne,partialTranscript:k,error:A,volume:ie}=E,P=g(c),ae=u?m===`cancel`?`cancelling`:m===`edit`?`editing`:`recording`:f?`processing`:null,F,oe;t[6]!==ae||t[7]!==P?(F=()=>{P(ae)},oe=[ae,P],t[6]=ae,t[7]=P,t[8]=F,t[9]=oe):(F=t[8],oe=t[9]),(0,j.useEffect)(F,oe);let I,se;t[10]===P?(I=t[11],se=t[12]):(I=()=>()=>P(null),se=[P],t[10]=P,t[11]=I,t[12]=se),(0,j.useEffect)(I,se);let L;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{y.current&&clearTimeout(y.current),y.current=null},t[13]=L):L=t[13];let R=g(L),fe;t[14]!==n||t[15]!==r?(fe=e=>{if(r||!(e instanceof HTMLElement))return null;let t=n.current?.querySelector(`textarea`);return!t||t.value!==``||t.disabled||t.readOnly||t.ownerDocument.activeElement===t||e!==t&&!e.closest(`[data-yuri-composer-compact-surface]`)||e.closest(`button, [data-composer-action]`)?null:t},t[14]=n,t[15]=r,t[16]=fe):fe=t[16];let B=g(fe),pe;t[17]!==R||t[18]!==E||t[19]!==A||t[20]!==f||t[21]!==D?(pe=()=>{f||(R(),_.current=null,d(!1),h(`send`),D===`failed`||D===`idle`&&A?E.discardFailedDictation():E.cancelDictation())},t[17]=R,t[18]=E,t[19]=A,t[20]=f,t[21]=D,t[22]=pe):pe=t[22];let V=g(pe),H;t[23]!==E||t[24]!==r||t[25]!==B||t[26]!==f||t[27]!==D?(H=e=>{let t=e.target;r||f||D!==`idle`||_.current||!e.isPrimary||e.button!==0||!(t instanceof HTMLElement)||B(t)&&(e.preventDefault(),e.stopPropagation(),_.current={pointer:e.pointerId,x:e.clientX,y:e.clientY,intent:`send`,started:!1},y.current=setTimeout(()=>{if(y.current=null,!_.current)return;let e=B(t);if(!e){_.current=null;return}e.blur(),_.current.started=!0,b.current=`insert`,d(!0),h(`send`),E.startDictation()},300))},t[23]=E,t[24]=r,t[25]=B,t[26]=f,t[27]=D,t[28]=H):H=t[28];let U=g(H),me;t[29]===R?me=t[30]:(me=e=>{let t=_.current;if(!t||t.pointer!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let n=e.clientX-t.x,r=x.current?.getBoundingClientRect(),i=r&&r.width>0&&e.clientY>=r.top&&e.clientY<=r.bottom?e.clientX<r.left+r.width/2?`cancel`:`edit`:n<=-64?`cancel`:n>=64?`edit`:`send`;if(!t.started&&Math.hypot(n,t.y-e.clientY)>12){R(),_.current=null;return}t.started&&i!==t.intent&&(t.intent=i,h(i),ee(i===`send`?`light`:`medium`,{bypassCadence:!0}))},t[29]=R,t[30]=me);let W=g(me),he;t[31]!==V||t[32]!==R||t[33]!==n||t[34]!==E||t[35]!==A||t[36]!==o||t[37]!==k||t[38]!==D?(he=e=>{let t=_.current;if(!(!t||t.pointer!==e.pointerId)){if(e.preventDefault(),e.stopPropagation(),R(),A||D===`failed`){V();return}_.current=null,d(!1),t.started?t.intent===`cancel`?E.cancelDictation():(b.current=t.intent===`edit`?`insert`:`send`,o(k),p(!0),Promise.resolve(E.confirmDictation()).finally(()=>{p(!1),E.discardFailedDictation(),t.intent===`edit`&&n.current?.querySelector(`textarea`)?.focus()})):n.current?.querySelector(`textarea`)?.focus()}},t[31]=V,t[32]=R,t[33]=n,t[34]=E,t[35]=A,t[36]=o,t[37]=k,t[38]=D,t[39]=he):he=t[39];let G=g(he),ge;t[40]===V?ge=t[41]:(ge=e=>{_.current?.pointer===e.pointerId&&V()},t[40]=V,t[41]=ge);let _e=g(ge),ve;t[42]===B?ve=t[43]:(ve=e=>{B(e.target)&&e.preventDefault()},t[42]=B,t[43]=ve);let K=g(ve),q,J;t[44]!==V||t[45]!==R||t[46]!==n||t[47]!==U||t[48]!==_e||t[49]!==W||t[50]!==K||t[51]!==G?(q=()=>{let e=n.current;if(!e)return;let t=()=>{document.visibilityState===`hidden`&&V()};return e.addEventListener(`pointerdown`,U,!0),e.addEventListener(`touchstart`,K,{capture:!0,passive:!1}),window.addEventListener(`pointermove`,W,{capture:!0,passive:!1}),window.addEventListener(`pointerup`,G,!0),window.addEventListener(`pointercancel`,_e,!0),e.addEventListener(`contextmenu`,K,!0),e.addEventListener(`selectstart`,K,!0),window.addEventListener(`blur`,V),document.addEventListener(`visibilitychange`,t),()=>{R(),e.removeEventListener(`pointerdown`,U,!0),e.removeEventListener(`touchstart`,K,!0),window.removeEventListener(`pointermove`,W,!0),window.removeEventListener(`pointerup`,G,!0),window.removeEventListener(`pointercancel`,_e,!0),e.removeEventListener(`contextmenu`,K,!0),e.removeEventListener(`selectstart`,K,!0),window.removeEventListener(`blur`,V),document.removeEventListener(`visibilitychange`,t)}},J=[n,U,W,G,_e,V,R,K],t[44]=V,t[45]=R,t[46]=n,t[47]=U,t[48]=_e,t[49]=W,t[50]=K,t[51]=G,t[52]=q,t[53]=J):(q=t[52],J=t[53]),(0,j.useEffect)(q,J);let ye,Y;if(t[54]!==V||t[55]!==r?(ye=()=>{r&&V()},Y=[r,V],t[54]=V,t[55]=r,t[56]=ye,t[57]=Y):(ye=t[56],Y=t[57]),(0,j.useEffect)(ye,Y),!u&&!f)return null;let be=Math.min(1,Math.max(0,ie))**.6,X=!!A,xe=A?V:void 0,Se;t[58]===be?Se=t[59]:(Se={...de,"--speech-energy":be},t[58]=be,t[59]=Se);let Ce=Se,we;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,N.jsx)(`div`,{className:`yuri-speech-light-field`,"aria-hidden":`true`,children:[`ice`,`lilac`,`mint`,`blush`,`mid`,`core`].map(z)}),t[60]=we):we=t[60];let Te=ne||f,Z;t[61]!==A||t[62]!==ne||t[63]!==k||t[64]!==f||t[65]!==D||t[66]!==l?(Z=A&&!f?(0,N.jsx)(`p`,{role:`alert`,className:`yuri-speech-caption yuri-speech-error`,children:A}):(0,N.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`yuri-speech-caption`,children:ne||f?(0,N.jsx)(ce,{size:72}):k?(0,N.jsx)(`span`,{className:`yuri-speech-interim`,children:k}):l(D===`uploading`?`chat.dictation.processing`:`chat.dictation.listening`)}),t[61]=A,t[62]=ne,t[63]=k,t[64]=f,t[65]=D,t[66]=l,t[67]=Z):Z=t[67];let Q;t[68]!==Te||t[69]!==Z?(Q=(0,N.jsx)(`div`,{className:`yuri-speech-content`,"data-starting":Te,children:Z}),t[68]=Te,t[69]=Z,t[70]=Q):Q=t[70];let $;t[71]!==S||t[72]!==C||t[73]!==te||t[74]!==u||t[75]!==m||t[76]!==l?($=u&&(0,N.jsx)(`div`,{className:`yuri-speech-gesture-stage`,"aria-hidden":`true`,children:(0,N.jsxs)(`div`,{className:`yuri-speech-gesture-surfaces`,children:[(0,N.jsx)(`div`,{className:`yuri-speech-target-glass`,style:{clipPath:`url(#${C})`}}),(0,N.jsx)(`div`,{className:`yuri-speech-target-glass`,style:{clipPath:`url(#${te})`}}),(0,N.jsxs)(`svg`,{className:`yuri-speech-geometry`,viewBox:`0 0 400 226`,focusable:`false`,children:[(0,N.jsxs)(`defs`,{children:[(0,N.jsx)(`clipPath`,{id:C,clipPathUnits:`objectBoundingBox`,children:(0,N.jsx)(`path`,{transform:`scale(0.0025 0.004424778761)`,d:le})}),(0,N.jsx)(`clipPath`,{id:te,clipPathUnits:`objectBoundingBox`,children:(0,N.jsx)(`path`,{transform:`scale(0.0025 0.004424778761)`,d:ue})}),(0,N.jsxs)(`linearGradient`,{id:S,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,N.jsx)(`stop`,{offset:`0%`,className:`yuri-speech-arc-top`}),(0,N.jsx)(`stop`,{offset:`100%`,className:`yuri-speech-arc-bottom`})]})]}),(0,N.jsxs)(`g`,{className:`yuri-speech-targets`,ref:x,children:[(0,N.jsxs)(`g`,{className:`yuri-speech-target yuri-speech-target--cancel`,"data-active":m===`cancel`,children:[(0,N.jsx)(`path`,{d:le}),(0,N.jsx)(`text`,{x:`95`,y:`68`,textAnchor:`middle`,dominantBaseline:`central`,transform:`rotate(-11 95 68)`,children:l(`chat.dictation.cancelGesture`)})]}),(0,N.jsxs)(`g`,{className:`yuri-speech-target yuri-speech-target--edit`,"data-active":m===`edit`,children:[(0,N.jsx)(`path`,{d:ue}),(0,N.jsx)(`text`,{x:`305`,y:`68`,textAnchor:`middle`,dominantBaseline:`central`,transform:`rotate(11 305 68)`,children:l(`chat.dictation.edit`)})]})]}),(0,N.jsx)(`path`,{className:`yuri-speech-hold-arc`,fill:`url(#${S})`,d:`M-50 186.987 A500 500 0 0 1 450 186.987 L450 300 H-50 Z`})]})]})}),t[71]=S,t[72]=C,t[73]=te,t[74]=u,t[75]=m,t[76]=l,t[77]=$):$=t[77];let Ee;return t[78]!==m||t[79]!==X||t[80]!==xe||t[81]!==Ce||t[82]!==Q||t[83]!==$?(Ee=(0,re.createPortal)((0,N.jsxs)(`div`,{className:`yuri-speech-overlay`,"data-intent":m,"data-error":X,onClick:xe,style:Ce,children:[we,Q,$]}),document.body),t[78]=m,t[79]=X,t[80]=xe,t[81]=Ce,t[82]=Q,t[83]=$,t[84]=Ee):Ee=t[84],Ee}function z(e){return(0,N.jsx)(`div`,{className:`yuri-speech-reactor yuri-speech-reactor--${e}`,children:(0,N.jsx)(`div`,{className:`yuri-speech-light`})},e)}function B(e){let n=(0,M.c)(7),{available:r}=e,i=x(pe),[a,o]=(0,j.useState)(null),s;n[0]!==r||n[1]!==i?(s=r&&i&&!t()&&ne(),n[0]=r,n[1]=i,n[2]=s):s=n[2];let c=s,l=c?a:null,u;return n[3]!==c||n[4]!==i||n[5]!==l?(u={globallyEnabled:i,enabled:c,hint:l,onHintChange:o},n[3]=c,n[4]=i,n[5]=l,n[6]=u):u=n[6],u}function pe(e){return e.dictationEnabled}var V=j.createContext(null),H=e=>{let t=(0,M.c)(3),{actions:n,children:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,N.jsx)(V.Provider,{value:n,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},U=()=>j.useContext(V),me=e=>e.nativeEvent.isComposing||e.nativeEvent.keyCode===229;function W(e){let t=(0,M.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=y(`inline-flex shrink-0 items-center justify-center rounded-full bg-foreground text-background`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,N.jsx)(`span`,{className:a,...i,"aria-hidden":!0,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function he(e){let t=(0,M.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(`span`,{"data-stop-glyph":`true`,className:`block size-[38%] rounded-[20%] bg-current`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,N.jsx)(W,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function G(e){let t=(0,M.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,spinning:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i,o=a?`loader-4`:`arrow-up`,s=a?`size-[50%] animate-spin`:`size-[56%]`,c;t[4]===s?c=t[5]:(c=y(s),t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,N.jsx)(T,{name:o,weight:`medium`,className:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==r||t[11]!==l?(u=(0,N.jsx)(W,{className:n,...r,children:l}),t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12],u}var ge=j.forwardRef((e,t)=>{let n=(0,M.c)(17),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({children:r,className:i,expanded:s,style:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c=s!==void 0&&s&&`min-h-0 flex-1`,l;n[6]!==i||n[7]!==c?(l=y(`relative flex flex-col overflow-visible border border-[color-mix(in_srgb,var(--interactive-border)_50%,transparent)] dark:border-transparent`,`bg-[var(--surface-background)] shadow-[0_2px_6px_-3px_color-mix(in_srgb,var(--surface-foreground)_4%,transparent),inset_0_1px_0_var(--yuri-mobile-glass-highlight)] transition-colors duration-150 motion-reduce:transition-none`,`dark:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_8%)] dark:shadow-none dark:hover:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)] dark:focus-within:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)]`,c,i),n[6]=i,n[7]=c,n[8]=l):l=n[8];let u;n[9]===o?u=n[10]:(u={borderRadius:`var(--radius-xl)`,...o},n[9]=o,n[10]=u);let d;return n[11]!==r||n[12]!==a||n[13]!==t||n[14]!==l||n[15]!==u?(d=(0,N.jsx)(`div`,{ref:t,className:l,style:u,...a,children:r}),n[11]=r,n[12]=a,n[13]=t,n[14]=l,n[15]=u,n[16]=d):d=n[16],d});ge.displayName=`ChatComposerSurface`;var _e=j.forwardRef((e,t)=>{let n=(0,M.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,N.jsx)(A,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});_e.displayName=`ChatPromptTextarea`;var ve=e=>{let t=(0,M.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=y(`flex shrink-0 items-center gap-2 bg-transparent px-2.5 py-1.5`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,N.jsx)(`div`,{className:a,"data-chat-input-footer":`true`,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o},K=(e,t)=>{typeof e==`function`?e(t):e&&(e.current=t)},q=({value:e,attachments:t=[],disabled:n=!1,pending:r=!1,placeholder:i,isMobile:a=!1,onChange:o,onSubmit:s,onStop:c,onAddFiles:l,onRemoveAttachment:u,addFilesLabel:d,removeAttachmentLabel:f,fileAccept:p=`image/*`,sendLabel:m,stopLabel:h,hint:b,leftControls:x,rightControls:S,footerContent:ee,inputHeader:te,attachmentContent:w,highlightedContent:E,highlightRef:D,inputRef:ne,textareaProps:O,textLayoutClassName:A,inputClassName:M,inputOuterClassName:re,inputStyle:ie,footerClassName:P,footerStyle:I,contentClassName:L,inputSectionClassName:ce,autoResize:R=!0,disableInputWhilePending:le=!0,layout:ue=`stacked`,children:de,className:fe,expanded:z=!1,...B})=>{let{t:pe}=v(),V=ue===`inline`,[H,U]=j.useState(!1),[W,q]=j.useState(!1),J=ae(),ye=t.length>0||H,Y=j.useRef(null),be=j.useRef(null),X=j.useRef(null),xe=j.useId().replace(/:/g,``),Se=g(()=>{if(!R||z||O?.fillContainer){V&&U(!1);return}let e=Y.current;if(!e)return;e.style.height=V?`0px`:`auto`;let t=Number.parseFloat(window.getComputedStyle(e).maxHeight),n=V?Math.max(e.scrollHeight,48):e.scrollHeight,r=Number.isFinite(t)?Math.min(n,t):n;e.style.height=`${r}px`,e.style.overflowY=Number.isFinite(t)&&n>t?`auto`:`hidden`;let i=r>48;V&&U(e=>e===i?e:i)});j.useLayoutEffect(()=>{Se()},[R,z,V,O?.fillContainer,e]),_(V&&R&&!z&&!O?.fillContainer?Y:null,Se);let Ce=e=>{O?.onKeyDown?.(e),!(e.defaultPrevented||me(e))&&e.key===`Enter`&&!e.shiftKey&&!a&&(e.preventDefault(),!n&&(!r||!le)&&s())},we=e=>{l?.(e.target.files),e.target.value=``},Te=g(()=>{Y.current?.blur(),q(!0)}),Z=g(e=>{q(!1),requestAnimationFrame(()=>e?.click())}),Q=g(()=>{q(!1),requestAnimationFrame(()=>{(async()=>{if(!F()){X.current?.click();return}try{let e=await oe(20);if(e===null){X.current?.click();return}e.length>0&&l?.(e)}catch(e){console.error(`Native photo pick failed`,e),C.error(pe(`chat.chatInput.toast.attachFileFailed`))}})()})}),$=e.trim().length>0||t.length>0,Ee=t.filter(e=>e.mime.startsWith(`image/`)),De=t.filter(e=>!e.mime.startsWith(`image/`)),Oe=l?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`input`,{ref:be,type:`file`,accept:p,multiple:!0,className:`hidden`,onChange:we}),J?(0,N.jsx)(`input`,{ref:X,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:we}):null,(0,N.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>J?Te():be.current?.click(),onMouseDown:a?e=>e.preventDefault():void 0,onPointerDownCapture:a?e=>e.preventDefault():void 0,disabled:n||r,"aria-label":d,children:(0,N.jsx)(T,{name:`attachment-2`,className:`size-[18px]`})})]}):null,ke=!n&&!r&&$,Ae=a?`size-6`:`size-full`,je=r&&c?(0,N.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":h,children:(0,N.jsx)(he,{className:Ae})}):(0,N.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":ke?`true`:void 0,className:y(`flex size-8 shrink-0 items-center justify-center outline-none`,ke?`rounded-full hover:opacity-80`:`rounded-md text-primary hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-30`),disabled:n||r||!$,"aria-label":m,children:ke?(0,N.jsx)(G,{className:Ae}):(0,N.jsx)(T,{name:r?`loader-4`:`send-plane-2`,className:y(`size-4`,r&&`animate-spin`)})}),Me=r&&c?(0,N.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":h,children:(0,N.jsx)(he,{className:Ae})}):(0,N.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":`true`,className:y(`flex size-8 shrink-0 items-center justify-center rounded-full outline-none`,ke?`hover:opacity-80`:`cursor-not-allowed opacity-30`),disabled:n||r||!$,"aria-busy":r||void 0,"aria-label":m,onClick:()=>Y.current?.focus({preventScroll:!0}),onMouseDown:e=>e.preventDefault(),onPointerDownCapture:a?e=>e.preventDefault():void 0,children:(0,N.jsx)(G,{className:Ae,spinning:r})}),Ne=V?Me:je,Pe=x===void 0?Oe:x;return(0,N.jsxs)(ge,{className:fe,expanded:z,...B,children:[de,(0,N.jsxs)(`div`,{"data-composer-content":`true`,"data-composer-layout":ue,className:y(`relative flex min-h-0`,V?y(`min-h-12 flex-row`,ye?`items-end`:`items-center`):`flex-col`,z&&`flex-1`,L),children:[V&&Pe?(0,N.jsx)(`div`,{className:`flex h-12 shrink-0 items-center pl-1.5`,"data-composer-inline-attach":`true`,children:Pe}):null,(0,N.jsxs)(`div`,{className:y(`overflow-hidden`,V&&`min-w-0 flex-1`,z&&`flex min-h-0 flex-1 flex-col`,ce),children:[te,w,Ee.length>0?(0,N.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-3 pt-3`,"data-chat-prompt-attachments":`true`,children:Ee.map(e=>(0,N.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,N.jsx)(`span`,{className:`block size-16`,children:(0,N.jsx)(k,{fill:!0,src:e.url,alt:e.name,className:`size-16 rounded-lg border border-border object-cover`})}),u?(0,N.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] shadow-sm hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,N.jsx)(T,{name:`close`,className:`size-3`})}):null]},e.id))}):null,De.length>0?(0,N.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,"data-chat-prompt-file-attachments":`true`,children:De.map(e=>(0,N.jsxs)(`div`,{className:`relative flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border bg-[var(--surface-elevated)] px-2 py-1`,children:[(0,N.jsx)(T,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,N.jsx)(`span`,{className:`min-w-0 truncate typography-micro`,children:e.name}),u?(0,N.jsx)(`button`,{type:`button`,className:`flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,N.jsx)(T,{name:`close`,className:`size-3`})}):null]},e.id))}):null,(0,N.jsxs)(`div`,{className:y(`relative overflow-hidden`,V&&y(`flex min-h-12`,H?`items-end`:`items-center`),z&&`flex min-h-0 flex-1 flex-col`),"data-composer-input-shell":`true`,children:[E?(0,N.jsx)(`div`,{ref:D,"aria-hidden":!0,"data-composer-highlight":`true`,className:y(`pointer-events-none absolute inset-0 z-0 rounded-b-none`,A,M),children:E}):null,(0,N.jsx)(_e,{...O,simple:!0,fillContainer:!V&&O?.fillContainer,ref:e=>{Y.current=e,K(ne,e)},"data-chat-input":`true`,value:e,onChange:e=>o(e.target.value,e),onKeyDown:Ce,disabled:n||r&&le,placeholder:i,enterKeyHint:a?`enter`:O?.enterKeyHint,outerClassName:y(`ring-0 bg-transparent shadow-none hover:bg-transparent focus-within:ring-0`,V&&`flex-none`,z&&`min-h-0 flex-1`,re),className:y(`relative z-10 resize-none overflow-y-hidden appearance-none border-0 bg-transparent typography-markdown hover:border-transparent md:typography-ui-label`,V?`field-sizing-fixed min-h-12 max-h-32 px-3 py-3 leading-6`:`min-h-[52px] max-h-40 rounded-b-none px-3 pb-2 pt-4`,A,M,E&&`text-transparent caret-[var(--surface-foreground)]`),style:ie,rows:O?.rows??1})]})]}),V?(0,N.jsx)(`div`,{className:y(`flex h-12 shrink-0 items-center pr-1.5`,P),style:I,"data-composer-inline-send":`true`,children:S??Ne}):(0,N.jsx)(ve,{className:P,style:I,children:ee??(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`flex items-center gap-1.5`,children:x??Oe}),b?(0,N.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,children:b}):(0,N.jsx)(`div`,{className:`flex-1`}),(0,N.jsx)(`div`,{className:`flex items-center gap-1.5`,children:S??Ne})]})})]}),J&&l?(0,N.jsx)(se,{id:`mobile-attach-pick-${xe}`,open:W,onOpenChange:e=>{e||q(!1)},onPickPhotos:Q,onPickFiles:()=>Z(be.current)}):null]})},J={dictation:102,mentionFile:100,mentionAgent:100,mentionSession:100,mentionCommand:100,mentionPaste:100,code:90,codeFence:90,link:80,linkUrl:78,heading:70,blockquote:40,listMarker:35,marker:10},ye={dictation:`text-foreground underline decoration-current underline-offset-4`,mentionFile:`text-[var(--primary)]`,mentionAgent:`text-[var(--primary)]`,mentionSession:`text-[var(--primary)]`,mentionCommand:`text-[var(--primary)]`,mentionPaste:`text-[var(--primary)]`,code:`rounded-[3px] bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,codeFence:`bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,link:`text-[var(--status-info)] underline`,linkUrl:`text-muted-foreground`,heading:`text-[var(--syntax-keyword)]`,blockquote:`text-muted-foreground`,listMarker:`text-[var(--syntax-keyword)]`,marker:`text-muted-foreground`},Y=`text-foreground`;function be(e,t){if(!e||t.length===0)return null;let n=e.length,r=new Set([0,n]);for(let e of t)e.start>0&&e.start<n&&r.add(e.start),e.end>0&&e.end<n&&r.add(e.end);let i=[...r].sort((e,t)=>e-t),a=t.map((e,t)=>({range:e,index:t})).filter(e=>e.range.end>e.range.start).sort((e,t)=>e.range.start-t.range.start),o=[],s=[],c=0;for(let t=0;t<i.length-1;t+=1){let n=i[t],r=i[t+1];if(r<=n)continue;for(;c<a.length&&a[c].range.start<=n;)s.push(a[c]),c+=1;for(let e=s.length-1;e>=0;--e)s[e].range.end<=n&&s.splice(e,1);let u=null,d=-1,f=1/0;for(let{range:e,index:t}of s){let n=e.priority??J[e.style];(n>d||n===d&&t<f)&&(d=n,f=t,u=e)}let p=u?u.className??ye[u.style]:Y,m=e.slice(n,r),h=u?.visual,g=u?.skillName,_=o[o.length-1];_&&_.className===p&&l(_.visual,h)&&_.skillName===g?_.text+=m:o.push({text:m,className:p,visual:h,skillName:g})}return o.length>0?o:null}function X(e,t){let n=new Set(Array.from(t,e=>e.toLowerCase())),r=[];for(let t of[/(^|\s)\/(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)/gi,/(^|\s)@(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)(?=$|\s|[),.;:!?])/gi]){let i;for(;(i=t.exec(e))!==null;){let e=i[2]??``,t=i[3]||``;if(!n.has(t.toLowerCase()))continue;let a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+e.length+t.length,name:t})}}return r}function xe(e,t,n){if(e===t){let t=n.find(t=>e>t.start&&e<t.end);return t?{start:t.start,end:t.end}:null}let r=n.filter(n=>n.start<t&&n.end>e);return r.length===0?null:{start:Math.min(e,...r.map(e=>e.start)),end:Math.max(t,...r.map(e=>e.end))}}function Se(e,t,n){let r=X(e,t),i=Math.max(0,Math.min(n.selectionStart,e.length)),a=Math.max(i,Math.min(n.selectionEnd,e.length)),o=i,s=a;if(i===a)if(n.altKey)if(n.key===`Backspace`){for(;o>0&&/\s/.test(e[o-1]);)--o;for(;o>0&&!/\s/.test(e[o-1]);)--o}else{for(;s<e.length&&/\s/.test(e[s]);)s+=1;for(;s<e.length&&!/\s/.test(e[s]);)s+=1}else n.key===`Backspace`?o=Math.max(0,i-1):s=Math.min(e.length,i+1);if(o===s)return null;let c=r.filter(e=>e.start<s&&e.end>o);if(c.length===0)return null;let l=Math.min(o,...c.map(e=>e.start)),u=Math.max(s,...c.map(e=>e.end));return u<e.length&&/\s/.test(e[u])&&(l===0||/\s/.test(e[l-1]))?u+=1:u===e.length&&l>0&&/\s/.test(e[l-1])&&--l,{text:`${e.slice(0,l)}${e.slice(u)}`,caret:l,removedSkillNames:c.map(e=>e.name)}}function Ce(e){return e.map(e=>({start:e.start,end:e.end,style:e.kind===`file`?`mentionFile`:e.kind===`session`?`mentionSession`:`mentionAgent`,visual:e.kind===`session`&&e.label?s({trigger:`@`,icon:`chat-thread`,label:e.label},u({trigger:`@`,icon:`chat-thread`,label:e.label})):void 0}))}function we(e){let t=(0,M.c)(28),{visual:n,text:r}=e,i=n.trigger.length,a=i+n.label.length,s=a+(n.suffix?.length??0),l;t[0]!==a||t[1]!==i||t[2]!==r?(l=r.slice(i,Math.min(a,r.length)),t[0]=a,t[1]=i,t[2]=r,t[3]=l):l=t[3];let u=l,d;t[4]!==a||t[5]!==s||t[6]!==r?(d=r.slice(a,Math.min(s,r.length)),t[4]=a,t[5]=s,t[6]=r,t[7]=d):d=t[7];let f=d,p;t[8]!==s||t[9]!==r?(p=r.slice(Math.min(s,r.length)),t[8]=s,t[9]=r,t[10]=p):p=t[10];let m=p,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h={left:o,right:o},t[11]=h):h=t[11];let g=n.icon,_;t[12]===g?_=t[13]:(_=(0,N.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 inline-flex items-center justify-center`,style:h,children:(0,N.jsx)(T,{name:g,className:`${c} shrink-0 text-[var(--primary)]`,"aria-hidden":`true`})}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==n.trigger?(v=(0,N.jsxs)(`span`,{className:`relative inline-block align-baseline text-transparent leading-none`,children:[n.trigger,_]}),t[14]=_,t[15]=n.trigger,t[16]=v):v=t[16];let y;t[17]===u?y=t[18]:(y=(0,N.jsx)(`span`,{children:u}),t[17]=u,t[18]=y);let b;t[19]===f?b=t[20]:(b=f?(0,N.jsx)(`span`,{className:`text-transparent`,children:f}):null,t[19]=f,t[20]=b);let x;t[21]===m?x=t[22]:(x=m?(0,N.jsx)(`span`,{className:`text-transparent`,children:m}):null,t[21]=m,t[22]=x);let S;return t[23]!==x||t[24]!==v||t[25]!==y||t[26]!==b?(S=(0,N.jsxs)(N.Fragment,{children:[v,y,b,x]}),t[23]=x,t[24]=v,t[25]=y,t[26]=b,t[27]=S):S=t[27],S}var Te=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return!1;switch(e.key){case`ArrowUp`:case`PageUp`:case`Home`:return!0;default:return!1}},Z=(e,t,n)=>{let r=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;r&&r!==e;){if(r instanceof HTMLElement){let e=r.scrollHeight-r.clientHeight;if(e>1&&(n===`up`?r.scrollTop>0:r.scrollTop<e-1))return!0}r=r.parentElement}return!1},Q=(e,t)=>Z(e,t,`up`),$=(e,t)=>Z(e,t,`down`),Ee=e=>({text:e.text,references:e.references.map(e=>({...e}))}),De=e=>e.map(e=>({...e,range:{...e.range}})),Oe=(e,t)=>e.text===t.text&&JSON.stringify(e.references)===JSON.stringify(t.references),ke=(e,t,n)=>({document:Ee(e),mentions:De(t),selection:{...n}}),Ae=()=>({undo:[],redo:[]}),je=(e,t)=>({undo:[...e.undo,t].slice(-100),redo:[]}),Me=(e,t)=>{let n=e.undo.at(-1);return!n||!Oe(n.after.document,t)?null:{history:{undo:e.undo.slice(0,-1),redo:[...e.redo,n]},snapshot:ke(n.before.document,n.before.mentions,n.before.selection)}},Ne=(e,t)=>{let n=e.redo.at(-1);return!n||!Oe(n.before.document,t)?null:{history:{undo:[...e.undo,n],redo:e.redo.slice(0,-1)},snapshot:ke(n.after.document,n.after.mentions,n.after.selection)}},Pe=e=>{if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.trunc(e);return t>=0?t:void 0},Fe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.summary;return!t||typeof t!=`object`||Array.isArray(t)?null:t},Ie=e=>{let t=Pe(e);return t!==void 0&&t>0?t:void 0};function Le(e){let t=Fe(e);if(!t)return null;let n=Ie(t.additions),r=Ie(t.deletions),i=Ie(t.files)??Ie(t.diffCount);return n===void 0&&r===void 0&&i===void 0?null:{...n===void 0?{}:{additions:n},...r===void 0?{}:{deletions:r},...i===void 0?{}:{files:i}}}function Re(e){if(!e)return null;let t=[];return e.additions!==void 0&&e.additions>0&&t.push(`+${e.additions}`),e.deletions!==void 0&&e.deletions>0&&t.push(`−${e.deletions}`),t.length>0?t.join(` `):null}function ze(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.providerID==`string`?t.providerID.trim():``,r=typeof t.modelID==`string`?t.modelID.trim():``;if(n&&r)return`${n}/${r}`;let i=t.model;if(typeof i==`string`&&i.trim())return i.trim();if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i,t=typeof e.providerID==`string`?e.providerID.trim():typeof e.provider==`string`?e.provider.trim():``,n=typeof e.modelID==`string`?e.modelID.trim():typeof e.id==`string`?e.id.trim():``;if(t&&n)return`${t}/${n}`}return null}function Be(e){if(!e||e.trim().length===0)return null;let t=S.getState(),n=t.activeSessions.find(t=>t.id===e)??t.archivedSessions.find(t=>t.id===e)??null;if(!n)return null;let r=te(n);return r?{sessionId:e,directory:r,session:n,fromCache:!t.hasLoaded,source:`memory`}:null}function Ve(e){return Be(e)?.directory??null}var He=new Map;async function Ue(e,t){let n=e.trim();if(!n)return null;let r=Be(n);if(r)return r;let i=He.get(n);if(i)return i;let o=(async()=>{let e=Be(n);if(e)return e;let r=await w(n,{signal:t?.signal});if(r?.directory)return{sessionId:r.id,directory:r.directory,session:null,fromCache:!1,source:`session-index`};if(t?.trySessionGet===!1)return null;try{let e=await a.getSession(n),t=typeof e.directory==`string`&&e.directory.trim()||(typeof e.project?.worktree==`string`?e.project.worktree.trim():``)||null;return t?{sessionId:n,directory:t,session:e,fromCache:!1,source:`session-get`}:null}catch{return null}})().finally(()=>{He.get(n)===o&&He.delete(n)});return He.set(n,o),o}export{se as A,he as C,B as D,U as E,oe as M,ae as N,fe as O,G as S,H as T,X as _,Le as a,Se as b,Ae as c,Me as d,Te as f,be as g,we as h,Re as i,F as j,ce as k,je as l,Q as m,Ve as n,ze as o,$ as p,Ue as r,ke as s,Be as t,Ne as u,Ce as v,me as w,q as x,xe as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{r}from"./useUIStore-BerIUSLP.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{f as a,r as o}from"./button-C-gRcs_2.js";import{n as s}from"./Icon-OJf0qBKf.js";import{r as c}from"./device-w1ioiqv3.js";import{_ as l,l as u,n as d,s as ee,t as f,v as p,y as m}from"./vendor-dnd-kit-core-DK4OoOTr.js";import{o as h,r as te,t as g}from"./vendor-dnd-kit-sortable-Cv69eQm1.js";var ne=i(),_=e(n(),1),v=t(),re=({transform:e})=>({...e,y:0}),ie=e=>{let t=(0,ne.c)(18),{id:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a={id:n},t[0]=n,t[1]=a);let{attributes:s,listeners:c,setNodeRef:l,transform:u,transition:d,isDragging:ee}=h(a),f;t[2]===u?f=t[3]:(f=m.Transform.toString(u),t[2]=u,t[3]=f);let p;t[4]!==f||t[5]!==d?(p={transform:f,transition:d},t[4]=f,t[5]=d,t[6]=p):p=t[6];let te=ee&&`opacity-50`,g;t[7]!==i||t[8]!==te?(g=o(`h-full rounded-md`,i,te),t[7]=i,t[8]=te,t[9]=g):g=t[9];let _;return t[10]!==s||t[11]!==r||t[12]!==n||t[13]!==c||t[14]!==l||t[15]!==p||t[16]!==g?(_=(0,v.jsx)(`div`,{ref:l,"data-sortable-tab-id":n,style:p,className:g,...s,...c,children:r}),t[10]=s,t[11]=r,t[12]=n,t[13]=c,t[14]=l,t[15]=p,t[16]=g,t[17]=_):_=t[17],_},ae=e=>{let t=(0,ne.c)(6),{id:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=o(`h-full`,i),t[0]=i,t[1]=a);let s;return t[2]!==r||t[3]!==n||t[4]!==a?(s=(0,v.jsx)(`div`,{className:a,"data-sortable-tab-id":n,children:r}),t[2]=r,t[3]=n,t[4]=a,t[5]=s):s=t[5],s},y=e=>{let t=(0,ne.c)(124),{items:n,activeId:i,onSelect:m,onClose:h,onReorder:y,layoutMode:he,variant:ge,activePillInsetClassName:_e,activePillButtonClassName:b,inactiveTabsIconOnly:ve,iconOnlyActiveTab:ye,animateActivePill:be,activePillLowercase:xe,className:Se}=e,Ce=he===void 0?`scrollable`:he,we=ge===void 0?`default`:ge,x=ve!==void 0&&ve,S=ye!==void 0&&ye,C=xe===void 0||xe,{t:Te}=a(),w=r(oe),{isTablet:Ee}=c(),T=w||Ee,E=_.useRef(null),De;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(De={left:!1,right:!1},t[0]=De):De=t[0];let[D,Oe]=_.useState(De),ke;t[1]===n?ke=t[2]:(ke=n.map(se),t[1]=n,t[2]=ke);let Ae=ke,O=Ce===`scrollable`,je=we==="default",k=we===`compact`,A=we===`active-pill`,Me=we===`animated`,j=A||Me,M=je,N=j||M,P=A&&O,Ne=j,Pe=be??Me,Fe=typeof y==`function`,F=Fe?ie:ae,Ie;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=new Map,t[3]=Ie):Ie=t[3];let Le=_.useRef(Ie),[I,Re]=_.useState(null),ze;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ze={activationConstraint:{distance:8}},t[4]=ze):ze=t[4];let Be=p(l(ee,ze)),Ve=ce,He;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(He=(e,t)=>{if(t){Le.current.set(e,t);return}Le.current.delete(e)},t[5]=He):He=t[5];let Ue=He,We;t[6]!==i||t[7]!==N?(We=()=>{if(!N||!i){Re(le);return}let e=E.current,t=Le.current.get(i);if(!e||!t){Re(ue);return}let n=0,r=0,a=t;for(;a&&a!==e;)n+=a.offsetLeft,r+=a.offsetTop,a=a.offsetParent;let o={left:n,top:r,width:t.offsetWidth,height:t.offsetHeight};Re(e=>Ve(e,o)?e:o)},t[6]=i,t[7]=N,t[8]=We):We=t[8];let L=We,R;t[9]===O?R=t[10]:(R=()=>{if(!O){Oe({left:!1,right:!1});return}let e=E.current;if(!e){Oe({left:!1,right:!1});return}Oe({left:e.scrollLeft>2,right:e.scrollLeft+e.clientWidth<e.scrollWidth-2})},t[9]=O,t[10]=R);let z=R,Ge;t[11]!==O||t[12]!==z?(Ge=()=>{if(!O){Oe({left:!1,right:!1});return}let e=E.current;if(!e)return;z(),e.addEventListener(`scroll`,z,{passive:!0});let t=new ResizeObserver(z);return t.observe(e),()=>{e.removeEventListener(`scroll`,z),t.disconnect()}},t[11]=O,t[12]=z,t[13]=Ge):Ge=t[13];let B;t[14]!==O||t[15]!==n.length||t[16]!==z?(B=[O,n.length,z],t[14]=O,t[15]=n.length,t[16]=z,t[17]=B):B=t[17],_.useEffect(Ge,B);let V;t[18]!==i||t[19]!==L||t[20]!==N?(V=()=>{if(!N){Re(null);return}L();let e=E.current;if(!e)return;let t=new ResizeObserver(L);if(t.observe(e),i){let e=Le.current.get(i);e&&t.observe(e)}return()=>{t.disconnect()}},t[18]=i,t[19]=L,t[20]=N,t[21]=V):V=t[21];let H;t[22]!==i||t[23]!==n.length||t[24]!==L||t[25]!==N?(H=[i,n.length,L,N],t[22]=i,t[23]=n.length,t[24]=L,t[25]=N,t[26]=H):H=t[26],_.useEffect(V,H);let Ke;t[27]===L?Ke=t[28]:(Ke=()=>{L()},t[27]=L,t[28]=Ke),_.useLayoutEffect(Ke);let qe;t[29]!==i||t[30]!==O||t[31]!==z?(qe=()=>{if(!O||!i)return;let e=E.current;if(!e)return;let t=window.requestAnimationFrame(()=>{let t=typeof window.CSS?.escape==`function`?window.CSS.escape(i):i.replace(/"/g,`\\"`),n=e.querySelector(`[data-sortable-tab-id="${t}"]`);n&&(n.scrollIntoView({block:`nearest`,inline:`nearest`}),z())});return()=>{window.cancelAnimationFrame(t)}},t[29]=i,t[30]=O,t[31]=z,t[32]=qe):qe=t[32];let Je;t[33]!==i||t[34]!==O||t[35]!==n.length||t[36]!==z?(Je=[i,O,n.length,z],t[33]=i,t[34]=O,t[35]=n.length,t[36]=z,t[37]=Je):Je=t[37],_.useEffect(qe,Je);let Ye;t[38]===y?Ye=t[39]:(Ye=e=>{if(!y)return;let{active:t,over:n}=e;!n||t.id===n.id||y(String(t.id),String(n.id))},t[38]=y,t[39]=Ye);let Xe=Ye,U;t[40]===Se?U=t[41]:(U=o(`relative flex h-full min-w-0 flex-1`,Se),t[40]=Se,t[41]=U);let W;t[42]!==O||t[43]!==D||t[44]!==j?(W=O&&D.left?(0,v.jsx)(`div`,{className:o(`pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent`,j?`w-8 from-[var(--surface-background)]`:`w-6 from-background`)}):null,t[42]=O,t[43]=D,t[44]=j,t[45]=W):W=t[45];let G;t[46]!==O||t[47]!==D||t[48]!==j?(G=O&&D.right?(0,v.jsx)(`div`,{className:o(`pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent`,j?`w-8 from-[var(--surface-background)]`:`w-6 from-background`)}):null,t[46]=O,t[47]=D,t[48]=j,t[49]=G):G=t[49];let Ze=j?`items-center overflow-x-hidden overflow-y-hidden`:`items-stretch`,Qe=j&&`@container/pill-tabs`,$e=j&&`pill-tabs__track`,et=j&&(_e??`gap-0.5 py-0.5`),tt=M&&`items-center overflow-y-hidden`,nt=k&&`items-center gap-1 overflow-y-hidden`,rt=Ne&&`rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_2%,transparent)] p-0.5 gap-0.5`,it=O?`overflow-x-auto scrollbar-none`:`overflow-x-hidden`,K;t[50]!==Ze||t[51]!==Qe||t[52]!==$e||t[53]!==et||t[54]!==tt||t[55]!==nt||t[56]!==rt||t[57]!==it?(K=o(`relative flex h-full min-w-0 flex-1`,Ze,Qe,$e,et,tt,nt,rt,it),t[50]=Ze,t[51]=Qe,t[52]=$e,t[53]=et,t[54]=tt,t[55]=nt,t[56]=rt,t[57]=it,t[58]=K):K=t[58];let q;t[59]===O?q=t[60]:(q=O?{scrollbarWidth:`none`,msOverflowStyle:`none`}:void 0,t[59]=O,t[60]=q);let J;t[61]===Te?J=t[62]:(J=Te(`sortableTabsStrip.aria.tabs`),t[61]=Te,t[62]=J);let Y;t[63]!==I||t[64]!==Pe||t[65]!==j?(Y=j&&I?(0,v.jsx)(`div`,{className:o(`yuri-segmented-selected-pill pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`),style:{transform:`translate3d(${I.left}px, ${I.top}px, 0)`,width:`${I.width}px`,height:`${I.height}px`,transition:Pe?`transform 300ms cubic-bezier(0.65, 0, 0.35, 1), width 300ms cubic-bezier(0.65, 0, 0.35, 1), height 300ms cubic-bezier(0.65, 0, 0.35, 1)`:void 0}}):null,t[63]=I,t[64]=Pe,t[65]=j,t[66]=Y):Y=t[66];let X;t[67]!==I||t[68]!==M?(X=M&&I?(0,v.jsx)(`div`,{className:`pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]`,style:{transform:`translate3d(${I.left}px, 0, 0)`,width:`${I.width}px`},"aria-hidden":!0}):null,t[67]=I,t[68]=M,t[69]=X):X=t[69];let Z;if(t[70]!==F||t[71]!==i||t[72]!==b||t[73]!==C||t[74]!==T||t[75]!==S||t[76]!==x||t[77]!==A||t[78]!==k||t[79]!==w||t[80]!==O||t[81]!==n||t[82]!==h||t[83]!==m||t[84]!==P||t[85]!==j){let e;t[87]!==F||t[88]!==i||t[89]!==b||t[90]!==C||t[91]!==T||t[92]!==S||t[93]!==x||t[94]!==A||t[95]!==k||t[96]!==w||t[97]!==O||t[98]!==h||t[99]!==m||t[100]!==P||t[101]!==j?(e=e=>{let t=e.id===i,n=x&&j&&!t&&!!e.icon,r=!n,a=!!e.icon&&(!S||t),c=x&&j&&t&&!O&&!P,l=e.closable!==!1&&!!h,u=l&&!!e.icon&&!k,d=O||P?void 0:j?c?`flex-none basis-auto`:w?`flex-1 basis-0 min-w-0`:`flex-1 basis-0 min-w-fit`:`min-w-0 flex-1 basis-0`,ee=l?t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),h?.(e.id))}:void 0,f=l?de:void 0;return(0,v.jsx)(F,{id:e.id,className:d,children:(0,v.jsxs)(`div`,{ref:t=>Ue(e.id,t),onAuxClick:ee,onMouseDown:f,className:o(`group flex h-full min-w-0 flex-nowrap items-center`,O||P?`shrink-0`:j?`w-full`:`w-full min-w-0`,k?o(`relative rounded-md transition-colors`,t?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`):j?`relative z-10 bg-transparent`:t?`relative z-10 bg-transparent text-foreground`:`relative z-10 bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,v.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-label":n?e.title??e.label:void 0,onClick:()=>m(e.id),className:o(k?`flex h-full max-w-56 min-w-0 flex-nowrap items-center rounded-md px-2 text-left text-xs font-normal !min-h-0 !min-w-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`:j?`animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0`:`flex h-full min-w-0 flex-nowrap items-center typography-micro`,j&&C?`lowercase`:null,j&&(n?`gap-0`:`gap-1.5`),j?P?`shrink-0 whitespace-nowrap px-3 text-center`:O?`max-w-56 shrink-0 px-3 text-center`:n?`px-2 !min-w-0 text-center`:c?`shrink-0 whitespace-nowrap px-3 text-center`:`px-3 text-center`:k?null:O?`max-w-56 justify-start truncate px-3 text-left`:`w-full justify-center truncate px-3 text-center`,j?b??(A?w?`h-[38px]`:`h-[31px]`:`h-7`):null,j?t?`text-foreground`:`text-muted-foreground hover:text-foreground`:null,j?`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`:null),title:e.title??e.label,children:j?(0,v.jsxs)(v.Fragment,{children:[a?(0,v.jsxs)(`span`,{className:`relative flex h-4 w-4 shrink-0 items-center justify-center`,children:[(0,v.jsx)(`span`,{className:o(`flex items-center justify-center transition-opacity`,u&&(T?`opacity-0`:`group-hover:opacity-0`)),children:e.icon}),u?(0,v.jsx)(`span`,{role:`button`,tabIndex:-1,className:o(`absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground`,T?`opacity-100`:`opacity-0 group-hover:opacity-100`),onPointerDown:fe,onClick:t=>{t.stopPropagation(),h?.(e.id)},"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3.5 w-3.5`})}):null]}):null,r?(0,v.jsx)(`span`,{className:`animated-tabs__label truncate`,children:e.label}):null]}):(0,v.jsxs)(`span`,{className:o(`flex min-w-0 flex-nowrap items-center gap-1.5`,!O&&`justify-center`),children:[a?(0,v.jsxs)(`span`,{className:o(`relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out`,!k&&(t?`text-[var(--primary-base)]`:`text-muted-foreground`)),children:[(0,v.jsx)(`span`,{className:o(`flex items-center justify-center transition-opacity`,u&&(T?`opacity-0`:`group-hover:opacity-0`)),children:e.icon}),u?(0,v.jsx)(`span`,{role:`button`,tabIndex:-1,className:o(`absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground`,T?`opacity-100`:`opacity-0 group-hover:opacity-100`),onPointerDown:pe,onClick:t=>{t.stopPropagation(),h?.(e.id)},"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3.5 w-3.5`})}):null]}):null,(0,v.jsx)(`span`,{className:`truncate leading-[1.2]`,children:e.label})]})}),l&&!u?(0,v.jsx)(`button`,{type:`button`,onPointerDown:me,onClick:t=>{t.stopPropagation(),h?.(e.id)},className:o(`relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity`,k?`mr-1 size-4 shrink-0 self-center rounded-sm text-muted-foreground hover:bg-interactive-hover hover:text-foreground`:j?`-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md`:`aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1`,!k&&(j?t?`text-muted-foreground hover:bg-transparent hover:text-foreground`:`text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100`:t?`text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground`:`text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100`)),"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3 w-3`})}):null]})},e.id)},t[87]=F,t[88]=i,t[89]=b,t[90]=C,t[91]=T,t[92]=S,t[93]=x,t[94]=A,t[95]=k,t[96]=w,t[97]=O,t[98]=h,t[99]=m,t[100]=P,t[101]=j,t[102]=e):e=t[102],Z=n.map(e),t[70]=F,t[71]=i,t[72]=b,t[73]=C,t[74]=T,t[75]=S,t[76]=x,t[77]=A,t[78]=k,t[79]=w,t[80]=O,t[81]=n,t[82]=h,t[83]=m,t[84]=P,t[85]=j,t[86]=Z}else Z=t[86];let Q;t[103]!==K||t[104]!==q||t[105]!==J||t[106]!==Y||t[107]!==X||t[108]!==Z?(Q=(0,v.jsxs)(`div`,{ref:E,className:K,style:q,role:`tablist`,"aria-label":J,children:[Y,X,Z]}),t[103]=K,t[104]=q,t[105]=J,t[106]=Y,t[107]=X,t[108]=Z,t[109]=Q):Q=t[109];let at;t[110]!==U||t[111]!==W||t[112]!==G||t[113]!==Q?(at=(0,v.jsxs)(`div`,{className:U,children:[W,G,Q]}),t[110]=U,t[111]=W,t[112]=G,t[113]=Q,t[114]=at):at=t[114];let ot=at;if(!Fe)return ot;let st;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(st=[re],t[115]=st):st=t[115];let $;t[116]!==Ae||t[117]!==ot?($=(0,v.jsx)(g,{items:Ae,strategy:te,children:ot}),t[116]=Ae,t[117]=ot,t[118]=$):$=t[118];let ct;t[119]===Symbol.for(`react.memo_cache_sentinel`)?(ct=(0,v.jsx)(d,{dropAnimation:null}),t[119]=ct):ct=t[119];let lt;return t[120]!==Xe||t[121]!==Be||t[122]!==$?(lt=(0,v.jsxs)(f,{sensors:Be,collisionDetection:u,onDragEnd:Xe,modifiers:st,children:[$,ct]}),t[120]=Xe,t[121]=Be,t[122]=$,t[123]=lt):lt=t[123],lt};function oe(e){return e.isMobile}function se(e){return e.id}function ce(e,t){return!e||!t?e===t:Math.abs(e.left-t.left)<.5&&Math.abs(e.top-t.top)<.5&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function le(e){return e===null?e:null}function ue(e){return e===null?e:null}function de(e){e.button===1&&e.preventDefault()}function fe(e){e.stopPropagation()}function pe(e){e.stopPropagation()}function me(e){e.stopPropagation()}export{y as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{r}from"./useUIStore-B61bCFEM.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{f as a,r as o}from"./button-B7w-b2yV.js";import{n as s}from"./Icon-D7VxRqha.js";import{r as c}from"./device-w1ioiqv3.js";import{_ as l,l as u,n as d,s as ee,t as f,v as p,y as m}from"./vendor-dnd-kit-core-DK4OoOTr.js";import{o as h,r as te,t as g}from"./vendor-dnd-kit-sortable-Cv69eQm1.js";var ne=i(),_=e(n(),1),v=t(),re=({transform:e})=>({...e,y:0}),ie=e=>{let t=(0,ne.c)(18),{id:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a={id:n},t[0]=n,t[1]=a);let{attributes:s,listeners:c,setNodeRef:l,transform:u,transition:d,isDragging:ee}=h(a),f;t[2]===u?f=t[3]:(f=m.Transform.toString(u),t[2]=u,t[3]=f);let p;t[4]!==f||t[5]!==d?(p={transform:f,transition:d},t[4]=f,t[5]=d,t[6]=p):p=t[6];let te=ee&&`opacity-50`,g;t[7]!==i||t[8]!==te?(g=o(`h-full rounded-md`,i,te),t[7]=i,t[8]=te,t[9]=g):g=t[9];let _;return t[10]!==s||t[11]!==r||t[12]!==n||t[13]!==c||t[14]!==l||t[15]!==p||t[16]!==g?(_=(0,v.jsx)(`div`,{ref:l,"data-sortable-tab-id":n,style:p,className:g,...s,...c,children:r}),t[10]=s,t[11]=r,t[12]=n,t[13]=c,t[14]=l,t[15]=p,t[16]=g,t[17]=_):_=t[17],_},ae=e=>{let t=(0,ne.c)(6),{id:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=o(`h-full`,i),t[0]=i,t[1]=a);let s;return t[2]!==r||t[3]!==n||t[4]!==a?(s=(0,v.jsx)(`div`,{className:a,"data-sortable-tab-id":n,children:r}),t[2]=r,t[3]=n,t[4]=a,t[5]=s):s=t[5],s},y=e=>{let t=(0,ne.c)(124),{items:n,activeId:i,onSelect:m,onClose:h,onReorder:y,layoutMode:he,variant:ge,activePillInsetClassName:_e,activePillButtonClassName:b,inactiveTabsIconOnly:ve,iconOnlyActiveTab:ye,animateActivePill:be,activePillLowercase:xe,className:Se}=e,Ce=he===void 0?`scrollable`:he,we=ge===void 0?`default`:ge,x=ve!==void 0&&ve,S=ye!==void 0&&ye,C=xe===void 0||xe,{t:Te}=a(),w=r(oe),{isTablet:Ee}=c(),T=w||Ee,E=_.useRef(null),De;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(De={left:!1,right:!1},t[0]=De):De=t[0];let[D,Oe]=_.useState(De),ke;t[1]===n?ke=t[2]:(ke=n.map(se),t[1]=n,t[2]=ke);let Ae=ke,O=Ce===`scrollable`,je=we==="default",k=we===`compact`,A=we===`active-pill`,Me=we===`animated`,j=A||Me,M=je,N=j||M,P=A&&O,Ne=j,Pe=be??Me,Fe=typeof y==`function`,F=Fe?ie:ae,Ie;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=new Map,t[3]=Ie):Ie=t[3];let Le=_.useRef(Ie),[I,Re]=_.useState(null),ze;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ze={activationConstraint:{distance:8}},t[4]=ze):ze=t[4];let Be=p(l(ee,ze)),Ve=ce,He;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(He=(e,t)=>{if(t){Le.current.set(e,t);return}Le.current.delete(e)},t[5]=He):He=t[5];let Ue=He,We;t[6]!==i||t[7]!==N?(We=()=>{if(!N||!i){Re(le);return}let e=E.current,t=Le.current.get(i);if(!e||!t){Re(ue);return}let n=0,r=0,a=t;for(;a&&a!==e;)n+=a.offsetLeft,r+=a.offsetTop,a=a.offsetParent;let o={left:n,top:r,width:t.offsetWidth,height:t.offsetHeight};Re(e=>Ve(e,o)?e:o)},t[6]=i,t[7]=N,t[8]=We):We=t[8];let L=We,R;t[9]===O?R=t[10]:(R=()=>{if(!O){Oe({left:!1,right:!1});return}let e=E.current;if(!e){Oe({left:!1,right:!1});return}Oe({left:e.scrollLeft>2,right:e.scrollLeft+e.clientWidth<e.scrollWidth-2})},t[9]=O,t[10]=R);let z=R,Ge;t[11]!==O||t[12]!==z?(Ge=()=>{if(!O){Oe({left:!1,right:!1});return}let e=E.current;if(!e)return;z(),e.addEventListener(`scroll`,z,{passive:!0});let t=new ResizeObserver(z);return t.observe(e),()=>{e.removeEventListener(`scroll`,z),t.disconnect()}},t[11]=O,t[12]=z,t[13]=Ge):Ge=t[13];let B;t[14]!==O||t[15]!==n.length||t[16]!==z?(B=[O,n.length,z],t[14]=O,t[15]=n.length,t[16]=z,t[17]=B):B=t[17],_.useEffect(Ge,B);let V;t[18]!==i||t[19]!==L||t[20]!==N?(V=()=>{if(!N){Re(null);return}L();let e=E.current;if(!e)return;let t=new ResizeObserver(L);if(t.observe(e),i){let e=Le.current.get(i);e&&t.observe(e)}return()=>{t.disconnect()}},t[18]=i,t[19]=L,t[20]=N,t[21]=V):V=t[21];let H;t[22]!==i||t[23]!==n.length||t[24]!==L||t[25]!==N?(H=[i,n.length,L,N],t[22]=i,t[23]=n.length,t[24]=L,t[25]=N,t[26]=H):H=t[26],_.useEffect(V,H);let Ke;t[27]===L?Ke=t[28]:(Ke=()=>{L()},t[27]=L,t[28]=Ke),_.useLayoutEffect(Ke);let qe;t[29]!==i||t[30]!==O||t[31]!==z?(qe=()=>{if(!O||!i)return;let e=E.current;if(!e)return;let t=window.requestAnimationFrame(()=>{let t=typeof window.CSS?.escape==`function`?window.CSS.escape(i):i.replace(/"/g,`\\"`),n=e.querySelector(`[data-sortable-tab-id="${t}"]`);n&&(n.scrollIntoView({block:`nearest`,inline:`nearest`}),z())});return()=>{window.cancelAnimationFrame(t)}},t[29]=i,t[30]=O,t[31]=z,t[32]=qe):qe=t[32];let Je;t[33]!==i||t[34]!==O||t[35]!==n.length||t[36]!==z?(Je=[i,O,n.length,z],t[33]=i,t[34]=O,t[35]=n.length,t[36]=z,t[37]=Je):Je=t[37],_.useEffect(qe,Je);let Ye;t[38]===y?Ye=t[39]:(Ye=e=>{if(!y)return;let{active:t,over:n}=e;!n||t.id===n.id||y(String(t.id),String(n.id))},t[38]=y,t[39]=Ye);let Xe=Ye,U;t[40]===Se?U=t[41]:(U=o(`relative flex h-full min-w-0 flex-1`,Se),t[40]=Se,t[41]=U);let W;t[42]!==O||t[43]!==D||t[44]!==j?(W=O&&D.left?(0,v.jsx)(`div`,{className:o(`pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent`,j?`w-8 from-[var(--surface-background)]`:`w-6 from-background`)}):null,t[42]=O,t[43]=D,t[44]=j,t[45]=W):W=t[45];let G;t[46]!==O||t[47]!==D||t[48]!==j?(G=O&&D.right?(0,v.jsx)(`div`,{className:o(`pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent`,j?`w-8 from-[var(--surface-background)]`:`w-6 from-background`)}):null,t[46]=O,t[47]=D,t[48]=j,t[49]=G):G=t[49];let Ze=j?`items-center overflow-x-hidden overflow-y-hidden`:`items-stretch`,Qe=j&&`@container/pill-tabs`,$e=j&&`pill-tabs__track`,et=j&&(_e??`gap-0.5 py-0.5`),tt=M&&`items-center overflow-y-hidden`,nt=k&&`items-center gap-1 overflow-y-hidden`,rt=Ne&&`rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_2%,transparent)] p-0.5 gap-0.5`,it=O?`overflow-x-auto scrollbar-none`:`overflow-x-hidden`,K;t[50]!==Ze||t[51]!==Qe||t[52]!==$e||t[53]!==et||t[54]!==tt||t[55]!==nt||t[56]!==rt||t[57]!==it?(K=o(`relative flex h-full min-w-0 flex-1`,Ze,Qe,$e,et,tt,nt,rt,it),t[50]=Ze,t[51]=Qe,t[52]=$e,t[53]=et,t[54]=tt,t[55]=nt,t[56]=rt,t[57]=it,t[58]=K):K=t[58];let q;t[59]===O?q=t[60]:(q=O?{scrollbarWidth:`none`,msOverflowStyle:`none`}:void 0,t[59]=O,t[60]=q);let J;t[61]===Te?J=t[62]:(J=Te(`sortableTabsStrip.aria.tabs`),t[61]=Te,t[62]=J);let Y;t[63]!==I||t[64]!==Pe||t[65]!==j?(Y=j&&I?(0,v.jsx)(`div`,{className:o(`yuri-segmented-selected-pill pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`),style:{transform:`translate3d(${I.left}px, ${I.top}px, 0)`,width:`${I.width}px`,height:`${I.height}px`,transition:Pe?`transform 300ms cubic-bezier(0.65, 0, 0.35, 1), width 300ms cubic-bezier(0.65, 0, 0.35, 1), height 300ms cubic-bezier(0.65, 0, 0.35, 1)`:void 0}}):null,t[63]=I,t[64]=Pe,t[65]=j,t[66]=Y):Y=t[66];let X;t[67]!==I||t[68]!==M?(X=M&&I?(0,v.jsx)(`div`,{className:`pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]`,style:{transform:`translate3d(${I.left}px, 0, 0)`,width:`${I.width}px`},"aria-hidden":!0}):null,t[67]=I,t[68]=M,t[69]=X):X=t[69];let Z;if(t[70]!==F||t[71]!==i||t[72]!==b||t[73]!==C||t[74]!==T||t[75]!==S||t[76]!==x||t[77]!==A||t[78]!==k||t[79]!==w||t[80]!==O||t[81]!==n||t[82]!==h||t[83]!==m||t[84]!==P||t[85]!==j){let e;t[87]!==F||t[88]!==i||t[89]!==b||t[90]!==C||t[91]!==T||t[92]!==S||t[93]!==x||t[94]!==A||t[95]!==k||t[96]!==w||t[97]!==O||t[98]!==h||t[99]!==m||t[100]!==P||t[101]!==j?(e=e=>{let t=e.id===i,n=x&&j&&!t&&!!e.icon,r=!n,a=!!e.icon&&(!S||t),c=x&&j&&t&&!O&&!P,l=e.closable!==!1&&!!h,u=l&&!!e.icon&&!k,d=O||P?void 0:j?c?`flex-none basis-auto`:w?`flex-1 basis-0 min-w-0`:`flex-1 basis-0 min-w-fit`:`min-w-0 flex-1 basis-0`,ee=l?t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),h?.(e.id))}:void 0,f=l?de:void 0;return(0,v.jsx)(F,{id:e.id,className:d,children:(0,v.jsxs)(`div`,{ref:t=>Ue(e.id,t),onAuxClick:ee,onMouseDown:f,className:o(`group flex h-full min-w-0 flex-nowrap items-center`,O||P?`shrink-0`:j?`w-full`:`w-full min-w-0`,k?o(`relative rounded-md transition-colors`,t?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`):j?`relative z-10 bg-transparent`:t?`relative z-10 bg-transparent text-foreground`:`relative z-10 bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,v.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-label":n?e.title??e.label:void 0,onClick:()=>m(e.id),className:o(k?`flex h-full max-w-56 min-w-0 flex-nowrap items-center rounded-md px-2 text-left text-xs font-normal !min-h-0 !min-w-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`:j?`animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0`:`flex h-full min-w-0 flex-nowrap items-center typography-micro`,j&&C?`lowercase`:null,j&&(n?`gap-0`:`gap-1.5`),j?P?`shrink-0 whitespace-nowrap px-3 text-center`:O?`max-w-56 shrink-0 px-3 text-center`:n?`px-2 !min-w-0 text-center`:c?`shrink-0 whitespace-nowrap px-3 text-center`:`px-3 text-center`:k?null:O?`max-w-56 justify-start truncate px-3 text-left`:`w-full justify-center truncate px-3 text-center`,j?b??(A?w?`h-[38px]`:`h-[31px]`:`h-7`):null,j?t?`text-foreground`:`text-muted-foreground hover:text-foreground`:null,j?`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`:null),title:e.title??e.label,children:j?(0,v.jsxs)(v.Fragment,{children:[a?(0,v.jsxs)(`span`,{className:`relative flex h-4 w-4 shrink-0 items-center justify-center`,children:[(0,v.jsx)(`span`,{className:o(`flex items-center justify-center transition-opacity`,u&&(T?`opacity-0`:`group-hover:opacity-0`)),children:e.icon}),u?(0,v.jsx)(`span`,{role:`button`,tabIndex:-1,className:o(`absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground`,T?`opacity-100`:`opacity-0 group-hover:opacity-100`),onPointerDown:fe,onClick:t=>{t.stopPropagation(),h?.(e.id)},"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3.5 w-3.5`})}):null]}):null,r?(0,v.jsx)(`span`,{className:`animated-tabs__label truncate`,children:e.label}):null]}):(0,v.jsxs)(`span`,{className:o(`flex min-w-0 flex-nowrap items-center gap-1.5`,!O&&`justify-center`),children:[a?(0,v.jsxs)(`span`,{className:o(`relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out`,!k&&(t?`text-[var(--primary-base)]`:`text-muted-foreground`)),children:[(0,v.jsx)(`span`,{className:o(`flex items-center justify-center transition-opacity`,u&&(T?`opacity-0`:`group-hover:opacity-0`)),children:e.icon}),u?(0,v.jsx)(`span`,{role:`button`,tabIndex:-1,className:o(`absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground`,T?`opacity-100`:`opacity-0 group-hover:opacity-100`),onPointerDown:pe,onClick:t=>{t.stopPropagation(),h?.(e.id)},"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3.5 w-3.5`})}):null]}):null,(0,v.jsx)(`span`,{className:`truncate leading-[1.2]`,children:e.label})]})}),l&&!u?(0,v.jsx)(`button`,{type:`button`,onPointerDown:me,onClick:t=>{t.stopPropagation(),h?.(e.id)},className:o(`relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity`,k?`mr-1 size-4 shrink-0 self-center rounded-sm text-muted-foreground hover:bg-interactive-hover hover:text-foreground`:j?`-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md`:`aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1`,!k&&(j?t?`text-muted-foreground hover:bg-transparent hover:text-foreground`:`text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100`:t?`text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground`:`text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100`)),"aria-label":e.closeLabel??`Close ${e.label} tab`,title:e.closeLabel??`Close ${e.label} tab`,children:(0,v.jsx)(s,{name:`close`,className:`h-3 w-3`})}):null]})},e.id)},t[87]=F,t[88]=i,t[89]=b,t[90]=C,t[91]=T,t[92]=S,t[93]=x,t[94]=A,t[95]=k,t[96]=w,t[97]=O,t[98]=h,t[99]=m,t[100]=P,t[101]=j,t[102]=e):e=t[102],Z=n.map(e),t[70]=F,t[71]=i,t[72]=b,t[73]=C,t[74]=T,t[75]=S,t[76]=x,t[77]=A,t[78]=k,t[79]=w,t[80]=O,t[81]=n,t[82]=h,t[83]=m,t[84]=P,t[85]=j,t[86]=Z}else Z=t[86];let Q;t[103]!==K||t[104]!==q||t[105]!==J||t[106]!==Y||t[107]!==X||t[108]!==Z?(Q=(0,v.jsxs)(`div`,{ref:E,className:K,style:q,role:`tablist`,"aria-label":J,children:[Y,X,Z]}),t[103]=K,t[104]=q,t[105]=J,t[106]=Y,t[107]=X,t[108]=Z,t[109]=Q):Q=t[109];let at;t[110]!==U||t[111]!==W||t[112]!==G||t[113]!==Q?(at=(0,v.jsxs)(`div`,{className:U,children:[W,G,Q]}),t[110]=U,t[111]=W,t[112]=G,t[113]=Q,t[114]=at):at=t[114];let ot=at;if(!Fe)return ot;let st;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(st=[re],t[115]=st):st=t[115];let $;t[116]!==Ae||t[117]!==ot?($=(0,v.jsx)(g,{items:Ae,strategy:te,children:ot}),t[116]=Ae,t[117]=ot,t[118]=$):$=t[118];let ct;t[119]===Symbol.for(`react.memo_cache_sentinel`)?(ct=(0,v.jsx)(d,{dropAnimation:null}),t[119]=ct):ct=t[119];let lt;return t[120]!==Xe||t[121]!==Be||t[122]!==$?(lt=(0,v.jsxs)(f,{sensors:Be,collisionDetection:u,onDragEnd:Xe,modifiers:st,children:[$,ct]}),t[120]=Xe,t[121]=Be,t[122]=$,t[123]=lt):lt=t[123],lt};function oe(e){return e.isMobile}function se(e){return e.id}function ce(e,t){return!e||!t?e===t:Math.abs(e.left-t.left)<.5&&Math.abs(e.top-t.top)<.5&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function le(e){return e===null?e:null}function ue(e){return e===null?e:null}function de(e){e.button===1&&e.preventDefault()}function fe(e){e.stopPropagation()}function pe(e){e.stopPropagation()}function me(e){e.stopPropagation()}export{y as t};
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEZ1K7qW.js";import{n as i}from"./runtime-fetch-D0YWp3FJ.js";import{st as a}from"./vendor-base-ui-CzHs0bHY.js";import{d as o}from"./bootstrap-C8paoQ0j.js";import{n as s}from"./vendor-react-DlzBev0S.js";import{s as c}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as l}from"./queryRuntime-2dx7jbt9.js";import{i as u}from"./vendor-reactuses-core-DWo5Wn6R.js";import{wa as d}from"./useMobileNavigationStore-BOlo2VUm.js";import{a as f,c as p,d as m,i as h,l as g,o as _,r as v,s as y,u as b}from"./useDictation-DFVJpRbm.js";var x=e(a(),1),S=e=>e.replace(/[^\p{L}\p{N}]/gu,``).toLowerCase();function C(e){let t=[],n=``;for(let r=0;r<e.length;){let i=String.fromCodePoint(e.codePointAt(r)),a=S(i);for(let e=0;e<a.length;e++)t.push(r);n+=a,r+=i.length}let r=[],i=0,a=[];return{append(o){if(!o||typeof o!=`object`)throw Error(`Invalid speech subtitle`);let{text:s,words:c}=o;if(typeof s!=`string`||s.length>1e4||!Array.isArray(c)||c.length>1e4)throw Error(`Invalid speech subtitle`);if(!c.length||!s.trim())return;let l=1/0,u=0,d=-1;for(let e of c){if(!e||typeof e!=`object`||typeof e.word!=`string`||!Number.isFinite(e.startTime)||!Number.isFinite(e.endTime)||e.startTime<0||e.endTime<e.startTime||e.endTime>7200||e.startTime<d)throw Error(`Invalid speech subtitle timestamp`);l=Math.min(l,e.startTime),u=Math.max(u,e.endTime),d=e.startTime}if(r.some(e=>e.startTime===l&&e.text===s))return;if(i+=s.length,r.length>=1e3||i>2e4)throw Error(`Speech subtitle limit exceeded`);r.push({text:s,startTime:l,endTime:u}),r.sort((e,t)=>e.startTime-t.startTime);let f=0;a=[];for(let i of r){let r=S(i.text),o=r?n.indexOf(r,f):-1;if(o<0)continue;let s=t[o],c=t[o+r.length-1],l=c+(e.codePointAt(c)>65535?2:1);l+=e.slice(l).match(/^[^\p{L}\p{N}]*/u)[0].length,a.push({...i,start:s,end:l}),f=o+r.length}},at(e){let t=0,n=a.length;for(;t<n;){let r=t+n>>>1;a[r].startTime<=e?t=r+1:n=r}let r=a[t-1];return r&&e<=r.endTime?r:void 0},lastBefore(e){for(let t=a.length-1;t>=0;t--)if(a[t].endTime<=e)return a[t]}}}function w(e){return{chunks:[],samples:0,complete:!1,position:0,timeline:C(e)}}async function T(e,t,n){if(e&&!e.body)throw Error(`Speech response has no stream`);let r=n.cache??w(``),i=e?.body?.getReader(),a=t.createGain();a.gain.value=n.volume,a.connect(t.destination);let o=new Set,s=new Set,c=new Set,l=()=>{for(let e of c)e();c.clear()},u=()=>new Promise(e=>{c.add(e)}),d=new TextDecoder,f=[],p=t.currentTime,m=!1,h=!1,g=!i,_=!i,v,y=-1,b=2**(n.pitch-1),x=i?0:r.position,S=()=>{let e=t.getOutputTimestamp?.().contextTime,i=e!==void 0&&Number.isFinite(e)&&e>=0?e:Math.max(0,t.currentTime-(t.outputLatency||0));for(;f.length&&i>=f[0].at;){h=!0;let e=f[0];if(r.position=e.offset+Math.min(e.duration,(i-e.at)*b),i<e.end)break;f.shift()}let a=r.timeline.at(r.position);a&&a.start>y&&h&&(y=a.start,n.onProgress?.(a))},C=()=>{for(let e of o)e.stop();l()},T=()=>{S(),i?.cancel().catch(()=>void 0),C()};n.signal.addEventListener(`abort`,T,{once:!0});let E=setInterval(S,50),D=()=>{if(n.signal.throwIfAborted(),v)throw v},O=(async()=>{if(!i)return;let e=``,t,a=0,o=e=>{if(!e.trim())return;if(_)throw Error(`Unexpected audio after speech completion`);if(e.length>1048576)throw Error(`Speech frame exceeds the size limit`);let n=JSON.parse(e);if(n.type===`error`)throw Error(`Speech synthesis interrupted or failed`);if(n.type===`done`){_=!0,l();return}if(n.type===`subtitle`){r.timeline.append(n),S();return}if(n.type!==`audio`||typeof n.data!=`string`||n.data.length>12800)throw Error(`Invalid speech audio frame`);let i=atob(n.data),a=new Uint8Array(i.length+(t===void 0?0:1)),o=0;t!==void 0&&(a[o++]=t);for(let e=0;e<i.length;e++)a[o+e]=i.charCodeAt(e);if(t=a.length%2?a[a.length-1]:void 0,a.length>1){if(r.samples*2+a.length>25165824||r.chunks.length>=8192)throw Error(`Speech cache exceeds the size limit`);let e=t===void 0?a:a.slice(0,-1);r.chunks.push(e),r.samples+=e.length/2,l()}};try{for(;;){let t=await i.read();if(n.signal.throwIfAborted(),t.done)break;if(a+=t.value.length,a>33554432)throw Error(`Speech stream exceeds the size limit`);e+=d.decode(t.value,{stream:!0});let r;for(;(r=e.indexOf(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEZ1K7qW.js";import{n as i}from"./runtime-fetch-D0YWp3FJ.js";import{st as a}from"./vendor-base-ui-CzHs0bHY.js";import{d as o}from"./bootstrap-Bi91NjXG.js";import{n as s}from"./vendor-react-DlzBev0S.js";import{s as c}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as l}from"./queryRuntime-2dx7jbt9.js";import{i as u}from"./vendor-reactuses-core-DWo5Wn6R.js";import{xa as d}from"./useMobileNavigationStore-DRBFwjAg.js";import{a as f,c as p,d as m,i as h,l as g,o as _,r as v,s as y,u as b}from"./useDictation-DO12CgDE.js";var x=e(a(),1),S=e=>e.replace(/[^\p{L}\p{N}]/gu,``).toLowerCase();function C(e){let t=[],n=``;for(let r=0;r<e.length;){let i=String.fromCodePoint(e.codePointAt(r)),a=S(i);for(let e=0;e<a.length;e++)t.push(r);n+=a,r+=i.length}let r=[],i=0,a=[];return{append(o){if(!o||typeof o!=`object`)throw Error(`Invalid speech subtitle`);let{text:s,words:c}=o;if(typeof s!=`string`||s.length>1e4||!Array.isArray(c)||c.length>1e4)throw Error(`Invalid speech subtitle`);if(!c.length||!s.trim())return;let l=1/0,u=0,d=-1;for(let e of c){if(!e||typeof e!=`object`||typeof e.word!=`string`||!Number.isFinite(e.startTime)||!Number.isFinite(e.endTime)||e.startTime<0||e.endTime<e.startTime||e.endTime>7200||e.startTime<d)throw Error(`Invalid speech subtitle timestamp`);l=Math.min(l,e.startTime),u=Math.max(u,e.endTime),d=e.startTime}if(r.some(e=>e.startTime===l&&e.text===s))return;if(i+=s.length,r.length>=1e3||i>2e4)throw Error(`Speech subtitle limit exceeded`);r.push({text:s,startTime:l,endTime:u}),r.sort((e,t)=>e.startTime-t.startTime);let f=0;a=[];for(let i of r){let r=S(i.text),o=r?n.indexOf(r,f):-1;if(o<0)continue;let s=t[o],c=t[o+r.length-1],l=c+(e.codePointAt(c)>65535?2:1);l+=e.slice(l).match(/^[^\p{L}\p{N}]*/u)[0].length,a.push({...i,start:s,end:l}),f=o+r.length}},at(e){let t=0,n=a.length;for(;t<n;){let r=t+n>>>1;a[r].startTime<=e?t=r+1:n=r}let r=a[t-1];return r&&e<=r.endTime?r:void 0},lastBefore(e){for(let t=a.length-1;t>=0;t--)if(a[t].endTime<=e)return a[t]}}}function w(e){return{chunks:[],samples:0,complete:!1,position:0,timeline:C(e)}}async function T(e,t,n){if(e&&!e.body)throw Error(`Speech response has no stream`);let r=n.cache??w(``),i=e?.body?.getReader(),a=t.createGain();a.gain.value=n.volume,a.connect(t.destination);let o=new Set,s=new Set,c=new Set,l=()=>{for(let e of c)e();c.clear()},u=()=>new Promise(e=>{c.add(e)}),d=new TextDecoder,f=[],p=t.currentTime,m=!1,h=!1,g=!i,_=!i,v,y=-1,b=2**(n.pitch-1),x=i?0:r.position,S=()=>{let e=t.getOutputTimestamp?.().contextTime,i=e!==void 0&&Number.isFinite(e)&&e>=0?e:Math.max(0,t.currentTime-(t.outputLatency||0));for(;f.length&&i>=f[0].at;){h=!0;let e=f[0];if(r.position=e.offset+Math.min(e.duration,(i-e.at)*b),i<e.end)break;f.shift()}let a=r.timeline.at(r.position);a&&a.start>y&&h&&(y=a.start,n.onProgress?.(a))},C=()=>{for(let e of o)e.stop();l()},T=()=>{S(),i?.cancel().catch(()=>void 0),C()};n.signal.addEventListener(`abort`,T,{once:!0});let E=setInterval(S,50),D=()=>{if(n.signal.throwIfAborted(),v)throw v},O=(async()=>{if(!i)return;let e=``,t,a=0,o=e=>{if(!e.trim())return;if(_)throw Error(`Unexpected audio after speech completion`);if(e.length>1048576)throw Error(`Speech frame exceeds the size limit`);let n=JSON.parse(e);if(n.type===`error`)throw Error(`Speech synthesis interrupted or failed`);if(n.type===`done`){_=!0,l();return}if(n.type===`subtitle`){r.timeline.append(n),S();return}if(n.type!==`audio`||typeof n.data!=`string`||n.data.length>12800)throw Error(`Invalid speech audio frame`);let i=atob(n.data),a=new Uint8Array(i.length+(t===void 0?0:1)),o=0;t!==void 0&&(a[o++]=t);for(let e=0;e<i.length;e++)a[o+e]=i.charCodeAt(e);if(t=a.length%2?a[a.length-1]:void 0,a.length>1){if(r.samples*2+a.length>25165824||r.chunks.length>=8192)throw Error(`Speech cache exceeds the size limit`);let e=t===void 0?a:a.slice(0,-1);r.chunks.push(e),r.samples+=e.length/2,l()}};try{for(;;){let t=await i.read();if(n.signal.throwIfAborted(),t.done)break;if(a+=t.value.length,a>33554432)throw Error(`Speech stream exceeds the size limit`);e+=d.decode(t.value,{stream:!0});let r;for(;(r=e.indexOf(`
2
2
  `))!==-1;)o(e.slice(0,r)),e=e.slice(r+1);if(e.length>1048576)throw Error(`Speech frame exceeds the size limit`)}if(e+=d.decode(),e.trim()&&o(e),!_||!r.samples||t!==void 0)throw Error(`Incomplete speech audio stream`);r.complete=!0}finally{g=!0,l()}})().catch(e=>{v=e,C()}),k=async(e,r)=>{for(;p-t.currentTime>2&&s.size;)await Promise.race([Promise.race(s),u()]),D();D();let i=Math.min(e.length/2,Math.max(0,Math.round(((n.endAt??1/0)-r)*24e3))),c=Math.max(0,Math.round((x-r)*24e3));if(c>=i)return;let d=t.createBuffer(1,i-c,24e3),h=d.getChannelData(0),g=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=c;e<i;e++)h[e-c]=g.getInt16(e*2,!0)/32768;let _=t.createBufferSource();_.buffer=d,_.detune.value=(n.pitch-1)*1200,_.connect(a);let v,y=new Promise(e=>{v=e});s.add(y),o.add(_),_.onended=()=>{S(),o.delete(_),s.delete(y),_.disconnect(),v(),l()};let C=Math.max(p,t.currentTime+.02);p=C+d.duration/b,f.push({at:C,end:p,offset:r+c/24e3,duration:d.duration}),_.start(C),m||(m=!0,n.onStart())};try{D();let e=0,i=0,a=!0;for(;D(),!(i>=(n.endAt??1/0));){if(e>=r.chunks.length){if(g)break;await u();continue}p<t.currentTime+.02&&(a=!0);let n=(r.samples/24e3-Math.max(i,x))/b;if(a&&!_&&n<.4){await u();continue}a=!1;let o=r.chunks[e++];await k(o,i),i+=o.length/48e3}if(await O,D(),!m&&x<Math.min(r.samples/24e3,n.endAt??1/0))throw Error(`Incomplete speech audio stream`);await Promise.all(s),D(),r.position=Math.min(r.samples/24e3,n.endAt??1/0)}finally{S(),clearInterval(E),n.signal.removeEventListener(`abort`,T),await i?.cancel().catch(()=>void 0),await O,i?.releaseLock();for(let e of o)e.onended=null,e.stop(),e.disconnect();a.disconnect()}}async function*E(e,t,n){let r=await y(m(e,`tts`),n),i=crypto.randomUUID(),a=new TextEncoder,o={speaker:e.voice,audio_params:{format:`pcm`,sample_rate:24e3,speech_rate:Math.round((e.speed-1)*100),...[`seed-tts-2.0`,`seed-icl-2.0`].includes(e.resourceId)?{enable_subtitle:!0}:{}},...e.resourceId===`seed-tts-2.0`&&e.voice===`zh_female_vv_uranus_bigtts`?{additions:JSON.stringify({context_texts:[`请用自然、温暖的对话语气朗读,根据文本内容表达恰当的情感,保持清晰自然的停顿与重音,避免夸张的播音腔。`]})}:{}},s=(e,n=!1)=>({user:{uid:`yuri`},namespace:`BidirectionalTTS`,event:e,req_params:{...o,...n?{text:t}:{}}}),c=`connection`,l=0;try{for(r.send(g(1));;){let e=await _(await r.read(),`tts`);if(n.throwIfAborted(),e.event===51||e.event===153||e.event===151)throw Error(`Speech synthesis failed`);if(e.event>=100&&e.sessionId!==i)throw Error(`Unexpected speech session`);if(e.event===50&&c===`connection`)c=`session`,r.send(g(100,i,s(100)));else if(e.event===150&&c===`session`)c=`audio`,r.send(g(200,i,s(200,!0))),r.send(g(102,i));else if(e.event===352&&c===`audio`&&e.type===11){if(l+=e.payload.length,l>33554432)throw Error(`Speech audio exceeds size limit`);for(let t=0;t<e.payload.length;t+=9600){let n=e.payload.subarray(t,t+9600),r=``;for(let e of n)r+=String.fromCharCode(e);yield a.encode(`${JSON.stringify({type:`audio`,data:btoa(r)})}\n`)}}else if(e.event===364&&c===`audio`){let t=p(e.payload);yield a.encode(`${JSON.stringify({type:`subtitle`,text:t.text,words:t.words})}\n`)}else if(e.event===152&&c===`audio`){let t=p(e.payload);if(t.status_code!==void 0&&t.status_code!==0&&t.status_code!==2e7)throw Error(`Speech synthesis failed`);if(!l)throw Error(`Speech returned no audio`);try{r.send(g(2))}catch{}yield a.encode(`{"type":"done"}
3
3
  `);return}else if(e.event!==350&&e.event!==351)throw Error(`Unexpected speech synthesis event`)}}finally{r.close()}}async function D(e,t){if(!e.trim())throw Error(`Speech text is required`);let n=await b(`tts`,t);if(!n)return i(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/x-ndjson, audio/*`},body:JSON.stringify({text:e.trim()}),signal:t});if(e.length>1e4)throw Error(`Speech text must contain 1–10000 characters`);let r=new AbortController,a=E(n,e.trim(),AbortSignal.any([t,r.signal])),o=new ReadableStream({async pull(e){try{let t=await a.next();t.done?e.close():e.enqueue(t.value)}catch(t){e.error(t)}},async cancel(){r.abort(),await a.return(void 0)}});return new Response(o,{headers:{"Content-Type":`application/x-ndjson`,"X-Speech-Pitch":String(n.pitch),"X-Speech-Volume":String(n.volume)}})}var O=3e4,k=new Map,A=new Map;async function j(e){let t=Date.now(),n=k.get(e);if(n&&t-n.checkedAt<O)return n.available;let r=A.get(e);if(r)return r;let a=(async()=>{try{let t=await i(`/api/tts/status`);if(!t.ok)return k.set(e,{available:!1,checkedAt:Date.now()}),!1;let n=!!(await t.json()).available;return k.set(e,{available:n,checkedAt:Date.now()}),n}catch{return k.set(e,{available:!1,checkedAt:Date.now()}),!1}finally{A.delete(e)}})();return A.set(e,a),a}var M=null,N=null;function P(){return h(),N||=new(window.AudioContext||window.webkitAudioContext),N}function F(e={}){let r=e.enabled??!0,[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null),d=(0,x.useRef)(null),p=(0,x.useRef)(null),m=(0,x.useRef)(0),h=u(async()=>{let e=++m.current,t=n(),i=r=>(e===m.current&&n()===t&&s(r),r);if(!r)return i(!1);try{return i(await j(t))}catch{return i(!1)}});(0,x.useEffect)(()=>{h()},[r,h]),(0,x.useEffect)(()=>t(()=>{h()}),[h]);let g=u(()=>{let e=p.current;if(p.current=null,e?.abort.abort(),d.current){try{d.current.onended=null,d.current.stop()}catch{}d.current=null}a(!1)}),_=u(async()=>{try{let e=P();e.state===`suspended`&&await e.resume();let t=e.createBuffer(1,1,22050),n=e.createBufferSource();n.buffer=t,n.connect(e.destination),n.start(0)}catch(e){console.error(`[useServerTTS] Failed to unlock audio:`,e)}}),v=u(async(e,t)=>{if(g(),!e.trim()){l(`No text to speak`),t?.onError?.(`No text to speak`);return}l(null);let r={abort:new AbortController};p.current=r;try{let i=P();i.state===`suspended`&&await i.resume();let o=i.createBuffer(1,1,22050),s=i.createBufferSource();s.buffer=o,s.connect(i.destination),s.start(0);let c=n(),l=t?.resume&&t.playbackKey&&M?.key===t.playbackKey&&M.identity===c&&M.text===e?M:null,u=Math.max(0,Math.min(e.length,t?.resumeOffset??0)),f=async(e,n,o,s,c,l)=>{await T(e,i,{signal:r.abort.signal,pitch:o,volume:s,cache:n,endAt:l,onStart:()=>{p.current===r&&(a(!0),t?.onStart?.())},onProgress:e=>{p.current===r&&t?.onProgress?.({...e,start:e.start+c,end:e.end+c})}})},m=()=>{p.current===r&&(M?.key===t?.playbackKey&&(M=null),p.current=null,a(!1),t?.onEnd?.())};if(l){if(l.pcm.complete){await f(null,l.pcm,l.pitch,l.volume,l.offset),m();return}let t=l.pcm.timeline.lastBefore(l.pcm.samples/24e3);t&&l.offset+t.end<e.trimEnd().length&&(t.endTime>l.pcm.position&&await f(null,l.pcm,l.pitch,l.volume,l.offset,t.endTime),u=Math.max(u,l.offset+t.end))}if(r.abort.signal.throwIfAborted(),M=null,u+=e.slice(u).match(/^\s*/u)[0].length,u===e.length){m();return}let h=await D(e.slice(u),r.abort.signal);if(p.current!==r){await h.body?.cancel();return}if(!h.ok){let e=await h.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${h.status}`)}let g=Number(h.headers.get(`X-Speech-Pitch`)??1),_=Number(h.headers.get(`X-Speech-Volume`)??1);if(h.headers.get(`content-type`)?.includes(`application/x-ndjson`)){let n=w(e.slice(u));t?.playbackKey&&(M={key:t.playbackKey,identity:c,text:e,offset:u,pcm:n,pitch:g,volume:_}),await f(h,n,g,_,u),m();return}let v=await(await h.blob()).arrayBuffer();if(p.current!==r)return;let y=await i.decodeAudioData(v);if(p.current!==r)return;let b=i.createBufferSource();b.buffer=y,g!==1&&(b.detune.value=(g-1)*1200);let x=i.createGain();if(x.gain.value=_,b.connect(x),x.connect(i.destination),d.current=b,b.onended=()=>{p.current===r&&d.current===b&&(a(!1),d.current=null,p.current=null,t?.onEnd?.())},a(!0),t?.onStart?.(),p.current!==r||d.current!==b)return;b.start(0)}catch(e){if(e.name===`AbortError`||p.current!==r)return;let n=e instanceof Error?e.message:`Failed to speak`;console.error(`[useServerTTS] Error:`,n),l(n),t?.onError?.(n),a(!1),d.current&&=(d.current.onended=null,null),p.current=null}});return(0,x.useEffect)(()=>t(()=>{g(),M=null}),[g]),(0,x.useEffect)(()=>f(g),[g]),(0,x.useEffect)(()=>()=>{g()},[g]),{isPlaying:i,isAvailable:o,error:c,speak:v,stop:g,checkAvailability:h,unlockAudio:_}}var I=60,L=400;function R(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return[];let n=t.match(/[^.!?…]+[.!?…]+["')\]]*\s*|[^.!?…]+$/g)??[t],r=[],i=``;for(let e of n)for(let t=0;t<e.length;t+=L){let n=e.slice(t,t+L);i&&i.length+n.length>L&&(r.push(i.trim()),i=``),i+=n,i.length>=I&&/[.!?…]["')\]]*\s*$/.test(i)&&(r.push(i.trim()),i=``)}if(i.trim()&&r.push(i.trim()),r.length>0&&r[0].length>120){let e=r[0],t=/[,;:]\s/g,n=-1,i;for(;(i=t.exec(e))!==null;){let e=i.index+1;if(!(e<40)){if(e>160)break;n=e;break}}if(n>0){let t=e.slice(0,n).trim(),i=e.slice(n).trim();r.splice(0,1,t,i)}}return r}var z=null;function B(){return h(),z||=new(window.AudioContext||window.webkitAudioContext),z}function V(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(null),a=(0,x.useRef)(null),o=(0,x.useRef)(null),s=(0,x.useCallback)(async()=>{try{let e=B();e.state===`suspended`&&await e.resume();let t=e.createBuffer(1,1,22050),n=e.createBufferSource();n.buffer=t,n.connect(e.destination),n.start(0)}catch{}},[]),c=(0,x.useCallback)(()=>{let e=o.current;if(e&&(e.cancelled=!0,e.abort.abort(),o.current=null),a.current){try{a.current.onended=null,a.current.stop()}catch{}a.current=null}t(!1)},[]),l=(0,x.useCallback)(async(e,n)=>{c();let s=R(e);if(s.length===0){r(`No text to speak`),n?.onError?.(`No text to speak`);return}r(null);let l={cancelled:!1,abort:new AbortController};o.current=l;let u=async e=>{let t=await i(`/api/dictation/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e}),signal:l.abort.signal});if(!t.ok){let e=await t.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${t.status}`)}return(await t.blob()).arrayBuffer()},d=async e=>{let t=B();t.state===`suspended`&&await t.resume();let n=await t.decodeAudioData(e);l.cancelled||await new Promise(e=>{let r=t.createBufferSource();r.buffer=n,r.connect(t.destination),a.current=r,r.onended=()=>{a.current===r&&(a.current=null),e()},r.start(0)})};try{t(!0),n?.onStart?.();let e=u(s[0]);for(let t=0;t<s.length;t+=1){let n=await e;if(l.cancelled||(t+1<s.length&&(e=u(s[t+1])),await d(n),l.cancelled))return}t(!1),n?.onEnd?.()}catch(e){if(e.name===`AbortError`||l.cancelled)return;let i=e instanceof Error?e.message:`Failed to speak`;r(i),n?.onError?.(i),t(!1)}finally{o.current===l&&(o.current=null)}},[c]);return(0,x.useEffect)(()=>f(c),[c]),(0,x.useEffect)(()=>()=>{c()},[c]),{isPlaying:e,error:n,speak:l,stop:c,unlockAudio:s}}var H=new class{recognition=null;isListening=!1;currentLang=`en-US`;onResultCallback=null;onErrorCallback=null;restartOnEnd=!1;conversationMode=!1;isSpeaking=!1;audioContext=null;audioUnlockRequired=!1;speechGeneration=0;isSupported(){let e=`SpeechRecognition`in window||`webkitSpeechRecognition`in window,t=`speechSynthesis`in window;return e&&t}getSupportDetails(){return{recognition:`SpeechRecognition`in window||`webkitSpeechRecognition`in window,synthesis:`speechSynthesis`in window,prefixed:!(`SpeechRecognition`in window)&&`webkitSpeechRecognition`in window,secureContext:window.isSecureContext}}setConversationMode(e){this.conversationMode=e,e||(this.restartOnEnd=!1)}isConversationMode(){return this.conversationMode}pauseListening(){if(this.restartOnEnd=!1,this.recognition)try{this.recognition.stop()}catch{}this.isListening=!1}resumeListening(){if(this.conversationMode,this.onResultCallback,this.isSpeaking,this.currentLang,this.conversationMode&&this.onResultCallback&&!this.isSpeaking)try{this.startListeningSync(this.currentLang,this.onResultCallback,this.onErrorCallback||void 0)}catch(e){console.error(`[BrowserVoiceService] Failed to resume listening:`,e)}}async checkMicrophonePermission(){try{return`permissions`in navigator&&(await navigator.permissions.query({name:`microphone`})).state===`granted`}catch{return!1}}async prepareListening(){if(!this.isSupported())throw Error(`Web Speech API not supported in this browser`);if(typeof navigator>`u`||typeof navigator.mediaDevices?.getUserMedia!=`function`)return!0;try{return v(),(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),!0}catch(e){let t=typeof e==`object`&&e&&`name`in e?String(e.name):``;if(t===`NotAllowedError`)throw Error(`Microphone permission denied`);if(t===`NotFoundError`)throw Error(`No microphone found`);let n=e instanceof Error?e.message:`Unable to access microphone`;throw Error(n)}}startListeningSync(e,t,n){if(!this.isSupported()){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}this.stopListening(),v(),this.isSpeaking=!1;let r=window.SpeechRecognition||window.webkitSpeechRecognition;if(!r){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}let i=new r;this.recognition=i,this.currentLang=e,this.onResultCallback=t,this.onErrorCallback=n||null,i.continuous=!0,i.interimResults=!0,i.lang=e,i.onstart=()=>{this.isListening=!0,this.restartOnEnd=!0},i.onaudiostart=()=>{},i.onsoundstart=()=>{},i.onresult=e=>{e.results.length;let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];i.isFinal?t+=i[0].transcript:n+=i[0].transcript}n&&this.onResultCallback?.(n,!1),t&&this.onResultCallback?.(t,!0)},i.onerror=e=>{if(e.error===`aborted`)return;let t=this.getErrorMessage(e.error);this.onErrorCallback?.(t),(e.error===`not-allowed`||e.error===`service-not-allowed`||e.error===`network`)&&(this.restartOnEnd=!1,this.isListening=!1)},i.onend=()=>{if(this.isListening=!1,this.restartOnEnd&&this.recognition&&!this.isSpeaking)try{this.recognition.start()}catch{}};try{i.start()}catch(e){let t=e instanceof Error?e.message:`Failed to start speech recognition`;throw n?.(t),Error(t)}}async startListening(e,t,n){this.startListeningSync(e,t,n)}stopListening(){if(this.restartOnEnd=!1,this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}this.isListening=!1}getIsListening(){return this.isListening}getCurrentLang(){return this.currentLang}async resumeAudioContext(){h(),this.audioContext||=new(window.AudioContext||window.webkitAudioContext),this.audioContext.state===`suspended`&&await this.audioContext.resume()}isAudioUnlockRequired(){return this.audioUnlockRequired}async unlockAudio(){h();try{let e=new Audio;if(e.src=`data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA`,e.volume=.01,await e.play(),await this.resumeAudioContext(),this.isMobileDevice()&&`speechSynthesis`in window){let e=new SpeechSynthesisUtterance(``);e.volume=0,window.speechSynthesis.speak(e),window.speechSynthesis.cancel()}return this.audioUnlockRequired=!1,!0}catch(e){return console.error(`[BrowserVoiceService] Failed to unlock audio:`,e),!1}}async speakText(e,t,n,r){if(!(`speechSynthesis`in window))throw Error(`Speech synthesis not supported`);let i=++this.speechGeneration;await this.resumeAudioContext();let a=await this.waitForVoices();if(await new Promise(e=>setTimeout(e,50)),i!==this.speechGeneration)return;this.isSpeaking=!0,this.pauseListening(),window.speechSynthesis.cancel();let o=new SpeechSynthesisUtterance(e);o.lang=t,o.rate=r?.rate??1,o.pitch=r?.pitch??1,o.volume=r?.volume??1;let s=null;return r?.voiceName&&(s=a.find(e=>e.name===r.voiceName)||null,s?`${s.name}${s.lang}`:console.warn(`[BrowserVoiceService] Selected voice "${r.voiceName}" not found, falling back to language match`)),s||(s=this.findBestVoice(a,t),s?`${s.name}${s.lang}`:console.warn(`[BrowserVoiceService] No voice found for language: ${t}, using default`)),s&&(o.voice=s),`${e.length}${t}`,new Promise((e,t)=>{let a=!1;o.onstart=()=>{i===this.speechGeneration&&(a=!0,r?.onStart?.(),e())},o.onend=()=>{i===this.speechGeneration&&(this.isSpeaking=!1,n?.())},o.onerror=e=>{if(i!==this.speechGeneration)return;this.isSpeaking=!1,console.error(`[BrowserVoiceService] Speech synthesis error:`,e.error),(e.error===`not-allowed`||e.error===`interrupted`)&&(this.audioUnlockRequired=!0);let n=`Speech synthesis error: ${e.error||`unknown`}`;e.error===`not-allowed`?n=`Audio blocked by browser autoplay policy. Please interact with the page first.`:e.error===`interrupted`&&(n=`Speech was interrupted. Please try again.`),r?.onError?.(n),t(Error(n))},setTimeout(()=>{a||(console.warn(`[BrowserVoiceService] Speech start timeout - audio may be blocked`),this.audioUnlockRequired=!0)},2e3),window.speechSynthesis.speak(o)})}cancelSpeech(){this.speechGeneration+=1,this.isSpeaking=!1,`speechSynthesis`in window&&window.speechSynthesis.cancel()}getVoices(){return`speechSynthesis`in window?window.speechSynthesis.getVoices():[]}async waitForVoices(){if(!(`speechSynthesis`in window))return[];let e=window.speechSynthesis.getVoices();return e.length>0?e:new Promise(e=>{let t=()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null};window.speechSynthesis.onvoiceschanged=t,setTimeout(()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null},1e3)})}findBestVoice(e,t){let n=e.find(e=>e.lang===t);if(!n){let r=t.split(`-`)[0];n=e.find(e=>e.lang.startsWith(r))}return n||=e.find(e=>e.lang.startsWith(t.split(`-`)[0])&&e.localService),n||null}isMobileDevice(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return/iphone|ipad|ipod|android|mobile|webos|blackberry|iemobile|opera mini/i.test(e)}isIOSSafari(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase(),t=/iphone|ipad|ipod/i.test(e),n=/safari/i.test(e)&&!/chrome|crios|crmo/i.test(e);return t&&n}getErrorMessage(e){let t=this.isMobileDevice(),n=this.isIOSSafari();return{"no-speech":`No speech detected`,aborted:`Speech recognition aborted`,"audio-capture":`No microphone found`,network:`Network error - check connection`,"not-allowed":t?`Microphone permission denied. Check Settings > Safari > Microphone`:`Microphone permission denied`,"service-not-allowed":n?`Speech recognition requires a user gesture. Please tap the microphone button again.`:`Speech recognition service not allowed`,"bad-grammar":`Grammar error`,"language-not-supported":`Language not supported`}[e]||`Speech recognition error: ${e}`}};f(()=>H.cancelSpeech());var U=s(),W=(e=n())=>({queryKey:[e,`speech`,`settings`],queryFn:({signal:e})=>o(e,async e=>{let t=await i(`/api/voice/settings`,{signal:e});if(!t.ok)throw Error(`Unable to load speech settings`);return d(await t.json())}),staleTime:3e4,networkMode:`always`,retry:1,refetchOnWindowFocus:!0}),G=()=>{let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=W(),e[0]=t):t=e[0],c(t)};async function K(e,t=r(),a=n()){let{queryKey:s}=W(a);if(await l.cancelQueries({queryKey:s,exact:!0}),t!==r())throw Error(`Runtime changed`);let c=await o(new AbortController().signal,async t=>{let n=await i(`/api/voice/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t});if(!n.ok)throw Error(`Unable to save speech settings`);return d(await n.json())});if(t!==r()||a!==n()||(await l.cancelQueries({queryKey:s,exact:!0}),t!==r()))throw Error(`Runtime changed`);return l.setQueryData(s,c),c}export{V as a,H as i,W as n,F as o,G as r,K as t};