@worktango/ai-assistant 0.0.82-betaryan003 → 0.0.82-betaryan005

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 (175) hide show
  1. package/dist/{Absenteeism-D02pHjLR.mjs → Absenteeism-DjjLKobT.mjs} +1 -1
  2. package/dist/{ActivityFeed-DbNMgYXD.mjs → ActivityFeed-BJT46mRA.mjs} +1 -1
  3. package/dist/{AddUser-Chu2IAkr.mjs → AddUser-CnLpoE5U.mjs} +1 -1
  4. package/dist/{Admin-B9gD0AfL.mjs → Admin-BtsUajEV.mjs} +1 -1
  5. package/dist/{Admin-vWgD0bWI.mjs → Admin-X4xq97Oj.mjs} +1 -1
  6. package/dist/{AiGeneral-a-KY8XYp.mjs → AiGeneral-B9UhP-H8.mjs} +1 -1
  7. package/dist/{AiScoring-D8xhbh4x.mjs → AiScoring-BtgdGBeL.mjs} +1 -1
  8. package/dist/{AiText-B80vrjGH.mjs → AiText-BnvK2vvj.mjs} +1 -1
  9. package/dist/{Anniversary-EUQCfsmM.mjs → Anniversary-CnmB8E5l.mjs} +1 -1
  10. package/dist/{Appreciation-Bwz2sR19.mjs → Appreciation-BWWXjKgk.mjs} +1 -1
  11. package/dist/{ArrowDown-D0QKKIoR.mjs → ArrowDown-CgQvhvkL.mjs} +1 -1
  12. package/dist/{ArrowLeft-M64n9db7.mjs → ArrowLeft-D4RnhgEU.mjs} +1 -1
  13. package/dist/{ArrowRight-Djc0Umdm.mjs → ArrowRight-CsoXPuMF.mjs} +1 -1
  14. package/dist/{ArrowUp-DAt8_oct.mjs → ArrowUp-CMZ5NM5-.mjs} +1 -1
  15. package/dist/{Attachment-CoN8JBqt.mjs → Attachment-DMOKl4Qm.mjs} +1 -1
  16. package/dist/{BeQuickDontHurry--YyDdaZz.mjs → BeQuickDontHurry-CU0pB801.mjs} +1 -1
  17. package/dist/{Birthday-D0cTM18S.mjs → Birthday-B0hElEn8.mjs} +1 -1
  18. package/dist/{BrandPromise-D6nqoGFL.mjs → BrandPromise-BVlaV1wO.mjs} +1 -1
  19. package/dist/{BrandVision-5lpek5Oe.mjs → BrandVision-C9oa69iy.mjs} +1 -1
  20. package/dist/{Calendar-Dx1js24Q.mjs → Calendar-OENtLdtV.mjs} +1 -1
  21. package/dist/{CaretDn-QJWCtsDC.mjs → CaretDn-DKo120X3.mjs} +1 -1
  22. package/dist/{CaretDown-C1Cepag8.mjs → CaretDown-DZmYyQC-.mjs} +1 -1
  23. package/dist/{CaretLeft-DV25fSHo.mjs → CaretLeft-CSAAJPXL.mjs} +1 -1
  24. package/dist/{CaretRight-B_9XSh87.mjs → CaretRight-Bw354_ue.mjs} +1 -1
  25. package/dist/{CaretUp-BLwNKT7K.mjs → CaretUp-BEz15bep.mjs} +1 -1
  26. package/dist/{ChallengeAccepted-DTkDJ1FI.mjs → ChallengeAccepted-CSWc7uwf.mjs} +1 -1
  27. package/dist/{CheckIn-DIX-MLb_.mjs → CheckIn-Bx1Vaizm.mjs} +1 -1
  28. package/dist/{CheckIns-Cjv7mSmI.mjs → CheckIns-CJufzJjM.mjs} +1 -1
  29. package/dist/{CheckSeal-gnspHyAT.mjs → CheckSeal-D6yypnoB.mjs} +1 -1
  30. package/dist/{Checkmark-_uqJrgEb.mjs → Checkmark-sUXXaI5p.mjs} +1 -1
  31. package/dist/{Clock-CzX2RUz8.mjs → Clock-Csmit3ET.mjs} +1 -1
  32. package/dist/{Close-hsC7-VkL.mjs → Close-BCC-p_X9.mjs} +1 -1
  33. package/dist/{CloudDownload-5Ipb5s1l.mjs → CloudDownload-CiIp-bA1.mjs} +1 -1
  34. package/dist/{Comment-CeasyH8c.mjs → Comment-CUnXTDf9.mjs} +1 -1
  35. package/dist/{Comments-DtRRZpEv.mjs → Comments-MfSSvX5j.mjs} +1 -1
  36. package/dist/{Connections-BAviHBKY.mjs → Connections-CHVrwSbq.mjs} +1 -1
  37. package/dist/{Copy-wD3ibkJ1.mjs → Copy-CVcojtBe.mjs} +1 -1
  38. package/dist/{CustomQuestion-BrQSmaLZ.mjs → CustomQuestion-B6jLcffV.mjs} +1 -1
  39. package/dist/{CustomerSuccess-DpvHrXyr.mjs → CustomerSuccess-CbzMsqca.mjs} +1 -1
  40. package/dist/{DatePicker-Tsgp_2Y7.mjs → DatePicker-Bq0jf4A7.mjs} +1 -1
  41. package/dist/{Dot-DblJD0O7.mjs → Dot-FI2-kK30.mjs} +1 -1
  42. package/dist/{Download-D9O_7L27.mjs → Download-DudxiUlS.mjs} +1 -1
  43. package/dist/{Drag-CdKGhyXF.mjs → Drag-Bafluk9f.mjs} +1 -1
  44. package/dist/{Earn-CbFBhJvI.mjs → Earn-BIvZe2HI.mjs} +1 -1
  45. package/dist/{Email-D2tVGgIJ.mjs → Email-DvDYi-lM.mjs} +1 -1
  46. package/dist/{EmojiDisplay-BY5BAXWq.mjs → EmojiDisplay-CViPSTKA.mjs} +2 -2
  47. package/dist/{EmojiPicker-DhbTVPyE.mjs → EmojiPicker-nF5Yjnnf.mjs} +2 -2
  48. package/dist/{EnpsSurvey-DFK3cAOq.mjs → EnpsSurvey-D9NwsRGm.mjs} +1 -1
  49. package/dist/{Expired-DJPJNBTA.mjs → Expired-CaGLvY2P.mjs} +1 -1
  50. package/dist/{Eye-CUn5LvKD.mjs → Eye-tHJQeJJU.mjs} +1 -1
  51. package/dist/{Feedback-BOEIYQuZ.mjs → Feedback-9vk4KO1R.mjs} +1 -1
  52. package/dist/{Feedback-C3aY9JWG.mjs → Feedback-BS-oOt9G.mjs} +1 -1
  53. package/dist/{Filter-BI3OvbP9.mjs → Filter-BjDlTFIf.mjs} +1 -1
  54. package/dist/{Flag-Ct93IoCu.mjs → Flag-eByiEU7E.mjs} +1 -1
  55. package/dist/{Giphy-CBPN4p9Q.mjs → Giphy-ZMpzlTtq.mjs} +1 -1
  56. package/dist/{GoalCount-CordSqxP.mjs → GoalCount-96N89p_D.mjs} +1 -1
  57. package/dist/{GoalPercent-ClwSv0NY.mjs → GoalPercent-Cm1AGZoY.mjs} +1 -1
  58. package/dist/{GoalTask-Cfg0-L-J.mjs → GoalTask-BUbln1q-.mjs} +1 -1
  59. package/dist/{GoalTask-CpllpMce.mjs → GoalTask-hw1HvdN5.mjs} +1 -1
  60. package/dist/{Goals-DBHq4vQm.mjs → Goals-7pj_N48_.mjs} +1 -1
  61. package/dist/{Goals-x9ePpmq9.mjs → Goals-C-H6aBWb.mjs} +1 -1
  62. package/dist/{Growth-Bt8SWqN4.mjs → Growth-Dt0d_02g.mjs} +1 -1
  63. package/dist/{Hamburger-C4LYRkxx.mjs → Hamburger-DOmto_bM.mjs} +1 -1
  64. package/dist/{Help-W2fOvtEt.mjs → Help-dPYFwREi.mjs} +1 -1
  65. package/dist/{HighFive-BPhbyPex.mjs → HighFive-CA7n2Vmk.mjs} +1 -1
  66. package/dist/{HighFive-wqmYe47o.mjs → HighFive-DQ4Tl7GB.mjs} +1 -1
  67. package/dist/{Home-B6tAB--l.mjs → Home-CHJl2O4-.mjs} +1 -1
  68. package/dist/{Home-CufxB32N.mjs → Home-HvRkXPxO.mjs} +1 -1
  69. package/dist/{HorizontalLine-DYGs1yHG.mjs → HorizontalLine-BIF-FtH_.mjs} +1 -1
  70. package/dist/{Hourglass-DPgL4Fyr.mjs → Hourglass-D9de5GSn.mjs} +1 -1
  71. package/dist/{Image-yoOPH7cM.mjs → Image-DZHZEIgz.mjs} +1 -1
  72. package/dist/{ImageFile-CwD20Ffa.mjs → ImageFile-Bf1xe3Ml.mjs} +1 -1
  73. package/dist/{InGoodCompany-DW0tmklX.mjs → InGoodCompany-Bexmjgyv.mjs} +1 -1
  74. package/dist/{Incentives-rmJz14TT.mjs → Incentives-C60GOeOD.mjs} +1 -1
  75. package/dist/{Info-CZxrP_oO.mjs → Info-IsinwixQ.mjs} +1 -1
  76. package/dist/{Insights-D9ROZv2y.mjs → Insights-CTa_5WNX.mjs} +1 -1
  77. package/dist/{Insights-CTio-WML.mjs → Insights-D4V1O8Pe.mjs} +1 -1
  78. package/dist/{Integrations-BPf3DQbU.mjs → Integrations-DvBwQ-Fh.mjs} +1 -1
  79. package/dist/{KazooLogo-DM35JJm4.mjs → KazooLogo-BYc4Af-T.mjs} +1 -1
  80. package/dist/{KnowYourAudience-Ccmf1y5K.mjs → KnowYourAudience-ZLj70sWp.mjs} +1 -1
  81. package/dist/{Launch-DmV8uGdV.mjs → Launch-wn4uiV5z.mjs} +1 -1
  82. package/dist/{Link-BgMvlvGP.mjs → Link-DWTwz7nW.mjs} +1 -1
  83. package/dist/{LinkArrow-B1WyVWSC.mjs → LinkArrow-BzfXqnGf.mjs} +1 -1
  84. package/dist/{Loading-khg8ILxk.mjs → Loading-9Fyov1C3.mjs} +1 -1
  85. package/dist/{Lock-CeuRXltN.mjs → Lock-Btku3Vkn.mjs} +1 -1
  86. package/dist/{Management-CkK1VQIP.mjs → Management-0OruR6XX.mjs} +1 -1
  87. package/dist/{MeatballMenu--ywi2UQV.mjs → MeatballMenu-Btfzf_DP.mjs} +1 -1
  88. package/dist/{Messages-ByuzudIP.mjs → Messages-BP6LKeZ9.mjs} +1 -1
  89. package/dist/{Microphone-mdLi0O9y.mjs → Microphone-xBBzDHaO.mjs} +1 -1
  90. package/dist/{Mobile-HnjUZz3m.mjs → Mobile-B-uX77Eh.mjs} +1 -1
  91. package/dist/{Nomination-BMZ8VwCa.mjs → Nomination-Cc0cQZR0.mjs} +1 -1
  92. package/dist/{NominationsAndAwards-eUGEmBZI.mjs → NominationsAndAwards-Cm1C13Pv.mjs} +1 -1
  93. package/dist/{Notification-BOoeO8oq.mjs → Notification-DqF6zD2U.mjs} +1 -1
  94. package/dist/{Okrs-CM0vDE6C.mjs → Okrs-y9wAzLBH.mjs} +1 -1
  95. package/dist/{Pause-BFVBXNXB.mjs → Pause-CofG5Z_H.mjs} +1 -1
  96. package/dist/{PeerToPeer-DtAkZ2NW.mjs → PeerToPeer-CcT3vBdT.mjs} +1 -1
  97. package/dist/{Pencil-DDOxDv9B.mjs → Pencil-DBNgDm4K.mjs} +1 -1
  98. package/dist/{People-CA4510vT.mjs → People-Dt464kId.mjs} +1 -1
  99. package/dist/{PerformanceManagement-BoA03iGI.mjs → PerformanceManagement-C1lqFf50.mjs} +1 -1
  100. package/dist/{Pin-BNjhYZ77.mjs → Pin-BrG9zrT1.mjs} +1 -1
  101. package/dist/{PinnedIconAward-yFJsrCNZ.mjs → PinnedIconAward-CHmbEl9F.mjs} +1 -1
  102. package/dist/{PinnedIconBrightIdea-Bxz9cXfk.mjs → PinnedIconBrightIdea-Dl5rfbYT.mjs} +1 -1
  103. package/dist/{PinnedIconBullseye-S-RK8iSt.mjs → PinnedIconBullseye-CTF-cWKa.mjs} +1 -1
  104. package/dist/{PinnedIconChampagne-qE6NES4o.mjs → PinnedIconChampagne-CK-VCjXG.mjs} +1 -1
  105. package/dist/{PinnedIconCheer-By-51sQr.mjs → PinnedIconCheer-0f7VchUR.mjs} +1 -1
  106. package/dist/{PinnedIconCrown-CbmZgTW_.mjs → PinnedIconCrown-CEmQw9HS.mjs} +1 -1
  107. package/dist/{PinnedIconDiamond-DY7HnQWW.mjs → PinnedIconDiamond-DaH7Jqmz.mjs} +1 -1
  108. package/dist/{PinnedIconHoleInOne-W2PdFROc.mjs → PinnedIconHoleInOne-4D3ipP_M.mjs} +1 -1
  109. package/dist/{PinnedIconMedal-BRtjAn0C.mjs → PinnedIconMedal-L_0sULFz.mjs} +1 -1
  110. package/dist/{PinnedIconMetrics-BELUF7fn.mjs → PinnedIconMetrics-t4-Ol7At.mjs} +1 -1
  111. package/dist/{PinnedIconPin-BoDWRYV1.mjs → PinnedIconPin-BQ2nhodU.mjs} +1 -1
  112. package/dist/{PinnedIconRockAndRoll-CxTFS5Ds.mjs → PinnedIconRockAndRoll-B2xhSKpb.mjs} +1 -1
  113. package/dist/{PinnedIconRocket-CpsEQGDn.mjs → PinnedIconRocket-GpJLFRT-.mjs} +1 -1
  114. package/dist/{PinnedIconStrength-BbdUpqsE.mjs → PinnedIconStrength-BnBunrhm.mjs} +1 -1
  115. package/dist/{PinnedIconTeddyBear-BlciOz8d.mjs → PinnedIconTeddyBear-3cF_HCIQ.mjs} +1 -1
  116. package/dist/{PlatformLogo-CJJ5HCCH.mjs → PlatformLogo-D1UsB4wR.mjs} +1 -1
  117. package/dist/{Plus-BjLGcunq.mjs → Plus-DmnsHHtk.mjs} +1 -1
  118. package/dist/{Popper-CZpCye-e.mjs → Popper-Crb89jui.mjs} +1 -1
  119. package/dist/{PrivateEye-ClYLE1JM.mjs → PrivateEye-DH-b1W4J.mjs} +1 -1
  120. package/dist/{PrivatePushPin-DQ3Owt3A.mjs → PrivatePushPin-Cg1qbefT.mjs} +1 -1
  121. package/dist/{Processing-49PnuVLR.mjs → Processing-Dk9tPbSs.mjs} +1 -1
  122. package/dist/{Productivity-9weqpR6p.mjs → Productivity-BavdrbH7.mjs} +1 -1
  123. package/dist/{ProgressCircle-CHYmSaTF.mjs → ProgressCircle-COPwUL4d.mjs} +1 -1
  124. package/dist/{PulseSurvey-Dh5RidO_.mjs → PulseSurvey-D19VH4qE.mjs} +1 -1
  125. package/dist/{PushPin-BTq8MvAF.mjs → PushPin-abGLbJHB.mjs} +1 -1
  126. package/dist/{Recognition-D4CfaIpV.mjs → Recognition-BTPp1cKK.mjs} +1 -1
  127. package/dist/{Recognition-BtJ-BHwH.mjs → Recognition-mTg0R8Kq.mjs} +1 -1
  128. package/dist/{Retention-BW3qiY_f.mjs → Retention-sBM7uMHt.mjs} +1 -1
  129. package/dist/{Rewards-DmLAHzLP.mjs → Rewards-Bkj7YIbG.mjs} +1 -1
  130. package/dist/{Rewards-CL2aAN9j.mjs → Rewards-F7u7LIU2.mjs} +1 -1
  131. package/dist/{RewardsCatalog--Q2gooGs.mjs → RewardsCatalog-BVAp9bRu.mjs} +1 -1
  132. package/dist/{Roadmap-CACCiqyG.mjs → Roadmap-DbK1FZZv.mjs} +1 -1
  133. package/dist/{Search-Cs9FtiBE.mjs → Search-C5e6sy27.mjs} +1 -1
  134. package/dist/{Security-DodYx0bP.mjs → Security-7vhpJgYM.mjs} +1 -1
  135. package/dist/{SendRecognition-BNeVuh3D.mjs → SendRecognition-Dh0gLIrb.mjs} +1 -1
  136. package/dist/{ShareLink-Cxc6KDVq.mjs → ShareLink-DZuhgL44.mjs} +1 -1
  137. package/dist/{SidebarCollapse-DvSZ6lzL.mjs → SidebarCollapse-vuSSXNE2.mjs} +1 -1
  138. package/dist/{Skill-QMET2Z-c.mjs → Skill-BBZO58Nt.mjs} +1 -1
  139. package/dist/{Skills-BUogp_qY.mjs → Skills-hmuRZV7N.mjs} +1 -1
  140. package/dist/{Smiley-CSZTVHeS.mjs → Smiley-CpdwKAbc.mjs} +1 -1
  141. package/dist/{Stop-koExtB6X.mjs → Stop-CQc6yVQV.mjs} +1 -1
  142. package/dist/{Survey-B-zqYzJf.mjs → Survey-Dck1gV3N.mjs} +1 -1
  143. package/dist/{Surveys-C0-Y-481.mjs → Surveys-BIjZUqLW.mjs} +1 -1
  144. package/dist/{SyncUps-BfvyAFvB.mjs → SyncUps-DfmRsIkQ.mjs} +1 -1
  145. package/dist/{Syncs-DLHE2LAt.mjs → Syncs-Bc_z6-8g.mjs} +1 -1
  146. package/dist/{TalentReview-B5hmz2tY.mjs → TalentReview-BS0_zKQG.mjs} +1 -1
  147. package/dist/{TalentReview-CuyTUUrJ.mjs → TalentReview-VkxkMym6.mjs} +1 -1
  148. package/dist/{TalentReviewInsights-B6zUbNxO.mjs → TalentReviewInsights-BxRzF004.mjs} +1 -1
  149. package/dist/{TaskCompleted-C-UzjnDH.mjs → TaskCompleted-pAtKiimm.mjs} +1 -1
  150. package/dist/{Team-BAd8d9ld.mjs → Team-BicytAm3.mjs} +1 -1
  151. package/dist/{Teams-KNrlYWm-.mjs → Teams-Fe1vIhgq.mjs} +1 -1
  152. package/dist/{TextBold-v5QOXNy5.mjs → TextBold-rYAvpyTf.mjs} +1 -1
  153. package/dist/{TextBulletList-BcsD1hWp.mjs → TextBulletList-zU4UNdlC.mjs} +1 -1
  154. package/dist/{TextInput-CHhb4iSD.mjs → TextInput-CV9W_768.mjs} +1 -1
  155. package/dist/{TextItalic-dsSmJxob.mjs → TextItalic-1WIxagh4.mjs} +1 -1
  156. package/dist/{TextNumberList-BIUcjrMs.mjs → TextNumberList-C0YBE5Ka.mjs} +1 -1
  157. package/dist/{TextUnderline-CVJMvYAt.mjs → TextUnderline-a9Em5CGj.mjs} +1 -1
  158. package/dist/{Toggle-BCL3a0kw.mjs → Toggle-BdlkQlXV.mjs} +1 -1
  159. package/dist/{Translate-CZYwjCmY.mjs → Translate-CIQuj5Bx.mjs} +1 -1
  160. package/dist/{Trash-v26klzVj.mjs → Trash-CuR84h12.mjs} +1 -1
  161. package/dist/{TrendDown-B95hvWuI.mjs → TrendDown-BeeLT4U3.mjs} +1 -1
  162. package/dist/{TrendUp-CGZsZdcd.mjs → TrendUp-AO5FI3uV.mjs} +1 -1
  163. package/dist/{Undo-DQqReEjk.mjs → Undo-oygJMMfe.mjs} +1 -1
  164. package/dist/{Unplugged-BwLk0Fio.mjs → Unplugged-B89a6aKO.mjs} +1 -1
  165. package/dist/{UpDownCaret-DzFuW4_N.mjs → UpDownCaret-BvuEdEvj.mjs} +1 -1
  166. package/dist/{VerticalLine-TaEbMCj1.mjs → VerticalLine-B8P8DHka.mjs} +1 -1
  167. package/dist/{Warning-AMEI9JXl.mjs → Warning-BdutjG5p.mjs} +1 -1
  168. package/dist/{WarningNoOutline-D_tpvR2l.mjs → WarningNoOutline-DuplNNim.mjs} +1 -1
  169. package/dist/{YesAnd-CesS5gEY.mjs → YesAnd-B1UKaoss.mjs} +1 -1
  170. package/dist/{emoji-ChmbRPG7.mjs → emoji-Gzsw175D.mjs} +1 -1
  171. package/dist/{react-apexcharts.min-CrzLklXP.mjs → react-apexcharts.min-BtXEiRaR.mjs} +1 -1
  172. package/dist/react.es.js +1 -1
  173. package/dist/react.umd.js +2 -2
  174. package/dist/{reactComponent-CTEUZIfv.mjs → reactComponent-C96ovRuk.mjs} +278 -227
  175. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { s as gs, h as ma, r as fs, g as ps } from "./reactComponent-CTEUZIfv.mjs";
1
+ import { s as gs, h as ma, r as fs, g as ps } from "./reactComponent-C96ovRuk.mjs";
2
2
  import xs from "react";
3
3
  function bs(o, e) {
4
4
  for (var t = 0; t < e.length; t++) {
package/dist/react.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as o, u as e, v as a, t as n, w as i, B as g, z as A, y as p, x as u } from "./reactComponent-CTEUZIfv.mjs";
1
+ import { A as o, u as e, v as a, t as n, w as i, B as g, z as A, y as p, x as u } from "./reactComponent-C96ovRuk.mjs";
2
2
  export {
3
3
  o as AiAssistant,
4
4
  e as AiAssistantSettingsComponent,
package/dist/react.umd.js CHANGED
@@ -302,7 +302,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
302
302
 
303
303
  `),tr):"";class NdJson{static parse(er){return er.trim().split(`
304
304
  `).map(ir=>JSON.parse(ir))}static stringify(er){return er.map(rr=>JSON.stringify(rr)).join(`
305
- `)}}const config={kazooUrlStrategy:tr=>tr,llmCallUrlStrategy:tr=>tr,pulseUrlStrategy:tr=>tr,pulseBearerTokenStrategy:()=>null,screenshotMainContentSelector:"#root",structuredResponseUrlStrategy:tr=>tr};function getSynthesizeUrl(){return config.llmCallUrlStrategy("/api/api-ai-assistant/v1/tts")}function getTranscribeUrl(){return config.llmCallUrlStrategy("/api/api-ai-assistant/v1/stt")}function getLlmCallUrl(){return config.llmCallUrlStrategy("/api/api-ai-assistant/v1/chat")}function getStructuredResponseUrl(){return config.structuredResponseUrlStrategy("/api/api-ai-assistant/v1/structured-response")}function getKazooUrl(tr){return config.kazooUrlStrategy(tr)}function getPulseUrl(tr){return config.pulseUrlStrategy(tr)}function getPulseBearerToken(){return config.pulseBearerTokenStrategy()}function getScreenshotMainContentSelector(){return config.screenshotMainContentSelector}function setScreenshotMainContentSelector(tr){config.screenshotMainContentSelector=tr}function setKazooUrlStrategy(tr){config.kazooUrlStrategy=tr}function setLlmCallUrlStrategy(tr){config.llmCallUrlStrategy=tr}function setPulseUrlStrategy(tr){config.pulseUrlStrategy=tr}function setPulseBearerTokenStrategy(tr){config.pulseBearerTokenStrategy=tr}function setStructuredResponseUrlStrategy(tr){config.structuredResponseUrlStrategy=tr}const config$1=Object.freeze(Object.defineProperty({__proto__:null,getKazooUrl,getLlmCallUrl,getPulseBearerToken,getPulseUrl,getScreenshotMainContentSelector,getStructuredResponseUrl,getSynthesizeUrl,getTranscribeUrl,setKazooUrlStrategy,setLlmCallUrlStrategy,setPulseBearerTokenStrategy,setPulseUrlStrategy,setScreenshotMainContentSelector,setStructuredResponseUrlStrategy},Symbol.toStringTag,{value:"Module"}));async function getChatCompletion({model:tr,temperature:er,stream:rr,messages:ir,tools:ar,onChunk:nr,onError:or,onComplete:lr,systemInstruction:fr}){var cr;const dr=getPulseBearerToken();try{const ur=await fetch(getLlmCallUrl(),{method:"POST",body:JSON.stringify({model:tr,temperature:er,stream:rr,messages:ir,tools:ar,systemInstruction:fr}),credentials:dr?void 0:"include",headers:{"Content-Type":"application/json",Accept:rr?"text/event-stream":"application/json",...dr?{Authorization:`Bearer ${dr}`}:{}}});if(!ur||!ur.ok)throw new Error("Unable to connect to LLM API. Please try again.");if(rr){const hr=(cr=ur.body)==null?void 0:cr.getReader();if(!hr)throw new Error("Unexpected client error. Response body reader not available.");const gr=new TextDecoder,_r=[],pr=nr||(Fr=>{_r.push(Fr)}),mr=1e4;for(;mr>0;){const{done:Fr,value:Ar}=await hr.read();if(Fr)break;const br=gr.decode(Ar),yr=NdJson.parse(br);for(const xr of yr)pr(xr)}return lr==null||lr(),_r}return(await ur.json()).parts}catch(ur){const sr=ur instanceof Error?ur:new Error("Unexpected error calling LLM API");throw or==null||or(sr),sr}}var Voice=(tr=>(tr.AOEDE="Aoede",tr.PUCK="Puck",tr.CHARON="Charon",tr.KORE="Kore",tr.FENRIR="Fenrir",tr.LEDA="Leda",tr.ORUS="Orus",tr.ZEPHYR="Zephyr",tr))(Voice||{});async function synthesizeText(tr,er){const rr=getPulseBearerToken(),ir=await fetch(getSynthesizeUrl(),{method:"POST",body:JSON.stringify({text:tr,voice:er}),credentials:rr?void 0:"include",headers:{"Content-Type":"application/json",Accept:"application/json",...rr?{Authorization:`Bearer ${rr}`}:{}}});if(!ir||!ir.ok)throw new Error("Unable to connect to LLM API. Please try again.");const ar=await ir.json();if(!ar.synthesis)throw new Error("No synthesis data received.");return ar.synthesis}async function transcribeAudio(tr){const er=getPulseBearerToken(),rr=await fetch(getTranscribeUrl(),{method:"POST",body:JSON.stringify({audio:tr}),credentials:er?void 0:"include",headers:{"Content-Type":"application/json",Accept:"application/json",...er?{Authorization:`Bearer ${er}`}:{}}});if(!rr||!rr.ok)throw new Error("Unable to connect to LLM API. Please try again.");const ir=await rr.json();if(!ir.transcription)throw new Error("No transcription data received.");return ir.transcription}function useAiAssistantSession({model:tr,initialMessages:er,temperature:rr,onAfterLlmCall:ir,onBeforeLlmCall:ar,onError:nr,tools:or,onChunkAdded:lr,systemInstruction:fr,onLlmTextReply:dr}={}){const[cr,ur]=React.useState(!1),[sr,hr]=React.useState(!1),[gr,_r]=React.useState(()=>(er==null?void 0:er.map(vr=>({...vr,timestamp:coalesce(vr.timestamp,new Date)})))??[]),[pr,mr]=React.useState(null),Fr=React.useRef([]),Ar=React.useRef({onAfterLlmCall:ir,onBeforeLlmCall:ar,onError:nr,tools:or,onLlmTextReply:dr});Ar.current={onAfterLlmCall:ir,onBeforeLlmCall:ar,onError:nr,tools:or,onLlmTextReply:dr};const br=React.useCallback(async vr=>await transcribeAudio(vr),[]),yr=React.useCallback(async vr=>await synthesizeText(vr),[]),xr=React.useCallback(async vr=>{var Dr,Lr;mr(null);try{Ar.current.onBeforeLlmCall&&Ar.current.onBeforeLlmCall()}catch(Tr){Fr.current.push({time:new Date,message:"Error calling onBeforeLlmCall",data:Tr,level:"error"})}let Er;try{fr&&(Er=await fr())}catch(Tr){Fr.current.push({time:new Date,message:"Error getting system instruction",data:Tr,level:"error"}),(Lr=(Dr=Ar.current).onError)==null||Lr.call(Dr,Tr)}ur(!0);try{const Tr={type:"text",text:""},Rr=[],Pr=[...vr];return _r(Pr),await getChatCompletion({model:tr,temperature:rr,stream:!0,messages:vr.filter(Br=>!Br.filterFromApiCalls),tools:or,systemInstruction:Er,onChunk:Br=>{Br.type==="text"?Tr.text+=Br.text:Br.type==="toolCall"&&Rr.push(Br),_r(Ir=>{var Nr;const Mr=[...Ir];return((Nr=Mr[Mr.length-1])==null?void 0:Nr.role)!=="model"&&Mr.push({role:"model",parts:[],timestamp:new Date}),Mr[Mr.length-1].parts=[...Rr,...Tr.text?[Tr]:[]],lr&&lr(),Mr})},onError:Br=>{var Mr,Nr;const Ir=composeSimpleFunctions(getClosureFor(mr,null),getClosureFor(ur,!0),getClosureFor(xr,vr));ur(!1),Fr.current.push({time:new Date,message:"Error calling LLM API",data:Br,level:"error"}),mr({message:jsxRuntimeExports.jsx(ConnectionError,{retry:Ir}),retry:Ir}),(Nr=(Mr=Ar.current).onError)==null||Nr.call(Mr,Br)},onComplete:()=>{safelyInvokeUserCallback({condition:!!Ar.current.onAfterLlmCall,setMessages:_r,callbackToInvoke:Ar.current.onAfterLlmCall,callbackName:"onAfterLlmCall",debugInfo:Fr,onError:Ar.current.onError}),safelyInvokeUserCallback({condition:!!Ar.current.onLlmTextReply,setMessages:_r,callbackToInvoke:Ar.current.onLlmTextReply,callbackName:"onLlmTextReply",debugInfo:Fr,onError:Ar.current.onError}),handlePendingToolCalls({toolCalls:Rr,setMessages:_r,sendMessages:xr,propRefs:Ar,debugInfo:Fr})}}),!0}catch{return!1}finally{ur(!1)}},[tr,rr]),wr=React.useCallback(async vr=>{const Er=[...gr],Dr={role:"user",parts:[{type:"text",text:vr}],timestamp:new Date};kr(Dr),await xr([...Er,Dr])||(Fr.current.push({time:new Date,message:"Error sending message. Reverting to original messages",data:Er,level:"error"}),_r(Er))},[gr]),kr=React.useCallback(vr=>{_r([...gr,vr])},[gr]);return{isLoading:cr,messages:gr,setMessages:_r,isVoiceEnabled:sr,setIsVoiceEnabled:hr,getSpeech:yr,getTranscription:br,debugInfo:Fr.current,addMessage:kr,sendUserMessage:wr,connectionError:pr}}async function handlePendingToolCalls({toolCalls:tr,sendMessages:er,setMessages:rr,propRefs:ir,debugInfo:ar}){var lr,fr,dr,cr;if(tr.length===0)return;const nr=[];for(const ur of tr){const sr=(lr=ir.current.tools)==null?void 0:lr.find(gr=>gr.name===ur.toolName);if(!sr){(dr=(fr=ir.current).onError)==null||dr.call(fr,new Error(`Tool ${ur.toolName} not found`)),ar.current.push({time:new Date,message:`Tool ${ur.toolName} not found`,data:{toolCall:ur,tools:ir.current.tools},level:"error"});continue}const hr=`${Date.now()}-${Math.random()}`;try{rr(Fr=>{const Ar=[...Fr];return Ar.push({role:"tool",parts:[ur],id:hr,timestamp:new Date,isPending:!0,filterFromApiCalls:!0}),Ar}),ar.current.push({time:new Date,level:"info",message:"Fulfilling tool call",data:{toolCall:ur}});const gr=Date.now(),_r=coalesce((cr=ur.args)==null?void 0:cr.args,ur.args),pr=await sr.fulfill(_r),mr=Date.now();typeof pr=="string"?nr.push({type:"toolResult",toolName:ur.toolName,result:pr}):(nr.push({type:"toolResult",toolName:ur.toolName,result:`Tool ${ur.toolName} returned the following file`}),nr.push({type:"file",fileUri:pr==null?void 0:pr.fileUri,mimeType:pr==null?void 0:pr.mimeType})),ar.current.push({time:new Date,level:"info",message:"Tool call fulfilled",data:{toolCall:ur,durationMs:mr-gr}})}catch(gr){ar.current.push({time:new Date,message:"Error calling tool",level:"error",data:{toolCall:ur,error:{message:gr.message,stack:gr.stack}}}),nr.push({type:"toolResult",toolName:ur.toolName,result:{error:{message:gr.message,stack:gr.stack}}})}finally{rr(gr=>gr.map(_r=>_r.id===hr?{..._r,isPending:!1}:_r))}}const or={role:"tool",parts:nr};rr(ur=>{const sr=[...ur,or];return er(sr),sr})}function ConnectionError({retry:tr}){const er=()=>{window.location.reload()};return jsxRuntimeExports.jsxs(Flex,{direction:"column",gap:"24px",children:[jsxRuntimeExports.jsx(Divider,{}),jsxRuntimeExports.jsx(Spacer,{}),jsxRuntimeExports.jsxs(Flex,{direction:"row",gap:"8px",alignItems:"center",children:[jsxRuntimeExports.jsx(Icon,{icon:"warning",color:"#ff0000"}),jsxRuntimeExports.jsxs(Text,{children:["Error calling LLM API. If this persists, try"," ",jsxRuntimeExports.jsx("a",{href:"#",onClick:er,"data-testid":"connection-error-refresh-page",children:"refreshing the page"}),"."]})]}),jsxRuntimeExports.jsxs(Flex,{justifyContent:"flex-end",gap:"8px",children:[jsxRuntimeExports.jsx(Button,{onClick:er,variant:"system",size:"small","data-testid":"connection-error-refresh-page-button",children:"Refresh Page"}),jsxRuntimeExports.jsx(Button,{onClick:tr,variant:"primary","data-testid":"connection-error-retry-button",children:"Retry"})]})]})}function safelyInvokeUserCallback({condition:tr,setMessages:er,callbackToInvoke:rr,callbackName:ir,debugInfo:ar,onError:nr}){!tr||!rr||(ar.current.push({time:new Date,message:`Calling ${ir}`,level:"info"}),er(or=>{try{return rr(or),or}catch(lr){ar.current.push({time:new Date,message:`Error calling ${ir}`,data:lr,level:"error"}),nr&&nr(lr)}finally{ar.current.push({time:new Date,message:`Finished calling ${ir}`,level:"info"})}return or}))}function createMessageHandlers({appendMessageToConversation:tr,errorToast:er,getConversationId:rr}){const ir=appendMessageFactory(tr,er,rr),ar=ir(fr=>({role:"MODEL",messageText:fr})),nr=ir((fr,dr)=>({role:"TOOL",messageText:fr,metadata:{toolName:dr}})),or=ir(fr=>({role:"USER",messageText:fr}));return{appendAssistantMessage:ar,appendToolMessage:nr,appendUserMessage:or,handleGeneratedMessages:fr=>{if(!rr())return;fr.filter(ur=>!ur.id).forEach(ur=>{if(ur.role==="model"){const sr=ur.parts.find(hr=>hr.type==="text");sr&&"text"in sr&&(ar(sr.text),ur.id=`saved-${Date.now()}`)}else if(ur.role==="tool"){const sr=ur.parts.find(hr=>hr.type==="toolResult");sr&&"result"in sr&&"toolName"in sr&&(nr(sr.result,sr.toolName),ur.id=`saved-${Date.now()}`)}})}}}function appendMessageFactory(tr,er,rr){return function(ar){return function(...or){const lr=rr();if(lr)try{return tr({variables:{input:{conversationId:lr,message:ar(...or)}}})}catch(fr){er(fr.message)}else er("No conversation ID available");return!1}}}const getConversationsByDateRange=(tr,er,rr=0)=>{const ir=new Date;return tr.filter(ar=>{const nr=ar.updatedAt instanceof Date?ar.updatedAt:new Date(ar.updatedAt||new Date),or=Math.abs(ir.getTime()-nr.getTime()),lr=Math.ceil(or/(1e3*60*60*24));return(er===null||lr<=er)&&lr>rr})},getTruncatedTitle=tr=>tr.length>30?`${tr.substring(0,30)}...`:tr,generateChatTitle=async tr=>{try{const er=await getChatCompletion({model:"small",temperature:.25,stream:!1,messages:[{role:"user",parts:[{type:"text",text:`Generate a concise 3-4 word title for this chat based on the first message. The title should be descriptive but brief. Do not use any punctuation. Return only the title, nothing else.
305
+ `)}}const config={kazooUrlStrategy:tr=>tr,llmCallUrlStrategy:tr=>tr,pulseUrlStrategy:tr=>tr,pulseBearerTokenStrategy:()=>null,screenshotMainContentSelector:"#root",structuredResponseUrlStrategy:tr=>tr};function getSynthesizeUrl(){return config.llmCallUrlStrategy("/api/api-ai-assistant/v1/tts")}function getTranscribeUrl(){return config.llmCallUrlStrategy("/api/api-ai-assistant/v1/stt")}function getLlmCallUrl(){return config.llmCallUrlStrategy("/api/api-ai-assistant/v1/chat")}function getStructuredResponseUrl(){return config.structuredResponseUrlStrategy("/api/api-ai-assistant/v1/structured-response")}function getKazooUrl(tr){return config.kazooUrlStrategy(tr)}function getPulseUrl(tr){return config.pulseUrlStrategy(tr)}function getPulseBearerToken(){return config.pulseBearerTokenStrategy()}function getScreenshotMainContentSelector(){return config.screenshotMainContentSelector}function setScreenshotMainContentSelector(tr){config.screenshotMainContentSelector=tr}function setKazooUrlStrategy(tr){config.kazooUrlStrategy=tr}function setLlmCallUrlStrategy(tr){config.llmCallUrlStrategy=tr}function setPulseUrlStrategy(tr){config.pulseUrlStrategy=tr}function setPulseBearerTokenStrategy(tr){config.pulseBearerTokenStrategy=tr}function setStructuredResponseUrlStrategy(tr){config.structuredResponseUrlStrategy=tr}const config$1=Object.freeze(Object.defineProperty({__proto__:null,getKazooUrl,getLlmCallUrl,getPulseBearerToken,getPulseUrl,getScreenshotMainContentSelector,getStructuredResponseUrl,getSynthesizeUrl,getTranscribeUrl,setKazooUrlStrategy,setLlmCallUrlStrategy,setPulseBearerTokenStrategy,setPulseUrlStrategy,setScreenshotMainContentSelector,setStructuredResponseUrlStrategy},Symbol.toStringTag,{value:"Module"}));async function getChatCompletion({model:tr,temperature:er,stream:rr,messages:ir,tools:ar,onChunk:nr,onError:or,onComplete:lr,systemInstruction:fr}){var cr;const dr=getPulseBearerToken();try{const ur=await fetch(getLlmCallUrl(),{method:"POST",body:JSON.stringify({model:tr,temperature:er,stream:rr,messages:ir,tools:ar,systemInstruction:fr}),credentials:dr?void 0:"include",headers:{"Content-Type":"application/json",Accept:rr?"text/event-stream":"application/json",...dr?{Authorization:`Bearer ${dr}`}:{}}});if(!ur||!ur.ok)throw new Error("Unable to connect to LLM API. Please try again.");if(rr){const hr=(cr=ur.body)==null?void 0:cr.getReader();if(!hr)throw new Error("Unexpected client error. Response body reader not available.");const gr=new TextDecoder,_r=[],pr=nr||(Fr=>{_r.push(Fr)}),mr=1e4;for(;mr>0;){const{done:Fr,value:Ar}=await hr.read();if(Fr)break;const br=gr.decode(Ar),yr=NdJson.parse(br);for(const xr of yr)pr(xr)}return lr==null||lr(),_r}return(await ur.json()).parts}catch(ur){const sr=ur instanceof Error?ur:new Error("Unexpected error calling LLM API");throw or==null||or(sr),sr}}var Voice=(tr=>(tr.AOEDE="Aoede",tr.PUCK="Puck",tr.CHARON="Charon",tr.KORE="Kore",tr.FENRIR="Fenrir",tr.LEDA="Leda",tr.ORUS="Orus",tr.ZEPHYR="Zephyr",tr))(Voice||{});async function synthesizeText(tr,er){const rr=getPulseBearerToken(),ir=await fetch(getSynthesizeUrl(),{method:"POST",body:JSON.stringify({text:tr,voice:er}),credentials:rr?void 0:"include",headers:{"Content-Type":"application/json",Accept:"application/json",...rr?{Authorization:`Bearer ${rr}`}:{}}});if(!ir||!ir.ok)throw new Error("Unable to connect to LLM API. Please try again.");const ar=await ir.json();if(!ar.synthesis)throw new Error("No synthesis data received.");return ar.synthesis}async function transcribeAudio(tr){const er=getPulseBearerToken(),rr=await fetch(getTranscribeUrl(),{method:"POST",body:JSON.stringify({audio:tr}),credentials:er?void 0:"include",headers:{"Content-Type":"application/json",Accept:"application/json",...er?{Authorization:`Bearer ${er}`}:{}}});if(!rr||!rr.ok)throw new Error("Unable to connect to LLM API. Please try again.");const ir=await rr.json();if(!ir.transcription)throw new Error("No transcription data received.");return ir.transcription}function useAiAssistantSession({model:tr,initialMessages:er,temperature:rr,onAfterLlmCall:ir,onBeforeLlmCall:ar,onError:nr,tools:or,onChunkAdded:lr,systemInstruction:fr,onLlmTextReply:dr}={}){const[cr,ur]=React.useState(!1),[sr,hr]=React.useState(!1),[gr,_r]=React.useState(()=>(er==null?void 0:er.map(vr=>({...vr,timestamp:coalesce(vr.timestamp,new Date)})))??[]),[pr,mr]=React.useState(null),Fr=React.useRef([]),Ar=React.useRef({onAfterLlmCall:ir,onBeforeLlmCall:ar,onError:nr,tools:or,onLlmTextReply:dr,model:tr,temperature:rr,isMounted:!0});Ar.current={onAfterLlmCall:ir,onBeforeLlmCall:ar,onError:nr,tools:or,onLlmTextReply:dr,model:tr,temperature:rr,isMounted:!0},React.useEffect(()=>()=>{Ar.current.isMounted=!1},[]);const br=React.useCallback(async vr=>await transcribeAudio(vr),[]),yr=React.useCallback(async vr=>await synthesizeText(vr),[]),xr=React.useCallback(async vr=>{var Dr,Lr;console.log("sendMessages",vr,new Error().stack),mr(null);try{Ar.current.onBeforeLlmCall&&Ar.current.onBeforeLlmCall()}catch(Tr){Fr.current.push({time:new Date,message:"Error calling onBeforeLlmCall",data:Tr,level:"error"})}let Er;try{fr&&(Er=await fr())}catch(Tr){Fr.current.push({time:new Date,message:"Error getting system instruction",data:Tr,level:"error"}),(Lr=(Dr=Ar.current).onError)==null||Lr.call(Dr,Tr)}ur(!0);try{const Tr={type:"text",text:""},Rr=[],Pr=[...vr];return _r(Pr),await getChatCompletion({model:Ar.current.model,temperature:Ar.current.temperature,stream:!0,messages:vr.filter(Br=>!Br.filterFromApiCalls),tools:or,systemInstruction:Er,onChunk:Br=>{Ar.current.isMounted&&(Br.type==="text"?Tr.text+=Br.text:Br.type==="toolCall"&&Rr.push(Br),_r(Ir=>{var Nr;const Mr=[...Ir];return((Nr=Mr[Mr.length-1])==null?void 0:Nr.role)!=="model"&&Mr.push({role:"model",parts:[],timestamp:new Date}),Mr[Mr.length-1].parts=[...Rr,...Tr.text?[Tr]:[]],lr&&lr(),Mr}))},onError:Br=>{var Mr,Nr;if(!Ar.current.isMounted)return;const Ir=composeSimpleFunctions(getClosureFor(mr,null),getClosureFor(ur,!0),getClosureFor(xr,vr));ur(!1),Fr.current.push({time:new Date,message:"Error calling LLM API",data:Br,level:"error"}),mr({message:jsxRuntimeExports.jsx(ConnectionError,{retry:Ir}),retry:Ir}),(Nr=(Mr=Ar.current).onError)==null||Nr.call(Mr,Br)},onComplete:()=>{Ar.current.isMounted&&(safelyInvokeUserCallback({condition:!!Ar.current.onAfterLlmCall,setMessages:_r,callbackToInvoke:Ar.current.onAfterLlmCall,callbackName:"onAfterLlmCall",debugInfo:Fr,onError:Ar.current.onError}),safelyInvokeUserCallback({condition:!!Ar.current.onLlmTextReply,setMessages:_r,callbackToInvoke:Ar.current.onLlmTextReply,callbackName:"onLlmTextReply",debugInfo:Fr,onError:Ar.current.onError}),handlePendingToolCalls({toolCalls:Rr,setMessages:_r,sendMessages:xr,propRefs:Ar,debugInfo:Fr}))}}),!0}catch{return!1}finally{ur(!1)}},[]),wr=React.useCallback(async vr=>{const Er=[...gr],Dr={role:"user",parts:[{type:"text",text:vr}],timestamp:new Date};kr(Dr),await xr([...Er,Dr])||(Fr.current.push({time:new Date,message:"Error sending message. Reverting to original messages",data:Er,level:"error"}),_r(Er))},[gr]),kr=React.useCallback(vr=>{_r([...gr,vr])},[gr]);return{isLoading:cr,messages:gr,setMessages:_r,isVoiceEnabled:sr,setIsVoiceEnabled:hr,getSpeech:yr,getTranscription:br,debugInfo:Fr.current,addMessage:kr,sendUserMessage:wr,connectionError:pr}}async function handlePendingToolCalls({toolCalls:tr,sendMessages:er,setMessages:rr,propRefs:ir,debugInfo:ar}){var lr,fr,dr,cr;if(tr.length===0)return;const nr=[];for(const ur of tr){const sr=(lr=ir.current.tools)==null?void 0:lr.find(gr=>gr.name===ur.toolName);if(!sr){(dr=(fr=ir.current).onError)==null||dr.call(fr,new Error(`Tool ${ur.toolName} not found`)),ar.current.push({time:new Date,message:`Tool ${ur.toolName} not found`,data:{toolCall:ur,tools:ir.current.tools},level:"error"});continue}const hr=`${Date.now()}-${Math.random()}`;try{rr(Fr=>{const Ar=[...Fr];return Ar.push({role:"tool",parts:[ur],id:hr,timestamp:new Date,isPending:!0,filterFromApiCalls:!0}),Ar}),ar.current.push({time:new Date,level:"info",message:"Fulfilling tool call",data:{toolCall:ur}});const gr=Date.now(),_r=coalesce((cr=ur.args)==null?void 0:cr.args,ur.args),pr=await sr.fulfill(_r),mr=Date.now();typeof pr=="string"?(nr.push({type:"toolResult",toolName:ur.toolName,result:pr}),ar.current.push({time:new Date,level:"info",message:"Tool call fulfilled",data:{toolCall:ur,durationMs:mr-gr,result:pr}})):(nr.push({type:"toolResult",toolName:ur.toolName,result:`Tool ${ur.toolName} returned the following file`}),nr.push({type:"file",fileUri:pr==null?void 0:pr.fileUri,mimeType:pr==null?void 0:pr.mimeType}),ar.current.push({time:new Date,level:"info",message:"Tool call fulfilled with file",data:{toolCall:ur,durationMs:mr-gr,result:pr}}))}catch(gr){ar.current.push({time:new Date,message:"Error calling tool",level:"error",data:{toolCall:ur,error:{message:gr.message,stack:gr.stack}}}),nr.push({type:"toolResult",toolName:ur.toolName,result:{error:{message:gr.message,stack:gr.stack}}})}finally{rr(gr=>gr.map(_r=>_r.id===hr?{..._r,isPending:!1}:_r))}}const or={role:"tool",parts:nr};rr(ur=>{const sr=[...ur,or];return er(sr),sr})}function ConnectionError({retry:tr}){const er=()=>{window.location.reload()};return jsxRuntimeExports.jsxs(Flex,{direction:"column",gap:"24px",children:[jsxRuntimeExports.jsx(Divider,{}),jsxRuntimeExports.jsx(Spacer,{}),jsxRuntimeExports.jsxs(Flex,{direction:"row",gap:"8px",alignItems:"center",children:[jsxRuntimeExports.jsx(Icon,{icon:"warning",color:"#ff0000"}),jsxRuntimeExports.jsxs(Text,{children:["Error calling LLM API. If this persists, try"," ",jsxRuntimeExports.jsx("a",{href:"#",onClick:er,"data-testid":"connection-error-refresh-page",children:"refreshing the page"}),"."]})]}),jsxRuntimeExports.jsxs(Flex,{justifyContent:"flex-end",gap:"8px",children:[jsxRuntimeExports.jsx(Button,{onClick:er,variant:"system",size:"small","data-testid":"connection-error-refresh-page-button",children:"Refresh Page"}),jsxRuntimeExports.jsx(Button,{onClick:tr,variant:"primary","data-testid":"connection-error-retry-button",children:"Retry"})]})]})}function safelyInvokeUserCallback({condition:tr,setMessages:er,callbackToInvoke:rr,callbackName:ir,debugInfo:ar,onError:nr}){!tr||!rr||(ar.current.push({time:new Date,message:`Calling ${ir}`,level:"info"}),er(or=>{try{return rr(or),or}catch(lr){ar.current.push({time:new Date,message:`Error calling ${ir}`,data:lr,level:"error"}),nr&&nr(lr)}finally{ar.current.push({time:new Date,message:`Finished calling ${ir}`,level:"info"})}return or}))}function createMessageHandlers({appendMessageToConversation:tr,errorToast:er,getConversationId:rr}){const ir=appendMessageFactory(tr,er,rr),ar=ir(fr=>({role:"MODEL",messageText:fr})),nr=ir((fr,dr)=>({role:"TOOL",messageText:fr,metadata:{toolName:dr}})),or=ir(fr=>({role:"USER",messageText:fr}));return{appendAssistantMessage:ar,appendToolMessage:nr,appendUserMessage:or,handleGeneratedMessages:fr=>{if(!rr())return;fr.filter(ur=>!ur.id).forEach(ur=>{if(ur.role==="model"){const sr=ur.parts.find(hr=>hr.type==="text");sr&&"text"in sr&&(ar(sr.text),ur.id=`saved-${Date.now()}`)}else if(ur.role==="tool"){const sr=ur.parts.find(hr=>hr.type==="toolResult");sr&&"result"in sr&&"toolName"in sr&&(nr(sr.result,sr.toolName),ur.id=`saved-${Date.now()}`)}})}}}function appendMessageFactory(tr,er,rr){return function(ar){return function(...or){const lr=rr();if(lr)try{return tr({variables:{input:{conversationId:lr,message:ar(...or)}}})}catch(fr){er(fr.message)}else er("No conversation ID available");return!1}}}const getConversationsByDateRange=(tr,er,rr=0)=>{const ir=new Date;return tr.filter(ar=>{const nr=ar.updatedAt instanceof Date?ar.updatedAt:new Date(ar.updatedAt||new Date),or=Math.abs(ir.getTime()-nr.getTime()),lr=Math.ceil(or/(1e3*60*60*24));return(er===null||lr<=er)&&lr>rr})},getTruncatedTitle=tr=>tr.length>30?`${tr.substring(0,30)}...`:tr,generateChatTitle=async tr=>{try{const er=await getChatCompletion({model:"small",temperature:.25,stream:!1,messages:[{role:"user",parts:[{type:"text",text:`Generate a concise 3-4 word title for this chat based on the first message. The title should be descriptive but brief. Do not use any punctuation. Return only the title, nothing else.
306
306
 
307
307
  First message: "${tr}"`}]}]});if(er&&er.length>0){const rr=er[0];if(rr.type==="text")return rr.text.trim()}return"New Chat"}catch(er){return console.error("Error generating chat title:",er),"New Chat"}};function extractSources(tr){var ar;const er=/\[([^\]]+)\]\((https?:\/\/[^")]+)\)(?:\s*\n\s*([^\n]+))?/g,rr=[];let ir;for(;(ir=er.exec(tr))!==null;)rr.push({name:ir[1],url:ir[2],pageInfo:(ar=ir[3])==null?void 0:ar.trim()});return rr}function removeSourcesFromText(tr){return tr.replace(/<?Source[s]*>?[:]?(\s*)((\[[^\]]+\]\([^)]+\)(?:\s*\n\s*[^\n]+)?[, ]*)+)(?:\s*<\/Source[s]*>)?/gi,"")}const styles$6={"ai-assistant-textarea":"AiAssistantComponent-module_ai-assistant-textarea_dJrtB","ai-assistant-popup-container":"AiAssistantComponent-module_ai-assistant-popup-container_OH04M","ai-assistant-chat-history-container":"AiAssistantComponent-module_ai-assistant-chat-history-container_mIJ3y","ai-assistant-chat-history-header":"AiAssistantComponent-module_ai-assistant-chat-history-header_aR6OI","ai-assistant-chat-history-button":"AiAssistantComponent-module_ai-assistant-chat-history-button_Q34D6","conversation-selected":"AiAssistantComponent-module_conversation-selected_-ijIe","ai-assistant-chat-history-button-text":"AiAssistantComponent-module_ai-assistant-chat-history-button-text_cAi5Q","text-updated":"AiAssistantComponent-module_text-updated_bYi3h","textarea-container":"AiAssistantComponent-module_textarea-container_4eE9f","placeholder-content":"AiAssistantComponent-module_placeholder-content_8vmjp","placeholder-text":"AiAssistantComponent-module_placeholder-text_8edUF","loading-container":"AiAssistantComponent-module_loading-container_7BNjW","messages-scroll-container":"AiAssistantComponent-module_messages-scroll-container_8O6Kb","ai-assistant-send-btn":"AiAssistantComponent-module_ai-assistant-send-btn_h2wdX","ai-assistant-search-input-container":"AiAssistantComponent-module_ai-assistant-search-input-container_lUZKm"};var dist$1={},dist={},ortWeb_min={exports:{}};const backends={},backendsSortedByPriority=[],registerBackend=(tr,er,rr)=>{if(er&&typeof er.init=="function"&&typeof er.createSessionHandler=="function"){const ir=backends[tr];if(ir===void 0)backends[tr]={backend:er,priority:rr};else{if(ir.priority>rr)return;if(ir.priority===rr&&ir.backend!==er)throw new Error(`cannot register backend "${tr}" using priority ${rr}`)}if(rr>=0){const ar=backendsSortedByPriority.indexOf(tr);ar!==-1&&backendsSortedByPriority.splice(ar,1);for(let nr=0;nr<backendsSortedByPriority.length;nr++)if(backends[backendsSortedByPriority[nr]].priority<=rr){backendsSortedByPriority.splice(nr,0,tr);return}backendsSortedByPriority.push(tr)}return}throw new TypeError("not a valid backend")},resolveBackend=async tr=>{const er=tr.length===0?backendsSortedByPriority:tr,rr=[];for(const ir of er){const ar=backends[ir];if(ar){if(ar.initialized)return ar.backend;if(ar.aborted)continue;const nr=!!ar.initPromise;try{return nr||(ar.initPromise=ar.backend.init()),await ar.initPromise,ar.initialized=!0,ar.backend}catch(or){nr||rr.push({name:ir,err:or}),ar.aborted=!0}finally{delete ar.initPromise}}}throw new Error(`no available backend found. ERR: ${rr.map(ir=>`[${ir.name}] ${ir.err}`).join(", ")}`)};class EnvImpl{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(er){if(er!==void 0){if(typeof er!="string"||["verbose","info","warning","error","fatal"].indexOf(er)===-1)throw new Error(`Unsupported logging level: ${er}`);this.logLevelInternal=er}}get logLevel(){return this.logLevelInternal}}const env=new EnvImpl,isBigInt64ArrayAvailable=typeof BigInt64Array<"u"&&typeof BigInt64Array.from=="function",isBigUint64ArrayAvailable=typeof BigUint64Array<"u"&&typeof BigUint64Array.from=="function",NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);isBigInt64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("int64",BigInt64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigInt64Array,"int64")),isBigUint64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("uint64",BigUint64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigUint64Array,"uint64"));const calculateSize=tr=>{let er=1;for(let rr=0;rr<tr.length;rr++){const ir=tr[rr];if(typeof ir!="number"||!Number.isSafeInteger(ir))throw new TypeError(`dims[${rr}] must be an integer, got: ${ir}`);if(ir<0)throw new RangeError(`dims[${rr}] must be a non-negative integer, got: ${ir}`);er*=ir}return er};let Tensor$1=class Mo{constructor(er,rr,ir){let ar,nr,or;if(typeof er=="string")if(ar=er,or=ir,er==="string"){if(!Array.isArray(rr))throw new TypeError("A string tensor's data must be a string array.");nr=rr}else{const fr=NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(er);if(fr===void 0)throw new TypeError(`Unsupported tensor type: ${er}.`);if(Array.isArray(rr))nr=fr.from(rr);else if(rr instanceof fr)nr=rr;else throw new TypeError(`A ${ar} tensor's data must be type of ${fr}`)}else if(or=rr,Array.isArray(er)){if(er.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");const fr=typeof er[0];if(fr==="string")ar="string",nr=er;else if(fr==="boolean")ar="bool",nr=Uint8Array.from(er);else throw new TypeError(`Invalid element type of data array: ${fr}.`)}else{const fr=NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.get(er.constructor);if(fr===void 0)throw new TypeError(`Unsupported type for tensor data: ${er.constructor}.`);ar=fr,nr=er}if(or===void 0)or=[nr.length];else if(!Array.isArray(or))throw new TypeError("A tensor's dims must be a number array");const lr=calculateSize(or);if(lr!==nr.length)throw new Error(`Tensor's size(${lr}) does not match data length(${nr.length}).`);this.dims=or,this.type=ar,this.data=nr,this.size=lr}static bufferToTensor(er,rr){if(er===void 0)throw new Error("Image buffer must be defined");if(rr.height===void 0||rr.width===void 0)throw new Error("Image height and width must be defined");const{height:ir,width:ar}=rr,nr=rr.norm;let or,lr;nr===void 0||nr.mean===void 0?or=255:or=nr.mean,nr===void 0||nr.bias===void 0?lr=0:lr=nr.bias;const fr=rr.bitmapFormat!==void 0?rr.bitmapFormat:"RGBA",dr=rr.tensorFormat!==void 0&&rr.tensorFormat!==void 0?rr.tensorFormat:"RGB",cr=ir*ar,ur=dr==="RGBA"?new Float32Array(cr*4):new Float32Array(cr*3);let sr=4,hr=0,gr=1,_r=2,pr=3,mr=0,Fr=cr,Ar=cr*2,br=-1;fr==="RGB"&&(sr=3,hr=0,gr=1,_r=2,pr=-1),dr==="RGBA"?br=cr*3:dr==="RBG"?(mr=0,Ar=cr,Fr=cr*2):dr==="BGR"&&(Ar=0,Fr=cr,mr=cr*2);for(let xr=0;xr<cr;xr++,hr+=sr,_r+=sr,gr+=sr,pr+=sr)ur[mr++]=(er[hr]+lr)/or,ur[Fr++]=(er[gr]+lr)/or,ur[Ar++]=(er[_r]+lr)/or,br!==-1&&pr!==-1&&(ur[br++]=(er[pr]+lr)/or);return dr==="RGBA"?new Mo("float32",ur,[1,4,ir,ar]):new Mo("float32",ur,[1,3,ir,ar])}static async fromImage(er,rr){const ir=typeof HTMLImageElement<"u"&&er instanceof HTMLImageElement,ar=typeof ImageData<"u"&&er instanceof ImageData,nr=typeof ImageBitmap<"u"&&er instanceof ImageBitmap,or=typeof String<"u"&&(er instanceof String||typeof er=="string");let lr,fr={};if(ir){const dr=document.createElement("canvas"),cr=dr.getContext("2d");if(cr!=null){let ur=er.naturalHeight,sr=er.naturalWidth;if(rr!==void 0&&rr.resizedHeight!==void 0&&rr.resizedWidth!==void 0&&(ur=rr.resizedHeight,sr=rr.resizedWidth),rr!==void 0){if(fr=rr,rr.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");if(fr.tensorFormat="RGBA",rr.height!==void 0&&rr.height!==ur)throw new Error("Image input config height doesn't match HTMLImageElement height");if(fr.height=ur,rr.width!==void 0&&rr.width!==sr)throw new Error("Image input config width doesn't match HTMLImageElement width");fr.width=sr}else fr.tensorFormat="RGBA",fr.height=ur,fr.width=sr;dr.width=sr,dr.height=ur,cr.drawImage(er,0,0,sr,ur),lr=cr.getImageData(0,0,sr,ur).data}else throw new Error("Can not access image data")}else if(ar){const dr="RGBA";let cr,ur;if(rr!==void 0&&rr.resizedWidth!==void 0&&rr.resizedHeight!==void 0?(cr=rr.resizedHeight,ur=rr.resizedWidth):(cr=er.height,ur=er.width),rr!==void 0){if(fr=rr,rr.bitmapFormat!==void 0&&rr.bitmapFormat!==dr)throw new Error("Image input config format must be RGBA for ImageData");fr.bitmapFormat="RGBA"}else fr.bitmapFormat="RGBA";if(fr.height=cr,fr.width=ur,rr!==void 0){const sr=document.createElement("canvas");sr.width=ur,sr.height=cr;const hr=sr.getContext("2d");if(hr!=null)hr.putImageData(er,0,0),lr=hr.getImageData(0,0,ur,cr).data;else throw new Error("Can not access image data")}else lr=er.data}else if(nr){if(rr===void 0)throw new Error("Please provide image config with format for Imagebitmap");if(rr.bitmapFormat!==void 0)throw new Error("Image input config format must be defined for ImageBitmap");const dr=document.createElement("canvas").getContext("2d");if(dr!=null){const cr=er.height,ur=er.width;if(dr.drawImage(er,0,0,ur,cr),lr=dr.getImageData(0,0,ur,cr).data,rr!==void 0){if(rr.height!==void 0&&rr.height!==cr)throw new Error("Image input config height doesn't match ImageBitmap height");if(fr.height=cr,rr.width!==void 0&&rr.width!==ur)throw new Error("Image input config width doesn't match ImageBitmap width");fr.width=ur}else fr.height=cr,fr.width=ur;return Mo.bufferToTensor(lr,fr)}else throw new Error("Can not access image data")}else{if(or)return new Promise((dr,cr)=>{const ur=document.createElement("canvas"),sr=ur.getContext("2d");if(!er||!sr)return cr();const hr=new Image;hr.crossOrigin="Anonymous",hr.src=er,hr.onload=()=>{ur.width=hr.width,ur.height=hr.height,sr.drawImage(hr,0,0,ur.width,ur.height);const gr=sr.getImageData(0,0,ur.width,ur.height);if(rr!==void 0){if(rr.height!==void 0&&rr.height!==ur.height)throw new Error("Image input config height doesn't match ImageBitmap height");if(fr.height=ur.height,rr.width!==void 0&&rr.width!==ur.width)throw new Error("Image input config width doesn't match ImageBitmap width");fr.width=ur.width}else fr.height=ur.height,fr.width=ur.width;dr(Mo.bufferToTensor(gr.data,fr))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(lr!==void 0)return Mo.bufferToTensor(lr,fr);throw new Error("Input data provided is not supported - aborted tensor creation")}toImageData(er){var rr,ir;const ar=document.createElement("canvas").getContext("2d");let nr;if(ar!=null){const or=this.dims[3],lr=this.dims[2],fr=this.dims[1],dr=er!==void 0&&er.format!==void 0?er.format:"RGB",cr=er!==void 0&&((rr=er.norm)===null||rr===void 0?void 0:rr.mean)!==void 0?er.norm.mean:255,ur=er!==void 0&&((ir=er.norm)===null||ir===void 0?void 0:ir.bias)!==void 0?er.norm.bias:0,sr=lr*or;if(er!==void 0){if(er.height!==void 0&&er.height!==lr)throw new Error("Image output config height doesn't match tensor height");if(er.width!==void 0&&er.width!==or)throw new Error("Image output config width doesn't match tensor width");if(er.format!==void 0&&fr===4&&er.format!=="RGBA"||fr===3&&er.format!=="RGB"&&er.format!=="BGR")throw new Error("Tensor format doesn't match input tensor dims")}const hr=4;let gr=0,_r=1,pr=2,mr=3,Fr=0,Ar=sr,br=sr*2,yr=-1;dr==="RGBA"?(Fr=0,Ar=sr,br=sr*2,yr=sr*3):dr==="RGB"?(Fr=0,Ar=sr,br=sr*2):dr==="RBG"&&(Fr=0,br=sr,Ar=sr*2),nr=ar.createImageData(or,lr);for(let xr=0;xr<lr*or;gr+=hr,_r+=hr,pr+=hr,mr+=hr,xr++)nr.data[gr]=(this.data[Fr++]-ur)*cr,nr.data[_r]=(this.data[Ar++]-ur)*cr,nr.data[pr]=(this.data[br++]-ur)*cr,nr.data[mr]=yr===-1?255:(this.data[yr++]-ur)*cr}else throw new Error("Can not access image data");return nr}reshape(er){return new Mo(this.type,this.data,er)}};const Tensor=Tensor$1;let InferenceSession$1=class Rs{constructor(er){this.handler=er}async run(er,rr,ir){const ar={};let nr={};if(typeof er!="object"||er===null||er instanceof Tensor||Array.isArray(er))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let or=!0;if(typeof rr=="object"){if(rr===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(rr instanceof Tensor)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(rr)){if(rr.length===0)throw new TypeError("'fetches' cannot be an empty array.");or=!1;for(const dr of rr){if(typeof dr!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(dr)===-1)throw new RangeError(`'fetches' contains invalid output name: ${dr}.`);ar[dr]=null}if(typeof ir=="object"&&ir!==null)nr=ir;else if(typeof ir<"u")throw new TypeError("'options' must be an object.")}else{let dr=!1;const cr=Object.getOwnPropertyNames(rr);for(const ur of this.outputNames)if(cr.indexOf(ur)!==-1){const sr=rr[ur];(sr===null||sr instanceof Tensor)&&(dr=!0,or=!1,ar[ur]=sr)}if(dr){if(typeof ir=="object"&&ir!==null)nr=ir;else if(typeof ir<"u")throw new TypeError("'options' must be an object.")}else nr=rr}}else if(typeof rr<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const dr of this.inputNames)if(typeof er[dr]>"u")throw new Error(`input '${dr}' is missing in 'feeds'.`);if(or)for(const dr of this.outputNames)ar[dr]=null;const lr=await this.handler.run(er,ar,nr),fr={};for(const dr in lr)Object.hasOwnProperty.call(lr,dr)&&(fr[dr]=new Tensor(lr[dr].type,lr[dr].data,lr[dr].dims));return fr}static async create(er,rr,ir,ar){let nr,or={};if(typeof er=="string"){if(nr=er,typeof rr=="object"&&rr!==null)or=rr;else if(typeof rr<"u")throw new TypeError("'options' must be an object.")}else if(er instanceof Uint8Array){if(nr=er,typeof rr=="object"&&rr!==null)or=rr;else if(typeof rr<"u")throw new TypeError("'options' must be an object.")}else if(er instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&er instanceof SharedArrayBuffer){const ur=er;let sr=0,hr=er.byteLength;if(typeof rr=="object"&&rr!==null)or=rr;else if(typeof rr=="number"){if(sr=rr,!Number.isSafeInteger(sr))throw new RangeError("'byteOffset' must be an integer.");if(sr<0||sr>=ur.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${ur.byteLength}).`);if(hr=er.byteLength-sr,typeof ir=="number"){if(hr=ir,!Number.isSafeInteger(hr))throw new RangeError("'byteLength' must be an integer.");if(hr<=0||sr+hr>ur.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${ur.byteLength-sr}].`);if(typeof ar=="object"&&ar!==null)or=ar;else if(typeof ar<"u")throw new TypeError("'options' must be an object.")}else if(typeof ir<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof rr<"u")throw new TypeError("'options' must be an object.");nr=new Uint8Array(ur,sr,hr)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");const fr=(or.executionProviders||[]).map(ur=>typeof ur=="string"?ur:ur.name),cr=await(await resolveBackend(fr)).createSessionHandler(nr,or);return new Rs(cr)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}};const InferenceSession=InferenceSession$1,lib=Object.freeze(Object.defineProperty({__proto__:null,InferenceSession,Tensor,env,registerBackend},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(lib);/*!
308
308
  * ONNX Runtime Web v1.14.0
@@ -2096,7 +2096,7 @@ ${cr}`);return hr}deleteShader(cr){this.gl.deleteShader(cr)}bindTextureToUniform
2096
2096
  `},1670:tr=>{tr.exports=__WEBPACK_EXTERNAL_MODULE__1670__},7067:()=>{},1296:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},5686:(tr,er,rr)=>{rr.r(er),rr.d(er,{flatbuffers:()=>ir});var ir={};ir.Offset,ir.Table,ir.SIZEOF_SHORT=2,ir.SIZEOF_INT=4,ir.FILE_IDENTIFIER_LENGTH=4,ir.SIZE_PREFIX_LENGTH=4,ir.Encoding={UTF8_BYTES:1,UTF16_STRING:2},ir.int32=new Int32Array(2),ir.float32=new Float32Array(ir.int32.buffer),ir.float64=new Float64Array(ir.int32.buffer),ir.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,ir.Long=function(ar,nr){this.low=0|ar,this.high=0|nr},ir.Long.create=function(ar,nr){return ar==0&&nr==0?ir.Long.ZERO:new ir.Long(ar,nr)},ir.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},ir.Long.prototype.equals=function(ar){return this.low==ar.low&&this.high==ar.high},ir.Long.ZERO=new ir.Long(0,0),ir.Builder=function(ar){if(ar)nr=ar;else var nr=1024;this.bb=ir.ByteBuffer.allocate(nr),this.space=nr,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},ir.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},ir.Builder.prototype.forceDefaults=function(ar){this.force_defaults=ar},ir.Builder.prototype.dataBuffer=function(){return this.bb},ir.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},ir.Builder.prototype.prep=function(ar,nr){ar>this.minalign&&(this.minalign=ar);for(var or=1+~(this.bb.capacity()-this.space+nr)&ar-1;this.space<or+ar+nr;){var lr=this.bb.capacity();this.bb=ir.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-lr}this.pad(or)},ir.Builder.prototype.pad=function(ar){for(var nr=0;nr<ar;nr++)this.bb.writeInt8(--this.space,0)},ir.Builder.prototype.writeInt8=function(ar){this.bb.writeInt8(this.space-=1,ar)},ir.Builder.prototype.writeInt16=function(ar){this.bb.writeInt16(this.space-=2,ar)},ir.Builder.prototype.writeInt32=function(ar){this.bb.writeInt32(this.space-=4,ar)},ir.Builder.prototype.writeInt64=function(ar){this.bb.writeInt64(this.space-=8,ar)},ir.Builder.prototype.writeFloat32=function(ar){this.bb.writeFloat32(this.space-=4,ar)},ir.Builder.prototype.writeFloat64=function(ar){this.bb.writeFloat64(this.space-=8,ar)},ir.Builder.prototype.addInt8=function(ar){this.prep(1,0),this.writeInt8(ar)},ir.Builder.prototype.addInt16=function(ar){this.prep(2,0),this.writeInt16(ar)},ir.Builder.prototype.addInt32=function(ar){this.prep(4,0),this.writeInt32(ar)},ir.Builder.prototype.addInt64=function(ar){this.prep(8,0),this.writeInt64(ar)},ir.Builder.prototype.addFloat32=function(ar){this.prep(4,0),this.writeFloat32(ar)},ir.Builder.prototype.addFloat64=function(ar){this.prep(8,0),this.writeFloat64(ar)},ir.Builder.prototype.addFieldInt8=function(ar,nr,or){(this.force_defaults||nr!=or)&&(this.addInt8(nr),this.slot(ar))},ir.Builder.prototype.addFieldInt16=function(ar,nr,or){(this.force_defaults||nr!=or)&&(this.addInt16(nr),this.slot(ar))},ir.Builder.prototype.addFieldInt32=function(ar,nr,or){(this.force_defaults||nr!=or)&&(this.addInt32(nr),this.slot(ar))},ir.Builder.prototype.addFieldInt64=function(ar,nr,or){!this.force_defaults&&nr.equals(or)||(this.addInt64(nr),this.slot(ar))},ir.Builder.prototype.addFieldFloat32=function(ar,nr,or){(this.force_defaults||nr!=or)&&(this.addFloat32(nr),this.slot(ar))},ir.Builder.prototype.addFieldFloat64=function(ar,nr,or){(this.force_defaults||nr!=or)&&(this.addFloat64(nr),this.slot(ar))},ir.Builder.prototype.addFieldOffset=function(ar,nr,or){(this.force_defaults||nr!=or)&&(this.addOffset(nr),this.slot(ar))},ir.Builder.prototype.addFieldStruct=function(ar,nr,or){nr!=or&&(this.nested(nr),this.slot(ar))},ir.Builder.prototype.nested=function(ar){if(ar!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},ir.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},ir.Builder.prototype.slot=function(ar){this.vtable[ar]=this.offset()},ir.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},ir.Builder.growByteBuffer=function(ar){var nr=ar.capacity();if(3221225472&nr)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var or=nr<<1,lr=ir.ByteBuffer.allocate(or);return lr.setPosition(or-nr),lr.bytes().set(ar.bytes(),or-nr),lr},ir.Builder.prototype.addOffset=function(ar){this.prep(ir.SIZEOF_INT,0),this.writeInt32(this.offset()-ar+ir.SIZEOF_INT)},ir.Builder.prototype.startObject=function(ar){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=ar;for(var nr=0;nr<ar;nr++)this.vtable[nr]=0;this.isNested=!0,this.object_start=this.offset()},ir.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var ar=this.offset(),nr=this.vtable_in_use-1;nr>=0&&this.vtable[nr]==0;nr--);for(var or=nr+1;nr>=0;nr--)this.addInt16(this.vtable[nr]!=0?ar-this.vtable[nr]:0);this.addInt16(ar-this.object_start);var lr=(or+2)*ir.SIZEOF_SHORT;this.addInt16(lr);var fr=0,dr=this.space;e:for(nr=0;nr<this.vtables.length;nr++){var cr=this.bb.capacity()-this.vtables[nr];if(lr==this.bb.readInt16(cr)){for(var ur=ir.SIZEOF_SHORT;ur<lr;ur+=ir.SIZEOF_SHORT)if(this.bb.readInt16(dr+ur)!=this.bb.readInt16(cr+ur))continue e;fr=this.vtables[nr];break}}return fr?(this.space=this.bb.capacity()-ar,this.bb.writeInt32(this.space,fr-ar)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-ar,this.offset()-ar)),this.isNested=!1,ar},ir.Builder.prototype.finish=function(ar,nr,or){var lr=or?ir.SIZE_PREFIX_LENGTH:0;if(nr){var fr=nr;if(this.prep(this.minalign,ir.SIZEOF_INT+ir.FILE_IDENTIFIER_LENGTH+lr),fr.length!=ir.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+ir.FILE_IDENTIFIER_LENGTH);for(var dr=ir.FILE_IDENTIFIER_LENGTH-1;dr>=0;dr--)this.writeInt8(fr.charCodeAt(dr))}this.prep(this.minalign,ir.SIZEOF_INT+lr),this.addOffset(ar),lr&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},ir.Builder.prototype.finishSizePrefixed=function(ar,nr){this.finish(ar,nr,!0)},ir.Builder.prototype.requiredField=function(ar,nr){var or=this.bb.capacity()-ar,lr=or-this.bb.readInt32(or);if(this.bb.readInt16(lr+nr)==0)throw new Error("FlatBuffers: field "+nr+" must be set")},ir.Builder.prototype.startVector=function(ar,nr,or){this.notNested(),this.vector_num_elems=nr,this.prep(ir.SIZEOF_INT,ar*nr),this.prep(or,ar*nr)},ir.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},ir.Builder.prototype.createString=function(ar){if(ar instanceof Uint8Array)var nr=ar;else{nr=[];for(var or=0;or<ar.length;){var lr,fr=ar.charCodeAt(or++);(lr=fr<55296||fr>=56320?fr:(fr<<10)+ar.charCodeAt(or++)+-56613888)<128?nr.push(lr):(lr<2048?nr.push(lr>>6&31|192):(lr<65536?nr.push(lr>>12&15|224):nr.push(lr>>18&7|240,lr>>12&63|128),nr.push(lr>>6&63|128)),nr.push(63&lr|128))}}this.addInt8(0),this.startVector(1,nr.length,1),this.bb.setPosition(this.space-=nr.length),or=0;for(var dr=this.space,cr=this.bb.bytes();or<nr.length;or++)cr[dr++]=nr[or];return this.endVector()},ir.Builder.prototype.createLong=function(ar,nr){return ir.Long.create(ar,nr)},ir.ByteBuffer=function(ar){this.bytes_=ar,this.position_=0},ir.ByteBuffer.allocate=function(ar){return new ir.ByteBuffer(new Uint8Array(ar))},ir.ByteBuffer.prototype.clear=function(){this.position_=0},ir.ByteBuffer.prototype.bytes=function(){return this.bytes_},ir.ByteBuffer.prototype.position=function(){return this.position_},ir.ByteBuffer.prototype.setPosition=function(ar){this.position_=ar},ir.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},ir.ByteBuffer.prototype.readInt8=function(ar){return this.readUint8(ar)<<24>>24},ir.ByteBuffer.prototype.readUint8=function(ar){return this.bytes_[ar]},ir.ByteBuffer.prototype.readInt16=function(ar){return this.readUint16(ar)<<16>>16},ir.ByteBuffer.prototype.readUint16=function(ar){return this.bytes_[ar]|this.bytes_[ar+1]<<8},ir.ByteBuffer.prototype.readInt32=function(ar){return this.bytes_[ar]|this.bytes_[ar+1]<<8|this.bytes_[ar+2]<<16|this.bytes_[ar+3]<<24},ir.ByteBuffer.prototype.readUint32=function(ar){return this.readInt32(ar)>>>0},ir.ByteBuffer.prototype.readInt64=function(ar){return new ir.Long(this.readInt32(ar),this.readInt32(ar+4))},ir.ByteBuffer.prototype.readUint64=function(ar){return new ir.Long(this.readUint32(ar),this.readUint32(ar+4))},ir.ByteBuffer.prototype.readFloat32=function(ar){return ir.int32[0]=this.readInt32(ar),ir.float32[0]},ir.ByteBuffer.prototype.readFloat64=function(ar){return ir.int32[ir.isLittleEndian?0:1]=this.readInt32(ar),ir.int32[ir.isLittleEndian?1:0]=this.readInt32(ar+4),ir.float64[0]},ir.ByteBuffer.prototype.writeInt8=function(ar,nr){this.bytes_[ar]=nr},ir.ByteBuffer.prototype.writeUint8=function(ar,nr){this.bytes_[ar]=nr},ir.ByteBuffer.prototype.writeInt16=function(ar,nr){this.bytes_[ar]=nr,this.bytes_[ar+1]=nr>>8},ir.ByteBuffer.prototype.writeUint16=function(ar,nr){this.bytes_[ar]=nr,this.bytes_[ar+1]=nr>>8},ir.ByteBuffer.prototype.writeInt32=function(ar,nr){this.bytes_[ar]=nr,this.bytes_[ar+1]=nr>>8,this.bytes_[ar+2]=nr>>16,this.bytes_[ar+3]=nr>>24},ir.ByteBuffer.prototype.writeUint32=function(ar,nr){this.bytes_[ar]=nr,this.bytes_[ar+1]=nr>>8,this.bytes_[ar+2]=nr>>16,this.bytes_[ar+3]=nr>>24},ir.ByteBuffer.prototype.writeInt64=function(ar,nr){this.writeInt32(ar,nr.low),this.writeInt32(ar+4,nr.high)},ir.ByteBuffer.prototype.writeUint64=function(ar,nr){this.writeUint32(ar,nr.low),this.writeUint32(ar+4,nr.high)},ir.ByteBuffer.prototype.writeFloat32=function(ar,nr){ir.float32[0]=nr,this.writeInt32(ar,ir.int32[0])},ir.ByteBuffer.prototype.writeFloat64=function(ar,nr){ir.float64[0]=nr,this.writeInt32(ar,ir.int32[ir.isLittleEndian?0:1]),this.writeInt32(ar+4,ir.int32[ir.isLittleEndian?1:0])},ir.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+ir.SIZEOF_INT+ir.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var ar="",nr=0;nr<ir.FILE_IDENTIFIER_LENGTH;nr++)ar+=String.fromCharCode(this.readInt8(this.position_+ir.SIZEOF_INT+nr));return ar},ir.ByteBuffer.prototype.__offset=function(ar,nr){var or=ar-this.readInt32(ar);return nr<this.readInt16(or)?this.readInt16(or+nr):0},ir.ByteBuffer.prototype.__union=function(ar,nr){return ar.bb_pos=nr+this.readInt32(nr),ar.bb=this,ar},ir.ByteBuffer.prototype.__string=function(ar,nr){ar+=this.readInt32(ar);var or=this.readInt32(ar),lr="",fr=0;if(ar+=ir.SIZEOF_INT,nr===ir.Encoding.UTF8_BYTES)return this.bytes_.subarray(ar,ar+or);for(;fr<or;){var dr,cr=this.readUint8(ar+fr++);if(cr<192)dr=cr;else{var ur=this.readUint8(ar+fr++);if(cr<224)dr=(31&cr)<<6|63&ur;else{var sr=this.readUint8(ar+fr++);dr=cr<240?(15&cr)<<12|(63&ur)<<6|63&sr:(7&cr)<<18|(63&ur)<<12|(63&sr)<<6|63&this.readUint8(ar+fr++)}}dr<65536?lr+=String.fromCharCode(dr):(dr-=65536,lr+=String.fromCharCode(55296+(dr>>10),56320+(1023&dr)))}return lr},ir.ByteBuffer.prototype.__indirect=function(ar){return ar+this.readInt32(ar)},ir.ByteBuffer.prototype.__vector=function(ar){return ar+this.readInt32(ar)+ir.SIZEOF_INT},ir.ByteBuffer.prototype.__vector_len=function(ar){return this.readInt32(ar+this.readInt32(ar))},ir.ByteBuffer.prototype.__has_identifier=function(ar){if(ar.length!=ir.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+ir.FILE_IDENTIFIER_LENGTH);for(var nr=0;nr<ir.FILE_IDENTIFIER_LENGTH;nr++)if(ar.charCodeAt(nr)!=this.readInt8(this.position_+ir.SIZEOF_INT+nr))return!1;return!0},ir.ByteBuffer.prototype.createLong=function(ar,nr){return ir.Long.create(ar,nr)}}},__webpack_module_cache__={};function __webpack_require__(tr){var er=__webpack_module_cache__[tr];if(er!==void 0)return er.exports;var rr=__webpack_module_cache__[tr]={exports:{}};return __webpack_modules__[tr].call(rr.exports,rr,rr.exports,__webpack_require__),rr.exports}__webpack_require__.n=tr=>{var er=tr&&tr.__esModule?()=>tr.default:()=>tr;return __webpack_require__.d(er,{a:er}),er},__webpack_require__.d=(tr,er)=>{for(var rr in er)__webpack_require__.o(er,rr)&&!__webpack_require__.o(tr,rr)&&Object.defineProperty(tr,rr,{enumerable:!0,get:er[rr]})},__webpack_require__.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),__webpack_require__.o=(tr,er)=>Object.prototype.hasOwnProperty.call(tr,er),__webpack_require__.r=tr=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(tr,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(tr,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(6018);return __webpack_exports__})())}(ortWeb_min)),ortWeb_min.exports}var assetPath={},hasRequiredAssetPath;function requireAssetPath(){if(hasRequiredAssetPath)return assetPath;hasRequiredAssetPath=1,Object.defineProperty(assetPath,"__esModule",{value:!0}),assetPath.baseAssetPath=void 0;const er=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let rr="/";return er&&(rr=er.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),assetPath.baseAssetPath=rr,assetPath}var defaultModelFetcher={},hasRequiredDefaultModelFetcher;function requireDefaultModelFetcher(){if(hasRequiredDefaultModelFetcher)return defaultModelFetcher;hasRequiredDefaultModelFetcher=1,Object.defineProperty(defaultModelFetcher,"__esModule",{value:!0}),defaultModelFetcher.defaultModelFetcher=void 0;const tr=er=>fetch(er).then(rr=>rr.arrayBuffer());return defaultModelFetcher.defaultModelFetcher=tr,defaultModelFetcher}var frameProcessor={},logging={},hasRequiredLogging;function requireLogging(){return hasRequiredLogging||(hasRequiredLogging=1,function(tr){Object.defineProperty(tr,"__esModule",{value:!0}),tr.log=tr.LOG_PREFIX=void 0,tr.LOG_PREFIX="[VAD]";const er=["error","debug","warn"];function rr(ar){return(...nr)=>{console[ar](tr.LOG_PREFIX,...nr)}}const ir=er.reduce((ar,nr)=>(ar[nr]=rr(nr),ar),{});tr.log=ir}(logging)),logging}var messages={},hasRequiredMessages;function requireMessages(){if(hasRequiredMessages)return messages;hasRequiredMessages=1,Object.defineProperty(messages,"__esModule",{value:!0}),messages.Message=void 0;var tr;return function(er){er.AudioFrame="AUDIO_FRAME",er.SpeechStart="SPEECH_START",er.VADMisfire="VAD_MISFIRE",er.SpeechEnd="SPEECH_END",er.SpeechStop="SPEECH_STOP"}(tr||(messages.Message=tr={})),messages}var hasRequiredFrameProcessor;function requireFrameProcessor(){if(hasRequiredFrameProcessor)return frameProcessor;hasRequiredFrameProcessor=1,Object.defineProperty(frameProcessor,"__esModule",{value:!0}),frameProcessor.FrameProcessor=frameProcessor.validateOptions=frameProcessor.defaultV5FrameProcessorOptions=frameProcessor.defaultLegacyFrameProcessorOptions=void 0;const tr=requireLogging(),er=requireMessages(),rr=[512,1024,1536];frameProcessor.defaultLegacyFrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.5-.15,preSpeechPadFrames:1,redemptionFrames:8,frameSamples:1536,minSpeechFrames:3,submitUserSpeechOnPause:!1},frameProcessor.defaultV5FrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.5-.15,preSpeechPadFrames:3,redemptionFrames:24,frameSamples:512,minSpeechFrames:9,submitUserSpeechOnPause:!1};function ir(or){rr.includes(or.frameSamples)||tr.log.warn("You are using an unusual frame size"),(or.positiveSpeechThreshold<0||or.positiveSpeechThreshold>1)&&tr.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(or.negativeSpeechThreshold<0||or.negativeSpeechThreshold>or.positiveSpeechThreshold)&&tr.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),or.preSpeechPadFrames<0&&tr.log.error("preSpeechPadFrames should be positive"),or.redemptionFrames<0&&tr.log.error("redemptionFrames should be positive")}frameProcessor.validateOptions=ir;const ar=or=>{const lr=or.reduce((dr,cr)=>(dr.push(dr.at(-1)+cr.length),dr),[0]),fr=new Float32Array(lr.at(-1));return or.forEach((dr,cr)=>{const ur=lr[cr];fr.set(dr,ur)}),fr};class nr{constructor(lr,fr,dr){this.modelProcessFunc=lr,this.modelResetFunc=fr,this.options=dr,this.speaking=!1,this.redemptionCounter=0,this.active=!1,this.reset=()=>{this.speaking=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0},this.pause=()=>(this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment():(this.reset(),{})),this.resume=()=>{this.active=!0},this.endSegment=()=>{const cr=this.audioBuffer;this.audioBuffer=[];const ur=this.speaking;this.reset();const sr=cr.reduce((hr,gr)=>hr+ +gr.isSpeech,0);if(ur)if(sr>=this.options.minSpeechFrames){const hr=ar(cr.map(gr=>gr.frame));return{msg:er.Message.SpeechEnd,audio:hr}}else return{msg:er.Message.VADMisfire};return{}},this.process=async cr=>{if(!this.active)return{};const ur=await this.modelProcessFunc(cr);if(this.audioBuffer.push({frame:cr,isSpeech:ur.isSpeech>=this.options.positiveSpeechThreshold}),ur.isSpeech>=this.options.positiveSpeechThreshold&&this.redemptionCounter&&(this.redemptionCounter=0),ur.isSpeech>=this.options.positiveSpeechThreshold&&!this.speaking)return this.speaking=!0,{probs:ur,msg:er.Message.SpeechStart,frame:cr};if(ur.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.options.redemptionFrames){this.redemptionCounter=0,this.speaking=!1;const sr=this.audioBuffer;if(this.audioBuffer=[],sr.reduce((gr,_r)=>gr+ +_r.isSpeech,0)>=this.options.minSpeechFrames){const gr=ar(sr.map(_r=>_r.frame));return{probs:ur,msg:er.Message.SpeechEnd,audio:gr,frame:cr}}else return{probs:ur,msg:er.Message.VADMisfire,frame:cr}}if(!this.speaking)for(;this.audioBuffer.length>this.options.preSpeechPadFrames;)this.audioBuffer.shift();return{probs:ur,frame:cr}},this.audioBuffer=[],this.reset()}}return frameProcessor.FrameProcessor=nr,frameProcessor}var nonRealTimeVad={},models={},common={},hasRequiredCommon;function requireCommon(){return hasRequiredCommon||(hasRequiredCommon=1,Object.defineProperty(common,"__esModule",{value:!0})),common}var legacy={},hasRequiredLegacy;function requireLegacy(){if(hasRequiredLegacy)return legacy;hasRequiredLegacy=1;var tr;Object.defineProperty(legacy,"__esModule",{value:!0}),legacy.SileroLegacy=void 0;const er=requireLogging();class rr{constructor(ar,nr,or,lr,fr){this.ortInstance=ar,this._session=nr,this._h=or,this._c=lr,this._sr=fr,this.reset_state=()=>{const dr=Array(128).fill(0);this._h=new this.ortInstance.Tensor("float32",dr,[2,1,64]),this._c=new this.ortInstance.Tensor("float32",dr,[2,1,64])},this.process=async dr=>{var _r;const ur={input:new this.ortInstance.Tensor("float32",dr,[1,dr.length]),h:this._h,c:this._c,sr:this._sr},sr=await this._session.run(ur);this._h=sr.hn,this._c=sr.cn;const[hr]=(_r=sr.output)==null?void 0:_r.data;return{notSpeech:1-hr,isSpeech:hr}}}}return legacy.SileroLegacy=rr,tr=rr,rr.new=async(ir,ar)=>{er.log.debug("initializing vad");const nr=await ar(),or=await ir.InferenceSession.create(nr),lr=new ir.Tensor("int64",[16000n]),fr=Array(2*64).fill(0),dr=new ir.Tensor("float32",fr,[2,1,64]),cr=new ir.Tensor("float32",fr,[2,1,64]);return er.log.debug("vad is initialized"),new tr(ir,or,dr,cr,lr)},legacy}var v5={},hasRequiredV5;function requireV5(){if(hasRequiredV5)return v5;hasRequiredV5=1;var tr;Object.defineProperty(v5,"__esModule",{value:!0}),v5.SileroV5=void 0;const er=requireLogging();function rr(ar){const nr=Array(256).fill(0);return new ar.Tensor("float32",nr,[2,1,128])}class ir{constructor(nr,or,lr,fr){this._session=nr,this._state=or,this._sr=lr,this.ortInstance=fr,this.reset_state=()=>{this._state=rr(this.ortInstance)},this.process=async dr=>{var _r;const ur={input:new this.ortInstance.Tensor("float32",dr,[1,dr.length]),state:this._state,sr:this._sr},sr=await this._session.run(ur);this._state=sr.stateN;const[hr]=(_r=sr.output)==null?void 0:_r.data;return{notSpeech:1-hr,isSpeech:hr}}}}return v5.SileroV5=ir,tr=ir,ir.new=async(ar,nr)=>{er.log.debug("Loading VAD...");const or=await nr(),lr=await ar.InferenceSession.create(or),fr=new ar.Tensor("int64",[16000n]),dr=rr(ar);return er.log.debug("...finished loading VAD"),new tr(lr,dr,fr,ar)},v5}var hasRequiredModels;function requireModels(){return hasRequiredModels||(hasRequiredModels=1,function(tr){var er=models&&models.__createBinding||(Object.create?function(nr,or,lr,fr){fr===void 0&&(fr=lr);var dr=Object.getOwnPropertyDescriptor(or,lr);(!dr||("get"in dr?!or.__esModule:dr.writable||dr.configurable))&&(dr={enumerable:!0,get:function(){return or[lr]}}),Object.defineProperty(nr,fr,dr)}:function(nr,or,lr,fr){fr===void 0&&(fr=lr),nr[fr]=or[lr]}),rr=models&&models.__exportStar||function(nr,or){for(var lr in nr)lr!=="default"&&!Object.prototype.hasOwnProperty.call(or,lr)&&er(or,nr,lr)};Object.defineProperty(tr,"__esModule",{value:!0}),tr.SileroV5=tr.SileroLegacy=void 0,rr(requireCommon(),tr);var ir=requireLegacy();Object.defineProperty(tr,"SileroLegacy",{enumerable:!0,get:function(){return ir.SileroLegacy}});var ar=requireV5();Object.defineProperty(tr,"SileroV5",{enumerable:!0,get:function(){return ar.SileroV5}})}(models)),models}var resampler={},hasRequiredResampler;function requireResampler(){if(hasRequiredResampler)return resampler;hasRequiredResampler=1,Object.defineProperty(resampler,"__esModule",{value:!0}),resampler.Resampler=void 0;const tr=requireLogging();class er{constructor(ir){this.options=ir,this.process=ar=>{const nr=[];for(const or of ar)for(this.inputBuffer.push(or);this.hasEnoughDataForFrame();){const lr=this.generateOutputFrame();nr.push(lr)}return nr},this.stream=async function*(ar){for(const nr of ar)for(this.inputBuffer.push(nr);this.hasEnoughDataForFrame();)yield this.generateOutputFrame()},ir.nativeSampleRate<16e3&&tr.log.error("nativeSampleRate is too low. Should have 16000 = targetSampleRate <= nativeSampleRate"),this.inputBuffer=[]}hasEnoughDataForFrame(){return this.inputBuffer.length*this.options.targetSampleRate/this.options.nativeSampleRate>=this.options.targetFrameSize}generateOutputFrame(){const ir=new Float32Array(this.options.targetFrameSize);let ar=0,nr=0;for(;ar<this.options.targetFrameSize;){let or=0,lr=0;for(;nr<Math.min(this.inputBuffer.length,(ar+1)*this.options.nativeSampleRate/this.options.targetSampleRate);){const fr=this.inputBuffer[nr];fr!==void 0&&(or+=fr,lr++),nr++}ir[ar]=or/lr,ar++}return this.inputBuffer=this.inputBuffer.slice(nr),ir}}return resampler.Resampler=er,resampler}var hasRequiredNonRealTimeVad;function requireNonRealTimeVad(){return hasRequiredNonRealTimeVad||(hasRequiredNonRealTimeVad=1,function(tr){Object.defineProperty(tr,"__esModule",{value:!0}),tr.PlatformAgnosticNonRealTimeVAD=tr.defaultNonRealTimeVADOptions=void 0;const er=requireFrameProcessor(),rr=requireMessages(),ir=requireModels(),ar=requireResampler();tr.defaultNonRealTimeVADOptions={...er.defaultLegacyFrameProcessorOptions,ortConfig:void 0};class nr{static async _new(lr,fr,dr={}){const cr={...tr.defaultNonRealTimeVADOptions,...dr};cr.ortConfig!==void 0&&cr.ortConfig(fr);const ur=new this(lr,fr,cr);return await ur.init(),ur}constructor(lr,fr,dr){this.modelFetcher=lr,this.ort=fr,this.options=dr,this.init=async()=>{const cr=await ir.SileroLegacy.new(this.ort,this.modelFetcher);this.frameProcessor=new er.FrameProcessor(cr.process,cr.reset_state,{frameSamples:this.options.frameSamples,positiveSpeechThreshold:this.options.positiveSpeechThreshold,negativeSpeechThreshold:this.options.negativeSpeechThreshold,redemptionFrames:this.options.redemptionFrames,preSpeechPadFrames:this.options.preSpeechPadFrames,minSpeechFrames:this.options.minSpeechFrames,submitUserSpeechOnPause:this.options.submitUserSpeechOnPause}),this.frameProcessor.resume()},this.run=async function*(cr,ur){const sr={nativeSampleRate:ur,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples},hr=new ar.Resampler(sr);let gr=0,_r=0,pr=0;for await(const Ar of hr.stream(cr)){const{msg:br,audio:yr}=await this.frameProcessor.process(Ar);switch(br){case rr.Message.SpeechStart:gr=pr*this.options.frameSamples/16;break;case rr.Message.SpeechEnd:_r=(pr+1)*this.options.frameSamples/16,yield{audio:yr,start:gr,end:_r};break}pr++}const{msg:mr,audio:Fr}=this.frameProcessor.endSegment();mr==rr.Message.SpeechEnd&&(yield{audio:Fr,start:gr,end:pr*this.options.frameSamples/16})},(0,er.validateOptions)(dr)}}tr.PlatformAgnosticNonRealTimeVAD=nr}(nonRealTimeVad)),nonRealTimeVad}var utils={},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils;hasRequiredUtils=1,Object.defineProperty(utils,"__esModule",{value:!0}),utils.audioFileToArray=utils.encodeWAV=utils.arrayBufferToBase64=utils.minFramesForTargetMS=void 0;function tr(lr,fr,dr=16e3){return Math.ceil(lr*dr/1e3/fr)}utils.minFramesForTargetMS=tr;function er(lr){const fr=new Uint8Array(lr),dr=fr.byteLength,cr=new Array(dr);for(var ur=0;ur<dr;ur++){const sr=fr[ur];if(sr===void 0)break;cr[ur]=String.fromCharCode(sr)}return btoa(cr.join(""))}utils.arrayBufferToBase64=er;function rr(lr,fr=3,dr=16e3,cr=1,ur=32){var sr=ur/8,hr=cr*sr,gr=new ArrayBuffer(44+lr.length*sr),_r=new DataView(gr);return nr(_r,0,"RIFF"),_r.setUint32(4,36+lr.length*sr,!0),nr(_r,8,"WAVE"),nr(_r,12,"fmt "),_r.setUint32(16,16,!0),_r.setUint16(20,fr,!0),_r.setUint16(22,cr,!0),_r.setUint32(24,dr,!0),_r.setUint32(28,dr*hr,!0),_r.setUint16(32,hr,!0),_r.setUint16(34,ur,!0),nr(_r,36,"data"),_r.setUint32(40,lr.length*sr,!0),fr===1?ar(_r,44,lr):ir(_r,44,lr),gr}utils.encodeWAV=rr;function ir(lr,fr,dr){for(var cr=0;cr<dr.length;cr++,fr+=4)lr.setFloat32(fr,dr[cr],!0)}function ar(lr,fr,dr){for(var cr=0;cr<dr.length;cr++,fr+=2){var ur=Math.max(-1,Math.min(1,dr[cr]));lr.setInt16(fr,ur<0?ur*32768:ur*32767,!0)}}function nr(lr,fr,dr){for(var cr=0;cr<dr.length;cr++)lr.setUint8(fr+cr,dr.charCodeAt(cr))}async function or(lr){const fr=new OfflineAudioContext(1,1,44100),dr=new FileReader;let cr=null;if(await new Promise(hr=>{dr.addEventListener("loadend",gr=>{const _r=dr.result;fr.decodeAudioData(_r,pr=>{cr=pr,fr.startRendering().then(mr=>{console.log("Rendering completed successfully"),hr()}).catch(mr=>{console.error(`Rendering failed: ${mr}`)})},pr=>{console.log(`Error with decoding audio data: ${pr}`)})}),dr.readAsArrayBuffer(lr)}),cr===null)throw Error("some shit");let ur=cr,sr=new Float32Array(ur.length);for(let hr=0;hr<ur.length;hr++)for(let gr=0;gr<ur.numberOfChannels;gr++)sr[hr]+=ur.getChannelData(gr)[hr];return{audio:sr,sampleRate:ur.sampleRate}}return utils.audioFileToArray=or,utils}var realTimeVad={},hasRequiredRealTimeVad;function requireRealTimeVad(){return hasRequiredRealTimeVad||(hasRequiredRealTimeVad=1,function(tr){var er=realTimeVad&&realTimeVad.__createBinding||(Object.create?function(mr,Fr,Ar,br){br===void 0&&(br=Ar);var yr=Object.getOwnPropertyDescriptor(Fr,Ar);(!yr||("get"in yr?!Fr.__esModule:yr.writable||yr.configurable))&&(yr={enumerable:!0,get:function(){return Fr[Ar]}}),Object.defineProperty(mr,br,yr)}:function(mr,Fr,Ar,br){br===void 0&&(br=Ar),mr[br]=Fr[Ar]}),rr=realTimeVad&&realTimeVad.__setModuleDefault||(Object.create?function(mr,Fr){Object.defineProperty(mr,"default",{enumerable:!0,value:Fr})}:function(mr,Fr){mr.default=Fr}),ir=realTimeVad&&realTimeVad.__importStar||function(mr){if(mr&&mr.__esModule)return mr;var Fr={};if(mr!=null)for(var Ar in mr)Ar!=="default"&&Object.prototype.hasOwnProperty.call(mr,Ar)&&er(Fr,mr,Ar);return rr(Fr,mr),Fr};Object.defineProperty(tr,"__esModule",{value:!0}),tr.AudioNodeVAD=tr.MicVAD=tr.getDefaultRealTimeVADOptions=tr.ort=tr.DEFAULT_MODEL=void 0;const ar=ir(requireOrtWeb_min()),nr=requireDefaultModelFetcher(),or=requireFrameProcessor(),lr=requireLogging(),fr=requireMessages(),dr=requireModels(),cr=requireResampler();tr.DEFAULT_MODEL="legacy",tr.ort=ar;const ur="vad.worklet.bundle.min.js",sr="silero_vad_v5.onnx",hr="silero_vad_legacy.onnx",gr=mr=>({...mr==="v5"?or.defaultV5FrameProcessorOptions:or.defaultLegacyFrameProcessorOptions,onFrameProcessed:Ar=>{},onVADMisfire:()=>{lr.log.debug("VAD misfire")},onSpeechStart:()=>{lr.log.debug("Detected speech start")},onSpeechEnd:()=>{lr.log.debug("Detected speech end")},baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.22/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.14.0/dist/",stream:void 0,ortConfig:void 0,model:tr.DEFAULT_MODEL,workletOptions:{}});tr.getDefaultRealTimeVADOptions=gr;class _r{static async new(Fr={}){const Ar={...(0,tr.getDefaultRealTimeVADOptions)(Fr.model??tr.DEFAULT_MODEL),...Fr};(0,or.validateOptions)(Ar);let br;Ar.stream===void 0?br=await navigator.mediaDevices.getUserMedia({audio:{...Ar.additionalAudioConstraints,channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}):br=Ar.stream;const yr=new AudioContext,xr=new MediaStreamAudioSourceNode(yr,{mediaStream:br}),wr=await pr.new(yr,Ar);return wr.receive(xr),new _r(Ar,yr,br,wr,xr)}constructor(Fr,Ar,br,yr,xr,wr=!1){this.options=Fr,this.audioContext=Ar,this.stream=br,this.audioNodeVAD=yr,this.sourceNode=xr,this.listening=wr,this.pause=()=>{this.audioNodeVAD.pause(),this.listening=!1},this.start=()=>{this.audioNodeVAD.start(),this.listening=!0},this.destroy=()=>{this.listening&&this.pause(),this.options.stream===void 0&&this.stream.getTracks().forEach(kr=>kr.stop()),this.sourceNode.disconnect(),this.audioNodeVAD.destroy(),this.audioContext.close()}}}tr.MicVAD=_r;class pr{static async new(Fr,Ar={}){const br={...(0,tr.getDefaultRealTimeVADOptions)(Ar.model??tr.DEFAULT_MODEL),...Ar};(0,or.validateOptions)(br),tr.ort.env.wasm.wasmPaths=br.onnxWASMBasePath,br.ortConfig!==void 0&&br.ortConfig(tr.ort);const yr=br.model==="v5"?sr:hr,xr=br.baseAssetPath+yr,wr=br.model==="v5"?dr.SileroV5.new:dr.SileroLegacy.new;let kr;try{kr=await wr(tr.ort,()=>(0,nr.defaultModelFetcher)(xr))}catch(Dr){throw console.error(`Encountered an error while loading model file ${xr}`),Dr}const vr=new or.FrameProcessor(kr.process,kr.reset_state,{frameSamples:br.frameSamples,positiveSpeechThreshold:br.positiveSpeechThreshold,negativeSpeechThreshold:br.negativeSpeechThreshold,redemptionFrames:br.redemptionFrames,preSpeechPadFrames:br.preSpeechPadFrames,minSpeechFrames:br.minSpeechFrames,submitUserSpeechOnPause:br.submitUserSpeechOnPause}),Er=new pr(Fr,br,vr);return await Er.setupAudioNode(),Er}constructor(Fr,Ar,br){this.ctx=Fr,this.options=Ar,this.bufferIndex=0,this.pause=()=>{const yr=this.frameProcessor.pause();this.handleFrameProcessorEvent(yr)},this.start=()=>{this.frameProcessor.resume()},this.receive=yr=>{yr.connect(this.audioNode)},this.processFrame=async yr=>{const xr=await this.frameProcessor.process(yr);this.handleFrameProcessorEvent(xr)},this.handleFrameProcessorEvent=yr=>{switch(yr.probs!==void 0&&this.options.onFrameProcessed(yr.probs,yr.frame),yr.msg){case fr.Message.SpeechStart:this.options.onSpeechStart();break;case fr.Message.VADMisfire:this.options.onVADMisfire();break;case fr.Message.SpeechEnd:this.options.onSpeechEnd(yr.audio);break}},this.destroy=()=>{var yr;this.audioNode instanceof AudioWorkletNode&&this.audioNode.port.postMessage({message:fr.Message.SpeechStop}),this.audioNode.disconnect(),(yr=this.gainNode)==null||yr.disconnect()},this.frameProcessor=br}async setupAudioNode(){if("audioWorklet"in this.ctx&&typeof AudioWorkletNode=="function")try{const yr=this.options.baseAssetPath+ur;await this.ctx.audioWorklet.addModule(yr);const xr=this.options.workletOptions??{};xr.processorOptions={...xr.processorOptions??{},frameSamples:this.options.frameSamples},this.audioNode=new AudioWorkletNode(this.ctx,"vad-helper-worklet",xr),this.audioNode.port.onmessage=async wr=>{var kr;switch((kr=wr.data)==null?void 0:kr.message){case fr.Message.AudioFrame:let vr=wr.data.data;vr instanceof ArrayBuffer||(vr=new ArrayBuffer(wr.data.data.byteLength),new Uint8Array(vr).set(new Uint8Array(wr.data.data)));const Er=new Float32Array(vr);await this.processFrame(Er);break}};return}catch(yr){console.log("AudioWorklet setup failed, falling back to ScriptProcessor",yr)}this.resampler=new cr.Resampler({nativeSampleRate:this.ctx.sampleRate,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples??480});const Ar=4096;this.audioNode=this.ctx.createScriptProcessor(Ar,1,1),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=0;let br=!1;this.audioNode.onaudioprocess=async yr=>{if(!br){br=!0;try{const xr=yr.inputBuffer.getChannelData(0);if(yr.outputBuffer.getChannelData(0).fill(0),this.resampler){const kr=this.resampler.process(xr);for(const vr of kr)await this.processFrame(vr)}}catch(xr){console.error("Error processing audio:",xr)}finally{br=!1}}},this.audioNode.connect(this.gainNode),this.gainNode.connect(this.ctx.destination)}}tr.AudioNodeVAD=pr}(realTimeVad)),realTimeVad}var hasRequiredDist$1;function requireDist$1(){return hasRequiredDist$1||(hasRequiredDist$1=1,function(tr){var er=dist&&dist.__createBinding||(Object.create?function(hr,gr,_r,pr){pr===void 0&&(pr=_r);var mr=Object.getOwnPropertyDescriptor(gr,_r);(!mr||("get"in mr?!gr.__esModule:mr.writable||mr.configurable))&&(mr={enumerable:!0,get:function(){return gr[_r]}}),Object.defineProperty(hr,pr,mr)}:function(hr,gr,_r,pr){pr===void 0&&(pr=_r),hr[pr]=gr[_r]}),rr=dist&&dist.__setModuleDefault||(Object.create?function(hr,gr){Object.defineProperty(hr,"default",{enumerable:!0,value:gr})}:function(hr,gr){hr.default=gr}),ir=dist&&dist.__importStar||function(hr){if(hr&&hr.__esModule)return hr;var gr={};if(hr!=null)for(var _r in hr)_r!=="default"&&Object.prototype.hasOwnProperty.call(hr,_r)&&er(gr,hr,_r);return rr(gr,hr),gr};Object.defineProperty(tr,"__esModule",{value:!0}),tr.NonRealTimeVAD=tr.Message=tr.FrameProcessor=tr.getDefaultRealTimeVADOptions=tr.MicVAD=tr.DEFAULT_MODEL=tr.AudioNodeVAD=tr.utils=tr.defaultNonRealTimeVADOptions=void 0;const ar=ir(requireOrtWeb_min()),nr=requireAssetPath(),or=requireDefaultModelFetcher(),lr=requireFrameProcessor();Object.defineProperty(tr,"FrameProcessor",{enumerable:!0,get:function(){return lr.FrameProcessor}});const fr=requireMessages();Object.defineProperty(tr,"Message",{enumerable:!0,get:function(){return fr.Message}});const dr=requireNonRealTimeVad(),cr=requireUtils();tr.defaultNonRealTimeVADOptions={modelURL:nr.baseAssetPath+"silero_vad_legacy.onnx",modelFetcher:or.defaultModelFetcher};class ur extends dr.PlatformAgnosticNonRealTimeVAD{static async new(gr={}){const{modelURL:_r,modelFetcher:pr}={...tr.defaultNonRealTimeVADOptions,...gr};return await this._new(()=>pr(_r),ar,gr)}}tr.NonRealTimeVAD=ur,tr.utils={audioFileToArray:cr.audioFileToArray,minFramesForTargetMS:cr.minFramesForTargetMS,arrayBufferToBase64:cr.arrayBufferToBase64,encodeWAV:cr.encodeWAV};var sr=requireRealTimeVad();Object.defineProperty(tr,"AudioNodeVAD",{enumerable:!0,get:function(){return sr.AudioNodeVAD}}),Object.defineProperty(tr,"DEFAULT_MODEL",{enumerable:!0,get:function(){return sr.DEFAULT_MODEL}}),Object.defineProperty(tr,"MicVAD",{enumerable:!0,get:function(){return sr.MicVAD}}),Object.defineProperty(tr,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return sr.getDefaultRealTimeVADOptions}})}(dist)),dist}var hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,function(tr){var er=dist$1&&dist$1.__createBinding||(Object.create?function(pr,mr,Fr,Ar){Ar===void 0&&(Ar=Fr);var br=Object.getOwnPropertyDescriptor(mr,Fr);(!br||("get"in br?!mr.__esModule:br.writable||br.configurable))&&(br={enumerable:!0,get:function(){return mr[Fr]}}),Object.defineProperty(pr,Ar,br)}:function(pr,mr,Fr,Ar){Ar===void 0&&(Ar=Fr),pr[Ar]=mr[Fr]}),rr=dist$1&&dist$1.__setModuleDefault||(Object.create?function(pr,mr){Object.defineProperty(pr,"default",{enumerable:!0,value:mr})}:function(pr,mr){pr.default=mr}),ir=dist$1&&dist$1.__importStar||function(pr){if(pr&&pr.__esModule)return pr;var mr={};if(pr!=null)for(var Fr in pr)Fr!=="default"&&Object.prototype.hasOwnProperty.call(pr,Fr)&&er(mr,pr,Fr);return rr(mr,pr),mr};Object.defineProperty(tr,"__esModule",{value:!0}),tr.useMicVAD=tr.getDefaultReactRealTimeVADOptions=tr.utils=void 0;const ar=requireDist$1(),nr=ir(React);var or=requireDist$1();Object.defineProperty(tr,"utils",{enumerable:!0,get:function(){return or.utils}});const lr={startOnLoad:!0,userSpeakingThreshold:.6},fr=pr=>({...(0,ar.getDefaultRealTimeVADOptions)(pr),...lr});tr.getDefaultReactRealTimeVADOptions=fr;const dr=Object.keys(lr),cr=Object.keys((0,ar.getDefaultRealTimeVADOptions)("v5")),ur=(pr,mr)=>pr.reduce((Fr,Ar)=>(Fr[Ar]=mr[Ar],Fr),{});function sr(pr){const mr=pr.model??ar.DEFAULT_MODEL;pr={...(0,tr.getDefaultReactRealTimeVADOptions)(mr),...pr};const Fr=ur(dr,pr),Ar=ur(cr,pr);return[Fr,Ar]}function hr(pr){const mr=nr.default.useRef(pr);return _r(()=>{mr.current=pr}),nr.default.useCallback((...Fr)=>mr.current.apply(void 0,Fr),[])}function gr(pr){const[mr,Fr]=sr(pr),[Ar,br]=(0,nr.useReducer)((jr,Hr)=>Hr>mr.userSpeakingThreshold,!1),[yr,xr]=(0,nr.useState)(!0),[wr,kr]=(0,nr.useState)(!1),[vr,Er]=(0,nr.useState)(!1),[Dr,Lr]=(0,nr.useState)(null),Tr=hr(Fr.onFrameProcessed);Fr.onFrameProcessed=hr((jr,Hr)=>{br(jr.isSpeech),Tr(jr,Hr)});const{onSpeechEnd:Rr,onSpeechStart:Pr,onVADMisfire:Br}=Fr,Ir=hr(Rr),Mr=hr(Pr),Nr=hr(Br);Fr.onSpeechEnd=Ir,Fr.onSpeechStart=Mr,Fr.onVADMisfire=Nr,(0,nr.useEffect)(()=>{let jr,Hr=!1;return(async()=>{try{if(jr=await ar.MicVAD.new(Fr),Hr){jr.destroy();return}}catch(Vr){xr(!1),Vr instanceof Error?kr(Vr.message):kr(String(Vr));return}Lr(jr),xr(!1),mr.startOnLoad&&(jr==null||jr.start(),Er(!0))})().catch(Vr=>{console.log("Well that didn't work")}),function(){jr==null||jr.destroy(),Hr=!0,!yr&&!wr&&Er(!1)}},[]);const Cr=()=>{!yr&&!wr&&(Dr==null||Dr.pause(),Er(!1))},Sr=()=>{!yr&&!wr&&(Dr==null||Dr.start(),Er(!0))};return{listening:vr,errored:wr,loading:yr,userSpeaking:Ar,pause:Cr,start:Sr,toggle:()=>{vr?Cr():Sr()}}}tr.useMicVAD=gr;const _r=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?nr.default.useLayoutEffect:nr.default.useEffect}(dist$1)),dist$1}requireDist();function AiAssistantSubmitPromptButton({prompt:tr,handleSendUserMessage:er,currentAudioSourceRef:rr,canSubmit:ir,isLoading:ar,getTranscription:nr,isVoiceEnabled:or,setIsVoiceEnabled:lr}){return tr?jsxRuntimeExports.jsx(Button,{onClick:()=>er(),disabled:!ir||ar,size:"large",icon:"arrow_up",iconVariant:"regular","data-testid":"ai-assistant-send-button",className:styles$6["ai-assistant-send-btn"],style:{cursor:!ir||ar?"not-allowed":"pointer"}}):or?jsxRuntimeExports.jsx(MicrophoneEnabledButton,{isVoiceEnabled:or,setIsVoiceEnabled:lr,handleSendUserMessage:er,currentAudioSourceRef:rr,getTranscription:nr}):jsxRuntimeExports.jsx(MicrophoneDisabledButton,{isVoiceEnabled:or,setIsVoiceEnabled:lr})}function MicrophoneEnabledButton({isVoiceEnabled:tr,setIsVoiceEnabled:er,handleSendUserMessage:rr,currentAudioSourceRef:ir,getTranscription:ar}){return null}function MicrophoneDisabledButton({isVoiceEnabled:tr,setIsVoiceEnabled:er}){return null}function ConversationList({conversations:tr,selectedConversationId:er,onConversationSelect:rr,title:ir,updatingTitleId:ar,loadMoreThreshold:nr=10}){const[or,lr]=React.useState(!1),fr=!or&&tr.length>nr,dr=or?tr.length:nr,cr=tr.slice(0,dr);return jsxRuntimeExports.jsxs(Flex,{direction:"column",gap:"8px",children:[jsxRuntimeExports.jsx("span",{className:styles$6["ai-assistant-chat-history-header"],children:ir}),cr.map(ur=>jsxRuntimeExports.jsx(Button,{variant:"transparent",size:"small",className:`${styles$6["ai-assistant-chat-history-button"]} ${er===ur.id?styles$6["conversation-selected"]:""}`,onClick:()=>rr(ur.id),children:jsxRuntimeExports.jsx("span",{className:`${styles$6["ai-assistant-chat-history-button-text"]} ${ar===ur.id?styles$6["text-updated"]:""}`,children:ur.title})},ur.id)),fr&&jsxRuntimeExports.jsx(Button,{icon:"arrow_down",iconAlignment:"right",variant:"system",size:"small",onClick:()=>lr(!0),"data-testid":"chat-history-load-more",children:"Load More"})]})}function ChatHistory({recentConversations:tr,olderConversations:er,selectedConversationId:rr,onConversationSelect:ir,updatingTitleId:ar=null,loading:nr=!1}){return nr?jsxRuntimeExports.jsx(Loader,{centered:!0,size:"small"}):jsxRuntimeExports.jsxs(Flex,{direction:"column",gap:"24px",testId:"chat-history",children:[jsxRuntimeExports.jsx(Flex,{direction:"column",gap:"8px",children:jsxRuntimeExports.jsx(ConversationList,{conversations:tr,selectedConversationId:rr,onConversationSelect:ir,title:"Past 7 days",updatingTitleId:ar})}),jsxRuntimeExports.jsx(ConversationList,{conversations:er,selectedConversationId:rr,onConversationSelect:ir,title:"Past 30 days",updatingTitleId:ar})]})}function getExpandContractIcon(tr){return tr?"arrow_up":"arrow_down"}function getCardIcon(tr){return tr.level==="error"?"warning_no_outline":"info"}function getCardIconColor(tr){return tr.level==="warn"?"yellow":"gray"}function getCardBorderColor(tr){return tr.level==="error"?"red":"transparent"}function DebugData({debugInfo:tr}){const[,er]=React.useState(0),rr=React.useCallback(()=>er(fr=>fr+1),[]),ir=React.useRef([]),ar=React.useCallback(fr=>{ir.current.push(fr),rr()},[]),nr=React.useCallback(fr=>{ir.current=ir.current.filter(dr=>dr!==fr),rr()},[]),or=React.useCallback(fr=>{ir.current.includes(fr)?nr(fr):ar(fr)},[ar,nr]),lr=React.useCallback(fr=>ir.current.includes(fr),[]);return jsxRuntimeExports.jsx(Flex,{direction:"column",gap:"8px","test-id":"debug-data",children:tr.map((fr,dr)=>jsxRuntimeExports.jsx(Card,{style:{borderTop:`1px solid ${getCardBorderColor(fr)}`},children:jsxRuntimeExports.jsxs(Flex,{direction:"column",gap:"8px",children:[jsxRuntimeExports.jsxs(Flex,{gap:"12px",alignItems:"center",justifyContent:"space-between",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(Icon,{icon:getCardIcon(fr),color:getCardIconColor(fr)})}),jsxRuntimeExports.jsxs(FlexChild,{grow:1,children:[jsxRuntimeExports.jsx("div",{children:fr.message}),fr.time?jsxRuntimeExports.jsx(UtilityText,{size:"extraSmall",children:fr.time.toLocaleString()}):null]}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(Button,{variant:"primary_inverted",size:"small",icon:getExpandContractIcon(lr(dr)),onClick:getClosureFor(or,dr),children:lr(dr)?"Collapse":"Expand"})})]}),lr(dr)&&jsxRuntimeExports.jsx("textarea",{value:JSON.stringify(fr,null,2),readOnly:!0,"data-testid":"debug-textarea",style:{minWidth:"100%",height:"100%",minHeight:"200px",maxWidth:"100%"}})]})},dr))})}const styles$5={"follow-up-suggestion-pill":"FollowUpSuggestions-module_follow-up-suggestion-pill_mkFc2"};function FollowUpSuggestions({followUpSuggestions:tr}){return!tr||tr.length===0?null:jsxRuntimeExports.jsx(Flex,{gap:"5px",alignItems:"center",justifyContent:"flex-start",wrap:"wrap",style:{marginBottom:"10px"},children:tr.map(er=>jsxRuntimeExports.jsx(FollowUpSuggestionItem,{suggestion:er},`${er==null?void 0:er.id}-${er.type}`))})}function FollowUpSuggestionItem({suggestion:tr}){const er=`follow-up-suggestion-pill-${tr.id}`;if(tr.type==="loading")return jsxRuntimeExports.jsx(Loader,{size:"extraSmall"});const rr=()=>{tr.onClick()};return jsxRuntimeExports.jsx(Pill,{onClick:rr,size:"small",variant:"gray",text:tr.title,className:styles$5["follow-up-suggestion-pill"],"data-testid":er},tr.id)}const element=document.createElement("i");function decodeNamedCharacterReference(tr){const er="&"+tr+";";element.innerHTML=er;const rr=element.textContent;return rr.charCodeAt(rr.length-1)===59&&tr!=="semi"||rr===er?!1:rr}function splice(tr,er,rr,ir){const ar=tr.length;let nr=0,or;if(er<0?er=-er>ar?0:ar+er:er=er>ar?ar:er,rr=rr>0?rr:0,ir.length<1e4)or=Array.from(ir),or.unshift(er,rr),tr.splice(...or);else for(rr&&tr.splice(er,rr);nr<ir.length;)or=ir.slice(nr,nr+1e4),or.unshift(er,0),tr.splice(...or),nr+=1e4,er+=1e4}function push(tr,er){return tr.length>0?(splice(tr,tr.length,0,er),tr):er}const hasOwnProperty$1={}.hasOwnProperty;function combineExtensions(tr){const er={};let rr=-1;for(;++rr<tr.length;)syntaxExtension(er,tr[rr]);return er}function syntaxExtension(tr,er){let rr;for(rr in er){const ar=(hasOwnProperty$1.call(tr,rr)?tr[rr]:void 0)||(tr[rr]={}),nr=er[rr];let or;if(nr)for(or in nr){hasOwnProperty$1.call(ar,or)||(ar[or]=[]);const lr=nr[or];constructs(ar[or],Array.isArray(lr)?lr:lr?[lr]:[])}}}function constructs(tr,er){let rr=-1;const ir=[];for(;++rr<er.length;)(er[rr].add==="after"?tr:ir).push(er[rr]);splice(tr,0,0,ir)}function combineHtmlExtensions(tr){const er={};let rr=-1;for(;++rr<tr.length;)htmlExtension(er,tr[rr]);return er}function htmlExtension(tr,er){let rr;for(rr in er){const ar=(hasOwnProperty$1.call(tr,rr)?tr[rr]:void 0)||(tr[rr]={}),nr=er[rr];let or;if(nr)for(or in nr)ar[or]=nr[or]}}function decodeNumericCharacterReference(tr,er){const rr=Number.parseInt(tr,er);return rr<9||rr===11||rr>13&&rr<32||rr>126&&rr<160||rr>55295&&rr<57344||rr>64975&&rr<65008||(rr&65535)===65535||(rr&65535)===65534||rr>1114111?"�":String.fromCodePoint(rr)}const characterReferences={'"':"quot","&":"amp","<":"lt",">":"gt"};function encode(tr){return tr.replace(/["&<>]/g,er);function er(rr){return"&"+characterReferences[rr]+";"}}function normalizeIdentifier(tr){return tr.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const asciiAlpha=regexCheck(/[A-Za-z]/),asciiAlphanumeric=regexCheck(/[\dA-Za-z]/),asciiAtext=regexCheck(/[#-'*+\--9=?A-Z^-~]/);function asciiControl(tr){return tr!==null&&(tr<32||tr===127)}const asciiDigit=regexCheck(/\d/),asciiHexDigit=regexCheck(/[\dA-Fa-f]/),asciiPunctuation=regexCheck(/[!-/:-@[-`{-~]/);function markdownLineEnding(tr){return tr!==null&&tr<-2}function markdownLineEndingOrSpace(tr){return tr!==null&&(tr<0||tr===32)}function markdownSpace(tr){return tr===-2||tr===-1||tr===32}const unicodePunctuation=regexCheck(new RegExp("\\p{P}|\\p{S}","u")),unicodeWhitespace=regexCheck(/\s/);function regexCheck(tr){return er;function er(rr){return rr!==null&&rr>-1&&tr.test(String.fromCharCode(rr))}}function sanitizeUri(tr,er){const rr=encode(normalizeUri(tr||""));if(!er)return rr;const ir=rr.indexOf(":"),ar=rr.indexOf("?"),nr=rr.indexOf("#"),or=rr.indexOf("/");return ir<0||or>-1&&ir>or||ar>-1&&ir>ar||nr>-1&&ir>nr||er.test(rr.slice(0,ir))?rr:""}function normalizeUri(tr){const er=[];let rr=-1,ir=0,ar=0;for(;++rr<tr.length;){const nr=tr.charCodeAt(rr);let or="";if(nr===37&&asciiAlphanumeric(tr.charCodeAt(rr+1))&&asciiAlphanumeric(tr.charCodeAt(rr+2)))ar=2;else if(nr<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(nr))||(or=String.fromCharCode(nr));else if(nr>55295&&nr<57344){const lr=tr.charCodeAt(rr+1);nr<56320&&lr>56319&&lr<57344?(or=String.fromCharCode(nr,lr),ar=1):or="�"}else or=String.fromCharCode(nr);or&&(er.push(tr.slice(ir,rr),encodeURIComponent(or)),ir=rr+ar+1,or=""),ar&&(rr+=ar,ar=0)}return er.join("")+tr.slice(ir)}const hasOwnProperty={}.hasOwnProperty,protocolHref=/^(https?|ircs?|mailto|xmpp)$/i,protocolSource=/^https?$/i;function compile(tr){const er=tr||{};let rr=!0;const ir={},ar=[[]],nr=[],or=[],fr=combineHtmlExtensions([{enter:{blockQuote:Pr,codeFenced:Nr,codeFencedFenceInfo:pr,codeFencedFenceMeta:pr,codeIndented:Ur,codeText:An,content:Tn,definition:bn,definitionDestinationString:Ln,definitionLabelString:pr,definitionTitleString:pr,emphasis:Zn,htmlFlow:xo,htmlText:ko,image:Hr,label:pr,link:Jr,listItemMarker:Dr,listItemValue:Er,listOrdered:kr,listUnordered:vr,paragraph:Ir,reference:pr,resource:on,resourceDestinationString:$r,resourceTitleString:pr,setextHeading:Un,strong:ao},exit:{atxHeading:io,atxHeadingSequence:qn,autolinkEmail:Wr,autolinkProtocol:Xn,blockQuote:Br,characterEscapeValue:so,characterReferenceMarkerHexadecimal:ho,characterReferenceMarkerNumeric:ho,characterReferenceValue:vo,codeFenced:jr,codeFencedFence:Sr,codeFencedFenceInfo:Cr,codeFencedFenceMeta:wr,codeFlowValue:Jn,codeIndented:jr,codeText:Bn,codeTextData:so,data:so,definition:In,definitionDestinationString:vn,definitionLabelString:kn,definitionTitleString:Rn,emphasis:Qn,hardBreakEscape:fo,hardBreakTrailing:fo,htmlFlow:po,htmlFlowData:so,htmlText:po,htmlTextData:so,image:gn,label:en,labelText:Vr,lineEnding:jn,link:gn,listOrdered:Lr,listUnordered:Tr,paragraph:Mr,reference:wr,referenceString:tn,resource:wr,resourceDestinationString:dn,resourceTitleString:Gr,setextHeading:yo,setextHeadingLineSequence:zn,setextHeadingText:Gn,strong:Hn,thematicBreak:Ao}},...er.htmlExtensions||[]]),dr={definitions:ir,tightStack:or},cr={buffer:pr,encode:xr,getData:_r,lineEndingIfNeeded:yr,options:er,raw:Ar,resume:mr,setData:gr,tag:Fr};let ur=er.defaultLineEnding;return sr;function sr(Qr){let nn=-1,Fn=0;const Dn=[];let Sn=[],Wn=[];for(;++nn<Qr.length;)!ur&&(Qr[nn][1].type==="lineEnding"||Qr[nn][1].type==="lineEndingBlank")&&(ur=Qr[nn][2].sliceSerialize(Qr[nn][1])),(Qr[nn][1].type==="listOrdered"||Qr[nn][1].type==="listUnordered")&&(Qr[nn][0]==="enter"?Dn.push(nn):hr(Qr.slice(Dn.pop(),nn))),Qr[nn][1].type==="definition"&&(Qr[nn][0]==="enter"?(Wn=push(Wn,Qr.slice(Fn,nn)),Fn=nn):(Sn=push(Sn,Qr.slice(Fn,nn+1)),Fn=nn+1));Sn=push(Sn,Wn),Sn=push(Sn,Qr.slice(Fn)),nn=-1;const Mn=Sn;for(fr.enter.null&&fr.enter.null.call(cr);++nn<Qr.length;){const to=fr[Mn[nn][0]],$n=Mn[nn][1].type,Kn=to[$n];hasOwnProperty.call(to,$n)&&Kn&&Kn.call({sliceSerialize:Mn[nn][2].sliceSerialize,...cr},Mn[nn][1])}return fr.exit.null&&fr.exit.null.call(cr),ar[0].join("")}function hr(Qr){const nn=Qr.length;let Fn=0,Dn=0,Sn=!1,Wn;for(;++Fn<nn;){const Mn=Qr[Fn];if(Mn[1]._container)Wn=void 0,Mn[0]==="enter"?Dn++:Dn--;else switch(Mn[1].type){case"listItemPrefix":{Mn[0]==="exit"&&(Wn=!0);break}case"linePrefix":break;case"lineEndingBlank":{Mn[0]==="enter"&&!Dn&&(Wn?Wn=void 0:Sn=!0);break}default:Wn=void 0}}Qr[0][1]._loose=Sn}function gr(Qr,nn){dr[Qr]=nn}function _r(Qr){return dr[Qr]}function pr(){ar.push([])}function mr(){return ar.pop().join("")}function Fr(Qr){rr&&(gr("lastWasTag",!0),ar[ar.length-1].push(Qr))}function Ar(Qr){gr("lastWasTag"),ar[ar.length-1].push(Qr)}function br(){Ar(ur||`
2097
2097
  `)}function yr(){const Qr=ar[ar.length-1],nn=Qr[Qr.length-1],Fn=nn?nn.charCodeAt(nn.length-1):null;Fn===10||Fn===13||Fn===null||br()}function xr(Qr){return _r("ignoreEncode")?Qr:encode(Qr)}function wr(){mr()}function kr(Qr){or.push(!Qr._loose),yr(),Fr("<ol"),gr("expectFirstItem",!0)}function vr(Qr){or.push(!Qr._loose),yr(),Fr("<ul"),gr("expectFirstItem",!0)}function Er(Qr){if(_r("expectFirstItem")){const nn=Number.parseInt(this.sliceSerialize(Qr),10);nn!==1&&Fr(' start="'+xr(String(nn))+'"')}}function Dr(){_r("expectFirstItem")?Fr(">"):Rr(),yr(),Fr("<li>"),gr("expectFirstItem"),gr("lastWasTag")}function Lr(){Rr(),or.pop(),br(),Fr("</ol>")}function Tr(){Rr(),or.pop(),br(),Fr("</ul>")}function Rr(){_r("lastWasTag")&&!_r("slurpAllLineEndings")&&yr(),Fr("</li>"),gr("slurpAllLineEndings")}function Pr(){or.push(!1),yr(),Fr("<blockquote>")}function Br(){or.pop(),yr(),Fr("</blockquote>"),gr("slurpAllLineEndings")}function Ir(){or[or.length-1]||(yr(),Fr("<p>")),gr("slurpAllLineEndings")}function Mr(){or[or.length-1]?gr("slurpAllLineEndings",!0):Fr("</p>")}function Nr(){yr(),Fr("<pre><code"),gr("fencesCount",0)}function Cr(){const Qr=mr();Fr(' class="language-'+Qr+'"')}function Sr(){const Qr=_r("fencesCount")||0;Qr||(Fr(">"),gr("slurpOneLineEnding",!0)),gr("fencesCount",Qr+1)}function Ur(){yr(),Fr("<pre><code>")}function jr(){const Qr=_r("fencesCount");Qr!==void 0&&Qr<2&&dr.tightStack.length>0&&!_r("lastWasTag")&&br(),_r("flowCodeSeenData")&&yr(),Fr("</code></pre>"),Qr!==void 0&&Qr<2&&yr(),gr("flowCodeSeenData"),gr("fencesCount"),gr("slurpOneLineEnding")}function Hr(){nr.push({image:!0}),rr=void 0}function Jr(){nr.push({})}function Vr(Qr){nr[nr.length-1].labelId=this.sliceSerialize(Qr)}function en(){nr[nr.length-1].label=mr()}function tn(Qr){nr[nr.length-1].referenceId=this.sliceSerialize(Qr)}function on(){pr(),nr[nr.length-1].destination=""}function $r(){pr(),gr("ignoreEncode",!0)}function dn(){nr[nr.length-1].destination=mr(),gr("ignoreEncode")}function Gr(){nr[nr.length-1].title=mr()}function gn(){let Qr=nr.length-1;const nn=nr[Qr],Fn=nn.referenceId||nn.labelId,Dn=nn.destination===void 0?ir[normalizeIdentifier(Fn)]:nn;for(rr=!0;Qr--;)if(nr[Qr].image){rr=void 0;break}nn.image?(Fr('<img src="'+sanitizeUri(Dn.destination,er.allowDangerousProtocol?void 0:protocolSource)+'" alt="'),Ar(nn.label),Fr('"')):Fr('<a href="'+sanitizeUri(Dn.destination,er.allowDangerousProtocol?void 0:protocolHref)+'"'),Fr(Dn.title?' title="'+Dn.title+'"':""),nn.image?Fr(" />"):(Fr(">"),Ar(nn.label),Fr("</a>")),nr.pop()}function bn(){pr(),nr.push({})}function kn(Qr){mr(),nr[nr.length-1].labelId=this.sliceSerialize(Qr)}function Ln(){pr(),gr("ignoreEncode",!0)}function vn(){nr[nr.length-1].destination=mr(),gr("ignoreEncode")}function Rn(){nr[nr.length-1].title=mr()}function In(){const Qr=nr[nr.length-1],nn=normalizeIdentifier(Qr.labelId);mr(),hasOwnProperty.call(ir,nn)||(ir[nn]=nr[nr.length-1]),nr.pop()}function Tn(){gr("slurpAllLineEndings",!0)}function qn(Qr){_r("headingRank")||(gr("headingRank",this.sliceSerialize(Qr).length),yr(),Fr("<h"+_r("headingRank")+">"))}function Un(){pr(),gr("slurpAllLineEndings")}function Gn(){gr("slurpAllLineEndings",!0)}function io(){Fr("</h"+_r("headingRank")+">"),gr("headingRank")}function zn(Qr){gr("headingRank",this.sliceSerialize(Qr).charCodeAt(0)===61?1:2)}function yo(){const Qr=mr();yr(),Fr("<h"+_r("headingRank")+">"),Ar(Qr),Fr("</h"+_r("headingRank")+">"),gr("slurpAllLineEndings"),gr("headingRank")}function so(Qr){Ar(xr(this.sliceSerialize(Qr)))}function jn(Qr){if(!_r("slurpAllLineEndings")){if(_r("slurpOneLineEnding")){gr("slurpOneLineEnding");return}if(_r("inCodeText")){Ar(" ");return}Ar(xr(this.sliceSerialize(Qr)))}}function Jn(Qr){Ar(xr(this.sliceSerialize(Qr))),gr("flowCodeSeenData",!0)}function fo(){Fr("<br />")}function xo(){yr(),ko()}function po(){gr("ignoreEncode")}function ko(){er.allowDangerousHtml&&gr("ignoreEncode",!0)}function Zn(){Fr("<em>")}function ao(){Fr("<strong>")}function An(){gr("inCodeText",!0),Fr("<code>")}function Bn(){gr("inCodeText"),Fr("</code>")}function Qn(){Fr("</em>")}function Hn(){Fr("</strong>")}function Ao(){yr(),Fr("<hr />")}function ho(Qr){gr("characterReferenceType",Qr.type)}function vo(Qr){const nn=this.sliceSerialize(Qr),Fn=_r("characterReferenceType")?decodeNumericCharacterReference(nn,_r("characterReferenceType")==="characterReferenceMarkerNumeric"?10:16):decodeNamedCharacterReference(nn);Ar(xr(Fn)),gr("characterReferenceType")}function Xn(Qr){const nn=this.sliceSerialize(Qr);Fr('<a href="'+sanitizeUri(nn,er.allowDangerousProtocol?void 0:protocolHref)+'">'),Ar(xr(nn)),Fr("</a>")}function Wr(Qr){const nn=this.sliceSerialize(Qr);Fr('<a href="'+sanitizeUri("mailto:"+nn)+'">'),Ar(xr(nn)),Fr("</a>")}}function factorySpace(tr,er,rr,ir){const ar=ir?ir-1:Number.POSITIVE_INFINITY;let nr=0;return or;function or(fr){return markdownSpace(fr)?(tr.enter(rr),lr(fr)):er(fr)}function lr(fr){return markdownSpace(fr)&&nr++<ar?(tr.consume(fr),lr):(tr.exit(rr),er(fr))}}const content$2={tokenize:initializeContent};function initializeContent(tr){const er=tr.attempt(this.parser.constructs.contentInitial,ir,ar);let rr;return er;function ir(lr){if(lr===null){tr.consume(lr);return}return tr.enter("lineEnding"),tr.consume(lr),tr.exit("lineEnding"),factorySpace(tr,er,"linePrefix")}function ar(lr){return tr.enter("paragraph"),nr(lr)}function nr(lr){const fr=tr.enter("chunkText",{contentType:"text",previous:rr});return rr&&(rr.next=fr),rr=fr,or(lr)}function or(lr){if(lr===null){tr.exit("chunkText"),tr.exit("paragraph"),tr.consume(lr);return}return markdownLineEnding(lr)?(tr.consume(lr),tr.exit("chunkText"),nr):(tr.consume(lr),or)}}const document$2={tokenize:initializeDocument},containerConstruct={tokenize:tokenizeContainer};function initializeDocument(tr){const er=this,rr=[];let ir=0,ar,nr,or;return lr;function lr(Ar){if(ir<rr.length){const br=rr[ir];return er.containerState=br[1],tr.attempt(br[0].continuation,fr,dr)(Ar)}return dr(Ar)}function fr(Ar){if(ir++,er.containerState._closeFlow){er.containerState._closeFlow=void 0,ar&&Fr();const br=er.events.length;let yr=br,xr;for(;yr--;)if(er.events[yr][0]==="exit"&&er.events[yr][1].type==="chunkFlow"){xr=er.events[yr][1].end;break}mr(ir);let wr=br;for(;wr<er.events.length;)er.events[wr][1].end={...xr},wr++;return splice(er.events,yr+1,0,er.events.slice(br)),er.events.length=wr,dr(Ar)}return lr(Ar)}function dr(Ar){if(ir===rr.length){if(!ar)return sr(Ar);if(ar.currentConstruct&&ar.currentConstruct.concrete)return gr(Ar);er.interrupt=!!(ar.currentConstruct&&!ar._gfmTableDynamicInterruptHack)}return er.containerState={},tr.check(containerConstruct,cr,ur)(Ar)}function cr(Ar){return ar&&Fr(),mr(ir),sr(Ar)}function ur(Ar){return er.parser.lazy[er.now().line]=ir!==rr.length,or=er.now().offset,gr(Ar)}function sr(Ar){return er.containerState={},tr.attempt(containerConstruct,hr,gr)(Ar)}function hr(Ar){return ir++,rr.push([er.currentConstruct,er.containerState]),sr(Ar)}function gr(Ar){if(Ar===null){ar&&Fr(),mr(0),tr.consume(Ar);return}return ar=ar||er.parser.flow(er.now()),tr.enter("chunkFlow",{_tokenizer:ar,contentType:"flow",previous:nr}),_r(Ar)}function _r(Ar){if(Ar===null){pr(tr.exit("chunkFlow"),!0),mr(0),tr.consume(Ar);return}return markdownLineEnding(Ar)?(tr.consume(Ar),pr(tr.exit("chunkFlow")),ir=0,er.interrupt=void 0,lr):(tr.consume(Ar),_r)}function pr(Ar,br){const yr=er.sliceStream(Ar);if(br&&yr.push(null),Ar.previous=nr,nr&&(nr.next=Ar),nr=Ar,ar.defineSkip(Ar.start),ar.write(yr),er.parser.lazy[Ar.start.line]){let xr=ar.events.length;for(;xr--;)if(ar.events[xr][1].start.offset<or&&(!ar.events[xr][1].end||ar.events[xr][1].end.offset>or))return;const wr=er.events.length;let kr=wr,vr,Er;for(;kr--;)if(er.events[kr][0]==="exit"&&er.events[kr][1].type==="chunkFlow"){if(vr){Er=er.events[kr][1].end;break}vr=!0}for(mr(ir),xr=wr;xr<er.events.length;)er.events[xr][1].end={...Er},xr++;splice(er.events,kr+1,0,er.events.slice(wr)),er.events.length=xr}}function mr(Ar){let br=rr.length;for(;br-- >Ar;){const yr=rr[br];er.containerState=yr[1],yr[0].exit.call(er,tr)}rr.length=Ar}function Fr(){ar.write([null]),nr=void 0,ar=void 0,er.containerState._closeFlow=void 0}}function tokenizeContainer(tr,er,rr){return factorySpace(tr,tr.attempt(this.parser.constructs.document,er,rr),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function classifyCharacter(tr){if(tr===null||markdownLineEndingOrSpace(tr)||unicodeWhitespace(tr))return 1;if(unicodePunctuation(tr))return 2}function resolveAll(tr,er,rr){const ir=[];let ar=-1;for(;++ar<tr.length;){const nr=tr[ar].resolveAll;nr&&!ir.includes(nr)&&(er=nr(er,rr),ir.push(nr))}return er}const attention={name:"attention",resolveAll:resolveAllAttention,tokenize:tokenizeAttention};function resolveAllAttention(tr,er){let rr=-1,ir,ar,nr,or,lr,fr,dr,cr;for(;++rr<tr.length;)if(tr[rr][0]==="enter"&&tr[rr][1].type==="attentionSequence"&&tr[rr][1]._close){for(ir=rr;ir--;)if(tr[ir][0]==="exit"&&tr[ir][1].type==="attentionSequence"&&tr[ir][1]._open&&er.sliceSerialize(tr[ir][1]).charCodeAt(0)===er.sliceSerialize(tr[rr][1]).charCodeAt(0)){if((tr[ir][1]._close||tr[rr][1]._open)&&(tr[rr][1].end.offset-tr[rr][1].start.offset)%3&&!((tr[ir][1].end.offset-tr[ir][1].start.offset+tr[rr][1].end.offset-tr[rr][1].start.offset)%3))continue;fr=tr[ir][1].end.offset-tr[ir][1].start.offset>1&&tr[rr][1].end.offset-tr[rr][1].start.offset>1?2:1;const ur={...tr[ir][1].end},sr={...tr[rr][1].start};movePoint(ur,-fr),movePoint(sr,fr),or={type:fr>1?"strongSequence":"emphasisSequence",start:ur,end:{...tr[ir][1].end}},lr={type:fr>1?"strongSequence":"emphasisSequence",start:{...tr[rr][1].start},end:sr},nr={type:fr>1?"strongText":"emphasisText",start:{...tr[ir][1].end},end:{...tr[rr][1].start}},ar={type:fr>1?"strong":"emphasis",start:{...or.start},end:{...lr.end}},tr[ir][1].end={...or.start},tr[rr][1].start={...lr.end},dr=[],tr[ir][1].end.offset-tr[ir][1].start.offset&&(dr=push(dr,[["enter",tr[ir][1],er],["exit",tr[ir][1],er]])),dr=push(dr,[["enter",ar,er],["enter",or,er],["exit",or,er],["enter",nr,er]]),dr=push(dr,resolveAll(er.parser.constructs.insideSpan.null,tr.slice(ir+1,rr),er)),dr=push(dr,[["exit",nr,er],["enter",lr,er],["exit",lr,er],["exit",ar,er]]),tr[rr][1].end.offset-tr[rr][1].start.offset?(cr=2,dr=push(dr,[["enter",tr[rr][1],er],["exit",tr[rr][1],er]])):cr=0,splice(tr,ir-1,rr-ir+3,dr),rr=ir+dr.length-cr-2;break}}for(rr=-1;++rr<tr.length;)tr[rr][1].type==="attentionSequence"&&(tr[rr][1].type="data");return tr}function tokenizeAttention(tr,er){const rr=this.parser.constructs.attentionMarkers.null,ir=this.previous,ar=classifyCharacter(ir);let nr;return or;function or(fr){return nr=fr,tr.enter("attentionSequence"),lr(fr)}function lr(fr){if(fr===nr)return tr.consume(fr),lr;const dr=tr.exit("attentionSequence"),cr=classifyCharacter(fr),ur=!cr||cr===2&&ar||rr.includes(fr),sr=!ar||ar===2&&cr||rr.includes(ir);return dr._open=!!(nr===42?ur:ur&&(ar||!sr)),dr._close=!!(nr===42?sr:sr&&(cr||!ur)),er(fr)}}function movePoint(tr,er){tr.column+=er,tr.offset+=er,tr._bufferIndex+=er}const autolink={name:"autolink",tokenize:tokenizeAutolink};function tokenizeAutolink(tr,er,rr){let ir=0;return ar;function ar(hr){return tr.enter("autolink"),tr.enter("autolinkMarker"),tr.consume(hr),tr.exit("autolinkMarker"),tr.enter("autolinkProtocol"),nr}function nr(hr){return asciiAlpha(hr)?(tr.consume(hr),or):hr===64?rr(hr):dr(hr)}function or(hr){return hr===43||hr===45||hr===46||asciiAlphanumeric(hr)?(ir=1,lr(hr)):dr(hr)}function lr(hr){return hr===58?(tr.consume(hr),ir=0,fr):(hr===43||hr===45||hr===46||asciiAlphanumeric(hr))&&ir++<32?(tr.consume(hr),lr):(ir=0,dr(hr))}function fr(hr){return hr===62?(tr.exit("autolinkProtocol"),tr.enter("autolinkMarker"),tr.consume(hr),tr.exit("autolinkMarker"),tr.exit("autolink"),er):hr===null||hr===32||hr===60||asciiControl(hr)?rr(hr):(tr.consume(hr),fr)}function dr(hr){return hr===64?(tr.consume(hr),cr):asciiAtext(hr)?(tr.consume(hr),dr):rr(hr)}function cr(hr){return asciiAlphanumeric(hr)?ur(hr):rr(hr)}function ur(hr){return hr===46?(tr.consume(hr),ir=0,cr):hr===62?(tr.exit("autolinkProtocol").type="autolinkEmail",tr.enter("autolinkMarker"),tr.consume(hr),tr.exit("autolinkMarker"),tr.exit("autolink"),er):sr(hr)}function sr(hr){if((hr===45||asciiAlphanumeric(hr))&&ir++<63){const gr=hr===45?sr:ur;return tr.consume(hr),gr}return rr(hr)}}const blankLine={partial:!0,tokenize:tokenizeBlankLine};function tokenizeBlankLine(tr,er,rr){return ir;function ir(nr){return markdownSpace(nr)?factorySpace(tr,ar,"linePrefix")(nr):ar(nr)}function ar(nr){return nr===null||markdownLineEnding(nr)?er(nr):rr(nr)}}const blockQuote={continuation:{tokenize:tokenizeBlockQuoteContinuation},exit,name:"blockQuote",tokenize:tokenizeBlockQuoteStart};function tokenizeBlockQuoteStart(tr,er,rr){const ir=this;return ar;function ar(or){if(or===62){const lr=ir.containerState;return lr.open||(tr.enter("blockQuote",{_container:!0}),lr.open=!0),tr.enter("blockQuotePrefix"),tr.enter("blockQuoteMarker"),tr.consume(or),tr.exit("blockQuoteMarker"),nr}return rr(or)}function nr(or){return markdownSpace(or)?(tr.enter("blockQuotePrefixWhitespace"),tr.consume(or),tr.exit("blockQuotePrefixWhitespace"),tr.exit("blockQuotePrefix"),er):(tr.exit("blockQuotePrefix"),er(or))}}function tokenizeBlockQuoteContinuation(tr,er,rr){const ir=this;return ar;function ar(or){return markdownSpace(or)?factorySpace(tr,nr,"linePrefix",ir.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(or):nr(or)}function nr(or){return tr.attempt(blockQuote,er,rr)(or)}}function exit(tr){tr.exit("blockQuote")}const characterEscape={name:"characterEscape",tokenize:tokenizeCharacterEscape};function tokenizeCharacterEscape(tr,er,rr){return ir;function ir(nr){return tr.enter("characterEscape"),tr.enter("escapeMarker"),tr.consume(nr),tr.exit("escapeMarker"),ar}function ar(nr){return asciiPunctuation(nr)?(tr.enter("characterEscapeValue"),tr.consume(nr),tr.exit("characterEscapeValue"),tr.exit("characterEscape"),er):rr(nr)}}const characterReference={name:"characterReference",tokenize:tokenizeCharacterReference};function tokenizeCharacterReference(tr,er,rr){const ir=this;let ar=0,nr,or;return lr;function lr(ur){return tr.enter("characterReference"),tr.enter("characterReferenceMarker"),tr.consume(ur),tr.exit("characterReferenceMarker"),fr}function fr(ur){return ur===35?(tr.enter("characterReferenceMarkerNumeric"),tr.consume(ur),tr.exit("characterReferenceMarkerNumeric"),dr):(tr.enter("characterReferenceValue"),nr=31,or=asciiAlphanumeric,cr(ur))}function dr(ur){return ur===88||ur===120?(tr.enter("characterReferenceMarkerHexadecimal"),tr.consume(ur),tr.exit("characterReferenceMarkerHexadecimal"),tr.enter("characterReferenceValue"),nr=6,or=asciiHexDigit,cr):(tr.enter("characterReferenceValue"),nr=7,or=asciiDigit,cr(ur))}function cr(ur){if(ur===59&&ar){const sr=tr.exit("characterReferenceValue");return or===asciiAlphanumeric&&!decodeNamedCharacterReference(ir.sliceSerialize(sr))?rr(ur):(tr.enter("characterReferenceMarker"),tr.consume(ur),tr.exit("characterReferenceMarker"),tr.exit("characterReference"),er)}return or(ur)&&ar++<nr?(tr.consume(ur),cr):rr(ur)}}const nonLazyContinuation={partial:!0,tokenize:tokenizeNonLazyContinuation},codeFenced={concrete:!0,name:"codeFenced",tokenize:tokenizeCodeFenced};function tokenizeCodeFenced(tr,er,rr){const ir=this,ar={partial:!0,tokenize:yr};let nr=0,or=0,lr;return fr;function fr(xr){return dr(xr)}function dr(xr){const wr=ir.events[ir.events.length-1];return nr=wr&&wr[1].type==="linePrefix"?wr[2].sliceSerialize(wr[1],!0).length:0,lr=xr,tr.enter("codeFenced"),tr.enter("codeFencedFence"),tr.enter("codeFencedFenceSequence"),cr(xr)}function cr(xr){return xr===lr?(or++,tr.consume(xr),cr):or<3?rr(xr):(tr.exit("codeFencedFenceSequence"),markdownSpace(xr)?factorySpace(tr,ur,"whitespace")(xr):ur(xr))}function ur(xr){return xr===null||markdownLineEnding(xr)?(tr.exit("codeFencedFence"),ir.interrupt?er(xr):tr.check(nonLazyContinuation,_r,br)(xr)):(tr.enter("codeFencedFenceInfo"),tr.enter("chunkString",{contentType:"string"}),sr(xr))}function sr(xr){return xr===null||markdownLineEnding(xr)?(tr.exit("chunkString"),tr.exit("codeFencedFenceInfo"),ur(xr)):markdownSpace(xr)?(tr.exit("chunkString"),tr.exit("codeFencedFenceInfo"),factorySpace(tr,hr,"whitespace")(xr)):xr===96&&xr===lr?rr(xr):(tr.consume(xr),sr)}function hr(xr){return xr===null||markdownLineEnding(xr)?ur(xr):(tr.enter("codeFencedFenceMeta"),tr.enter("chunkString",{contentType:"string"}),gr(xr))}function gr(xr){return xr===null||markdownLineEnding(xr)?(tr.exit("chunkString"),tr.exit("codeFencedFenceMeta"),ur(xr)):xr===96&&xr===lr?rr(xr):(tr.consume(xr),gr)}function _r(xr){return tr.attempt(ar,br,pr)(xr)}function pr(xr){return tr.enter("lineEnding"),tr.consume(xr),tr.exit("lineEnding"),mr}function mr(xr){return nr>0&&markdownSpace(xr)?factorySpace(tr,Fr,"linePrefix",nr+1)(xr):Fr(xr)}function Fr(xr){return xr===null||markdownLineEnding(xr)?tr.check(nonLazyContinuation,_r,br)(xr):(tr.enter("codeFlowValue"),Ar(xr))}function Ar(xr){return xr===null||markdownLineEnding(xr)?(tr.exit("codeFlowValue"),Fr(xr)):(tr.consume(xr),Ar)}function br(xr){return tr.exit("codeFenced"),er(xr)}function yr(xr,wr,kr){let vr=0;return Er;function Er(Pr){return xr.enter("lineEnding"),xr.consume(Pr),xr.exit("lineEnding"),Dr}function Dr(Pr){return xr.enter("codeFencedFence"),markdownSpace(Pr)?factorySpace(xr,Lr,"linePrefix",ir.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Pr):Lr(Pr)}function Lr(Pr){return Pr===lr?(xr.enter("codeFencedFenceSequence"),Tr(Pr)):kr(Pr)}function Tr(Pr){return Pr===lr?(vr++,xr.consume(Pr),Tr):vr>=or?(xr.exit("codeFencedFenceSequence"),markdownSpace(Pr)?factorySpace(xr,Rr,"whitespace")(Pr):Rr(Pr)):kr(Pr)}function Rr(Pr){return Pr===null||markdownLineEnding(Pr)?(xr.exit("codeFencedFence"),wr(Pr)):kr(Pr)}}}function tokenizeNonLazyContinuation(tr,er,rr){const ir=this;return ar;function ar(or){return or===null?rr(or):(tr.enter("lineEnding"),tr.consume(or),tr.exit("lineEnding"),nr)}function nr(or){return ir.parser.lazy[ir.now().line]?rr(or):er(or)}}const codeIndented={name:"codeIndented",tokenize:tokenizeCodeIndented},furtherStart={partial:!0,tokenize:tokenizeFurtherStart};function tokenizeCodeIndented(tr,er,rr){const ir=this;return ar;function ar(dr){return tr.enter("codeIndented"),factorySpace(tr,nr,"linePrefix",5)(dr)}function nr(dr){const cr=ir.events[ir.events.length-1];return cr&&cr[1].type==="linePrefix"&&cr[2].sliceSerialize(cr[1],!0).length>=4?or(dr):rr(dr)}function or(dr){return dr===null?fr(dr):markdownLineEnding(dr)?tr.attempt(furtherStart,or,fr)(dr):(tr.enter("codeFlowValue"),lr(dr))}function lr(dr){return dr===null||markdownLineEnding(dr)?(tr.exit("codeFlowValue"),or(dr)):(tr.consume(dr),lr)}function fr(dr){return tr.exit("codeIndented"),er(dr)}}function tokenizeFurtherStart(tr,er,rr){const ir=this;return ar;function ar(or){return ir.parser.lazy[ir.now().line]?rr(or):markdownLineEnding(or)?(tr.enter("lineEnding"),tr.consume(or),tr.exit("lineEnding"),ar):factorySpace(tr,nr,"linePrefix",5)(or)}function nr(or){const lr=ir.events[ir.events.length-1];return lr&&lr[1].type==="linePrefix"&&lr[2].sliceSerialize(lr[1],!0).length>=4?er(or):markdownLineEnding(or)?ar(or):rr(or)}}const codeText={name:"codeText",previous,resolve:resolveCodeText,tokenize:tokenizeCodeText};function resolveCodeText(tr){let er=tr.length-4,rr=3,ir,ar;if((tr[rr][1].type==="lineEnding"||tr[rr][1].type==="space")&&(tr[er][1].type==="lineEnding"||tr[er][1].type==="space")){for(ir=rr;++ir<er;)if(tr[ir][1].type==="codeTextData"){tr[rr][1].type="codeTextPadding",tr[er][1].type="codeTextPadding",rr+=2,er-=2;break}}for(ir=rr-1,er++;++ir<=er;)ar===void 0?ir!==er&&tr[ir][1].type!=="lineEnding"&&(ar=ir):(ir===er||tr[ir][1].type==="lineEnding")&&(tr[ar][1].type="codeTextData",ir!==ar+2&&(tr[ar][1].end=tr[ir-1][1].end,tr.splice(ar+2,ir-ar-2),er-=ir-ar-2,ir=ar+2),ar=void 0);return tr}function previous(tr){return tr!==96||this.events[this.events.length-1][1].type==="characterEscape"}function tokenizeCodeText(tr,er,rr){let ir=0,ar,nr;return or;function or(ur){return tr.enter("codeText"),tr.enter("codeTextSequence"),lr(ur)}function lr(ur){return ur===96?(tr.consume(ur),ir++,lr):(tr.exit("codeTextSequence"),fr(ur))}function fr(ur){return ur===null?rr(ur):ur===32?(tr.enter("space"),tr.consume(ur),tr.exit("space"),fr):ur===96?(nr=tr.enter("codeTextSequence"),ar=0,cr(ur)):markdownLineEnding(ur)?(tr.enter("lineEnding"),tr.consume(ur),tr.exit("lineEnding"),fr):(tr.enter("codeTextData"),dr(ur))}function dr(ur){return ur===null||ur===32||ur===96||markdownLineEnding(ur)?(tr.exit("codeTextData"),fr(ur)):(tr.consume(ur),dr)}function cr(ur){return ur===96?(tr.consume(ur),ar++,cr):ar===ir?(tr.exit("codeTextSequence"),tr.exit("codeText"),er(ur)):(nr.type="codeTextData",dr(ur))}}class SpliceBuffer{constructor(er){this.left=er?[...er]:[],this.right=[]}get(er){if(er<0||er>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+er+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return er<this.left.length?this.left[er]:this.right[this.right.length-er+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(er,rr){const ir=rr??Number.POSITIVE_INFINITY;return ir<this.left.length?this.left.slice(er,ir):er>this.left.length?this.right.slice(this.right.length-ir+this.left.length,this.right.length-er+this.left.length).reverse():this.left.slice(er).concat(this.right.slice(this.right.length-ir+this.left.length).reverse())}splice(er,rr,ir){const ar=rr||0;this.setCursor(Math.trunc(er));const nr=this.right.splice(this.right.length-ar,Number.POSITIVE_INFINITY);return ir&&chunkedPush(this.left,ir),nr.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(er){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(er)}pushMany(er){this.setCursor(Number.POSITIVE_INFINITY),chunkedPush(this.left,er)}unshift(er){this.setCursor(0),this.right.push(er)}unshiftMany(er){this.setCursor(0),chunkedPush(this.right,er.reverse())}setCursor(er){if(!(er===this.left.length||er>this.left.length&&this.right.length===0||er<0&&this.left.length===0))if(er<this.left.length){const rr=this.left.splice(er,Number.POSITIVE_INFINITY);chunkedPush(this.right,rr.reverse())}else{const rr=this.right.splice(this.left.length+this.right.length-er,Number.POSITIVE_INFINITY);chunkedPush(this.left,rr.reverse())}}}function chunkedPush(tr,er){let rr=0;if(er.length<1e4)tr.push(...er);else for(;rr<er.length;)tr.push(...er.slice(rr,rr+1e4)),rr+=1e4}function subtokenize(tr){const er={};let rr=-1,ir,ar,nr,or,lr,fr,dr;const cr=new SpliceBuffer(tr);for(;++rr<cr.length;){for(;rr in er;)rr=er[rr];if(ir=cr.get(rr),rr&&ir[1].type==="chunkFlow"&&cr.get(rr-1)[1].type==="listItemPrefix"&&(fr=ir[1]._tokenizer.events,nr=0,nr<fr.length&&fr[nr][1].type==="lineEndingBlank"&&(nr+=2),nr<fr.length&&fr[nr][1].type==="content"))for(;++nr<fr.length&&fr[nr][1].type!=="content";)fr[nr][1].type==="chunkText"&&(fr[nr][1]._isInFirstContentOfListItem=!0,nr++);if(ir[0]==="enter")ir[1].contentType&&(Object.assign(er,subcontent(cr,rr)),rr=er[rr],dr=!0);else if(ir[1]._container){for(nr=rr,ar=void 0;nr--;)if(or=cr.get(nr),or[1].type==="lineEnding"||or[1].type==="lineEndingBlank")or[0]==="enter"&&(ar&&(cr.get(ar)[1].type="lineEndingBlank"),or[1].type="lineEnding",ar=nr);else if(!(or[1].type==="linePrefix"||or[1].type==="listItemIndent"))break;ar&&(ir[1].end={...cr.get(ar)[1].start},lr=cr.slice(ar,rr),lr.unshift(ir),cr.splice(ar,rr-ar+1,lr))}}return splice(tr,0,Number.POSITIVE_INFINITY,cr.slice(0)),!dr}function subcontent(tr,er){const rr=tr.get(er)[1],ir=tr.get(er)[2];let ar=er-1;const nr=[];let or=rr._tokenizer;or||(or=ir.parser[rr.contentType](rr.start),rr._contentTypeTextTrailing&&(or._contentTypeTextTrailing=!0));const lr=or.events,fr=[],dr={};let cr,ur,sr=-1,hr=rr,gr=0,_r=0;const pr=[_r];for(;hr;){for(;tr.get(++ar)[1]!==hr;);nr.push(ar),hr._tokenizer||(cr=ir.sliceStream(hr),hr.next||cr.push(null),ur&&or.defineSkip(hr.start),hr._isInFirstContentOfListItem&&(or._gfmTasklistFirstContentOfListItem=!0),or.write(cr),hr._isInFirstContentOfListItem&&(or._gfmTasklistFirstContentOfListItem=void 0)),ur=hr,hr=hr.next}for(hr=rr;++sr<lr.length;)lr[sr][0]==="exit"&&lr[sr-1][0]==="enter"&&lr[sr][1].type===lr[sr-1][1].type&&lr[sr][1].start.line!==lr[sr][1].end.line&&(_r=sr+1,pr.push(_r),hr._tokenizer=void 0,hr.previous=void 0,hr=hr.next);for(or.events=[],hr?(hr._tokenizer=void 0,hr.previous=void 0):pr.pop(),sr=pr.length;sr--;){const mr=lr.slice(pr[sr],pr[sr+1]),Fr=nr.pop();fr.push([Fr,Fr+mr.length-1]),tr.splice(Fr,2,mr)}for(fr.reverse(),sr=-1;++sr<fr.length;)dr[gr+fr[sr][0]]=gr+fr[sr][1],gr+=fr[sr][1]-fr[sr][0]-1;return dr}const content$1={resolve:resolveContent,tokenize:tokenizeContent},continuationConstruct={partial:!0,tokenize:tokenizeContinuation};function resolveContent(tr){return subtokenize(tr),tr}function tokenizeContent(tr,er){let rr;return ir;function ir(lr){return tr.enter("content"),rr=tr.enter("chunkContent",{contentType:"content"}),ar(lr)}function ar(lr){return lr===null?nr(lr):markdownLineEnding(lr)?tr.check(continuationConstruct,or,nr)(lr):(tr.consume(lr),ar)}function nr(lr){return tr.exit("chunkContent"),tr.exit("content"),er(lr)}function or(lr){return tr.consume(lr),tr.exit("chunkContent"),rr.next=tr.enter("chunkContent",{contentType:"content",previous:rr}),rr=rr.next,ar}}function tokenizeContinuation(tr,er,rr){const ir=this;return ar;function ar(or){return tr.exit("chunkContent"),tr.enter("lineEnding"),tr.consume(or),tr.exit("lineEnding"),factorySpace(tr,nr,"linePrefix")}function nr(or){if(or===null||markdownLineEnding(or))return rr(or);const lr=ir.events[ir.events.length-1];return!ir.parser.constructs.disable.null.includes("codeIndented")&&lr&&lr[1].type==="linePrefix"&&lr[2].sliceSerialize(lr[1],!0).length>=4?er(or):tr.interrupt(ir.parser.constructs.flow,rr,er)(or)}}function factoryDestination(tr,er,rr,ir,ar,nr,or,lr,fr){const dr=fr||Number.POSITIVE_INFINITY;let cr=0;return ur;function ur(mr){return mr===60?(tr.enter(ir),tr.enter(ar),tr.enter(nr),tr.consume(mr),tr.exit(nr),sr):mr===null||mr===32||mr===41||asciiControl(mr)?rr(mr):(tr.enter(ir),tr.enter(or),tr.enter(lr),tr.enter("chunkString",{contentType:"string"}),_r(mr))}function sr(mr){return mr===62?(tr.enter(nr),tr.consume(mr),tr.exit(nr),tr.exit(ar),tr.exit(ir),er):(tr.enter(lr),tr.enter("chunkString",{contentType:"string"}),hr(mr))}function hr(mr){return mr===62?(tr.exit("chunkString"),tr.exit(lr),sr(mr)):mr===null||mr===60||markdownLineEnding(mr)?rr(mr):(tr.consume(mr),mr===92?gr:hr)}function gr(mr){return mr===60||mr===62||mr===92?(tr.consume(mr),hr):hr(mr)}function _r(mr){return!cr&&(mr===null||mr===41||markdownLineEndingOrSpace(mr))?(tr.exit("chunkString"),tr.exit(lr),tr.exit(or),tr.exit(ir),er(mr)):cr<dr&&mr===40?(tr.consume(mr),cr++,_r):mr===41?(tr.consume(mr),cr--,_r):mr===null||mr===32||mr===40||asciiControl(mr)?rr(mr):(tr.consume(mr),mr===92?pr:_r)}function pr(mr){return mr===40||mr===41||mr===92?(tr.consume(mr),_r):_r(mr)}}function factoryLabel(tr,er,rr,ir,ar,nr){const or=this;let lr=0,fr;return dr;function dr(hr){return tr.enter(ir),tr.enter(ar),tr.consume(hr),tr.exit(ar),tr.enter(nr),cr}function cr(hr){return lr>999||hr===null||hr===91||hr===93&&!fr||hr===94&&!lr&&"_hiddenFootnoteSupport"in or.parser.constructs?rr(hr):hr===93?(tr.exit(nr),tr.enter(ar),tr.consume(hr),tr.exit(ar),tr.exit(ir),er):markdownLineEnding(hr)?(tr.enter("lineEnding"),tr.consume(hr),tr.exit("lineEnding"),cr):(tr.enter("chunkString",{contentType:"string"}),ur(hr))}function ur(hr){return hr===null||hr===91||hr===93||markdownLineEnding(hr)||lr++>999?(tr.exit("chunkString"),cr(hr)):(tr.consume(hr),fr||(fr=!markdownSpace(hr)),hr===92?sr:ur)}function sr(hr){return hr===91||hr===92||hr===93?(tr.consume(hr),lr++,ur):ur(hr)}}function factoryTitle(tr,er,rr,ir,ar,nr){let or;return lr;function lr(sr){return sr===34||sr===39||sr===40?(tr.enter(ir),tr.enter(ar),tr.consume(sr),tr.exit(ar),or=sr===40?41:sr,fr):rr(sr)}function fr(sr){return sr===or?(tr.enter(ar),tr.consume(sr),tr.exit(ar),tr.exit(ir),er):(tr.enter(nr),dr(sr))}function dr(sr){return sr===or?(tr.exit(nr),fr(or)):sr===null?rr(sr):markdownLineEnding(sr)?(tr.enter("lineEnding"),tr.consume(sr),tr.exit("lineEnding"),factorySpace(tr,dr,"linePrefix")):(tr.enter("chunkString",{contentType:"string"}),cr(sr))}function cr(sr){return sr===or||sr===null||markdownLineEnding(sr)?(tr.exit("chunkString"),dr(sr)):(tr.consume(sr),sr===92?ur:cr)}function ur(sr){return sr===or||sr===92?(tr.consume(sr),cr):cr(sr)}}function factoryWhitespace(tr,er){let rr;return ir;function ir(ar){return markdownLineEnding(ar)?(tr.enter("lineEnding"),tr.consume(ar),tr.exit("lineEnding"),rr=!0,ir):markdownSpace(ar)?factorySpace(tr,ir,rr?"linePrefix":"lineSuffix")(ar):er(ar)}}const definition={name:"definition",tokenize:tokenizeDefinition},titleBefore={partial:!0,tokenize:tokenizeTitleBefore};function tokenizeDefinition(tr,er,rr){const ir=this;let ar;return nr;function nr(hr){return tr.enter("definition"),or(hr)}function or(hr){return factoryLabel.call(ir,tr,lr,rr,"definitionLabel","definitionLabelMarker","definitionLabelString")(hr)}function lr(hr){return ar=normalizeIdentifier(ir.sliceSerialize(ir.events[ir.events.length-1][1]).slice(1,-1)),hr===58?(tr.enter("definitionMarker"),tr.consume(hr),tr.exit("definitionMarker"),fr):rr(hr)}function fr(hr){return markdownLineEndingOrSpace(hr)?factoryWhitespace(tr,dr)(hr):dr(hr)}function dr(hr){return factoryDestination(tr,cr,rr,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(hr)}function cr(hr){return tr.attempt(titleBefore,ur,ur)(hr)}function ur(hr){return markdownSpace(hr)?factorySpace(tr,sr,"whitespace")(hr):sr(hr)}function sr(hr){return hr===null||markdownLineEnding(hr)?(tr.exit("definition"),ir.parser.defined.push(ar),er(hr)):rr(hr)}}function tokenizeTitleBefore(tr,er,rr){return ir;function ir(lr){return markdownLineEndingOrSpace(lr)?factoryWhitespace(tr,ar)(lr):rr(lr)}function ar(lr){return factoryTitle(tr,nr,rr,"definitionTitle","definitionTitleMarker","definitionTitleString")(lr)}function nr(lr){return markdownSpace(lr)?factorySpace(tr,or,"whitespace")(lr):or(lr)}function or(lr){return lr===null||markdownLineEnding(lr)?er(lr):rr(lr)}}const hardBreakEscape={name:"hardBreakEscape",tokenize:tokenizeHardBreakEscape};function tokenizeHardBreakEscape(tr,er,rr){return ir;function ir(nr){return tr.enter("hardBreakEscape"),tr.consume(nr),ar}function ar(nr){return markdownLineEnding(nr)?(tr.exit("hardBreakEscape"),er(nr)):rr(nr)}}const headingAtx={name:"headingAtx",resolve:resolveHeadingAtx,tokenize:tokenizeHeadingAtx};function resolveHeadingAtx(tr,er){let rr=tr.length-2,ir=3,ar,nr;return tr[ir][1].type==="whitespace"&&(ir+=2),rr-2>ir&&tr[rr][1].type==="whitespace"&&(rr-=2),tr[rr][1].type==="atxHeadingSequence"&&(ir===rr-1||rr-4>ir&&tr[rr-2][1].type==="whitespace")&&(rr-=ir+1===rr?2:4),rr>ir&&(ar={type:"atxHeadingText",start:tr[ir][1].start,end:tr[rr][1].end},nr={type:"chunkText",start:tr[ir][1].start,end:tr[rr][1].end,contentType:"text"},splice(tr,ir,rr-ir+1,[["enter",ar,er],["enter",nr,er],["exit",nr,er],["exit",ar,er]])),tr}function tokenizeHeadingAtx(tr,er,rr){let ir=0;return ar;function ar(cr){return tr.enter("atxHeading"),nr(cr)}function nr(cr){return tr.enter("atxHeadingSequence"),or(cr)}function or(cr){return cr===35&&ir++<6?(tr.consume(cr),or):cr===null||markdownLineEndingOrSpace(cr)?(tr.exit("atxHeadingSequence"),lr(cr)):rr(cr)}function lr(cr){return cr===35?(tr.enter("atxHeadingSequence"),fr(cr)):cr===null||markdownLineEnding(cr)?(tr.exit("atxHeading"),er(cr)):markdownSpace(cr)?factorySpace(tr,lr,"whitespace")(cr):(tr.enter("atxHeadingText"),dr(cr))}function fr(cr){return cr===35?(tr.consume(cr),fr):(tr.exit("atxHeadingSequence"),lr(cr))}function dr(cr){return cr===null||cr===35||markdownLineEndingOrSpace(cr)?(tr.exit("atxHeadingText"),lr(cr)):(tr.consume(cr),dr)}}const htmlBlockNames=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],htmlRawNames=["pre","script","style","textarea"],htmlFlow={concrete:!0,name:"htmlFlow",resolveTo:resolveToHtmlFlow,tokenize:tokenizeHtmlFlow},blankLineBefore={partial:!0,tokenize:tokenizeBlankLineBefore},nonLazyContinuationStart={partial:!0,tokenize:tokenizeNonLazyContinuationStart};function resolveToHtmlFlow(tr){let er=tr.length;for(;er--&&!(tr[er][0]==="enter"&&tr[er][1].type==="htmlFlow"););return er>1&&tr[er-2][1].type==="linePrefix"&&(tr[er][1].start=tr[er-2][1].start,tr[er+1][1].start=tr[er-2][1].start,tr.splice(er-2,2)),tr}function tokenizeHtmlFlow(tr,er,rr){const ir=this;let ar,nr,or,lr,fr;return dr;function dr(jr){return cr(jr)}function cr(jr){return tr.enter("htmlFlow"),tr.enter("htmlFlowData"),tr.consume(jr),ur}function ur(jr){return jr===33?(tr.consume(jr),sr):jr===47?(tr.consume(jr),nr=!0,_r):jr===63?(tr.consume(jr),ar=3,ir.interrupt?er:Cr):asciiAlpha(jr)?(tr.consume(jr),or=String.fromCharCode(jr),pr):rr(jr)}function sr(jr){return jr===45?(tr.consume(jr),ar=2,hr):jr===91?(tr.consume(jr),ar=5,lr=0,gr):asciiAlpha(jr)?(tr.consume(jr),ar=4,ir.interrupt?er:Cr):rr(jr)}function hr(jr){return jr===45?(tr.consume(jr),ir.interrupt?er:Cr):rr(jr)}function gr(jr){const Hr="CDATA[";return jr===Hr.charCodeAt(lr++)?(tr.consume(jr),lr===Hr.length?ir.interrupt?er:Lr:gr):rr(jr)}function _r(jr){return asciiAlpha(jr)?(tr.consume(jr),or=String.fromCharCode(jr),pr):rr(jr)}function pr(jr){if(jr===null||jr===47||jr===62||markdownLineEndingOrSpace(jr)){const Hr=jr===47,Jr=or.toLowerCase();return!Hr&&!nr&&htmlRawNames.includes(Jr)?(ar=1,ir.interrupt?er(jr):Lr(jr)):htmlBlockNames.includes(or.toLowerCase())?(ar=6,Hr?(tr.consume(jr),mr):ir.interrupt?er(jr):Lr(jr)):(ar=7,ir.interrupt&&!ir.parser.lazy[ir.now().line]?rr(jr):nr?Fr(jr):Ar(jr))}return jr===45||asciiAlphanumeric(jr)?(tr.consume(jr),or+=String.fromCharCode(jr),pr):rr(jr)}function mr(jr){return jr===62?(tr.consume(jr),ir.interrupt?er:Lr):rr(jr)}function Fr(jr){return markdownSpace(jr)?(tr.consume(jr),Fr):Er(jr)}function Ar(jr){return jr===47?(tr.consume(jr),Er):jr===58||jr===95||asciiAlpha(jr)?(tr.consume(jr),br):markdownSpace(jr)?(tr.consume(jr),Ar):Er(jr)}function br(jr){return jr===45||jr===46||jr===58||jr===95||asciiAlphanumeric(jr)?(tr.consume(jr),br):yr(jr)}function yr(jr){return jr===61?(tr.consume(jr),xr):markdownSpace(jr)?(tr.consume(jr),yr):Ar(jr)}function xr(jr){return jr===null||jr===60||jr===61||jr===62||jr===96?rr(jr):jr===34||jr===39?(tr.consume(jr),fr=jr,wr):markdownSpace(jr)?(tr.consume(jr),xr):kr(jr)}function wr(jr){return jr===fr?(tr.consume(jr),fr=null,vr):jr===null||markdownLineEnding(jr)?rr(jr):(tr.consume(jr),wr)}function kr(jr){return jr===null||jr===34||jr===39||jr===47||jr===60||jr===61||jr===62||jr===96||markdownLineEndingOrSpace(jr)?yr(jr):(tr.consume(jr),kr)}function vr(jr){return jr===47||jr===62||markdownSpace(jr)?Ar(jr):rr(jr)}function Er(jr){return jr===62?(tr.consume(jr),Dr):rr(jr)}function Dr(jr){return jr===null||markdownLineEnding(jr)?Lr(jr):markdownSpace(jr)?(tr.consume(jr),Dr):rr(jr)}function Lr(jr){return jr===45&&ar===2?(tr.consume(jr),Br):jr===60&&ar===1?(tr.consume(jr),Ir):jr===62&&ar===4?(tr.consume(jr),Sr):jr===63&&ar===3?(tr.consume(jr),Cr):jr===93&&ar===5?(tr.consume(jr),Nr):markdownLineEnding(jr)&&(ar===6||ar===7)?(tr.exit("htmlFlowData"),tr.check(blankLineBefore,Ur,Tr)(jr)):jr===null||markdownLineEnding(jr)?(tr.exit("htmlFlowData"),Tr(jr)):(tr.consume(jr),Lr)}function Tr(jr){return tr.check(nonLazyContinuationStart,Rr,Ur)(jr)}function Rr(jr){return tr.enter("lineEnding"),tr.consume(jr),tr.exit("lineEnding"),Pr}function Pr(jr){return jr===null||markdownLineEnding(jr)?Tr(jr):(tr.enter("htmlFlowData"),Lr(jr))}function Br(jr){return jr===45?(tr.consume(jr),Cr):Lr(jr)}function Ir(jr){return jr===47?(tr.consume(jr),or="",Mr):Lr(jr)}function Mr(jr){if(jr===62){const Hr=or.toLowerCase();return htmlRawNames.includes(Hr)?(tr.consume(jr),Sr):Lr(jr)}return asciiAlpha(jr)&&or.length<8?(tr.consume(jr),or+=String.fromCharCode(jr),Mr):Lr(jr)}function Nr(jr){return jr===93?(tr.consume(jr),Cr):Lr(jr)}function Cr(jr){return jr===62?(tr.consume(jr),Sr):jr===45&&ar===2?(tr.consume(jr),Cr):Lr(jr)}function Sr(jr){return jr===null||markdownLineEnding(jr)?(tr.exit("htmlFlowData"),Ur(jr)):(tr.consume(jr),Sr)}function Ur(jr){return tr.exit("htmlFlow"),er(jr)}}function tokenizeNonLazyContinuationStart(tr,er,rr){const ir=this;return ar;function ar(or){return markdownLineEnding(or)?(tr.enter("lineEnding"),tr.consume(or),tr.exit("lineEnding"),nr):rr(or)}function nr(or){return ir.parser.lazy[ir.now().line]?rr(or):er(or)}}function tokenizeBlankLineBefore(tr,er,rr){return ir;function ir(ar){return tr.enter("lineEnding"),tr.consume(ar),tr.exit("lineEnding"),tr.attempt(blankLine,er,rr)}}const htmlText={name:"htmlText",tokenize:tokenizeHtmlText};function tokenizeHtmlText(tr,er,rr){const ir=this;let ar,nr,or;return lr;function lr(Cr){return tr.enter("htmlText"),tr.enter("htmlTextData"),tr.consume(Cr),fr}function fr(Cr){return Cr===33?(tr.consume(Cr),dr):Cr===47?(tr.consume(Cr),yr):Cr===63?(tr.consume(Cr),Ar):asciiAlpha(Cr)?(tr.consume(Cr),kr):rr(Cr)}function dr(Cr){return Cr===45?(tr.consume(Cr),cr):Cr===91?(tr.consume(Cr),nr=0,gr):asciiAlpha(Cr)?(tr.consume(Cr),Fr):rr(Cr)}function cr(Cr){return Cr===45?(tr.consume(Cr),hr):rr(Cr)}function ur(Cr){return Cr===null?rr(Cr):Cr===45?(tr.consume(Cr),sr):markdownLineEnding(Cr)?(or=ur,Ir(Cr)):(tr.consume(Cr),ur)}function sr(Cr){return Cr===45?(tr.consume(Cr),hr):ur(Cr)}function hr(Cr){return Cr===62?Br(Cr):Cr===45?sr(Cr):ur(Cr)}function gr(Cr){const Sr="CDATA[";return Cr===Sr.charCodeAt(nr++)?(tr.consume(Cr),nr===Sr.length?_r:gr):rr(Cr)}function _r(Cr){return Cr===null?rr(Cr):Cr===93?(tr.consume(Cr),pr):markdownLineEnding(Cr)?(or=_r,Ir(Cr)):(tr.consume(Cr),_r)}function pr(Cr){return Cr===93?(tr.consume(Cr),mr):_r(Cr)}function mr(Cr){return Cr===62?Br(Cr):Cr===93?(tr.consume(Cr),mr):_r(Cr)}function Fr(Cr){return Cr===null||Cr===62?Br(Cr):markdownLineEnding(Cr)?(or=Fr,Ir(Cr)):(tr.consume(Cr),Fr)}function Ar(Cr){return Cr===null?rr(Cr):Cr===63?(tr.consume(Cr),br):markdownLineEnding(Cr)?(or=Ar,Ir(Cr)):(tr.consume(Cr),Ar)}function br(Cr){return Cr===62?Br(Cr):Ar(Cr)}function yr(Cr){return asciiAlpha(Cr)?(tr.consume(Cr),xr):rr(Cr)}function xr(Cr){return Cr===45||asciiAlphanumeric(Cr)?(tr.consume(Cr),xr):wr(Cr)}function wr(Cr){return markdownLineEnding(Cr)?(or=wr,Ir(Cr)):markdownSpace(Cr)?(tr.consume(Cr),wr):Br(Cr)}function kr(Cr){return Cr===45||asciiAlphanumeric(Cr)?(tr.consume(Cr),kr):Cr===47||Cr===62||markdownLineEndingOrSpace(Cr)?vr(Cr):rr(Cr)}function vr(Cr){return Cr===47?(tr.consume(Cr),Br):Cr===58||Cr===95||asciiAlpha(Cr)?(tr.consume(Cr),Er):markdownLineEnding(Cr)?(or=vr,Ir(Cr)):markdownSpace(Cr)?(tr.consume(Cr),vr):Br(Cr)}function Er(Cr){return Cr===45||Cr===46||Cr===58||Cr===95||asciiAlphanumeric(Cr)?(tr.consume(Cr),Er):Dr(Cr)}function Dr(Cr){return Cr===61?(tr.consume(Cr),Lr):markdownLineEnding(Cr)?(or=Dr,Ir(Cr)):markdownSpace(Cr)?(tr.consume(Cr),Dr):vr(Cr)}function Lr(Cr){return Cr===null||Cr===60||Cr===61||Cr===62||Cr===96?rr(Cr):Cr===34||Cr===39?(tr.consume(Cr),ar=Cr,Tr):markdownLineEnding(Cr)?(or=Lr,Ir(Cr)):markdownSpace(Cr)?(tr.consume(Cr),Lr):(tr.consume(Cr),Rr)}function Tr(Cr){return Cr===ar?(tr.consume(Cr),ar=void 0,Pr):Cr===null?rr(Cr):markdownLineEnding(Cr)?(or=Tr,Ir(Cr)):(tr.consume(Cr),Tr)}function Rr(Cr){return Cr===null||Cr===34||Cr===39||Cr===60||Cr===61||Cr===96?rr(Cr):Cr===47||Cr===62||markdownLineEndingOrSpace(Cr)?vr(Cr):(tr.consume(Cr),Rr)}function Pr(Cr){return Cr===47||Cr===62||markdownLineEndingOrSpace(Cr)?vr(Cr):rr(Cr)}function Br(Cr){return Cr===62?(tr.consume(Cr),tr.exit("htmlTextData"),tr.exit("htmlText"),er):rr(Cr)}function Ir(Cr){return tr.exit("htmlTextData"),tr.enter("lineEnding"),tr.consume(Cr),tr.exit("lineEnding"),Mr}function Mr(Cr){return markdownSpace(Cr)?factorySpace(tr,Nr,"linePrefix",ir.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Cr):Nr(Cr)}function Nr(Cr){return tr.enter("htmlTextData"),or(Cr)}}const labelEnd={name:"labelEnd",resolveAll:resolveAllLabelEnd,resolveTo:resolveToLabelEnd,tokenize:tokenizeLabelEnd},resourceConstruct={tokenize:tokenizeResource},referenceFullConstruct={tokenize:tokenizeReferenceFull},referenceCollapsedConstruct={tokenize:tokenizeReferenceCollapsed};function resolveAllLabelEnd(tr){let er=-1;const rr=[];for(;++er<tr.length;){const ir=tr[er][1];if(rr.push(tr[er]),ir.type==="labelImage"||ir.type==="labelLink"||ir.type==="labelEnd"){const ar=ir.type==="labelImage"?4:2;ir.type="data",er+=ar}}return tr.length!==rr.length&&splice(tr,0,tr.length,rr),tr}function resolveToLabelEnd(tr,er){let rr=tr.length,ir=0,ar,nr,or,lr;for(;rr--;)if(ar=tr[rr][1],nr){if(ar.type==="link"||ar.type==="labelLink"&&ar._inactive)break;tr[rr][0]==="enter"&&ar.type==="labelLink"&&(ar._inactive=!0)}else if(or){if(tr[rr][0]==="enter"&&(ar.type==="labelImage"||ar.type==="labelLink")&&!ar._balanced&&(nr=rr,ar.type!=="labelLink")){ir=2;break}}else ar.type==="labelEnd"&&(or=rr);const fr={type:tr[nr][1].type==="labelLink"?"link":"image",start:{...tr[nr][1].start},end:{...tr[tr.length-1][1].end}},dr={type:"label",start:{...tr[nr][1].start},end:{...tr[or][1].end}},cr={type:"labelText",start:{...tr[nr+ir+2][1].end},end:{...tr[or-2][1].start}};return lr=[["enter",fr,er],["enter",dr,er]],lr=push(lr,tr.slice(nr+1,nr+ir+3)),lr=push(lr,[["enter",cr,er]]),lr=push(lr,resolveAll(er.parser.constructs.insideSpan.null,tr.slice(nr+ir+4,or-3),er)),lr=push(lr,[["exit",cr,er],tr[or-2],tr[or-1],["exit",dr,er]]),lr=push(lr,tr.slice(or+1)),lr=push(lr,[["exit",fr,er]]),splice(tr,nr,tr.length,lr),tr}function tokenizeLabelEnd(tr,er,rr){const ir=this;let ar=ir.events.length,nr,or;for(;ar--;)if((ir.events[ar][1].type==="labelImage"||ir.events[ar][1].type==="labelLink")&&!ir.events[ar][1]._balanced){nr=ir.events[ar][1];break}return lr;function lr(sr){return nr?nr._inactive?ur(sr):(or=ir.parser.defined.includes(normalizeIdentifier(ir.sliceSerialize({start:nr.end,end:ir.now()}))),tr.enter("labelEnd"),tr.enter("labelMarker"),tr.consume(sr),tr.exit("labelMarker"),tr.exit("labelEnd"),fr):rr(sr)}function fr(sr){return sr===40?tr.attempt(resourceConstruct,cr,or?cr:ur)(sr):sr===91?tr.attempt(referenceFullConstruct,cr,or?dr:ur)(sr):or?cr(sr):ur(sr)}function dr(sr){return tr.attempt(referenceCollapsedConstruct,cr,ur)(sr)}function cr(sr){return er(sr)}function ur(sr){return nr._balanced=!0,rr(sr)}}function tokenizeResource(tr,er,rr){return ir;function ir(ur){return tr.enter("resource"),tr.enter("resourceMarker"),tr.consume(ur),tr.exit("resourceMarker"),ar}function ar(ur){return markdownLineEndingOrSpace(ur)?factoryWhitespace(tr,nr)(ur):nr(ur)}function nr(ur){return ur===41?cr(ur):factoryDestination(tr,or,lr,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(ur)}function or(ur){return markdownLineEndingOrSpace(ur)?factoryWhitespace(tr,fr)(ur):cr(ur)}function lr(ur){return rr(ur)}function fr(ur){return ur===34||ur===39||ur===40?factoryTitle(tr,dr,rr,"resourceTitle","resourceTitleMarker","resourceTitleString")(ur):cr(ur)}function dr(ur){return markdownLineEndingOrSpace(ur)?factoryWhitespace(tr,cr)(ur):cr(ur)}function cr(ur){return ur===41?(tr.enter("resourceMarker"),tr.consume(ur),tr.exit("resourceMarker"),tr.exit("resource"),er):rr(ur)}}function tokenizeReferenceFull(tr,er,rr){const ir=this;return ar;function ar(lr){return factoryLabel.call(ir,tr,nr,or,"reference","referenceMarker","referenceString")(lr)}function nr(lr){return ir.parser.defined.includes(normalizeIdentifier(ir.sliceSerialize(ir.events[ir.events.length-1][1]).slice(1,-1)))?er(lr):rr(lr)}function or(lr){return rr(lr)}}function tokenizeReferenceCollapsed(tr,er,rr){return ir;function ir(nr){return tr.enter("reference"),tr.enter("referenceMarker"),tr.consume(nr),tr.exit("referenceMarker"),ar}function ar(nr){return nr===93?(tr.enter("referenceMarker"),tr.consume(nr),tr.exit("referenceMarker"),tr.exit("reference"),er):rr(nr)}}const labelStartImage={name:"labelStartImage",resolveAll:labelEnd.resolveAll,tokenize:tokenizeLabelStartImage};function tokenizeLabelStartImage(tr,er,rr){const ir=this;return ar;function ar(lr){return tr.enter("labelImage"),tr.enter("labelImageMarker"),tr.consume(lr),tr.exit("labelImageMarker"),nr}function nr(lr){return lr===91?(tr.enter("labelMarker"),tr.consume(lr),tr.exit("labelMarker"),tr.exit("labelImage"),or):rr(lr)}function or(lr){return lr===94&&"_hiddenFootnoteSupport"in ir.parser.constructs?rr(lr):er(lr)}}const labelStartLink={name:"labelStartLink",resolveAll:labelEnd.resolveAll,tokenize:tokenizeLabelStartLink};function tokenizeLabelStartLink(tr,er,rr){const ir=this;return ar;function ar(or){return tr.enter("labelLink"),tr.enter("labelMarker"),tr.consume(or),tr.exit("labelMarker"),tr.exit("labelLink"),nr}function nr(or){return or===94&&"_hiddenFootnoteSupport"in ir.parser.constructs?rr(or):er(or)}}const lineEnding={name:"lineEnding",tokenize:tokenizeLineEnding};function tokenizeLineEnding(tr,er){return rr;function rr(ir){return tr.enter("lineEnding"),tr.consume(ir),tr.exit("lineEnding"),factorySpace(tr,er,"linePrefix")}}const thematicBreak={name:"thematicBreak",tokenize:tokenizeThematicBreak};function tokenizeThematicBreak(tr,er,rr){let ir=0,ar;return nr;function nr(dr){return tr.enter("thematicBreak"),or(dr)}function or(dr){return ar=dr,lr(dr)}function lr(dr){return dr===ar?(tr.enter("thematicBreakSequence"),fr(dr)):ir>=3&&(dr===null||markdownLineEnding(dr))?(tr.exit("thematicBreak"),er(dr)):rr(dr)}function fr(dr){return dr===ar?(tr.consume(dr),ir++,fr):(tr.exit("thematicBreakSequence"),markdownSpace(dr)?factorySpace(tr,lr,"whitespace")(dr):lr(dr))}}const list={continuation:{tokenize:tokenizeListContinuation},exit:tokenizeListEnd,name:"list",tokenize:tokenizeListStart},listItemPrefixWhitespaceConstruct={partial:!0,tokenize:tokenizeListItemPrefixWhitespace},indentConstruct={partial:!0,tokenize:tokenizeIndent};function tokenizeListStart(tr,er,rr){const ir=this,ar=ir.events[ir.events.length-1];let nr=ar&&ar[1].type==="linePrefix"?ar[2].sliceSerialize(ar[1],!0).length:0,or=0;return lr;function lr(hr){const gr=ir.containerState.type||(hr===42||hr===43||hr===45?"listUnordered":"listOrdered");if(gr==="listUnordered"?!ir.containerState.marker||hr===ir.containerState.marker:asciiDigit(hr)){if(ir.containerState.type||(ir.containerState.type=gr,tr.enter(gr,{_container:!0})),gr==="listUnordered")return tr.enter("listItemPrefix"),hr===42||hr===45?tr.check(thematicBreak,rr,dr)(hr):dr(hr);if(!ir.interrupt||hr===49)return tr.enter("listItemPrefix"),tr.enter("listItemValue"),fr(hr)}return rr(hr)}function fr(hr){return asciiDigit(hr)&&++or<10?(tr.consume(hr),fr):(!ir.interrupt||or<2)&&(ir.containerState.marker?hr===ir.containerState.marker:hr===41||hr===46)?(tr.exit("listItemValue"),dr(hr)):rr(hr)}function dr(hr){return tr.enter("listItemMarker"),tr.consume(hr),tr.exit("listItemMarker"),ir.containerState.marker=ir.containerState.marker||hr,tr.check(blankLine,ir.interrupt?rr:cr,tr.attempt(listItemPrefixWhitespaceConstruct,sr,ur))}function cr(hr){return ir.containerState.initialBlankLine=!0,nr++,sr(hr)}function ur(hr){return markdownSpace(hr)?(tr.enter("listItemPrefixWhitespace"),tr.consume(hr),tr.exit("listItemPrefixWhitespace"),sr):rr(hr)}function sr(hr){return ir.containerState.size=nr+ir.sliceSerialize(tr.exit("listItemPrefix"),!0).length,er(hr)}}function tokenizeListContinuation(tr,er,rr){const ir=this;return ir.containerState._closeFlow=void 0,tr.check(blankLine,ar,nr);function ar(lr){return ir.containerState.furtherBlankLines=ir.containerState.furtherBlankLines||ir.containerState.initialBlankLine,factorySpace(tr,er,"listItemIndent",ir.containerState.size+1)(lr)}function nr(lr){return ir.containerState.furtherBlankLines||!markdownSpace(lr)?(ir.containerState.furtherBlankLines=void 0,ir.containerState.initialBlankLine=void 0,or(lr)):(ir.containerState.furtherBlankLines=void 0,ir.containerState.initialBlankLine=void 0,tr.attempt(indentConstruct,er,or)(lr))}function or(lr){return ir.containerState._closeFlow=!0,ir.interrupt=void 0,factorySpace(tr,tr.attempt(list,er,rr),"linePrefix",ir.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(lr)}}function tokenizeIndent(tr,er,rr){const ir=this;return factorySpace(tr,ar,"listItemIndent",ir.containerState.size+1);function ar(nr){const or=ir.events[ir.events.length-1];return or&&or[1].type==="listItemIndent"&&or[2].sliceSerialize(or[1],!0).length===ir.containerState.size?er(nr):rr(nr)}}function tokenizeListEnd(tr){tr.exit(this.containerState.type)}function tokenizeListItemPrefixWhitespace(tr,er,rr){const ir=this;return factorySpace(tr,ar,"listItemPrefixWhitespace",ir.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function ar(nr){const or=ir.events[ir.events.length-1];return!markdownSpace(nr)&&or&&or[1].type==="listItemPrefixWhitespace"?er(nr):rr(nr)}}const setextUnderline={name:"setextUnderline",resolveTo:resolveToSetextUnderline,tokenize:tokenizeSetextUnderline};function resolveToSetextUnderline(tr,er){let rr=tr.length,ir,ar,nr;for(;rr--;)if(tr[rr][0]==="enter"){if(tr[rr][1].type==="content"){ir=rr;break}tr[rr][1].type==="paragraph"&&(ar=rr)}else tr[rr][1].type==="content"&&tr.splice(rr,1),!nr&&tr[rr][1].type==="definition"&&(nr=rr);const or={type:"setextHeading",start:{...tr[ir][1].start},end:{...tr[tr.length-1][1].end}};return tr[ar][1].type="setextHeadingText",nr?(tr.splice(ar,0,["enter",or,er]),tr.splice(nr+1,0,["exit",tr[ir][1],er]),tr[ir][1].end={...tr[nr][1].end}):tr[ir][1]=or,tr.push(["exit",or,er]),tr}function tokenizeSetextUnderline(tr,er,rr){const ir=this;let ar;return nr;function nr(dr){let cr=ir.events.length,ur;for(;cr--;)if(ir.events[cr][1].type!=="lineEnding"&&ir.events[cr][1].type!=="linePrefix"&&ir.events[cr][1].type!=="content"){ur=ir.events[cr][1].type==="paragraph";break}return!ir.parser.lazy[ir.now().line]&&(ir.interrupt||ur)?(tr.enter("setextHeadingLine"),ar=dr,or(dr)):rr(dr)}function or(dr){return tr.enter("setextHeadingLineSequence"),lr(dr)}function lr(dr){return dr===ar?(tr.consume(dr),lr):(tr.exit("setextHeadingLineSequence"),markdownSpace(dr)?factorySpace(tr,fr,"lineSuffix")(dr):fr(dr))}function fr(dr){return dr===null||markdownLineEnding(dr)?(tr.exit("setextHeadingLine"),er(dr)):rr(dr)}}const flow$1={tokenize:initializeFlow};function initializeFlow(tr){const er=this,rr=tr.attempt(blankLine,ir,tr.attempt(this.parser.constructs.flowInitial,ar,factorySpace(tr,tr.attempt(this.parser.constructs.flow,ar,tr.attempt(content$1,ar)),"linePrefix")));return rr;function ir(nr){if(nr===null){tr.consume(nr);return}return tr.enter("lineEndingBlank"),tr.consume(nr),tr.exit("lineEndingBlank"),er.currentConstruct=void 0,rr}function ar(nr){if(nr===null){tr.consume(nr);return}return tr.enter("lineEnding"),tr.consume(nr),tr.exit("lineEnding"),er.currentConstruct=void 0,rr}}const resolver={resolveAll:createResolver()},string$1=initializeFactory("string"),text$1=initializeFactory("text");function initializeFactory(tr){return{resolveAll:createResolver(tr==="text"?resolveAllLineSuffixes:void 0),tokenize:er};function er(rr){const ir=this,ar=this.parser.constructs[tr],nr=rr.attempt(ar,or,lr);return or;function or(cr){return dr(cr)?nr(cr):lr(cr)}function lr(cr){if(cr===null){rr.consume(cr);return}return rr.enter("data"),rr.consume(cr),fr}function fr(cr){return dr(cr)?(rr.exit("data"),nr(cr)):(rr.consume(cr),fr)}function dr(cr){if(cr===null)return!0;const ur=ar[cr];let sr=-1;if(ur)for(;++sr<ur.length;){const hr=ur[sr];if(!hr.previous||hr.previous.call(ir,ir.previous))return!0}return!1}}}function createResolver(tr){return er;function er(rr,ir){let ar=-1,nr;for(;++ar<=rr.length;)nr===void 0?rr[ar]&&rr[ar][1].type==="data"&&(nr=ar,ar++):(!rr[ar]||rr[ar][1].type!=="data")&&(ar!==nr+2&&(rr[nr][1].end=rr[ar-1][1].end,rr.splice(nr+2,ar-nr-2),ar=nr+2),nr=void 0);return tr?tr(rr,ir):rr}}function resolveAllLineSuffixes(tr,er){let rr=0;for(;++rr<=tr.length;)if((rr===tr.length||tr[rr][1].type==="lineEnding")&&tr[rr-1][1].type==="data"){const ir=tr[rr-1][1],ar=er.sliceStream(ir);let nr=ar.length,or=-1,lr=0,fr;for(;nr--;){const dr=ar[nr];if(typeof dr=="string"){for(or=dr.length;dr.charCodeAt(or-1)===32;)lr++,or--;if(or)break;or=-1}else if(dr===-2)fr=!0,lr++;else if(dr!==-1){nr++;break}}if(er._contentTypeTextTrailing&&rr===tr.length&&(lr=0),lr){const dr={type:rr===tr.length||fr||lr<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:nr?or:ir.start._bufferIndex+or,_index:ir.start._index+nr,line:ir.end.line,column:ir.end.column-lr,offset:ir.end.offset-lr},end:{...ir.end}};ir.end={...dr.start},ir.start.offset===ir.end.offset?Object.assign(ir,dr):(tr.splice(rr,0,["enter",dr,er],["exit",dr,er]),rr+=2)}rr++}return tr}const document$1={42:list,43:list,45:list,48:list,49:list,50:list,51:list,52:list,53:list,54:list,55:list,56:list,57:list,62:blockQuote},contentInitial={91:definition},flowInitial={[-2]:codeIndented,[-1]:codeIndented,32:codeIndented},flow={35:headingAtx,42:thematicBreak,45:[setextUnderline,thematicBreak],60:htmlFlow,61:setextUnderline,95:thematicBreak,96:codeFenced,126:codeFenced},string={38:characterReference,92:characterEscape},text={[-5]:lineEnding,[-4]:lineEnding,[-3]:lineEnding,33:labelStartImage,38:characterReference,42:attention,60:[autolink,htmlText],91:labelStartLink,92:[hardBreakEscape,characterEscape],93:labelEnd,95:attention,96:codeText},insideSpan={null:[attention,resolver]},attentionMarkers={null:[42,95]},disable={null:[]},defaultConstructs=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers,contentInitial,disable,document:document$1,flow,flowInitial,insideSpan,string,text},Symbol.toStringTag,{value:"Module"}));function createTokenizer(tr,er,rr){let ir={_bufferIndex:-1,_index:0,line:rr&&rr.line||1,column:rr&&rr.column||1,offset:rr&&rr.offset||0};const ar={},nr=[];let or=[],lr=[];const fr={attempt:wr(yr),check:wr(xr),consume:Fr,enter:Ar,exit:br,interrupt:wr(xr,{interrupt:!0})},dr={code:null,containerState:{},defineSkip:_r,events:[],now:gr,parser:tr,previous:null,sliceSerialize:sr,sliceStream:hr,write:ur};let cr=er.tokenize.call(dr,fr);return er.resolveAll&&nr.push(er),dr;function ur(Dr){return or=push(or,Dr),pr(),or[or.length-1]!==null?[]:(kr(er,0),dr.events=resolveAll(nr,dr.events,dr),dr.events)}function sr(Dr,Lr){return serializeChunks(hr(Dr),Lr)}function hr(Dr){return sliceChunks(or,Dr)}function gr(){const{_bufferIndex:Dr,_index:Lr,line:Tr,column:Rr,offset:Pr}=ir;return{_bufferIndex:Dr,_index:Lr,line:Tr,column:Rr,offset:Pr}}function _r(Dr){ar[Dr.line]=Dr.column,Er()}function pr(){let Dr;for(;ir._index<or.length;){const Lr=or[ir._index];if(typeof Lr=="string")for(Dr=ir._index,ir._bufferIndex<0&&(ir._bufferIndex=0);ir._index===Dr&&ir._bufferIndex<Lr.length;)mr(Lr.charCodeAt(ir._bufferIndex));else mr(Lr)}}function mr(Dr){cr=cr(Dr)}function Fr(Dr){markdownLineEnding(Dr)?(ir.line++,ir.column=1,ir.offset+=Dr===-3?2:1,Er()):Dr!==-1&&(ir.column++,ir.offset++),ir._bufferIndex<0?ir._index++:(ir._bufferIndex++,ir._bufferIndex===or[ir._index].length&&(ir._bufferIndex=-1,ir._index++)),dr.previous=Dr}function Ar(Dr,Lr){const Tr=Lr||{};return Tr.type=Dr,Tr.start=gr(),dr.events.push(["enter",Tr,dr]),lr.push(Tr),Tr}function br(Dr){const Lr=lr.pop();return Lr.end=gr(),dr.events.push(["exit",Lr,dr]),Lr}function yr(Dr,Lr){kr(Dr,Lr.from)}function xr(Dr,Lr){Lr.restore()}function wr(Dr,Lr){return Tr;function Tr(Rr,Pr,Br){let Ir,Mr,Nr,Cr;return Array.isArray(Rr)?Ur(Rr):"tokenize"in Rr?Ur([Rr]):Sr(Rr);function Sr(Vr){return en;function en(tn){const on=tn!==null&&Vr[tn],$r=tn!==null&&Vr.null,dn=[...Array.isArray(on)?on:on?[on]:[],...Array.isArray($r)?$r:$r?[$r]:[]];return Ur(dn)(tn)}}function Ur(Vr){return Ir=Vr,Mr=0,Vr.length===0?Br:jr(Vr[Mr])}function jr(Vr){return en;function en(tn){return Cr=vr(),Nr=Vr,Vr.partial||(dr.currentConstruct=Vr),Vr.name&&dr.parser.constructs.disable.null.includes(Vr.name)?Jr():Vr.tokenize.call(Lr?Object.assign(Object.create(dr),Lr):dr,fr,Hr,Jr)(tn)}}function Hr(Vr){return Dr(Nr,Cr),Pr}function Jr(Vr){return Cr.restore(),++Mr<Ir.length?jr(Ir[Mr]):Br}}}function kr(Dr,Lr){Dr.resolveAll&&!nr.includes(Dr)&&nr.push(Dr),Dr.resolve&&splice(dr.events,Lr,dr.events.length-Lr,Dr.resolve(dr.events.slice(Lr),dr)),Dr.resolveTo&&(dr.events=Dr.resolveTo(dr.events,dr))}function vr(){const Dr=gr(),Lr=dr.previous,Tr=dr.currentConstruct,Rr=dr.events.length,Pr=Array.from(lr);return{from:Rr,restore:Br};function Br(){ir=Dr,dr.previous=Lr,dr.currentConstruct=Tr,dr.events.length=Rr,lr=Pr,Er()}}function Er(){ir.line in ar&&ir.column<2&&(ir.column=ar[ir.line],ir.offset+=ar[ir.line]-1)}}function sliceChunks(tr,er){const rr=er.start._index,ir=er.start._bufferIndex,ar=er.end._index,nr=er.end._bufferIndex;let or;if(rr===ar)or=[tr[rr].slice(ir,nr)];else{if(or=tr.slice(rr,ar),ir>-1){const lr=or[0];typeof lr=="string"?or[0]=lr.slice(ir):or.shift()}nr>0&&or.push(tr[ar].slice(0,nr))}return or}function serializeChunks(tr,er){let rr=-1;const ir=[];let ar;for(;++rr<tr.length;){const nr=tr[rr];let or;if(typeof nr=="string")or=nr;else switch(nr){case-5:{or="\r";break}case-4:{or=`
2098
2098
  `;break}case-3:{or=`\r
2099
- `;break}case-2:{or=er?" ":" ";break}case-1:{if(!er&&ar)continue;or=" ";break}default:or=String.fromCharCode(nr)}ar=nr===-2,ir.push(or)}return ir.join("")}function parse$1(tr){const ir={constructs:combineExtensions([defaultConstructs,...(tr||{}).extensions||[]]),content:ar(content$2),defined:[],document:ar(document$2),flow:ar(flow$1),lazy:{},string:ar(string$1),text:ar(text$1)};return ir;function ar(nr){return or;function or(lr){return createTokenizer(ir,nr,lr)}}}function postprocess(tr){for(;!subtokenize(tr););return tr}const search$2=/[\0\t\n\r]/g;function preprocess(){let tr=1,er="",rr=!0,ir;return ar;function ar(nr,or,lr){const fr=[];let dr,cr,ur,sr,hr;for(nr=er+(typeof nr=="string"?nr.toString():new TextDecoder(or||void 0).decode(nr)),ur=0,er="",rr&&(nr.charCodeAt(0)===65279&&ur++,rr=void 0);ur<nr.length;){if(search$2.lastIndex=ur,dr=search$2.exec(nr),sr=dr&&dr.index!==void 0?dr.index:nr.length,hr=nr.charCodeAt(sr),!dr){er=nr.slice(ur);break}if(hr===10&&ur===sr&&ir)fr.push(-3),ir=void 0;else switch(ir&&(fr.push(-5),ir=void 0),ur<sr&&(fr.push(nr.slice(ur,sr)),tr+=sr-ur),hr){case 0:{fr.push(65533),tr++;break}case 9:{for(cr=Math.ceil(tr/4)*4,fr.push(-2);tr++<cr;)fr.push(-1);break}case 10:{fr.push(-4),tr=1;break}default:ir=!0,tr=1}ur=sr+1}return lr&&(ir&&fr.push(-5),er&&fr.push(er),fr.push(null)),fr}}function micromark(tr,er,rr){return typeof er!="string"&&(rr=er,er=void 0),compile(rr)(postprocess(parse$1(rr).document().write(preprocess()(tr,er,!0))))}const userMessageContainer="MessageRenderers-module_userMessageContainer_t-c-z",assistantMessageContainer="MessageRenderers-module_assistantMessageContainer_Q01NL",userMessage="MessageRenderers-module_userMessage_hXgT1",assistantMessage="MessageRenderers-module_assistantMessage_4H2Dy",iconWrapper="MessageRenderers-module_iconWrapper_Ai6Pd",styles$4={userMessageContainer,assistantMessageContainer,userMessage,assistantMessage,iconWrapper};function AssistantMessage({message:tr,isStreaming:er=!1}){const rr=tr.parts.filter(lr=>lr.type==="text").map(lr=>lr.text).join("");React.useRef(er);const[ir,ar]=React.useState(null),[nr,or]=React.useState(rr);return React.useEffect(()=>{const lr=setTimeout(()=>{const fr=removeSourcesFromText(rr);or(fr);const dr=extractSources(rr);if(!dr.length){ar(null);return}ar(jsxRuntimeExports.jsxs("div",{style:{marginTop:16},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Sources:"}),jsxRuntimeExports.jsx("div",{style:{border:"1px solid #e0e0e0",borderRadius:8,padding:8,background:"#fafbfc",fontSize:14,maxWidth:"fit-content"},children:dr.map((cr,ur)=>jsxRuntimeExports.jsxs("div",{style:{marginBottom:8},children:[jsxRuntimeExports.jsx("a",{href:cr.url,target:"_blank",rel:"noopener noreferrer",style:{color:"#2a5cdb",fontWeight:500,textDecoration:"underline",display:"block",marginBottom:2,padding:"4px",fontSize:12},children:cr.name}),cr.pageInfo&&jsxRuntimeExports.jsx("div",{style:{fontSize:12,color:"#666",padding:"0 4px"},children:cr.pageInfo})]},ur))})]}))},50);return()=>clearTimeout(lr)},[rr]),rr.trim()?jsxRuntimeExports.jsx("div",{className:styles$4.assistantMessageContainer,children:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs(Flex,{alignItems:"flex-start",gap:"8px",children:[jsxRuntimeExports.jsx("div",{className:styles$4.iconWrapper,children:jsxRuntimeExports.jsx(Icon,{icon:"ai_general",size:24,color:"#3094ED",variant:"filled"})}),jsxRuntimeExports.jsxs(CardPadding,{className:styles$4.assistantMessage,children:[jsxRuntimeExports.jsx("div",{className:"markdown",dangerouslySetInnerHTML:{__html:micromark(nr)}}),ir]})]})})},"text"):null}const ApexChartAsync=asyncComponent({module:()=>Promise.resolve().then(()=>reactApexcharts_min$1),component:tr=>tr.default}),chartWidth={small:"150px",default:"300px",large:"560px",full:"560px"},ToolChartsMessage=React.memo(({message:tr,chatSize:er})=>{const rr=[],ir=tr.parts.filter(ar=>ar.type==="toolResult"||ar.type==="toolCall");return ir.length>0&&ir.forEach(ar=>{var cr;const nr=ar.type==="toolResult"?ar.result:ar.text;if(typeof nr!="string"||!(nr!=null&&nr.includes("###chart_data_end###")))return;const or=nr.split(/###chart_data###|###chart_data_end###/);if(!(or.length===3))return;const fr=JSON.parse(or[1].trim()),dr=`${ar.toolName}-${fr.type}-${tr.id}`;rr.push(jsxRuntimeExports.jsx("div",{style:{width:chartWidth[er]},children:jsxRuntimeExports.jsx(ApexChartAsync,{type:fr.type,options:{...fr.options,chart:{...(cr=fr.options)==null?void 0:cr.chart,id:dr,animations:{enabled:!1},zoom:{enabled:!0},toolbar:{show:!0,tools:{download:!0,selection:!0,zoom:!0,zoomin:!0,zoomout:!0,pan:!0,reset:!0}}}},series:fr.series})},dr))}),rr.length===0?null:jsxRuntimeExports.jsx(CardPadding,{children:jsxRuntimeExports.jsx(Flex,{justifyContent:"flex-start",style:{marginLeft:"24px"},direction:"column",children:rr})})}),ToolPillMessage=React.memo(({message:tr,showDebugInfo:er=!1})=>{const[rr,ir]=React.useState(!1),ar=tr.parts.filter(or=>or.type==="toolCall"),nr=[];return ar.length>0&&nr.push(jsxRuntimeExports.jsx("div",{id:"just-checking",children:ar.map(or=>{const lr=jsxRuntimeExports.jsxs(Flex,{gap:"8px",alignItems:"center",children:[tr.isPending?jsxRuntimeExports.jsx(Icon,{icon:"loading"}):null,jsxRuntimeExports.jsx(Pill,{icon:"info",size:"large",text:tr.isPending?"Coach is thinking...":"Coach was thinking",variant:"outline",onClick:setStateValue(ir,!rr)})]});return jsxRuntimeExports.jsx("div",{title:`Tool call: ${or.toolName}`,style:{display:"inline-block"},children:er?jsxRuntimeExports.jsx(Popover,{parent:lr,isOpen:rr,onSetOpen:ir,popoverComponent:jsxRuntimeExports.jsx("textarea",{value:JSON.stringify(or,null,2),readOnly:!0,style:{width:"300px",height:"100px",resize:"none"}})}):lr},or.toolName)})},"tools")),nr.length===0?null:jsxRuntimeExports.jsx(CardPadding,{children:jsxRuntimeExports.jsx(Flex,{justifyContent:"flex-start",style:{marginLeft:"24px"},children:nr})})});function ToolCallMessage({message:tr,showDebugInfo:er=!1,chatSize:rr="default"}){return jsxRuntimeExports.jsxs("div",{className:styles$4.assistantMessageContainer,children:[jsxRuntimeExports.jsx(ToolPillMessage,{message:tr,showDebugInfo:er}),jsxRuntimeExports.jsx(ToolChartsMessage,{message:tr,chatSize:rr})]})}function UserMessage({message:tr}){const er=tr.parts.filter(ir=>ir.type==="text").map(ir=>ir.text).join(""),rr=[];return er&&rr.push(jsxRuntimeExports.jsx(Flex,{justifyContent:"flex-end",style:{width:"100%"},className:styles$4.userMessageContainer,children:jsxRuntimeExports.jsx(Card,{noShadow:!0,withBorder:!0,className:styles$4.userMessage,children:jsxRuntimeExports.jsx("div",{className:"markdown",dangerouslySetInnerHTML:{__html:micromark(er)}})})},"text")),rr.length===0?null:jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:rr})}const SearchConversations=({onExitSearch:tr,onSearch:er})=>jsxRuntimeExports.jsxs(Flex,{direction:"row",gap:"8px",testId:"search-conversations",className:styles$6["ai-assistant-search-input-container"],children:[jsxRuntimeExports.jsx(Input,{id:"search-conversations",onChange:er,placeholder:"Find chat","data-testid":"search-conversations-input",fullWidth:!0,autoFocus:!0}),jsxRuntimeExports.jsx(IconButton,{icon:"close",system:!0,size:"small",title:"Exit search","data-testid":"search-exit-button",onClick:tr})]}),audioVisualizerStyles=`
2099
+ `;break}case-2:{or=er?" ":" ";break}case-1:{if(!er&&ar)continue;or=" ";break}default:or=String.fromCharCode(nr)}ar=nr===-2,ir.push(or)}return ir.join("")}function parse$1(tr){const ir={constructs:combineExtensions([defaultConstructs,...(tr||{}).extensions||[]]),content:ar(content$2),defined:[],document:ar(document$2),flow:ar(flow$1),lazy:{},string:ar(string$1),text:ar(text$1)};return ir;function ar(nr){return or;function or(lr){return createTokenizer(ir,nr,lr)}}}function postprocess(tr){for(;!subtokenize(tr););return tr}const search$2=/[\0\t\n\r]/g;function preprocess(){let tr=1,er="",rr=!0,ir;return ar;function ar(nr,or,lr){const fr=[];let dr,cr,ur,sr,hr;for(nr=er+(typeof nr=="string"?nr.toString():new TextDecoder(or||void 0).decode(nr)),ur=0,er="",rr&&(nr.charCodeAt(0)===65279&&ur++,rr=void 0);ur<nr.length;){if(search$2.lastIndex=ur,dr=search$2.exec(nr),sr=dr&&dr.index!==void 0?dr.index:nr.length,hr=nr.charCodeAt(sr),!dr){er=nr.slice(ur);break}if(hr===10&&ur===sr&&ir)fr.push(-3),ir=void 0;else switch(ir&&(fr.push(-5),ir=void 0),ur<sr&&(fr.push(nr.slice(ur,sr)),tr+=sr-ur),hr){case 0:{fr.push(65533),tr++;break}case 9:{for(cr=Math.ceil(tr/4)*4,fr.push(-2);tr++<cr;)fr.push(-1);break}case 10:{fr.push(-4),tr=1;break}default:ir=!0,tr=1}ur=sr+1}return lr&&(ir&&fr.push(-5),er&&fr.push(er),fr.push(null)),fr}}function micromark(tr,er,rr){return typeof er!="string"&&(rr=er,er=void 0),compile(rr)(postprocess(parse$1(rr).document().write(preprocess()(tr,er,!0))))}const userMessageContainer="MessageRenderers-module_userMessageContainer_t-c-z",assistantMessageContainer="MessageRenderers-module_assistantMessageContainer_Q01NL",userMessage="MessageRenderers-module_userMessage_hXgT1",assistantMessage="MessageRenderers-module_assistantMessage_4H2Dy",iconWrapper="MessageRenderers-module_iconWrapper_Ai6Pd",styles$4={userMessageContainer,assistantMessageContainer,userMessage,assistantMessage,iconWrapper};function AssistantMessage({message:tr,isStreaming:er=!1}){const rr=tr.parts.filter(fr=>fr.type==="text").map(fr=>fr.text).join(""),ir=React.useRef(er),[ar,nr]=React.useState(null),[or,lr]=React.useState(rr);return React.useEffect(()=>{const fr=setTimeout(()=>{const dr=removeSourcesFromText(rr);lr(dr);const cr=extractSources(rr);if(!cr.length){nr(null);return}nr(jsxRuntimeExports.jsxs("div",{style:{marginTop:16},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Sources:"}),jsxRuntimeExports.jsx("div",{style:{border:"1px solid #e0e0e0",borderRadius:8,padding:8,background:"#fafbfc",fontSize:14,maxWidth:"fit-content"},children:cr.map((ur,sr)=>jsxRuntimeExports.jsxs("div",{style:{marginBottom:8},children:[jsxRuntimeExports.jsx("a",{href:ur.url,target:"_blank",rel:"noopener noreferrer",style:{color:"#2a5cdb",fontWeight:500,textDecoration:"underline",display:"block",marginBottom:2,padding:"4px",fontSize:12},children:ur.name}),ur.pageInfo&&jsxRuntimeExports.jsx("div",{style:{fontSize:12,color:"#666",padding:"0 4px"},children:ur.pageInfo})]},sr))})]}))},50);return()=>clearTimeout(fr)},[rr]),rr.trim()?jsxRuntimeExports.jsx("div",{className:styles$4.assistantMessageContainer,children:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs(Flex,{alignItems:"flex-start",gap:"8px",children:[jsxRuntimeExports.jsx("div",{className:styles$4.iconWrapper,children:jsxRuntimeExports.jsx(Icon,{icon:"ai_general",size:24,color:"#3094ED",variant:"filled"})}),jsxRuntimeExports.jsxs(CardPadding,{className:styles$4.assistantMessage,children:[ir.current?jsxRuntimeExports.jsx(StreamingText,{text:or,isStreaming:er}):jsxRuntimeExports.jsx("div",{className:"markdown",dangerouslySetInnerHTML:{__html:micromark(or)}}),ar]})]})})},"text"):null}function StreamingText({text:tr,isStreaming:er}){const[rr,ir]=React.useState("");return React.useEffect(()=>{let ar=!1;const nr=setInterval(function(){ar||(ar=!0,requestAnimationFrame(()=>{const fr=tr.slice(rr.length,rr.length+8);fr.length&&ir(rr+fr),rr.length+8>=tr.length&&clearInterval(nr),ar=!1}))},10);return()=>clearInterval(nr)},[tr,er,rr]),jsxRuntimeExports.jsx("div",{className:"markdown",dangerouslySetInnerHTML:{__html:micromark(rr)}})}const ApexChartAsync=asyncComponent({module:()=>Promise.resolve().then(()=>reactApexcharts_min$1),component:tr=>tr.default}),chartWidth={small:"150px",default:"300px",large:"560px",full:"560px"},ToolChartsMessage=React.memo(({message:tr,chatSize:er})=>{const rr=[],ir=tr.parts.filter(ar=>ar.type==="toolResult"||ar.type==="toolCall");return ir.length>0&&ir.forEach(ar=>{var cr;const nr=ar.type==="toolResult"?ar.result:ar.text;if(typeof nr!="string"||!(nr!=null&&nr.includes("###chart_data_end###")))return;const or=nr.split(/###chart_data###|###chart_data_end###/);if(!(or.length===3))return;const fr=JSON.parse(or[1].trim()),dr=`${ar.toolName}-${fr.type}-${tr.id}`;rr.push(jsxRuntimeExports.jsx("div",{style:{width:chartWidth[er]},children:jsxRuntimeExports.jsx(ApexChartAsync,{type:fr.type,options:{...fr.options,chart:{...(cr=fr.options)==null?void 0:cr.chart,id:dr,animations:{enabled:!1},zoom:{enabled:!0},toolbar:{show:!0,tools:{download:!0,selection:!0,zoom:!0,zoomin:!0,zoomout:!0,pan:!0,reset:!0}}}},series:fr.series})},dr))}),rr.length===0?null:jsxRuntimeExports.jsx(CardPadding,{children:jsxRuntimeExports.jsx(Flex,{justifyContent:"flex-start",style:{marginLeft:"24px"},direction:"column",children:rr})})}),ToolPillMessage=React.memo(({message:tr,showDebugInfo:er=!1})=>{const[rr,ir]=React.useState(!1),ar=tr.parts.filter(or=>or.type==="toolCall"),nr=[];return ar.length>0&&nr.push(jsxRuntimeExports.jsx("div",{id:"just-checking",children:ar.map(or=>{const lr=jsxRuntimeExports.jsxs(Flex,{gap:"8px",alignItems:"center",children:[tr.isPending?jsxRuntimeExports.jsx(Icon,{icon:"loading"}):null,jsxRuntimeExports.jsx(Pill,{icon:"info",size:"large",text:tr.isPending?"Coach is thinking...":"Coach was thinking",variant:"outline",onClick:setStateValue(ir,!rr)})]});return jsxRuntimeExports.jsx("div",{title:`Tool call: ${or.toolName}`,style:{display:"inline-block"},children:er?jsxRuntimeExports.jsx(Popover,{parent:lr,isOpen:rr,onSetOpen:ir,popoverComponent:jsxRuntimeExports.jsx("textarea",{value:JSON.stringify(or,null,2),readOnly:!0,style:{width:"300px",height:"100px",resize:"none"}})}):lr},or.toolName)})},"tools")),nr.length===0?null:jsxRuntimeExports.jsx(CardPadding,{children:jsxRuntimeExports.jsx(Flex,{justifyContent:"flex-start",style:{marginLeft:"24px"},children:nr})})});function ToolCallMessage({message:tr,showDebugInfo:er=!1,chatSize:rr="default"}){return jsxRuntimeExports.jsxs("div",{className:styles$4.assistantMessageContainer,children:[jsxRuntimeExports.jsx(ToolPillMessage,{message:tr,showDebugInfo:er}),jsxRuntimeExports.jsx(ToolChartsMessage,{message:tr,chatSize:rr})]})}function UserMessage({message:tr}){const er=tr.parts.filter(ir=>ir.type==="text").map(ir=>ir.text).join(""),rr=[];return er&&rr.push(jsxRuntimeExports.jsx(Flex,{justifyContent:"flex-end",style:{width:"100%"},className:styles$4.userMessageContainer,children:jsxRuntimeExports.jsx(Card,{noShadow:!0,withBorder:!0,className:styles$4.userMessage,children:jsxRuntimeExports.jsx("div",{className:"markdown",dangerouslySetInnerHTML:{__html:micromark(er)}})})},"text")),rr.length===0?null:jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:rr})}const SearchConversations=({onExitSearch:tr,onSearch:er})=>jsxRuntimeExports.jsxs(Flex,{direction:"row",gap:"8px",testId:"search-conversations",className:styles$6["ai-assistant-search-input-container"],children:[jsxRuntimeExports.jsx(Input,{id:"search-conversations",onChange:er,placeholder:"Find chat","data-testid":"search-conversations-input",fullWidth:!0,autoFocus:!0}),jsxRuntimeExports.jsx(IconButton,{icon:"close",system:!0,size:"small",title:"Exit search","data-testid":"search-exit-button",onClick:tr})]}),audioVisualizerStyles=`
2100
2100
  @keyframes pulse1 {
2101
2101
  0% { transform: scaleY(0.3); }
2102
2102
  20% { transform: scaleY(0.8); }