@everfur/sdk 1.6.1 → 1.7.0

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 (216) hide show
  1. package/dist/{Chat.d-B4GybUU4.d.ts → Chat.d-BIr_4AJt.d.ts} +1 -1
  2. package/dist/{Chat.d-DPM2ncxi.d.cts → Chat.d-BhevtXn9.d.cts} +1 -1
  3. package/dist/{DepthViews.d-BGspxovy.d.cts → DepthViews.d-C8KdfzwR.d.cts} +1 -1
  4. package/dist/{DepthViews.d-BaLh7Lsi.d.cts → DepthViews.d-DWQ-J208.d.cts} +1 -1
  5. package/dist/{DepthViews.d-BIHVrf9r.d.ts → DepthViews.d-DYVUq4Xk.d.ts} +1 -1
  6. package/dist/{DepthViews.d-CEVk9poG.d.ts → DepthViews.d-oKr9R0Ql.d.ts} +1 -1
  7. package/dist/{IntakeMedia.d-CwSkSLNM.d.ts → IntakeMedia.d-B-ZZK6vd.d.ts} +1 -1
  8. package/dist/{IntakeMedia.d-LRXO38_z.d.cts → IntakeMedia.d-CuVkzIsO.d.cts} +1 -1
  9. package/dist/{IntakeMedia.d-DmaeGU6T.d.cts → IntakeMedia.d-CyF6NPHx.d.cts} +1 -1
  10. package/dist/{IntakeMedia.d-Dyb9R8b0.d.ts → IntakeMedia.d-vU8g9OM5.d.ts} +1 -1
  11. package/dist/{RecordsPage.d-D10RIgdc.d.ts → RecordsPage.d-DU8Nswzh.d.ts} +1 -1
  12. package/dist/{RecordsPage.d-DbhYNSbq.d.cts → RecordsPage.d-DzPhqMHW.d.cts} +1 -1
  13. package/dist/animations/index.d.cts +3 -3
  14. package/dist/animations/index.d.ts +3 -3
  15. package/dist/{attachments.d-CF4lLuGK.d.cts → attachments.d-0nOPDIng.d.cts} +1 -1
  16. package/dist/{attachments.d-BlukNfIf.d.ts → attachments.d-BlyI-RCY.d.ts} +1 -1
  17. package/dist/{bookingCopy.d-Bn8bdo89.d.ts → bookingCopy.d-ClL8OxBS.d.ts} +3 -3
  18. package/dist/{bookingCopy.d-Dg7bPM-U.d.cts → bookingCopy.d-DUVqhF5f.d.cts} +3 -3
  19. package/dist/{branding.d-XrZYClN4.d.ts → branding.d-D0LV3aFE.d.ts} +1 -1
  20. package/dist/{branding.d-CqDLKj1U.d.cts → branding.d-DzSPLZKl.d.cts} +1 -1
  21. package/dist/{casesRepository.d-CVuKTkJo.d.cts → casesRepository.d-DnanKXJ1.d.cts} +1 -1
  22. package/dist/{casesRepository.d-Dn1fK1b2.d.ts → casesRepository.d-_4QucKVC.d.ts} +1 -1
  23. package/dist/chat/index.cjs +239 -238
  24. package/dist/chat/index.d.cts +11 -11
  25. package/dist/chat/index.d.ts +11 -11
  26. package/dist/chat/index.js +241 -240
  27. package/dist/chat/lite/index.cjs +239 -238
  28. package/dist/chat/lite/index.d.cts +11 -11
  29. package/dist/chat/lite/index.d.ts +11 -11
  30. package/dist/chat/lite/index.js +239 -238
  31. package/dist/{chatHandoffToken.d-zdp23Ukr.d.ts → chatHandoffToken.d-BoZGGbIB.d.ts} +5 -5
  32. package/dist/{chatHandoffToken.d-Cap2z62P.d.cts → chatHandoffToken.d-DhhGdLNH.d.cts} +5 -5
  33. package/dist/{checkin.d-CuIUahcd.d.cts → checkin.d-DB-HlK7r.d.cts} +9 -4
  34. package/dist/{checkin.d-BoZXWjxX.d.ts → checkin.d-DogrR06X.d.ts} +9 -4
  35. package/dist/{chunk-ZSCVH4UW.js → chunk-6E3J6IVM.js} +16 -16
  36. package/dist/{chunk-CQUKIPRU.js → chunk-J5ZUBY3S.js} +1 -1
  37. package/dist/{chunk-RF4N4WUN.js → chunk-LPHBCDJP.js} +18 -18
  38. package/dist/{chunk-DBQYQLJT.js → chunk-ULQDOC75.js} +1 -1
  39. package/dist/client/index.cjs +28 -27
  40. package/dist/client/index.d.cts +13 -13
  41. package/dist/client/index.d.ts +13 -13
  42. package/dist/client/index.js +25 -24
  43. package/dist/{clinicBatch.d-C0xx5L4j.d.cts → clinicBatch.d-BvPF6vXS.d.cts} +2 -2
  44. package/dist/{clinicBatch.d-DNi4UURs.d.ts → clinicBatch.d-CF0GIvpx.d.ts} +2 -2
  45. package/dist/{config.d-B7Z-KTGq.d.ts → config.d-Bc41Ax6M.d.ts} +5 -1
  46. package/dist/{config.d-ClAI2RZ6.d.cts → config.d-Bn6GEGfl.d.cts} +5 -1
  47. package/dist/consent/index.d.cts +5 -5
  48. package/dist/consent/index.d.ts +5 -5
  49. package/dist/{context.d-D7zX6Q0J.d.ts → context.d-0QfLaI3W.d.ts} +5 -5
  50. package/dist/{context.d-guaLkx5t.d.cts → context.d-CyQpedoU.d.cts} +5 -5
  51. package/dist/{copy.d--F5A9cXK.d.cts → copy.d-B55PpLxr.d.cts} +2 -2
  52. package/dist/{copy.d-DmxuFJFe.d.ts → copy.d-B8wIE6cH.d.ts} +2 -2
  53. package/dist/core/index.cjs +32 -31
  54. package/dist/core/index.d.cts +16 -16
  55. package/dist/core/index.d.ts +16 -16
  56. package/dist/core/index.js +32 -31
  57. package/dist/{depth.d-CgzYE6_n.d.ts → depth.d-CrtZXnLy.d.ts} +2 -2
  58. package/dist/{depth.d-DLaP0o8Y.d.cts → depth.d-Cxz6VisZ.d.cts} +2 -2
  59. package/dist/{entitlementRepository.d-CkUTlVAb.d.ts → entitlementRepository.d-BaZTIe1B.d.ts} +3 -3
  60. package/dist/{entitlementRepository.d-DVTp-BB9.d.cts → entitlementRepository.d-YeNG2TKI.d.cts} +3 -3
  61. package/dist/{focus.d-u-HYvim0.d.ts → focus.d-520VEHKB.d.ts} +1 -1
  62. package/dist/{focus.d-CLTjm6In.d.cts → focus.d-DoempN1I.d.cts} +1 -1
  63. package/dist/health-plan/index.cjs +236 -235
  64. package/dist/health-plan/index.d.cts +15 -15
  65. package/dist/health-plan/index.d.ts +15 -15
  66. package/dist/health-plan/index.js +236 -235
  67. package/dist/{healthPlanRepository.d-CwRXeoM7.d.ts → healthPlanRepository.d-BHu9LO0r.d.ts} +2 -2
  68. package/dist/{healthPlanRepository.d-B22kjrYa.d.cts → healthPlanRepository.d-tUR1f_5s.d.cts} +2 -2
  69. package/dist/{idempotency.d-DrxKLPPe.d.cts → idempotency.d-CcFLvzYW.d.cts} +1 -1
  70. package/dist/{idempotency.d-CbB07p64.d.ts → idempotency.d-CvqKG3Uq.d.ts} +1 -1
  71. package/dist/{identity.d-D4VtpqRr.d.ts → identity.d-Bex_XJZx.d.ts} +1 -1
  72. package/dist/{identity.d-DDpXOtas.d.cts → identity.d-Dm0Buvn8.d.cts} +1 -1
  73. package/dist/{inbox.d-B2JXK0uI.d.ts → inbox.d-9ajb0oiJ.d.ts} +1 -1
  74. package/dist/{inbox.d-CwA1ogzV.d.cts → inbox.d-CGCYOZIq.d.cts} +1 -1
  75. package/dist/index.cjs +362 -361
  76. package/dist/index.d.cts +17 -17
  77. package/dist/index.d.ts +17 -17
  78. package/dist/index.js +253 -252
  79. package/dist/{introEvents.d-DW3gLljE.d.ts → introEvents.d-CuVaufTy.d.ts} +1 -1
  80. package/dist/{introEvents.d-B7acmGwf.d.cts → introEvents.d-DU6feqx4.d.cts} +1 -1
  81. package/dist/{layout.d-C8y_ki1V.d.ts → layout.d-BQ5IVS-m.d.ts} +1 -1
  82. package/dist/{layout.d-DfaFM_lp.d.cts → layout.d-CSPr33BP.d.cts} +1 -1
  83. package/dist/notifications/inbox/index.d.cts +6 -6
  84. package/dist/notifications/inbox/index.d.ts +6 -6
  85. package/dist/notifications/index.d.cts +7 -7
  86. package/dist/notifications/index.d.ts +7 -7
  87. package/dist/{optInView.d-Cps7aLQN.d.ts → optInView.d-DpGXnpGw.d.ts} +21 -3
  88. package/dist/{optInView.d-ChJyJMBA.d.cts → optInView.d-dLjrI3co.d.cts} +21 -3
  89. package/dist/{pets.d-BpLObpfM.d.ts → pets.d-CHdSIoBf.d.ts} +1 -1
  90. package/dist/{pets.d-DXhzTNuI.d.cts → pets.d-jnhrJhqm.d.cts} +1 -1
  91. package/dist/{petsRepository.d-ai_tZ3lu.d.cts → petsRepository.d-BeKRiNao.d.cts} +1 -1
  92. package/dist/{petsRepository.d-_QfM7F6T.d.ts → petsRepository.d-BjwB1vku.d.ts} +1 -1
  93. package/dist/{presentation.d-BkIvMtIl.d.cts → presentation.d-Br3TnwA6.d.cts} +17 -1
  94. package/dist/{presentation.d-BkIvMtIl.d.ts → presentation.d-Br3TnwA6.d.ts} +17 -1
  95. package/dist/records/depth/index.d.cts +9 -9
  96. package/dist/records/depth/index.d.ts +9 -9
  97. package/dist/records/index.cjs +237 -228
  98. package/dist/records/index.d.cts +39 -12
  99. package/dist/records/index.d.ts +39 -12
  100. package/dist/records/index.js +155 -146
  101. package/dist/{requestFunnel.d-DKBPTpsy.d.ts → requestFunnel.d-C_NMgz9R.d.ts} +2 -2
  102. package/dist/{requestFunnel.d-BwZDfWVD.d.cts → requestFunnel.d-DoJWLySc.d.cts} +2 -2
  103. package/dist/{route.d-QBCoO62z.d.cts → route.d-BW2abFVK.d.cts} +2 -2
  104. package/dist/{route.d-B3u14HJT.d.ts → route.d-Olr_gXaa.d.ts} +2 -2
  105. package/dist/{runtimeTypes.d-hjN6xvxm.d.ts → runtimeTypes.d-Bp2VW6YE.d.ts} +6 -6
  106. package/dist/{runtimeTypes.d-BSxuUCOX.d.cts → runtimeTypes.d-StvJY45N.d.cts} +6 -6
  107. package/dist/{screenProps.d-fHBKArt_.d.ts → screenProps.d-BTLSji0N.d.ts} +1 -1
  108. package/dist/{screenProps.d-6xmE1C-V.d.cts → screenProps.d-B_5Bh7aQ.d.cts} +1 -1
  109. package/dist/server/events/index.cjs +2 -2
  110. package/dist/server/events/index.d.cts +19 -5
  111. package/dist/server/events/index.d.ts +19 -5
  112. package/dist/server/events/index.js +2 -2
  113. package/dist/server/index.cjs +1 -1
  114. package/dist/server/index.d.cts +3 -3
  115. package/dist/server/index.d.ts +3 -3
  116. package/dist/server/index.js +1 -1
  117. package/dist/shop/index.d.cts +3 -3
  118. package/dist/shop/index.d.ts +3 -3
  119. package/dist/slots/index.cjs +200 -199
  120. package/dist/slots/index.d.cts +5 -5
  121. package/dist/slots/index.d.ts +5 -5
  122. package/dist/slots/index.js +200 -199
  123. package/dist/tabs/index.cjs +200 -190
  124. package/dist/tabs/index.d.cts +68 -11
  125. package/dist/tabs/index.d.ts +68 -11
  126. package/dist/tabs/index.js +201 -191
  127. package/dist/tabs-bar/index.cjs +247 -0
  128. package/dist/tabs-bar/index.d.cts +10 -0
  129. package/dist/tabs-bar/index.d.ts +10 -0
  130. package/dist/tabs-bar/index.js +247 -0
  131. package/dist/{tabsModel.d-D9GWPFrL.d.ts → tabsModel.d-B4MSQB57.d.cts} +5 -2
  132. package/dist/{tabsModel.d-D9GWPFrL.d.cts → tabsModel.d-C8pd-DP3.d.ts} +5 -2
  133. package/dist/televet/booking/index.cjs +147 -145
  134. package/dist/televet/booking/index.d.cts +10 -10
  135. package/dist/televet/booking/index.d.ts +10 -10
  136. package/dist/televet/booking/index.js +163 -161
  137. package/dist/televet/call/index.cjs +52 -52
  138. package/dist/televet/call/index.d.cts +5 -0
  139. package/dist/televet/call/index.d.ts +5 -0
  140. package/dist/televet/call/index.js +25 -25
  141. package/dist/televet/index.d.cts +3 -3
  142. package/dist/televet/index.d.ts +3 -3
  143. package/dist/{televetGlobal.d-gZrXPaLl.d.cts → televetGlobal.d-B_I_fy7O.d.cts} +9 -0
  144. package/dist/{televetGlobal.d-DkJkV55Y.d.ts → televetGlobal.d-DN7o45WJ.d.ts} +9 -0
  145. package/dist/testing/index.cjs +3 -3
  146. package/dist/testing/index.d.cts +1 -1
  147. package/dist/testing/index.d.ts +1 -1
  148. package/dist/testing/index.js +3 -3
  149. package/dist/testing/rn/index.d.cts +9 -9
  150. package/dist/testing/rn/index.d.ts +9 -9
  151. package/dist/testing/web/index.d.cts +9 -9
  152. package/dist/testing/web/index.d.ts +9 -9
  153. package/dist/texting/index.cjs +32 -27
  154. package/dist/texting/index.d.cts +5 -5
  155. package/dist/texting/index.d.ts +5 -5
  156. package/dist/texting/index.js +52 -47
  157. package/dist/{threadOptions.d-NSlFx-Lp.d.ts → threadOptions.d-D_3hk79R.d.ts} +5 -5
  158. package/dist/{threadOptions.d-Dc57dm7h.d.cts → threadOptions.d-D_GU6lp9.d.cts} +5 -5
  159. package/dist/{timelineRows.d-CthNM5hV.d.ts → timelineRows.d-BbVuARtc.d.ts} +1 -1
  160. package/dist/{timelineRows.d-7w8NsNi4.d.cts → timelineRows.d-BiLAAbYl.d.cts} +1 -1
  161. package/dist/{typeStyle.d-8mcLhtbH.d.ts → typeStyle.d-DSk99BuZ.d.ts} +1 -1
  162. package/dist/{typeStyle.d-CLrQZW-r.d.cts → typeStyle.d-DqR6mWCF.d.cts} +1 -1
  163. package/dist/{useHealthPlanSubscription.d-CV7M21HS.d.ts → useHealthPlanSubscription.d-CpE6l1VW.d.ts} +3 -3
  164. package/dist/{useHealthPlanSubscription.d-SA9-SuKe.d.cts → useHealthPlanSubscription.d-DRiWDJXq.d.cts} +3 -3
  165. package/dist/{useInboxUnread.d-0DrQPn7J.d.ts → useInboxUnread.d-BV7PkWDH.d.ts} +1 -1
  166. package/dist/{useInboxUnread.d-CRcOTkmu.d.cts → useInboxUnread.d-CElyXBkY.d.cts} +1 -1
  167. package/dist/{usePresentation.d-BJzFicRQ.d.cts → usePresentation.d-BcazazQH.d.cts} +3 -3
  168. package/dist/{usePresentation.d-DgSGIWS-.d.ts → usePresentation.d-CMOypLlH.d.ts} +3 -3
  169. package/dist/{useRecordsDepth.d-ZX2rhcUx.d.ts → useRecordsDepth.d-Bka4KQhq.d.ts} +1 -1
  170. package/dist/{useRecordsDepth.d-C9W45gwS.d.cts → useRecordsDepth.d-TgmpxKdX.d.cts} +1 -1
  171. package/dist/{useUnread.d-4SbFChbd.d.ts → useUnread.d-CGqaP-dB.d.ts} +27 -5
  172. package/dist/{useUnread.d-B0YhhR_D.d.cts → useUnread.d-DVVnYNPU.d.cts} +27 -5
  173. package/dist/{view.d-3lxzyJlL.d.cts → view.d-CwruYhQy.d.cts} +3 -3
  174. package/dist/{view.d-DRiYNQJ8.d.ts → view.d-DamH8TQF.d.ts} +3 -3
  175. package/dist/web/consent/index.d.cts +5 -5
  176. package/dist/web/consent/index.d.ts +5 -5
  177. package/dist/web/health-plan/index.cjs +9 -8
  178. package/dist/web/health-plan/index.d.cts +16 -16
  179. package/dist/web/health-plan/index.d.ts +16 -16
  180. package/dist/web/health-plan/index.js +49 -48
  181. package/dist/web/inbox/index.d.cts +7 -7
  182. package/dist/web/inbox/index.d.ts +7 -7
  183. package/dist/web/index.cjs +185 -184
  184. package/dist/web/index.d.cts +32 -32
  185. package/dist/web/index.d.ts +32 -32
  186. package/dist/web/index.js +179 -178
  187. package/dist/web/intro/index.d.cts +7 -7
  188. package/dist/web/intro/index.d.ts +7 -7
  189. package/dist/web/notifications/index.d.cts +6 -6
  190. package/dist/web/notifications/index.d.ts +6 -6
  191. package/dist/web/records/depth/index.d.cts +9 -9
  192. package/dist/web/records/depth/index.d.ts +9 -9
  193. package/dist/web/records/index.d.cts +11 -11
  194. package/dist/web/records/index.d.ts +11 -11
  195. package/dist/web/records-sheet/index.cjs +111 -110
  196. package/dist/web/records-sheet/index.js +111 -110
  197. package/dist/web/shop/index.cjs +1 -1
  198. package/dist/web/shop/index.d.cts +3 -3
  199. package/dist/web/shop/index.d.ts +3 -3
  200. package/dist/web/shop/index.js +1 -1
  201. package/dist/web/televet/booking/index.cjs +3 -3
  202. package/dist/web/televet/booking/index.d.cts +10 -10
  203. package/dist/web/televet/booking/index.d.ts +10 -10
  204. package/dist/web/televet/booking/index.js +69 -69
  205. package/dist/web/televet/call/index.cjs +1 -1
  206. package/dist/web/televet/call/index.js +1 -1
  207. package/dist/web/televet/index.d.cts +3 -3
  208. package/dist/web/televet/index.d.ts +3 -3
  209. package/dist/web/texting/index.cjs +34 -29
  210. package/dist/web/texting/index.d.cts +5 -5
  211. package/dist/web/texting/index.d.ts +5 -5
  212. package/dist/web/texting/index.js +45 -40
  213. package/dist/web/ui/index.cjs +1 -1
  214. package/dist/web/ui/index.js +41 -41
  215. package/package.json +16 -1
  216. package/tabs-bar/package.json +8 -0
@@ -1,355 +1,356 @@
1
1
  /*! @everfur/sdk. Copyright (c) 2026 Strand Health Inc. dba Everfur. All rights reserved. Use is subject to the Everfur SDK License: https://docs.everfur.com/license */
2
2
  "use strict";var e=require("react"),t=require("react/jsx-runtime"),r=require("@everfur/sdk/televet/booking"),n=require("react-native"),l=require("react-native-safe-area-context"),i=require("@everfur/sdk/texting");function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);if(e){Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:true,get:function(){return e[r]}})}})}t.default=e;return Object.freeze(t)}var a=/*#__PURE__*/o(r);var s=/*#__PURE__*/o(n);var u=/*#__PURE__*/o(i);var c=e.createContext(null);function TelevetHostOutlet(){let r=e.useContext(c);return r===null?null:/* @__PURE__ */t.jsx(r,{})}var d=/* @__PURE__ */Symbol.for("@everfur/sdk/televet");function p(){let e=globalThis,t=e[d];if(t!==void 0)return t;let r={presenter:null,snapshot:/* @__PURE__ */Object.freeze({request:null,serial:0,activeHost:null}),hosts:[],nextHost:1,listeners:/* @__PURE__ */new Set,dailyRegistered:false};return e[d]=r,r}function f(e){let t=p();t.snapshot=/* @__PURE__ */Object.freeze({...t.snapshot,...e});for(let e of[...t.listeners])try{e()}catch{}}function h(e){let t=p().presenter;if(t===null)return"absent";try{return t(e)===!1?"declined":"presented"}catch(e){return console.warn("[everfur] Your registerEverfurTelevetFlow presenter threw; the in-app visit opened instead.",e),"threw"}}function b(e){let t=p();return t.listeners.add(e),()=>{t.listeners.delete(e)}}function g(){return p().snapshot}function m(){return p().hosts.length>0}function y(e){if(!m())return false;let t=/* @__PURE__ */Object.freeze({...e});return f({request:t,serial:p().snapshot.serial+1}),true}function v(){p().snapshot.request!==null&&f({request:null})}function x(){let e=p(),t=e.nextHost;return e.nextHost+=1,e.hosts=[...e.hosts,t],f({activeHost:e.hosts[0]??null}),t}function w(e){let t=p();t.hosts=t.hosts.filter(t=>t!==e);let r=t.hosts[0]??null;f(r===null?{activeHost:r,request:null}:{activeHost:r})}function k(e){let t=null;return()=>{if(t!==null)return t;let r=e();return t=r,r.then(void 0,()=>{t===r&&(t=null)}),r}}function S(t){let[r,n]=e.useState(null);e.useEffect(()=>{let e=x();return n(e),()=>{w(e)}},[]);let l=e.useSyncExternalStore(b,g,g),i=r!==null&&l.activeHost===r?l.request:null,[o,a]=e.useState(null),s=i!==null&&o===null;return e.useEffect(()=>{if(!s)return;let e=true;return t().then(t=>{e&&a(()=>t)},t=>{e&&(console.warn("[everfur] The in-app vet visit could not load its screens.",t),v())}),()=>{e=false}},[s,t]),i===null||o===null?null:{module:o,request:i,serial:l.serial,dismiss:v}}var C=k(()=>Promise.resolve(a));function EverfurTelevetHost({onAddToCalendar:e,onPickMedia:r,primaryVet:n,onFindEmergencyVet:l}={}){let i=S(C);if(i===null)return null;let{EverfurTelevetModal:o}=i.module;/* @__PURE__ */
3
- return t.jsx(o,{request:i.request,onClose:i.dismiss,...e?{onAddToCalendar:e}:{},...r?{onPickMedia:r}:{},...n?{primaryVet:n}:{},...l?{onFindEmergencyVet:l}:{}},i.serial)}var j=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[j[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[j[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function R(e){return e<=450?"regular":e<=650?"medium":"bold"}var T={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=_.get(e);r===void 0&&(r=/* @__PURE__ */new Map,_.set(e,r));let n=r.get(t);if(n!==void 0)return n;let l=z(e,t);return r.set(t,l),l}var _=/* @__PURE__ */new WeakMap;function z(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,l=R(Number(n)),i=r.face==="mono"?face(e,T[l]):r.face==="heading"?headingFace(e,l):face(e,l),o=r.face==="heading"?e.type.headingWeight??n:n,a=i.fontWeight===void 0?i:{fontFamily:i.fontFamily,fontWeight:o},s=r.size,u={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(u.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(u.textTransform="uppercase"),/* @__PURE__ */Object.freeze(u)}var I=/* @__PURE__ */Object.freeze({display:/* @__PURE__ */Object.freeze({size:29,lineHeight:1.06,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),title:/* @__PURE__ */Object.freeze({size:23,lineHeight:1.12,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),cardTitle:/* @__PURE__ */Object.freeze({size:19,lineHeight:1.22,weight:"800",face:"sans",letterSpacing:0,uppercase:false,tier:"heading"}),rowTitle:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.4,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),body:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),message:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),bodySmall:/* @__PURE__ */Object.freeze({size:14.5,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),caption:/* @__PURE__ */Object.freeze({size:13,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),label:/* @__PURE__ */Object.freeze({size:10.5,lineHeight:1.4,weight:"400",face:"mono",letterSpacing:.05,uppercase:true,tier:"compact"}),eyebrow:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"mono",letterSpacing:.07,uppercase:true,tier:"compact"}),chip:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.3,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),tab:/* @__PURE__ */Object.freeze({size:16,lineHeight:1.5,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"control"}),badge:/* @__PURE__ */Object.freeze({size:12,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"badge"})});var P=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){P(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var E=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var M={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},F={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},A={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},L={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},O={regular:"400",medium:"500",bold:"700"},V={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},D=0,B="System",H="monospace",W=["content","heading","control","compact","badge"];function N(e){let t={};for(let r of W)t[r]=e;return t}var U=[];function $(){return{family:B,mono:H,fontUrl:null,families:{regular:B,medium:B,bold:B,mono:H,monoMedium:H,monoBold:H},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:A,tierSizes:N(A),lineHeight:L,weight:O,letterSpacing:V,scale:1,maxScale:D,scaleCaps:E,headingFamily:null,headingWeight:null,fontSources:U,roles:I,typeScale:1}}var q={},G=/* @__PURE__ */Object.freeze({standard:/* @__PURE__ */Object.freeze([.2,0,0,1]),emphasized:/* @__PURE__ */Object.freeze([.2,.8,.2,1]),exit:/* @__PURE__ */Object.freeze([.4,0,1,1])});function cssCubicBezier(e){return`cubic-bezier(${e.join(", ")})`}var K={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(G.standard),emphasized:cssCubicBezier(G.emphasized),exit:cssCubicBezier(G.exit)},reducedMotion:false},Y={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",highlight:"#FFC3BC",onHighlight:"#000000",mark:"#07C168",controlEdge:"rgba(16,70,46,0.18)",structureEdge:"rgba(16,70,46,0.25)",primaryEdge:"#10462E",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)",info:"#10462E",badgeBgInfo:"rgba(16,70,46,0.10)",infoEdge:"rgba(16,70,46,0.25)"},Q=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Y,space:M,radius:F,type:$(),motion:K,slots:q}),Z={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",highlight:"#605051",onHighlight:"#F5F3F0",mark:"#07C168",controlEdge:"rgba(107,211,154,0.22)",structureEdge:"rgba(107,211,154,0.28)",primaryEdge:"#6BD39A",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)",info:"#6BD39A",badgeBgInfo:"rgba(107,211,154,0.12)",infoEdge:"rgba(107,211,154,0.28)"},J=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Z,space:M,radius:F,type:$(),motion:K,slots:q});var X=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),ee=globalThis,te=ee[X]??(ee[X]=e.createContext(Q));te.displayName??="EverfurThemeContext";function useEverfurTheme(){return e.useContext(te)}function re(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:t,variant:r,...l}){let i=useEverfurTheme(),o=r===void 0?void 0:i.type.roles[r],a=re(i.type,t??o?.tier??"content"),s=r===void 0?l:{...l,style:[{...textRole(i,r),color:i.color.text.primary,flexShrink:1},l.style]};return e.createElement(n.Text,a===void 0?s:{maxFontSizeMultiplier:a,...s})}var ne=e.forwardRef(function(t,r){return e.createElement(n.TextInput,{...t,...r===null?{}:{ref:r}})});var le=640,ie=600,oe=/* @__PURE__ */Object.freeze({width:0,height:0}),ae="useWindowDimensions"in s&&typeof s.useWindowDimensions=="function"?s.useWindowDimensions:()=>oe,se=/* @__PURE__ */Object.freeze({width:"100%",maxWidth:le,alignSelf:"center"});/* @__PURE__ */Object.freeze({...se,flex:1});var ue=/* @__PURE__ */Object.freeze({...se,flexGrow:1,flexShrink:1});function ce(){return ae().width>=ie}function de(e="flow"){let{width:t}=ae();if(t<ie)return null;if(e==="flow")return se;let r=Math.max(0,Math.round((t-le)/2));return{left:r,right:r}}function pe(e,t){return t===null?e:[e,t]}var fe=/* @__PURE__ */Symbol.for("@everfur/sdk#InSdkColumn@v1"),he=globalThis,be=he[fe]??(he[fe]=e.createContext(false));be.displayName??="EverfurInSdkColumn";function SdkTabletColumn({children:r,style:l,testID:i}){let o=ce(),a=e.useContext(be);return!o||a?r:/* @__PURE__ */t.jsx(n.View,{style:l===void 0?ue:[ue,l],testID:i??"everfur-tablet-column",children:/* @__PURE__ */t.jsx(be.Provider,{value:true,children:r})})}var ge=/* @__PURE__ */Object.freeze({chatAnswerStyle:"cards",chatHistoryStyle:"sheet",chatTopCard:"focus",chatFollowUpCount:3,chatFollowUpsExcludeTelevet:false,chatComposerMic:true,chatComposerUpload:true,safetyDisclaimerPlacement:"composer",healthPlanLayout:"focus_plan",recordsTopRiskLine:true,recordsClearResultsFilter:true,chatComposerStyle:"compact",chatComposerPlaceholder:"pet_name",chatHistoryBar:"scroll",chatGeneralBanner:true,chatSendButton:"always_dark",chatTextingAsk:true,serverSlots:false}),me=/* @__PURE__ */Object.freeze({chatAnswerStyle:"chat_answer_style",chatHistoryStyle:"chat_history_style",chatTopCard:"chat_top_card",chatFollowUpCount:"chat_follow_up_count",chatFollowUpsExcludeTelevet:"chat_follow_ups_exclude_televet",chatComposerMic:"chat_composer_mic",chatComposerUpload:"chat_composer_upload",safetyDisclaimerPlacement:"safety_disclaimer_placement",healthPlanLayout:"health_plan_layout",recordsTopRiskLine:"records_top_risk_line",recordsClearResultsFilter:"records_clear_results_filter",chatComposerStyle:"chat_composer_style",chatComposerPlaceholder:"chat_composer_placeholder",chatHistoryBar:"chat_history_bar",chatGeneralBanner:"chat_general_banner",chatSendButton:"chat_send_button",chatTextingAsk:"chat_texting_ask",serverSlots:"server_slots"}),ye=Object.keys(me),ve="presentation",xe="presentation.";var we={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer","none"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"]},ke=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function Se(e,t){if(t==null)return;let r=we[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:ke.has(e)?typeof t=="boolean"?t:void 0:typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=3?t:void 0}function parsePresentation(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let e of ye){let n=me[e],l=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],i=Se(e,l);i!==void 0&&(r[e]=i)}return Object.keys(r).length===0?null:/* @__PURE__ */Object.freeze(r)}function isPresentationFieldLocked(e,t){if(t==null)return false;let r=`${xe}${me[e]}`;for(let e of t)if(e===ve||e===r)return true;return false}function resolvePresentation(e){let t=parsePresentation(e?.server??null)??{},{safetyDisclaimerPlacement:r,...n}=t,l=r==="none"||r===void 0?n:{...n,safetyDisclaimerPlacement:r},i=parsePresentation(e?.client??null)??{},o=e?.locked?[...e.locked]:null,a={};for(let e of ye){let t=l[e],r=isPresentationFieldLocked(e,o)?void 0:i[e];a[e]=r??t??ge[e]}/* @__PURE__ */
4
- return Object.freeze(a)}var Ce="Go to the nearest emergency vet now.";var je=/* @__PURE__ */Object.freeze({placeholder:"Ask anything about {petName}…",placeholderFollowUpWeb:"Ask a follow-up…",placeholderUrgentWeb:"Tell us what’s happening…",composerLabel:"Message",attachPhotoOrFileNative:"Add a photo or file",suggestions:"Suggestions",reading:"Reading {petName}’s records…",answered:"Everfur answered.",assistantName:"Everfur",followUpsHeadingNative:"Follow-up questions",turnFailedTitleWeb:"Everfur couldn’t answer that just now.",send:"Send",stop:"Stop",retry:"Try again",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",senderVet:"Your vet",loading:"Loading",empty:"No messages yet",transcript:"Chat with Everfur",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting…",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",sourcesHeading:"Sources",openSource:"Open source",urgencyGeneralReason:"Just general info about {petName}. Nothing here needs action right now.",findVet:"Find a vet",findVetA11y:"Find a vet near you",nearestEmergencyVet:"Nearest emergency vet",goToNearestEmergencyVet:Ce,poisonControlWeb:"ASPCA Poison Control",poisonControlNative:"ASPCA Animal Poison Control, (888) 426-4435",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openHistoryNative:"Chats and vet messages",openHistoryWeb:"Chats",showChatsWeb:"Show chats",hideChatsWeb:"Hide chats",newReplySuffix:", a new reply",yourPets:"Your pets",yourPet:"Your pet",switchActivePet:"{name}. Switch pet",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active · ",close:"Close",addAnotherPet:"Add a pet",addPet:"Add a pet",capReached:"You've used your {cap} free messages this month.",attachmentPhoto:"Photo",attachmentCamera:"Camera",closeAttachmentPicker:"Close attachment picker",addAttachment:"Add attachment, {used} of {total} used",attachmentsFull:"Attachments full, {used} of {total} used",retryUpload:"Retry uploading {filename}",removeAttachment:"Remove {filename}",previewAttachment:"Preview {filename}",closePreview:"Close preview",attachedImage:"Attached image: {filename}, opens a full-screen preview",attachmentTooLarge:"Files must be under {max}. {filename} is {size}.",attachmentTooMany:"You can attach up to {max} files per message.",attachmentUnsupported:"{filename} isn't a supported file type yet.",attachmentNetwork:"Couldn't reach the server. Check your connection and try again.",attachmentServer:"Upload failed{status}. Please try again.",attachmentCancelled:"Upload cancelled.",attachmentRateLimited:"Slow down. Please wait a moment and try again.",attachmentQuota:"Daily image limit reached. Try again tomorrow.",attachmentConflict:"Something went wrong. Tap to retry.",attachmentUnknown:"Something went wrong. Please try again.",attachmentsFailedBlocked:"Some attachments failed to upload. Remove or retry them before sending.",dictate:"Dictate a message",stopDictation:"Stop dictation",listening:"Listening",micBlocked:"Microphone access is blocked. Allow it in your browser settings to dictate.",noSpeech:"We didn't catch that. Tap the mic and try again.",dictationUnavailable:"Voice typing isn't available right now."});function Re(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function Te(e){return e?.trim()||je.emptyTitlePetFallback}function _e(e,t){return Re(e,{petName:Te(t)})}var ze="tel:+18884264435";function ok(e,t){/* @__PURE__ */
3
+ return t.jsx(o,{request:i.request,onClose:i.dismiss,...e?{onAddToCalendar:e}:{},...r?{onPickMedia:r}:{},...n?{primaryVet:n}:{},...l?{onFindEmergencyVet:l}:{}},i.serial)}var j=/* @__PURE__ */Object.freeze({regular:"regular",medium:"medium",bold:"bold",mono:"regular",monoMedium:"medium",monoBold:"bold"});function face(e,t){let r=e.type,n=r.families[t];return t==="mono"||r.namedFaces[t]?{fontFamily:n}:{fontFamily:n,fontWeight:r.weight[j[t]]}}function headingFace(e,t="bold"){let{headingFamily:r,headingWeight:n}=e.type;if(r===null&&n===null)return face(e,t);if(r!==null)return{fontFamily:r,fontWeight:n??e.type.weight[j[t]]};let l=face(e,t);return l.fontWeight===void 0||n===null?l:{fontFamily:l.fontFamily,fontWeight:n}}function R(e){return e<=450?"regular":e<=650?"medium":"bold"}var T={regular:"mono",medium:"monoMedium",bold:"monoBold"};function textRole(e,t){let r=_.get(e);r===void 0&&(r=/* @__PURE__ */new Map,_.set(e,r));let n=r.get(t);if(n!==void 0)return n;let l=z(e,t);return r.set(t,l),l}var _=/* @__PURE__ */new WeakMap;function z(e,t){let r=e.type.roles[t],n=r.weight==="400"&&r.face!=="mono"?e.type.weight.regular:r.weight,l=R(Number(n)),i=r.face==="mono"?face(e,T[l]):r.face==="heading"?headingFace(e,l):face(e,l),o=r.face==="heading"?e.type.headingWeight??n:n,a=i.fontWeight===void 0?i:{fontFamily:i.fontFamily,fontWeight:o},s=r.size,u={...a,fontSize:s,lineHeight:Math.round(s*r.lineHeight*100)/100};return r.letterSpacing!==0&&(u.letterSpacing=Math.round(s*r.letterSpacing*100)/100),r.uppercase&&(u.textTransform="uppercase"),/* @__PURE__ */Object.freeze(u)}var I=/* @__PURE__ */Object.freeze({display:/* @__PURE__ */Object.freeze({size:29,lineHeight:1.06,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),title:/* @__PURE__ */Object.freeze({size:23,lineHeight:1.12,weight:"800",face:"heading",letterSpacing:-.01,uppercase:false,tier:"heading"}),cardTitle:/* @__PURE__ */Object.freeze({size:19,lineHeight:1.22,weight:"800",face:"sans",letterSpacing:0,uppercase:false,tier:"heading"}),rowTitle:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.4,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),body:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),message:/* @__PURE__ */Object.freeze({size:15.5,lineHeight:1.5,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),bodySmall:/* @__PURE__ */Object.freeze({size:14.5,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),caption:/* @__PURE__ */Object.freeze({size:13,lineHeight:1.4,weight:"400",face:"sans",letterSpacing:0,uppercase:false,tier:"content"}),label:/* @__PURE__ */Object.freeze({size:10.5,lineHeight:1.4,weight:"400",face:"mono",letterSpacing:.05,uppercase:true,tier:"compact"}),eyebrow:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"400",face:"mono",letterSpacing:.07,uppercase:true,tier:"compact"}),chip:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.3,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),tab:/* @__PURE__ */Object.freeze({size:16,lineHeight:1.5,weight:"600",face:"sans",letterSpacing:0,uppercase:false,tier:"compact"}),button:/* @__PURE__ */Object.freeze({size:15,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"control"}),badge:/* @__PURE__ */Object.freeze({size:12,lineHeight:1.5,weight:"700",face:"sans",letterSpacing:0,uppercase:false,tier:"badge"})});var P=Object.freeze;function deepFreeze(e){if(e!==null&&typeof e=="object"&&!Object.isFrozen(e)){P(e);for(let t of Object.keys(e))deepFreeze(e[t])}return e}var E=/* @__PURE__ */Object.freeze({content:0,heading:2,control:1.8,compact:1.5,badge:1.3});var M={xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},A={tile:5,xs:6,sm:10,md:14,lg:20,xl:28,pill:500},F={nano:8,small:9,micro:10,tiny:11,caption:13,bodyTight:15,body:17,subtitle:20,heading:22,verdict:24},L={tight:1.15,snug:1.3,normal:1.4,relaxed:1.55},O={regular:"400",medium:"500",bold:"700"},V={eyebrow:1,monoWide:.9,headerBrand:-.42,tight:-.35},D=0,B="System",H="monospace",W=["content","heading","control","compact","badge"];function N(e){let t={};for(let r of W)t[r]=e;return t}var U=[];function $(){return{family:B,mono:H,fontUrl:null,families:{regular:B,medium:B,bold:B,mono:H,monoMedium:H,monoBold:H},namedFaces:{regular:false,medium:false,bold:false,mono:false,monoMedium:false,monoBold:false},fontUrls:{},size:F,tierSizes:N(F),lineHeight:L,weight:O,letterSpacing:V,scale:1,maxScale:D,scaleCaps:E,headingFamily:null,headingWeight:null,fontSources:U,roles:I,typeScale:1}}var q={},G=/* @__PURE__ */Object.freeze({standard:/* @__PURE__ */Object.freeze([.2,0,0,1]),emphasized:/* @__PURE__ */Object.freeze([.2,.8,.2,1]),exit:/* @__PURE__ */Object.freeze([.4,0,1,1])});function cssCubicBezier(e){return`cubic-bezier(${e.join(", ")})`}var K={duration:{instant:80,fast:140,normal:220,slow:320},spring:{gentle:{damping:18,stiffness:200}},easing:{standard:cssCubicBezier(G.standard),emphasized:cssCubicBezier(G.emphasized),exit:cssCubicBezier(G.exit)},reducedMotion:false},Y={brand:"#10462E",brandSoft:"rgba(16,70,46,0.10)",brandSofter:"rgba(16,70,46,0.15)",brandBorder:"rgba(16,70,46,0.18)",borderHairlineGreen:"rgba(16,70,46,0.25)",brandBorderStrong:"rgba(16,70,46,0.55)",brandInk:"#10462E",linkInk:"#10462E",surface:"#FFFFFF",surfaceCream:"#FFFFFF",surfaceSubtle:"#F1F5F2",background:"#FFFFFF",borderRingCream:"#E4E4E4",chatGround:"#FFFFFF",composerFill:"#FFFFFF",composerBorder:"rgba(16,70,46,0.75)",shadow:"#0B3421",text:{primary:"#000000",secondary:"#0E462E",muted:"#6B6B6B",placeholder:"rgba(61,61,61,0.75)",onBrand:"#FFFFFF",metaCool:"#3D3D3D",timestamp:"rgba(61,61,61,0.75)"},primary:"#10462E",onPrimary:"#FFFFFF",accent:"#10462E",onAccent:"#FFFFFF",accentEdge:"#07C168",success:"#07C168",danger:"#C03410",onDanger:"#FFFFFF",errorRed:"#C03410",warningStrong:"#A45610",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.12)",badgeBgCaution:"rgba(217,130,29,0.14)",badgeBgCritical:"rgba(192,52,16,0.06)",badgeBgNeutral:"rgba(107,107,107,0.12)",bubbleUser:"#10462E",bubbleAssistant:"#FFFFFF",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#E9F1E9",scanButtonPink:"#FFC3BC",highlight:"#FFC3BC",onHighlight:"#000000",mark:"#07C168",controlEdge:"rgba(16,70,46,0.18)",structureEdge:"rgba(16,70,46,0.25)",primaryEdge:"#10462E",checkupCardLowRiskBg:"rgba(7,193,104,0.10)",checkupCardConcernBg:"rgba(239,167,0,0.10)",info:"#10462E",badgeBgInfo:"rgba(16,70,46,0.10)",infoEdge:"rgba(16,70,46,0.25)"},Q=deepFreeze({brightness:"light",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Y,space:M,radius:A,type:$(),motion:K,slots:q}),Z={brand:"#6BD39A",brandSoft:"rgba(107,211,154,0.12)",brandSofter:"rgba(107,211,154,0.18)",brandBorder:"rgba(107,211,154,0.22)",borderHairlineGreen:"rgba(107,211,154,0.28)",brandBorderStrong:"rgba(107,211,154,0.55)",brandInk:"#6BD39A",linkInk:"#6BD39A",surface:"#1C1F23",surfaceCream:"#23272C",surfaceSubtle:"#23272C",background:"#15171A",borderRingCream:"#3A3F45",chatGround:"#1C1F23",composerFill:"#23272C",composerBorder:"rgba(107,211,154,0.75)",shadow:"#000000",text:{primary:"#F5F3F0",secondary:"#A9E4C4",muted:"#9A9A9A",placeholder:"rgba(255,255,255,0.55)",onBrand:"#0E1F17",metaCool:"#C9C9C9",timestamp:"rgba(245,243,240,0.7)"},primary:"#6BD39A",onPrimary:"#0E1F17",accent:"#6BD39A",onAccent:"#0E1F17",accentEdge:"#34D888",success:"#07C168",danger:"#F87171",onDanger:"#0E1F17",errorRed:"#FF6B5B",warningStrong:"#F0A35E",cautionAccent:"#D9821D",riskConcern:"#EFA700",sentiment:{up:"#07C168",neutral:"#FBC558",down:"#FF1B00"},badgeBgPositive:"rgba(7,193,104,0.18)",badgeBgCaution:"rgba(217,130,29,0.20)",badgeBgCritical:"rgba(185,28,28,0.22)",badgeBgNeutral:"rgba(255,255,255,0.10)",bubbleUser:"#6BD39A",bubbleAssistant:"#1C1F23",bubbleVet:"#FFC3BC",onBubbleVet:"#000000",skeleton:"#23272C",scanButtonPink:"#FFC3BC",highlight:"#605051",onHighlight:"#F5F3F0",mark:"#07C168",controlEdge:"rgba(107,211,154,0.22)",structureEdge:"rgba(107,211,154,0.28)",primaryEdge:"#6BD39A",checkupCardLowRiskBg:"rgba(7,193,104,0.16)",checkupCardConcernBg:"rgba(239,167,0,0.16)",info:"#6BD39A",badgeBgInfo:"rgba(107,211,154,0.12)",infoEdge:"rgba(107,211,154,0.28)"},J=deepFreeze({brightness:"dark",highContrast:false,meta:{displayName:"Everfur",logoUrl:null,placeholder:null,hidePoweredBy:false,assistantAvatarUrl:null},color:Z,space:M,radius:A,type:$(),motion:K,slots:q});var X=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurThemeContext@v1"),ee=globalThis,te=ee[X]??(ee[X]=e.createContext(Q));te.displayName??="EverfurThemeContext";function useEverfurTheme(){return e.useContext(te)}function re(e,t){let r=e.scaleCaps[t];return r>0?r:void 0}function Text({tier:t,variant:r,...l}){let i=useEverfurTheme(),o=r===void 0?void 0:i.type.roles[r],a=re(i.type,t??o?.tier??"content"),s=r===void 0?l:{...l,style:[{...textRole(i,r),color:i.color.text.primary,flexShrink:1},l.style]};return e.createElement(n.Text,a===void 0?s:{maxFontSizeMultiplier:a,...s})}var ne=e.forwardRef(function(t,r){return e.createElement(n.TextInput,{...t,...r===null?{}:{ref:r}})});var le=640,ie=600,oe=/* @__PURE__ */Object.freeze({width:0,height:0}),ae="useWindowDimensions"in s&&typeof s.useWindowDimensions=="function"?s.useWindowDimensions:()=>oe,se=/* @__PURE__ */Object.freeze({width:"100%",maxWidth:le,alignSelf:"center"});/* @__PURE__ */Object.freeze({...se,flex:1});var ue=/* @__PURE__ */Object.freeze({...se,flexGrow:1,flexShrink:1});function ce(){return ae().width>=ie}function de(e="flow"){let{width:t}=ae();if(t<ie)return null;if(e==="flow")return se;let r=Math.max(0,Math.round((t-le)/2));return{left:r,right:r}}function pe(e,t){return t===null?e:[e,t]}var fe=/* @__PURE__ */Symbol.for("@everfur/sdk#InSdkColumn@v1"),he=globalThis,be=he[fe]??(he[fe]=e.createContext(false));be.displayName??="EverfurInSdkColumn";function SdkTabletColumn({children:r,style:l,testID:i}){let o=ce(),a=e.useContext(be);return!o||a?r:/* @__PURE__ */t.jsx(n.View,{style:l===void 0?ue:[ue,l],testID:i??"everfur-tablet-column",children:/* @__PURE__ */t.jsx(be.Provider,{value:true,children:r})})}var ge=/* @__PURE__ */Object.freeze(["ask","vet","plan","records"]),me=/* @__PURE__ */Object.freeze({chatAnswerStyle:"cards",chatHistoryStyle:"sheet",chatTopCard:"focus",chatFollowUpCount:3,chatFollowUpsExcludeTelevet:false,chatComposerMic:true,chatComposerUpload:true,safetyDisclaimerPlacement:"composer",healthPlanLayout:"focus_plan",recordsTopRiskLine:true,recordsClearResultsFilter:true,chatComposerStyle:"compact",chatComposerPlaceholder:"pet_name",chatHistoryBar:"scroll",chatGeneralBanner:true,chatSendButton:"always_dark",chatTextingAsk:true,serverSlots:false,shellTabs:null,shellHeader:"classic"}),ye=/* @__PURE__ */Object.freeze({chatAnswerStyle:"chat_answer_style",chatHistoryStyle:"chat_history_style",chatTopCard:"chat_top_card",chatFollowUpCount:"chat_follow_up_count",chatFollowUpsExcludeTelevet:"chat_follow_ups_exclude_televet",chatComposerMic:"chat_composer_mic",chatComposerUpload:"chat_composer_upload",safetyDisclaimerPlacement:"safety_disclaimer_placement",healthPlanLayout:"health_plan_layout",recordsTopRiskLine:"records_top_risk_line",recordsClearResultsFilter:"records_clear_results_filter",chatComposerStyle:"chat_composer_style",chatComposerPlaceholder:"chat_composer_placeholder",chatHistoryBar:"chat_history_bar",chatGeneralBanner:"chat_general_banner",chatSendButton:"chat_send_button",chatTextingAsk:"chat_texting_ask",serverSlots:"server_slots",shellTabs:"shell_tabs",shellHeader:"shell_header"}),ve=Object.keys(ye),xe="presentation",we="presentation.";var ke={chatAnswerStyle:["bubbles","cards"],chatHistoryStyle:["drawer","sheet"],chatTopCard:["none","focus"],safetyDisclaimerPlacement:["composer","answer_footer","none"],healthPlanLayout:["standard","focus_plan"],chatComposerStyle:["standard","compact"],chatComposerPlaceholder:["generic","pet_name"],chatHistoryBar:["pinned","scroll"],chatSendButton:["always_dark","dim_when_empty"],shellHeader:["classic","tabs_bar"]};function Se(e){if(!Array.isArray(e)||e.length===0)return;let t=/* @__PURE__ */new Set;for(let r of e){if(typeof r!="string"||!ge.includes(r)||t.has(r))return;t.add(r)}/* @__PURE__ */
4
+ return Object.freeze([...e])}var Ce=/* @__PURE__ */new Set(["chatFollowUpsExcludeTelevet","chatComposerMic","chatComposerUpload","recordsTopRiskLine","recordsClearResultsFilter","chatGeneralBanner","chatTextingAsk","serverSlots"]);function je(e,t){if(t==null)return;if(e==="shellTabs")return Se(t);let r=ke[e];return r!==void 0?typeof t=="string"&&r.includes(t)?t:void 0:Ce.has(e)?typeof t=="boolean"?t:void 0:typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=3?t:void 0}function parsePresentation(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let e of ve){let n=ye[e],l=Object.prototype.hasOwnProperty.call(t,n)?t[n]:t[e],i=je(e,l);i!==void 0&&(r[e]=i)}return Object.keys(r).length===0?null:/* @__PURE__ */Object.freeze(r)}function isPresentationFieldLocked(e,t){if(t==null)return false;let r=`${we}${ye[e]}`;for(let e of t)if(e===xe||e===r)return true;return false}function resolvePresentation(e){let t=parsePresentation(e?.server??null)??{},{safetyDisclaimerPlacement:r,...n}=t,l=r==="none"||r===void 0?n:{...n,safetyDisclaimerPlacement:r},i=parsePresentation(e?.client??null)??{},o=e?.locked?[...e.locked]:null,a={};for(let e of ve){let t=l[e],r=isPresentationFieldLocked(e,o)?void 0:i[e];a[e]=r??t??me[e]}/* @__PURE__ */
5
+ return Object.freeze(a)}var Re="Go to the nearest emergency vet now.";var Te=/* @__PURE__ */Object.freeze({placeholder:"Ask anything about {petName}…",placeholderFollowUpWeb:"Ask a follow-up…",placeholderUrgentWeb:"Tell us what’s happening…",composerLabel:"Message",attachPhotoOrFileNative:"Add a photo or file",suggestions:"Suggestions",reading:"Reading {petName}’s records…",answered:"Everfur answered.",assistantName:"Everfur",followUpsHeadingNative:"Follow-up questions",turnFailedTitleWeb:"Everfur couldn’t answer that just now.",send:"Send",stop:"Stop",retry:"Try again",poweredBy:"powered by everfur",senderUser:"You",senderAssistant:"Assistant",senderVet:"Your vet",loading:"Loading",empty:"No messages yet",transcript:"Chat with Everfur",emptyTitle:"What can we help {petName} with today?",emptyTitlePetFallback:"your pet",copied:"Copied",copyUserMessage:"Copy your message",copyAssistantMessage:"Copy assistant message",feedbackHelpful:"Helpful",feedbackNeutral:"Neutral",feedbackNotHelpful:"Not helpful",feedbackTitle:"What went wrong?",feedbackSubtitle:"Your feedback helps make answers more reliable.",feedbackReasonInaccurate:"Inaccurate",feedbackReasonOutdated:"Out of date",feedbackReasonUnsafe:"Unsafe advice",feedbackReasonUnclear:"Confusing or unclear",feedbackReasonOther:"Something else",feedbackNotesPlaceholder:"Add details (optional)",feedbackSubmit:"Submit feedback",feedbackSkip:"Skip",feedbackSkipA11y:"Skip feedback",feedbackThanks:"Thanks for the feedback",feedbackFailed:"Couldn't send feedback. Please try again.",turnFailedTitle:"Message failed",turnRetry:"Retry",turnUnreachableTitle:"Couldn't reach this chat",turnStartNewChat:"Start a new chat",reconnecting:"Reconnecting…",turnStoppedTitle:"Response stopped",turnStoppedBody:"You stopped this response before it finished. Tap retry to try again.",sourceSingular:"source",sourcePlural:"sources",showSources:"Show",hideSources:"Hide",sourcesHeading:"Sources",openSource:"Open source",urgencyGeneralReason:"Just general info about {petName}. Nothing here needs action right now.",findVet:"Find a vet",findVetA11y:"Find a vet near you",nearestEmergencyVet:"Nearest emergency vet",goToNearestEmergencyVet:Re,poisonControlWeb:"ASPCA Poison Control",poisonControlNative:"ASPCA Animal Poison Control, (888) 426-4435",showLatestVetAlert:"Show latest vet alert",dismissBanner:"Dismiss {label} banner",openHistoryNative:"Chats and vet messages",openHistoryWeb:"Chats",showChatsWeb:"Show chats",hideChatsWeb:"Hide chats",newReplySuffix:", a new reply",yourPets:"Your pets",yourPet:"Your pet",switchActivePet:"{name}. Switch pet",petCurrentlyActive:"{name}, currently active",switchToPet:"Switch to {name}",activePrefix:"Active · ",close:"Close",addAnotherPet:"Add a pet",addPet:"Add a pet",capReached:"You've used your {cap} free messages this month.",attachmentPhoto:"Photo",attachmentCamera:"Camera",closeAttachmentPicker:"Close attachment picker",addAttachment:"Add attachment, {used} of {total} used",attachmentsFull:"Attachments full, {used} of {total} used",retryUpload:"Retry uploading {filename}",removeAttachment:"Remove {filename}",previewAttachment:"Preview {filename}",closePreview:"Close preview",attachedImage:"Attached image: {filename}, opens a full-screen preview",attachmentTooLarge:"Files must be under {max}. {filename} is {size}.",attachmentTooMany:"You can attach up to {max} files per message.",attachmentUnsupported:"{filename} isn't a supported file type yet.",attachmentNetwork:"Couldn't reach the server. Check your connection and try again.",attachmentServer:"Upload failed{status}. Please try again.",attachmentCancelled:"Upload cancelled.",attachmentRateLimited:"Slow down. Please wait a moment and try again.",attachmentQuota:"Daily image limit reached. Try again tomorrow.",attachmentConflict:"Something went wrong. Tap to retry.",attachmentUnknown:"Something went wrong. Please try again.",attachmentsFailedBlocked:"Some attachments failed to upload. Remove or retry them before sending.",dictate:"Dictate a message",stopDictation:"Stop dictation",listening:"Listening",micBlocked:"Microphone access is blocked. Allow it in your browser settings to dictate.",noSpeech:"We didn't catch that. Tap the mic and try again.",dictationUnavailable:"Voice typing isn't available right now."});function _e(e,t){return e.replace(/\{(\w+)\}/g,(e,r)=>{let n=t[r];return n===void 0?e:String(n)})}function ze(e){return e?.trim()||Te.emptyTitlePetFallback}function Ie(e,t){return _e(e,{petName:ze(t)})}var Pe="tel:+18884264435";function ok(e,t){/* @__PURE__ */
5
6
  return Object.freeze({ok:true,value:e})}function err(e){/* @__PURE__ */
6
- return Object.freeze({ok:false,error:e})}var Ie=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var Pe=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Ee=globalThis,Me=Ee[Pe]??(Ee[Pe]=e.createContext(null));Me.displayName??="EverfurContext";function Fe(){let t=e.useContext(Me);if(t===null)throw new Ie("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return t}var Ae=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],Le=/* @__PURE__ */Object.freeze(Ae.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(Le.map(e=>e.wireCode));var Oe=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),Ve=/* @__PURE__ */Object.freeze(Le.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:Oe[e.wireCode]}))),De=new Map(Ve.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),Be=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(Ve.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...Be]){let t=De.get(e+r);if(t)return t}}var He=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(e){return He[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var We=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return We.has(e)}var Ne=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||Ne.has(e)}var Ue=500,$e=8e3,qe=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(Ue*2**r,$e);return Math.floor(t()*n)}var Ge="This feature isn't available on your account right now.",Ke="Something in that request was not right. Check the details and try again.",Ye=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:Ge,paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:Ke,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:Ge,runtimeDisposed:Ke,unknown:"Something went wrong. Please try again."}),Qe="This session has ended. Please sign in again.",Ze="linked_account_read_only";function Je(e,t,r){return e==="conflict"&&r===Ze?Ge:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?Qe:userFacingError(e)}function userFacingError(e){return Ye[e]}function Xe(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var et=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===Ze,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:Je(e,t?.wireCode,n?Ze:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&et.test(t.reasonCode)&&(l.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(l.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&Xe(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&Xe(l,"raw",t.raw),/* @__PURE__ */Object.freeze(l)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
7
- return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var tt="x-everfur-anon-token",rt="anonTokenInvalid";async function nt(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function lt(e,t){let r=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...r?{wireMessage:r}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[tt]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...it(e.headers),...authHeaders(t)}}}function it(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===tt||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await nt(t),n=await t.transport.request(withAuthHeaders(e,ot(t,r)));if(n.ok||st(n.error.raw)!==rt||t.anonIdentity===void 0||t.userRef!==null)return n;let l=await t.anonIdentity.token({forceRefresh:true});return l===null||l===r?n:t.transport.request(withAuthHeaders(e,ot(t,l)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(lt(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let l;try{l=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(lt(e,{wireCode:st(n.error.raw),requestId:n.error.requestId}))}let i=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:l,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!i.ok&&i.error.httpStatus===401?(t.identity.reportRejected?.(),err(at(i.error))):i}function ot(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function at(e){let t=e.raw,r=st(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function st(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}var ut="free_cap_reached";function ct(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function dt(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==ut&&n.code!==ut)return null;let l=ct(n.limit),i=ct(n.used);if(l===null||i===null)return null;let o=n.resets_at,a=n.emergency_guidance;/* @__PURE__ */
8
- return Object.freeze({limit:l,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof a=="string"&&a.trim().length>0?{emergencyGuidance:a}:{}})}function pt(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:dt(t)}function ft(e,t){let r=globalThis.URL;if(typeof r=="function"){let n;try{n=t===void 0?new r(e):new r(e,t)}catch{return null}try{if(n.protocol)return n}catch{}}return mt(e)}var ht=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,bt=/[\s\u0000-\u001f\u007f\\]/,gt={"http:":"80","https:":"443"};function mt(e,t){let r=e.trim();let n=bt.test(r)?null:ht.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",c="",d=""]=n,p=`${l.toLowerCase()}:`,f=Number(s);if(f>65535)return null;let h=s===""||String(f)===gt[p]?"":String(f),b=gt[p]!==void 0,g=a.toLowerCase()+(h&&`:${h}`),m=u||(b?"/":""),y=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${p}//${y}${g}${m}${c}${d}`,protocol:p,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:b?`${p}//${g}`:"null",pathname:m,search:c==="?"?"":c,hash:d==="#"?"":d}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:yt(e)})}function yt(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var vt=3e4,xt=$e*2,wt="idempotency-key",kt=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),St=/* @__PURE__ */Object.freeze({onEvent(){}}),Ct=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function jt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??St,r=e.timers??Ct,n=e.rng??Math.random,l=e.sleep??((e,t)=>Ht(e,r,t)),i=e.maxAttempts??qe,o=e.unaryTimeoutMs??vt,a=e.newIdempotencyKey??Tt(),s=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,c){let d=c?.maxAttempts,p=Math.max(1,d??i),f=c?.idempotent??kt.has(u.method),h=c?.idempotencyKey===void 0?null:jt(c.idempotencyKey),b=f?h??a():null,g=Rt(u,b),m=0;for(;;){let i=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:m,...b?{idempotencyKey:b}:{},...e});s(i({phase:"attempt"}));let a=Dt(o,r),c=Bt(a.signal,u.signal),f;try{f=await authedSend({...g,signal:c.signal},e.auth)}catch(e){f=err(networkError(e))}finally{c.dispose(),a.cancel()}if(f.ok)return s(i({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,y=zt(h,m,{maxAttempts:p,rng:n,now:r.now(),aborted:u.signal?.aborted===true,...d!==void 0?{perCallMaxAttempts:d}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:h.code,reason:y.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!y.retry)return s(i({phase:"settled",...v})),err(h);if(s(i({phase:"retry",...v,delayMs:y.delayMs})),await l(y.delayMs,u.signal),u.signal?.aborted===true)return s(i({phase:"settled",...v,reason:"aborted"})),err(h);m+=1}}async function c(t){return withAuthHeaders(t,await Vt(e.auth))}async function*d(t,r,n){s(
7
+ return Object.freeze({ok:false,error:e})}var Ee=class _EverfurConfigError extends Error{constructor(e,t){super(t),this.name="EverfurConfigError",this.kind=e,Object.setPrototypeOf(this,_EverfurConfigError.prototype)}};var Me=/* @__PURE__ */Symbol.for("@everfur/sdk#EverfurContext@v1"),Ae=globalThis,Fe=Ae[Me]??(Ae[Me]=e.createContext(null));Fe.displayName??="EverfurContext";function Le(){let t=e.useContext(Fe);if(t===null)throw new Ee("not-initialized","Everfur hooks must be called inside <EverfurProvider>. Wrap your tree once, high.");return t}var Oe=[{wireCode:"AccessDeniedException",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"AuthorizationException",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"ConflictException",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"DAILY_QUOTA_EXCEEDED",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"FILE_TOO_LARGE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"IDEMPOTENCY_KEY_IN_FLIGHT",envelope:"http_envelope",httpStatus:409,retryable:true},{wireCode:"IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"INVALID_CONTENT_TYPE",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"InternalFailureException",envelope:"http_envelope",httpStatus:500,retryable:true},{wireCode:"MethodNotAllowedException",envelope:"http_envelope",httpStatus:405,retryable:false},{wireCode:"NotImplementedException",envelope:"http_envelope",httpStatus:501,retryable:false},{wireCode:"PaymentRequiredException",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ResourceNotFoundException",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"ServiceUnavailableException",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"TIER_UPGRADE_REQUIRED",envelope:"http_envelope",httpStatus:402,retryable:false},{wireCode:"ThrottlingException",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"ValidationException",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"accessDenied",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"access_denied",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"anchor_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"anchor_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"anonTokenInvalid",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"attachment_unreadable",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"authExpired",envelope:"http_envelope",httpStatus:401,retryable:true},{wireCode:"authRejected",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"before_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundle_not_uploaded",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"bundles_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"catalog_empty_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"catalog_shrink_refused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"consent_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_required",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"consent_scope_wrong_route",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"device_cipher_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"email_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"endpoint_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"environment_mismatch",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_cursor_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"event_payload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_not_available",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"event_type_unknown",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_required",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"idempotency_key_reused",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"inbox_cursor_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"insufficientCapability",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"insufficient_scope",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"internal_error",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"invalidRequest",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"invalid_client",envelope:"oauth_error",httpStatus:401,retryable:false},{wireCode:"invalid_client_metadata",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_grant",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_redirect_uri",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_request",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_scope",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"invalid_target",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"item_id_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"linked_account_read_only",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_connection_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"mcp_request_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"mcp_request_gone",envelope:"http_envelope",httpStatus:410,retryable:false},{wireCode:"mcp_request_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"not_found",envelope:"sse_frame",httpStatus:200,retryable:false},{wireCode:"not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"open_url_not_allowed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"partner_visit_link_conflict",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"partner_visit_owner_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"partner_visit_pet_already_mapped",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"payload_too_large",envelope:"http_envelope",httpStatus:413,retryable:false},{wireCode:"petRefInUse",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"pet_health_list_removals_unconfirmed",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_health_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"pet_not_registered",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"provider_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"rateLimited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"read_target_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"record_subject_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"record_upload_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"records_consent_required",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"restricted_key",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"sandbox_only",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_required",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"session_revoked",envelope:"http_envelope",httpStatus:401,retryable:false},{wireCode:"share_limit_reached",envelope:"http_envelope",httpStatus:429,retryable:false},{wireCode:"slow_down",envelope:"oauth_error",httpStatus:429,retryable:true},{wireCode:"species_unsupported",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"subscription_keys_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"tenant_filter_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"tenant_has_no_capabilities",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tenant_resource_not_found",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"tenant_surface_not_enabled",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"ticket_not_resolved",envelope:"http_envelope",httpStatus:409,retryable:false},{wireCode:"tickets_disabled",envelope:"http_envelope",httpStatus:404,retryable:false},{wireCode:"timeout",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"timezone_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"token_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"unavailable",envelope:"sse_frame",httpStatus:200,retryable:true},{wireCode:"unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"unrestrictedKeyRequired",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"unsupported_grant_type",envelope:"oauth_error",httpStatus:400,retryable:false},{wireCode:"unsupported_response_type",envelope:"oauth_error",httpStatus:302,retryable:false},{wireCode:"user_ref_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"verify_mint_rate_limited",envelope:"http_envelope",httpStatus:429,retryable:true},{wireCode:"verify_mint_refused",envelope:"http_envelope",httpStatus:403,retryable:false},{wireCode:"verify_mint_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"verify_user_ref_invalid",envelope:"http_envelope",httpStatus:422,retryable:false},{wireCode:"web_push_unavailable",envelope:"http_envelope",httpStatus:503,retryable:true},{wireCode:"webhook_endpoint_update_empty",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_endpoint_update_invalid",envelope:"http_envelope",httpStatus:400,retryable:false},{wireCode:"webhook_url_rejected",envelope:"http_envelope",httpStatus:400,retryable:false}],Ve=/* @__PURE__ */Object.freeze(Oe.map(e=>/* @__PURE__ */Object.freeze(e)));/* @__PURE__ */Object.freeze(Ve.map(e=>e.wireCode));var De=/* @__PURE__ */Object.freeze({ValidationException:"validationFailed",AuthorizationException:"authRejected",PaymentRequiredException:"paymentRequired",AccessDeniedException:"accessDenied",ResourceNotFoundException:"resourceNotFound",ConflictException:"conflict",ThrottlingException:"rateLimited",InternalFailureException:"internalError",NotImplementedException:"notImplemented",ServiceUnavailableException:"serviceUnavailable",MethodNotAllowedException:"validationFailed",authExpired:"authExpired",unavailable:"serviceUnavailable",session_required:"sessionRequired",session_revoked:"authExpired",anonTokenInvalid:"authRejected",accessDenied:"accessDenied",invalidRequest:"sdkUpdateRequired",authRejected:"authRejected",rateLimited:"rateLimited",insufficientCapability:"accessDenied",unrestrictedKeyRequired:"accessDenied",user_ref_invalid:"validationFailed",event_cursor_invalid:"validationFailed",event_filter_invalid:"validationFailed",event_payload_invalid:"validationFailed",event_type_unknown:"validationFailed",idempotency_key_invalid:"validationFailed",idempotency_key_required:"validationFailed",idempotency_key_reused:"idempotencyConflict",payload_too_large:"validationFailed",webhook_url_rejected:"validationFailed",webhook_endpoint_update_empty:"validationFailed",webhook_endpoint_update_invalid:"validationFailed",event_type_not_available:"conflict",record_subject_not_found:"resourceNotFound",records_consent_required:"conflict",record_species_unsupported:"validationFailed",record_upload_invalid:"validationFailed",FILE_TOO_LARGE:"validationFailed",INVALID_CONTENT_TYPE:"validationFailed",attachment_unreadable:"validationFailed",provider_unsupported:"validationFailed",token_invalid:"validationFailed",device_cipher_unavailable:"serviceUnavailable",email_invalid:"validationFailed",consent_required:"validationFailed",consent_invalid:"validationFailed",consent_scope_wrong_route:"validationFailed",IDEMPOTENCY_KEY_IN_FLIGHT:"idempotencyInFlight",IDEMPOTENCY_KEY_REUSED_DIFFERENT_REQUEST:"idempotencyConflict",DAILY_QUOTA_EXCEEDED:"quotaExceeded",TIER_UPGRADE_REQUIRED:"paymentRequired",not_found:"conversationNotFound",timeout:"streamTimeout",internal_error:"internalError",invalid_request:"validationFailed",invalid_client:"authRejected",invalid_grant:"authRejected",unsupported_grant_type:"validationFailed",invalid_scope:"validationFailed",invalid_target:"validationFailed",invalid_redirect_uri:"validationFailed",invalid_client_metadata:"validationFailed",unsupported_response_type:"validationFailed",access_denied:"accessDenied",slow_down:"rateLimited",mcp_request_not_found:"resourceNotFound",mcp_request_gone:"resourceNotFound",mcp_connection_not_found:"resourceNotFound",mcp_request_conflict:"conflict",sandbox_only:"accessDenied",tenant_has_no_capabilities:"conflict",verify_mint_refused:"accessDenied",verify_mint_rate_limited:"rateLimited",verify_mint_unavailable:"serviceUnavailable",verify_user_ref_invalid:"validationFailed",insufficient_scope:"accessDenied",tenant_filter_invalid:"validationFailed",tenant_resource_not_found:"resourceNotFound",tenant_surface_not_enabled:"conflict",pet_health_species_unsupported:"validationFailed",pet_health_list_removals_unconfirmed:"validationFailed",petRefInUse:"conflict",share_limit_reached:"conflict",pet_not_registered:"resourceNotFound",species_unsupported:"validationFailed",partner_visit_owner_only:"accessDenied",partner_visit_link_conflict:"conflict",partner_visit_pet_already_mapped:"conflict",linked_account_read_only:"conflict",catalog_empty_refused:"conflict",catalog_shrink_refused:"conflict",endpoint_not_allowed:"validationFailed",event_id_invalid:"validationFailed",inbox_cursor_invalid:"validationFailed",item_id_invalid:"validationFailed",open_url_not_allowed:"validationFailed",read_target_invalid:"validationFailed",subscription_keys_invalid:"validationFailed",web_push_unavailable:"serviceUnavailable",anchor_not_found:"resourceNotFound",anchor_ref_invalid:"validationFailed",before_invalid:"validationFailed",bundle_mismatch:"validationFailed",bundle_not_uploaded:"validationFailed",bundles_unavailable:"serviceUnavailable",environment_mismatch:"validationFailed",restricted_key:"accessDenied",ticket_not_resolved:"conflict",tickets_disabled:"resourceNotFound",timezone_invalid:"validationFailed"}),Be=/* @__PURE__ */Object.freeze(Ve.map(e=>/* @__PURE__ */Object.freeze({wireCode:e.wireCode,envelope:e.envelope,retryable:e.retryable,normalized:De[e.wireCode]}))),He=new Map(Be.map(e=>[e.envelope+e.wireCode.toUpperCase(),e])),We=/* @__PURE__ */Object.freeze(["http_envelope",...[...new Set(Be.map(e=>e.envelope))].filter(e=>e!=="http_envelope").sort()]);function contractErrorFor(e,t){if(typeof e!="string")return;let r=e.trim().toUpperCase();if(r.length!==0)for(let e of[t??"http_envelope",...We]){let t=He.get(e+r);if(t)return t}}var Ne=/* @__PURE__ */Object.freeze({authExpired:"authentication",authRejected:"authentication",sessionRequired:"authentication",identitySignatureRequired:"authentication",accessDenied:"authorization",paymentRequired:"entitlement",quotaExceeded:"rateLimit",rateLimited:"rateLimit",validationFailed:"invalidRequest",sdkUpdateRequired:"invalidRequest",runtimeDisposed:"invalidRequest",conversationNotFound:"notFound",petNotFound:"notFound",resourceNotFound:"notFound",conflict:"conflict",idempotencyConflict:"conflict",idempotencyInFlight:"conflict",streamTimeout:"connection",streamIncomplete:"connection",upstreamLlmTimeout:"connection",serviceUnavailable:"connection",internalError:"server",notImplemented:"server",mediaUploadFailed:"media",moderationBlocked:"policy",unknown:"unknown"});function categoryFor(e){return Ne[e]}function fromWire(e){let t=contractErrorFor(e);if(t)return t.normalized;let r=(e??"").trim().toUpperCase(),n=r.replace(/[^A-Z0-9]/g,"");if(n==="AUTHREJECTED")return"authRejected";if(r.startsWith("AUTH"))return"authExpired";switch(n){case"DAILYQUOTAEXCEEDED":case"QUOTAEXCEEDED":return"quotaExceeded";case"RATELIMITED":case"TOOMANYREQUESTS":case"TELEVETRATELIMITED":return"rateLimited";case"IDEMPOTENCYKEYCONFLICT":case"IDEMPOTENCYCONFLICT":return"idempotencyConflict";case"ACCESSDENIED":case"FORBIDDEN":return"accessDenied";case"IDENTITYSIGNATUREREQUIRED":return"identitySignatureRequired";case"FREECAPREACHED":return"paymentRequired";case"RUNTIMEDISPOSED":return"runtimeDisposed";case"NOTFOUND":case"CONVERSATIONNOTFOUND":return"conversationNotFound";case"PETNOTFOUND":return"petNotFound";case"TIMEOUT":case"STREAMTIMEOUT":return"streamTimeout";case"MEDIAUPLOADFAILED":case"UNRECOGNIZEDVIDEOFORMAT":case"FILETOOSMALL":return"mediaUploadFailed";case"MODERATIONBLOCKED":return"moderationBlocked";case"UPSTREAMLLMTIMEOUT":return"upstreamLlmTimeout";case"INTERNALERROR":case"INTERNALSERVERERROR":return"internalError";case"STREAMINCOMPLETE":case"CHATSTREAMINCOMPLETE":return"streamIncomplete";case"INVALIDANALYSISTYPE":case"INVALIDUPLOADPURPOSE":return"unknown";default:return"unknown"}}var Ue=/* @__PURE__ */new Set(["streamTimeout","rateLimited","internalError","upstreamLlmTimeout","streamIncomplete"]);function isAutoRetryable(e){return Ue.has(e)}var $e=/* @__PURE__ */new Set(["serviceUnavailable","conflict","idempotencyInFlight"]);function isRetryableCode(e){return isAutoRetryable(e)||$e.has(e)}var qe=500,Ge=8e3,Ke=4;function backoffDelayMs(e,t=Math.random){let r=Math.max(0,e),n=Math.min(qe*2**r,Ge);return Math.floor(t()*n)}var Ye="This feature isn't available on your account right now.",Qe="Something in that request was not right. Check the details and try again.",Ze=/* @__PURE__ */Object.freeze({authExpired:"Please sign in again to continue.",authRejected:"Please sign in again to continue.",sessionRequired:"This app needs to be updated to keep using Everfur.",accessDenied:Ye,paymentRequired:"This is part of a paid plan.",quotaExceeded:"You have used today's messages. This resets tomorrow.",rateLimited:"You are sending messages quickly. Try again in a few seconds.",validationFailed:Qe,sdkUpdateRequired:"This app needs to be updated to keep using Everfur.",conflict:"That is already running. Wait for it to finish, then try again.",idempotencyConflict:"That message was already delivered.",idempotencyInFlight:"That is still processing. Give it a moment.",conversationNotFound:"This conversation is no longer available.",petNotFound:"We could not find that pet. Please pick a pet and try again.",resourceNotFound:"We could not find that.",streamTimeout:"The response timed out. Tap retry to try again.",mediaUploadFailed:"We could not upload that photo. Please attach it again.",moderationBlocked:"This request cannot be answered here.",upstreamLlmTimeout:"The response timed out. Tap retry to try again.",internalError:"We hit a snag on our end. Please try again.",notImplemented:"That is not available yet.",serviceUnavailable:"That service is briefly unavailable. Try again shortly.",streamIncomplete:"The connection dropped mid-answer. Tap retry to continue.",identitySignatureRequired:Ye,runtimeDisposed:Qe,unknown:"Something went wrong. Please try again."}),Je="This session has ended. Please sign in again.",Xe="linked_account_read_only";function et(e,t,r){return e==="conflict"&&r===Xe?Ye:(e==="authRejected"||e==="authExpired")&&typeof t=="string"&&t.trim().toLowerCase()==="session_revoked"?Je:userFacingError(e)}function userFacingError(e){return Ze[e]}function tt(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:false,writable:false,configurable:false})}var rt=/^[a-z][a-z0-9_]{0,63}$/;function makeEverfurError(e,t){let r=contractErrorFor(t?.wireCode,t?.wireEnvelope),n=e==="conflict"&&t?.reasonCode===Xe,l={code:e,category:categoryFor(e),retryable:t?.retryable??(n?false:isRetryableCode(e)),displayMessage:et(e,t?.wireCode,n?Xe:null)};t?.httpStatus!==void 0&&(l.httpStatus=t.httpStatus),t?.requestId&&(l.requestId=t.requestId),typeof t?.reasonCode=="string"&&rt.test(t.reasonCode)&&(l.reasonCode=t.reasonCode);let i=t?.retryAfterSeconds;if(typeof i=="number"&&Number.isFinite(i)&&i>=0&&(l.retryAfterSeconds=Math.round(i)),r);return t?.wireMessage&&tt(l,"wireMessage",t.wireMessage),t?.raw!==void 0&&t.raw!==null&&tt(l,"raw",t.raw),/* @__PURE__ */Object.freeze(l)}function assertNever(e){throw new Error(`assertNever: unhandled discriminated-union member ${JSON.stringify(e)}`)}function errorFrame(e){/* @__PURE__ */
8
+ return Object.freeze({kind:"error",terminal:true,code:e.code,retryable:e.retryable,wireMessage:e.wireMessage,synthesized:e.synthesized,lastEventId:e.lastEventId,serverRequestId:null,...e.freeCap?{freeCap:/* @__PURE__ */Object.freeze({...e.freeCap})}:{}})}var nt="x-everfur-anon-token",lt="anonTokenInvalid";async function it(e){if(e.userRef!==null||e.anonIdentity===void 0)return null;try{return await e.anonIdentity.token()}catch{return null}}function ot(e,t){let r=e instanceof Error?e.message:typeof e=="string"?e:null;return makeEverfurError("authRejected",{retryable:false,...t?.wireCode?{wireCode:t.wireCode}:{},...t?.requestId?{requestId:t.requestId}:{},...r?{wireMessage:r}:{},...e!=null?{raw:e}:{}})}function authHeaders(e){let t={};return e.mode==="personalized"?t.authorization=`Bearer ${e.token}`:(t["x-everfur-partner-key"]=e.publishableKey,e.anonToken&&(t[nt]=e.anonToken)),e.userRef&&(t["x-everfur-user-ref"]=e.userRef),e.sessionId&&(t["x-everfur-session-id"]=e.sessionId),t}function withAuthHeaders(e,t){return{...e,headers:{...at(e.headers),...authHeaders(t)}}}function at(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let e=r.toLowerCase();e==="authorization"||e==="x-everfur-partner-key"||e===nt||(t[r]=n)}return t}async function authedSend(e,t){if(t.mode==="anonymous"){let r=await it(t),n=await t.transport.request(withAuthHeaders(e,st(t,r)));if(n.ok||ct(n.error.raw)!==lt||t.anonIdentity===void 0||t.userRef!==null)return n;let l=await t.anonIdentity.token({forceRefresh:true});return l===null||l===r?n:t.transport.request(withAuthHeaders(e,st(t,l)))}let r;try{r=await t.identity.currentToken()}catch(e){return t.identity.reportRejected?.(),err(ot(e))}let n=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:r,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));if(n.ok||n.error.httpStatus!==401)return n;let l;try{l=await t.identity.currentToken({forceRefresh:!0})}catch(e){return t.identity.reportRejected?.(),err(ot(e,{wireCode:ct(n.error.raw),requestId:n.error.requestId}))}let i=await t.transport.request(withAuthHeaders(e,{mode:"personalized",token:l,userRef:t.userRef,...t.sessionId?{sessionId:t.sessionId}:{}}));return!i.ok&&i.error.httpStatus===401?(t.identity.reportRejected?.(),err(ut(i.error))):i}function st(e,t){return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}function ut(e){let t=e.raw,r=ct(t);return makeEverfurError("authRejected",{retryable:false,...e.httpStatus!==void 0?{httpStatus:e.httpStatus}:{},...e.requestId?{requestId:e.requestId}:{},...r?{wireCode:r}:{},...e.reasonCode?{reasonCode:e.reasonCode}:{},...e.wireMessage?{wireMessage:e.wireMessage}:{},...t!=null?{raw:t}:{}})}function ct(e){if(typeof e!="object"||e===null)return null;let t=e,r=(typeof t.error=="object"&&t.error!==null?t.error.code:void 0)??t.code;return typeof r=="string"&&r.length>0?r:null}var dt="free_cap_reached";function pt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ft(e){if(typeof e!="object"||e===null)return null;let t=e,r=t.detail,n=typeof r=="object"&&r!==null?r:t;if(n.error!==dt&&n.code!==dt)return null;let l=pt(n.limit),i=pt(n.used);if(l===null||i===null)return null;let o=n.resets_at,a=n.emergency_guidance;/* @__PURE__ */
9
+ return Object.freeze({limit:l,used:i,resetsAt:typeof o=="string"&&o.length>0?o:null,...typeof a=="string"&&a.trim().length>0?{emergencyGuidance:a}:{}})}function ht(e){let t=e.raw;if(typeof t!="object"||t===null)return null;let r=t.freeCap;return typeof r=="object"&&r!==null?r:ft(t)}function bt(e,t){let r=globalThis.URL;if(typeof r=="function"){let n;try{n=t===void 0?new r(e):new r(e,t)}catch{return null}try{if(n.protocol)return n}catch{}}return vt(e)}var gt=/^([a-z][a-z0-9+.-]*):\/\/(?:([^:@/?#]*)(?::([^@/?#]*))?@)?(\[[0-9a-f:.]+\]|[\w.~-]+)(?::(\d*))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i,mt=/[\s\u0000-\u001f\u007f\\]/,yt={"http:":"80","https:":"443"};function vt(e,t){let r=e.trim();let n=mt.test(r)?null:gt.exec(r);if(n===null)return null;let[,l="",i="",o="",a="",s="",u="",c="",d=""]=n,p=`${l.toLowerCase()}:`,f=Number(s);if(f>65535)return null;let h=s===""||String(f)===yt[p]?"":String(f),b=yt[p]!==void 0,g=a.toLowerCase()+(h&&`:${h}`),m=u||(b?"/":""),y=i||o?`${i}${o&&`:${o}`}@`:"";return{href:`${p}//${y}${g}${m}${c}${d}`,protocol:p,username:i,password:o,hostname:a.toLowerCase(),port:h,origin:b?`${p}//${g}`:"null",pathname:m,search:c==="?"?"":c,hash:d==="#"?"":d}}function networkError(e){return makeEverfurError("internalError",{retryable:true,wireMessage:xt(e)})}function xt(e){return e instanceof Error?e.message:typeof e=="string"?e:"network request failed"}var wt=3e4,kt=Ge*2,St="idempotency-key",Ct=/* @__PURE__ */new Set(["POST","PUT","PATCH","DELETE"]),jt=/* @__PURE__ */Object.freeze({onEvent(){}}),Rt=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Tt(e){let t=e.trim().replace(/[^A-Za-z0-9_.:-]/g,"-");return t.length===0?null:`efs_${t}`.slice(0,128)}function createRequestFunnel(e){let t=e.observer??jt,r=e.timers??Rt,n=e.rng??Math.random,l=e.sleep??((e,t)=>Nt(e,r,t)),i=e.maxAttempts??Ke,o=e.unaryTimeoutMs??wt,a=e.newIdempotencyKey??zt(),s=e=>{try{t.onEvent(e)}catch{}};async function u(t,u,c){let d=c?.maxAttempts,p=Math.max(1,d??i),f=c?.idempotent??Ct.has(u.method),h=c?.idempotencyKey===void 0?null:Tt(c.idempotencyKey),b=f?h??a():null,g=_t(u,b),m=0;for(;;){let i=e=>/* @__PURE__ */Object.freeze({call:t,method:u.method,path:u.path,attempt:m,...b?{idempotencyKey:b}:{},...e});s(i({phase:"attempt"}));let a=Ht(o,r),c=Wt(a.signal,u.signal),f;try{f=await authedSend({...g,signal:c.signal},e.auth)}catch(e){f=err(networkError(e))}finally{c.dispose(),a.cancel()}if(f.ok)return s(i({phase:"settled",ok:true,reason:"ok"})),f;let h=f.error,y=Pt(h,m,{maxAttempts:p,rng:n,now:r.now(),aborted:u.signal?.aborted===true,...d!==void 0?{perCallMaxAttempts:d}:{},...e.errorPolicy!==void 0?{policy:e.errorPolicy}:{}}),v={ok:false,code:h.code,reason:y.reason,...h.httpStatus!==void 0?{httpStatus:h.httpStatus}:{},...h.requestId!==void 0?{requestId:h.requestId}:{}};if(!y.retry)return s(i({phase:"settled",...v})),err(h);if(s(i({phase:"retry",...v,delayMs:y.delayMs})),await l(y.delayMs,u.signal),u.signal?.aborted===true)return s(i({phase:"settled",...v,reason:"aborted"})),err(h);m+=1}}async function c(t){return withAuthHeaders(t,await Bt(e.auth))}async function*d(t,r,n){s(
9
10
  /* @__PURE__ */Object.freeze({call:t,phase:"stream.open",method:r.method,path:r.path,attempt:0}));try{yield*e.auth.transport.stream(r,n)}catch{yield errorFrame({code:"internal_error",retryable:true,wireMessage:null,synthesized:true,lastEventId:null})}}/* @__PURE__ */
10
- return Object.freeze({send:u,authorize:c,stream:d})}function Rt(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==wt&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function Tt(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var _t=10;function zt(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=It(e);if(n==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let l=n==="burst"?"burst-throttle":"retryable-code";if((()=>{if(r.policy===void 0)return false;try{return!r.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let i=()=>{if(r.policy===void 0)return null;let t;try{t=r.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(_t,Math.floor(t)))},o=r.perCallMaxAttempts??i()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=Pt(e,r.now);return a!==null?a>xt?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:l,delayMs:a}:{retry:true,reason:l,delayMs:backoffDelayMs(t,r.rng)}}function It(e){let t=e.code==="unknown"?fromWire(Lt(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function Pt(e,t){let r=Mt(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=Et(e.raw);return n===null?null:Math.round(n*1e3)}function Et(e){for(let t of Ft(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function Mt(e){for(let t of Ft(e)){let e=t.resets_at,r=At(e);if(r!==null)return r}return null}function Ft(e){if(!Ot(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];Ot(n)&&t.push(n)}return t}function At(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}function Lt(e){for(let t of Ft(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function Ot(e){return typeof e=="object"&&e!==null}async function Vt(e){if(e.mode==="anonymous"){let t=await nt(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function Dt(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function Bt(e,t){let r=()=>{};if(!t)return{signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let l=()=>n.abort();return e.addEventListener("abort",l,{once:true}),t.addEventListener("abort",l,{once:true}),{signal:n.signal,dispose:()=>{e.removeEventListener("abort",l),t.removeEventListener("abort",l)}}}function Ht(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let l=t.setTimeout(()=>{r?.removeEventListener("abort",i),n()},e),i=()=>{t.clearTimeout(l),n()};r?.addEventListener("abort",i,{once:true})})}function Wt(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function Nt(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function Ut(e){return e.ok?e:err(Nt(e.error))}function $t(e){return{send:async(...t)=>Ut(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var qt=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function Gt(e){let t=qt(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}var Kt=6;function Yt(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function Qt(e,t,r){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let n=[];for(let l of e){if(n.length>=r)break;if(l===null||typeof l!="object"||Array.isArray(l))continue;let e=t(l);e!==null&&n.push(e)}/* @__PURE__ */
11
- return Object.freeze(n)}function Zt(e){let t=qt(e.title,80),r=qt(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function Jt(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=[];if(Array.isArray(t.gallery))for(let e of t.gallery){let t=Gt(e);t!==null&&r.length<Kt&&r.push(t)}let n=Qt(t.doses,e=>{let t=qt(e.label,60),r=qt(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:Yt(e.minLb??e.min_lb),maxLb:Yt(e.maxLb??e.max_lb)})},Kt),l=Qt(t.details,Zt,Kt),i=t.fit,o=i!==null&&typeof i=="object"&&!Array.isArray(i)?Zt(i):null,a=o!==null&&i.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:qt(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:l,fine:qt(t.fine,300),fit:a});return s.kicker===null&&r.length===0&&n.length===0&&l.length===0&&s.fine===null&&a===null?void 0:s}var Xt=128;var er=/* @__PURE__ */new Set(["shield","arrow","check","star","truck","refresh","card","alert","x","chat","repeat","calendar","flame","box","cart","minus","plus","chev","pulse","file","kit","dna","heart","bottle","harness","ramp"]),tr=/* @__PURE__ */new Set(["y","c","g","r"]),rr=/* @__PURE__ */new Set(["done","now","next"]),nr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,lr=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,ir=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,or=e=>typeof e=="string"&&er.has(e)?e:null;function ar(e){let t=lr(e,2048);return t===null||/\s/.test(t)?null:/^https:\/\/[^/]/i.test(t)||/^\/(?![/\\])/.test(t)?t:null}var sr=e=>typeof e=="number"&&Number.isInteger(e)?String(e):lr(e,Xt);function ur(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function cr(e){/* @__PURE__ */
12
- return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function dr(e,t,r=20){if(!Array.isArray(e))return null;let n=[];for(let l of e){if(n.length>=r)break;let e=t(l);e!==null&&n.push(e)}return n.length===0?null:/* @__PURE__ */Object.freeze(n)}var pr=(e,t=12,r=300)=>dr(e,e=>lr(e,r),t);function fr(e){let t=nr(e),r=lr(t?.kicker,120),n=lr(t?.title,300);if(t===null||r===null||n===null)return null;let l=nr(t.risk),i=nr(t.odds),o=nr(t.quote),a=nr(t.jump);return cr({kicker:r,title:n,sources:dr(t.sources,e=>{let t=lr(nr(e)?.label,60);return t===null?null:cr({label:t,kind:ir(nr(e)?.kind)})},6),risk:lr(l?.lead,300)===null?null:cr({lead:lr(l?.lead,300),body:lr(l?.body),kind:ir(l?.kind)}),odds:lr(i?.label,120)===null||lr(i?.from,20)===null||lr(i?.to,20)===null?null:cr({label:lr(i?.label,120),tag:lr(i?.tag,40),from:lr(i?.from,20),to:lr(i?.to,20),toLabel:lr(i?.toLabel,120)}),quote:lr(o?.text)===null?null:cr({kicker:lr(o?.kicker,120),tag:lr(o?.tag,40),text:lr(o?.text)}),jump:lr(a?.title,300)===null||lr(a?.go,60)===null?null:cr({title:lr(a?.title,300),go:lr(a?.go,60)}),report:hr(t.report)})}function hr(e){let t=nr(e),r=lr(t?.label,120),n=lr(t?.text,1200);return r===null||n===null?null:cr({label:r,text:n,actions:pr(t?.actions,5,300)})}function br(e){let t=nr(e),r=lr(t?.title,300),n=dr(t?.steps,e=>{let t=nr(e),r=lr(t?.title,300),n=t?.tone;return r===null?null:cr({title:r,body:lr(t?.body),source:lr(t?.source,200),tone:typeof n=="string"&&tr.has(n)?n:null,icon:or(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:cr({title:r,label:lr(t?.label,60),steps:n})}function gr(e){let t=nr(e),r=lr(t?.title,300);if(t===null||r===null)return null;let n=nr(t.rating),l=nr(t.reviews),i=nr(t.why),o=nr(i?.score),a=nr(t.dose),s=nr(t.ingredients),u=dr(l?.items,e=>{let t=nr(e),r=t?.stars,n=lr(t?.text),l=lr(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||l===null?null:cr({stars:Math.round(r),text:n,by:l})},5),c=dr(i?.rows,e=>{let t=nr(e),r=lr(t?.chip,40),n=lr(t?.title,300);return r===null||n===null?null:cr({chip:r,kind:ir(t?.kind),title:n,body:lr(t?.body)})}),d=dr(a?.stats,e=>{let t=nr(e),r=lr(t?.value,40),n=lr(t?.label,120),l=t?.kind;return r===null||n===null?null:cr({value:r,label:n,kind:l==="weight"||l==="dose"||l==="days"?l:null})},6),p=pr(s?.items,12,80);return cr({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:sr(t.productId),partnerSku:lr(t.partnerSku,200),rating:lr(n?.value,20)===null?null:cr({value:lr(n?.value,20),label:lr(n?.label,120)}),line:lr(t.line),reviews:lr(l?.label,200)===null||u===null?null:cr({label:lr(l?.label,200),items:u}),checkoutLine:lr(t.checkoutLine,300),why:lr(i?.title,200)===null||c===null?null:cr({title:lr(i?.title,200),rows:c,score:lr(o?.text,200)===null||lr(o?.value,20)===null?null:cr({text:lr(o?.text,200),value:lr(o?.value,20)})}),dose:lr(a?.title,200)===null||d===null?null:cr({title:lr(a?.title,200),stats:d,note:lr(a?.note)}),doseLabel:lr(t.doseLabel,120),ingredients:p===null?null:cr({label:lr(s?.label,200),items:p}),proof:lr(t.proof,300),trust:dr(t.trust,e=>{let t=nr(e),r=or(t?.icon),n=lr(t?.label,120);return r===null||n===null?null:cr({icon:r,label:n})},6),more:lr(t.more,120),fine:lr(t.fine),checkin:lr(t.checkin,200),detail:Jt(t.detail)??null})}function mr(e){let t=nr(e),r=lr(t?.title,200),n=dr(t?.items,e=>{let t=nr(e),r=lr(t?.title,300),n=lr(t?.body);return r===null||n===null?null:cr({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:cr({title:r,items:n})}function yr(e){let t=nr(e),r=lr(t?.title,200),n=pr(t?.questions,12,300),l=lr(t?.add,80),i=lr(t?.added,80);return r===null||n===null||l===null||i===null?null:cr({title:r,questions:n,add:l,added:i})}function vr(e){let t=nr(e),r=lr(t?.title,200),n=dr(t?.items,e=>{let t=nr(e),r=lr(t?.key,Xt),n=lr(t?.title,300),l=lr(t?.action,80),i=sr(t?.productId),o=lr(t?.added,80)??(i!==null?l:null);return r===null||n===null||l===null||o===null?null:cr({key:r,productId:i,title:n,body:lr(t?.body),price:lr(t?.price,40),was:lr(t?.was,40),tag:lr(t?.tag,40),imageUrl:ar(t?.imageUrl),icon:or(t?.icon),kind:ir(t?.kind),action:l,added:o,owned:t?.owned===true?true:null,detail:Jt(t?.detail)??null})},6);return r===null||n===null?null:cr({title:r,items:n})}function xr(e){let t=nr(e),r=lr(t?.kicker,120),n=lr(t?.title,120);return t===null||r===null||n===null?null:cr({kicker:r,title:n,icon:or(t.icon),track:dr(t.track,e=>{let t=nr(e),r=lr(t?.title,120),n=t?.state;return r===null?null:cr({title:r,detail:lr(t?.detail,120),state:typeof n=="string"&&rr.has(n)?n:null,tag:lr(t?.tag,40)})},6),heading:lr(t.heading,200),rows:dr(t.rows,e=>{let t=nr(e),r=or(t?.icon),n=lr(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return cr({icon:r,label:n,text:"",fromVet:true});let l=lr(t?.text,300);return l===null?null:cr({icon:r,label:n,text:l})},6),note:lr(t.note,300),action:lr(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=nr(e),r=lr(t?.title,300),n=gr(t?.pick);if(t===null||r===null||n===null)return null;let l=nr(t.byline);return cr({eyebrow:lr(t.eyebrow,120),title:r,subtitle:lr(t.subtitle,300),subtitleNoRecords:lr(t.subtitleNoRecords,300),headImageUrl:ar(t.headImageUrl),byline:lr(l?.name,120)===null?null:cr({name:lr(l?.name,120),role:lr(l?.role,120),imageUrl:ar(l?.imageUrl),shortName:lr(l?.shortName,60)}),focus:fr(t.focus),routine:br(t.routine),pick:n,signs:mr(t.signs),checkup:yr(t.checkup),extras:vr(t.extras),wait:xr(t.wait),fine:lr(t.fine),checkoutRows:dr(t.checkoutRows,e=>{let t=nr(e),r=or(t?.icon),n=lr(t?.label,60),l=lr(t?.value,200);return r===null||n===null||l===null?null:cr({icon:r,label:n,value:l})},6)})}function healthPlanPageFromWire(e,petRef){let t=nr(e);if(t===null||!("page"in t))return null;let r=nr(t.pet),n=r?.sex;/* @__PURE__ */
13
- return Object.freeze({petRef:lr(t.pet_ref,Xt)??petRef,pet:/* @__PURE__ */Object.freeze({name:lr(r?.name,120),species:lr(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:lr(r?.breed,120),weightKg:ur(r?.weight_kg),weightLb:ur(r?.weight_lb)}),checkout:t.checkout==="everfur_stripe"?"everfur_stripe":"partner",page:healthPlanFocusDesignFromWire(t.page),vetReviewed:t.vet_reviewed===true,trackingTextsEnabled:t.tracking_texts_enabled===true})}function wr(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function kr(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function Sr(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var Cr=e=>typeof e=="string"&&e.length>0&&e.length<=Xt;function jr(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function Rr(e,petRef,t){if(!Cr(petRef))return err(wr("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${jr(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(kr("healthPlan.page.read")):ok(n)}var Tr=/* @__PURE__ */new WeakMap;function _r(e){let t=Tr.get(e);if(t!==void 0)return t;let r=zr(e);return Tr.set(e,r),r}function zr(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(Sr("getPage")));let{services:r}=e.registry,n=$t(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return Rr(n,petRef,t)}}}function Ir(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function Pr(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Er(e,...t){if(typeof e=="function")try{let r=e(...t);return Pr(r)&&Promise.resolve(r).then(void 0,Ir),r}catch(e){Ir(e);return}}var Mr=/* @__PURE__ */new WeakMap;function Fr(e){if(typeof e!="function")return;let t=Mr.get(e);if(t!==void 0)return t;let r=(...t)=>{Er(e,...t)};return Mr.set(e,r),r}function Ar(e,...t){let r;try{r=e(...t)}catch(e){return Ir(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var Lr=6e4;function Or({lifecycle:t,refreshKey:r,readyAt:n,revalidate:l,refresh:i,now:o=Date.now}){let a=e.useRef({readyAt:n,revalidate:l,refresh:i??l,now:o});a.current={readyAt:n,revalidate:l,refresh:i??l,now:o},e.useEffect(()=>{if(t==null)return;let e=Er(()=>t.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=a.current;e!==null&&r()-e>=Lr&&t()}));return()=>{typeof e=="function"&&Er(e)}},[t]);let s=e.useRef(r);e.useEffect(()=>{Object.is(s.current,r)||(s.current=r,a.current.refresh())},[r])}var Vr=Lr,Dr=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function Br(){let e=globalThis,t=e[Dr];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[Dr]=r,r}function Hr(e,t,userRef,petRef,r){let n=Br(),l=n.get(t);l===void 0&&(l=/* @__PURE__ */new Map,n.set(t,l));let i=l,o=`${userRef}\0${petRef}`,a=i.get(o);if(!r&&a!==void 0&&(a.at===null||Date.now()-a.at<Vr))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(i.get(o)===s&&(e.ok||Wt(e.error)?s.at=Date.now():i.delete(o)),e))};return i.set(o,s),s.promise}function useHealthPlanPage(t){let{userRef:userRef,runtime:r}=Fe(),n=e.useMemo(()=>_r(r),[r]),l=t.repository,i=l??n,o=e.useCallback((e,t)=>l!==void 0||userRef==null?i.getPage(e):Hr(n,r,userRef,e,t),[l,i,n,r,userRef]),{petRef:petRef}=t,a=t.enabled!==false&&userRef!=null&&petRef!==null,[s,u]=e.useState({phase:"idle",petRef:null,page:null,error:null}),c=e.useRef(0),d=e.useRef(0),p=e.useCallback(async e=>{let t=++c.current;if(!a||petRef===null){u(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}u(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await o(petRef,e);t===c.current&&(r.ok?u({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):Wt(r.error)?u({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):u({phase:"failed",petRef:petRef,page:null,error:r.error}))},[a,petRef,o]),f=e.useCallback(()=>p(true),[p]),h=s.phase==="ready"&&s.petRef===petRef,b=e.useCallback(async()=>{if(!a||petRef===null||!h)return;let e=c.current,t=++d.current,r=await o(petRef,true);e!==c.current||t!==d.current||!r.ok||u(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[a,petRef,h,o]);Or({lifecycle:t.lifecycle,refreshKey:t.refreshKey,readyAt:h?s.readyAt??null:null,revalidate:()=>{b()},refresh:()=>{h?b():f()}}),e.useEffect(()=>(p(false),()=>{c.current+=1}),[p]);let g=a&&s.petRef!==petRef;return e.useMemo(()=>({phase:g?"loading":s.phase,page:g?null:s.page,error:g?null:s.error,missing:!g&&s.missing===true,refresh:f}),[g,s,f])}var Wr=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return Wr[e]}function decideCapability(e,t,r){let n=requires(e),l=/* @__PURE__ */new Map;for(let e of t)l.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!l.has(e)))return $r({name:e,enabled:false,isPending:true,limits:{}});let i=Nr(n,l);return n.filter(e=>l.get(e)?.granted!==true).length===0?$r({name:e,enabled:true,isPending:false,limits:i}):$r({name:e,enabled:false,isPending:false,limits:i,disabled:Ur(n,l)})}function Nr(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function Ur(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
11
+ return Object.freeze({send:u,authorize:c,stream:d})}function _t(e,t){let r={};for(let[t,n]of Object.entries(e.headers??{}))t.toLowerCase()!==St&&(r[t]=n);return t!==null&&(r["Idempotency-Key"]=t),{...e,headers:r}}function zt(){let e=0;return()=>`efk_${Date.now().toString(36)}_${(e++).toString(36)}_${Math.random().toString(36).slice(2,12)}`}var It=10;function Pt(e,t,r){if(r.aborted)return{retry:false,reason:"aborted"};let n=Et(e);if(n==="quota")return{retry:false,reason:"daily-quota-exhausted"};if(n!=="burst"&&!isAutoRetryable(e.code))return{retry:false,reason:"terminal-code"};let l=n==="burst"?"burst-throttle":"retryable-code";if((()=>{if(r.policy===void 0)return false;try{return!r.policy.shouldRetry(e.code,t)}catch{return false}})())return{retry:false,reason:"terminal-code"};let i=()=>{if(r.policy===void 0)return null;let t;try{t=r.policy.maxAttempts(e.code)}catch{return null}return typeof t!="number"||!Number.isFinite(t)?null:Math.max(1,Math.min(It,Math.floor(t)))},o=r.perCallMaxAttempts??i()??r.maxAttempts;if(t+1>=o)return{retry:false,reason:"attempts-exhausted"};let a=Mt(e,r.now);return a!==null?a>kt?{retry:false,reason:"server-reset-beyond-budget"}:{retry:true,reason:l,delayMs:a}:{retry:true,reason:l,delayMs:backoffDelayMs(t,r.rng)}}function Et(e){let t=e.code==="unknown"?fromWire(Vt(e.raw)):e.code;return t==="quotaExceeded"?"quota":t==="rateLimited"||e.httpStatus===429?"burst":null}function Mt(e,t){let r=Ft(e.raw);if(r!==null){let e=r-t;return e>0?e:0}let n=At(e.raw);return n===null?null:Math.round(n*1e3)}function At(e){for(let t of Lt(e)){let e=t.retry_after_seconds;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e}return null}function Ft(e){for(let t of Lt(e)){let e=t.resets_at,r=Ot(e);if(r!==null)return r}return null}function Lt(e){if(!Dt(e))return[];let t=[e];for(let r of["error","detail"]){let n=e[r];Dt(n)&&t.push(n)}return t}function Ot(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e11?Math.round(e*1e3):Math.round(e);if(typeof e=="string"&&e.trim().length>0){let t=Date.parse(e);return Number.isFinite(t)?t:null}return null}function Vt(e){for(let t of Lt(e)){let e=t.code;if(typeof e=="string"&&e.length>0)return e}return null}function Dt(e){return typeof e=="object"&&e!==null}async function Bt(e){if(e.mode==="anonymous"){let t=await it(e);return{mode:"anonymous",publishableKey:e.publishableKey,userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{},...t!==null?{anonToken:t}:{}}}return{mode:"personalized",token:await e.identity.currentToken(),userRef:e.userRef,...e.sessionId?{sessionId:e.sessionId}:{}}}function Ht(e,t){let r=new AbortController,n=t.setTimeout(()=>r.abort(),e);return{signal:r.signal,cancel:()=>t.clearTimeout(n)}}function Wt(e,t){let r=()=>{};if(!t)return{signal:e,dispose:r};let n=new AbortController;if(e.aborted||t.aborted)return n.abort(),{signal:n.signal,dispose:r};let l=()=>n.abort();return e.addEventListener("abort",l,{once:true}),t.addEventListener("abort",l,{once:true}),{signal:n.signal,dispose:()=>{e.removeEventListener("abort",l),t.removeEventListener("abort",l)}}}function Nt(e,t,r){return e<=0||r?.aborted===true?Promise.resolve():new Promise(n=>{let l=t.setTimeout(()=>{r?.removeEventListener("abort",i),n()},e),i=()=>{t.clearTimeout(l),n()};r?.addEventListener("abort",i,{once:true})})}function Ut(e){return e!=null&&(e.httpStatus===404||e.category==="notFound")}function $t(e){return e.code!=="conversationNotFound"?e:makeEverfurError("resourceNotFound",{retryable:false,...e.httpStatus===void 0?{}:{httpStatus:e.httpStatus},...e.requestId===void 0?{}:{requestId:e.requestId},...e.reasonCode===void 0?{}:{reasonCode:e.reasonCode},...e.wireMessage===void 0?{}:{wireMessage:e.wireMessage},...e.raw===void 0?{}:{raw:e.raw}})}function qt(e){return e.ok?e:err($t(e.error))}function Gt(e){return{send:async(...t)=>qt(await e.send(...t)),authorize:t=>e.authorize(t),stream:(t,r,n)=>e.stream(t,r,n)}}var Kt=(e,t=4e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null;function Yt(e){let t=Kt(e,2048);return t===null?null:/^https:\/\/[^\s]+$/i.test(t)?t:null}var Qt=6;function Zt(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=400?e:null}function Jt(e,t,r){if(!Array.isArray(e))/* @__PURE__ */return Object.freeze([]);let n=[];for(let l of e){if(n.length>=r)break;if(l===null||typeof l!="object"||Array.isArray(l))continue;let e=t(l);e!==null&&n.push(e)}/* @__PURE__ */
12
+ return Object.freeze(n)}function Xt(e){let t=Kt(e.title,80),r=Kt(e.body,600);return t===null||r===null?null:/* @__PURE__ */Object.freeze({title:t,body:r})}function er(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=[];if(Array.isArray(t.gallery))for(let e of t.gallery){let t=Yt(e);t!==null&&r.length<Qt&&r.push(t)}let n=Jt(t.doses,e=>{let t=Kt(e.label,60),r=Kt(e.amount,60);return t===null||r===null?null:/* @__PURE__ */Object.freeze({label:t,amount:r,minLb:Zt(e.minLb??e.min_lb),maxLb:Zt(e.maxLb??e.max_lb)})},Qt),l=Jt(t.details,Xt,Qt),i=t.fit,o=i!==null&&typeof i=="object"&&!Array.isArray(i)?Xt(i):null,a=o!==null&&i.pet===true?/* @__PURE__ */Object.freeze({...o,pet:true}):o,s=/* @__PURE__ */Object.freeze({kicker:Kt(t.kicker,80),gallery:/* @__PURE__ */Object.freeze(r),doses:n,details:l,fine:Kt(t.fine,300),fit:a});return s.kicker===null&&r.length===0&&n.length===0&&l.length===0&&s.fine===null&&a===null?void 0:s}var tr=128;var rr=/* @__PURE__ */new Set(["shield","arrow","check","star","truck","refresh","card","alert","x","chat","repeat","calendar","flame","box","cart","minus","plus","chev","pulse","file","kit","dna","heart","bottle","harness","ramp"]),nr=/* @__PURE__ */new Set(["y","c","g","r"]),lr=/* @__PURE__ */new Set(["done","now","next"]),ir=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null,or=(e,t=1e3)=>typeof e=="string"&&e.trim().length>0&&e.length<=t?e.trim():null,ar=e=>typeof e=="string"&&/^[A-Za-z0-9_-]{1,40}$/.test(e)?e:null,sr=e=>typeof e=="string"&&rr.has(e)?e:null;function ur(e){let t=or(e,2048);return t===null||/\s/.test(t)?null:/^https:\/\/[^/]/i.test(t)||/^\/(?![/\\])/.test(t)?t:null}var cr=e=>typeof e=="number"&&Number.isInteger(e)?String(e):or(e,tr);function dr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function pr(e){/* @__PURE__ */
13
+ return Object.freeze(Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null)))}function fr(e,t,r=20){if(!Array.isArray(e))return null;let n=[];for(let l of e){if(n.length>=r)break;let e=t(l);e!==null&&n.push(e)}return n.length===0?null:/* @__PURE__ */Object.freeze(n)}var hr=(e,t=12,r=300)=>fr(e,e=>or(e,r),t);function br(e){let t=ir(e),r=or(t?.kicker,120),n=or(t?.title,300);if(t===null||r===null||n===null)return null;let l=ir(t.risk),i=ir(t.odds),o=ir(t.quote),a=ir(t.jump);return pr({kicker:r,title:n,sources:fr(t.sources,e=>{let t=or(ir(e)?.label,60);return t===null?null:pr({label:t,kind:ar(ir(e)?.kind)})},6),risk:or(l?.lead,300)===null?null:pr({lead:or(l?.lead,300),body:or(l?.body),kind:ar(l?.kind)}),odds:or(i?.label,120)===null||or(i?.from,20)===null||or(i?.to,20)===null?null:pr({label:or(i?.label,120),tag:or(i?.tag,40),from:or(i?.from,20),to:or(i?.to,20),toLabel:or(i?.toLabel,120)}),quote:or(o?.text)===null?null:pr({kicker:or(o?.kicker,120),tag:or(o?.tag,40),text:or(o?.text)}),jump:or(a?.title,300)===null||or(a?.go,60)===null?null:pr({title:or(a?.title,300),go:or(a?.go,60)}),report:gr(t.report)})}function gr(e){let t=ir(e),r=or(t?.label,120),n=or(t?.text,1200);return r===null||n===null?null:pr({label:r,text:n,actions:hr(t?.actions,5,300)})}function mr(e){let t=ir(e),r=or(t?.title,300),n=fr(t?.steps,e=>{let t=ir(e),r=or(t?.title,300),n=t?.tone;return r===null?null:pr({title:r,body:or(t?.body),source:or(t?.source,200),tone:typeof n=="string"&&nr.has(n)?n:null,icon:sr(t?.icon),fromVet:t?.fromVet===true?true:null})});return r===null||n===null?null:pr({title:r,label:or(t?.label,60),steps:n})}function yr(e){let t=ir(e),r=or(t?.title,300);if(t===null||r===null)return null;let n=ir(t.rating),l=ir(t.reviews),i=ir(t.why),o=ir(i?.score),a=ir(t.dose),s=ir(t.ingredients),u=fr(l?.items,e=>{let t=ir(e),r=t?.stars,n=or(t?.text),l=or(t?.by,80);return typeof r!="number"||!Number.isFinite(r)||r<1||r>5||n===null||l===null?null:pr({stars:Math.round(r),text:n,by:l})},5),c=fr(i?.rows,e=>{let t=ir(e),r=or(t?.chip,40),n=or(t?.title,300);return r===null||n===null?null:pr({chip:r,kind:ar(t?.kind),title:n,body:or(t?.body)})}),d=fr(a?.stats,e=>{let t=ir(e),r=or(t?.value,40),n=or(t?.label,120),l=t?.kind;return r===null||n===null?null:pr({value:r,label:n,kind:l==="weight"||l==="dose"||l==="days"?l:null})},6),p=hr(s?.items,12,80);return pr({title:r,none:t.none===true?true:null,hidden:t.none===true&&t.hidden===true?true:null,productId:cr(t.productId),partnerSku:or(t.partnerSku,200),rating:or(n?.value,20)===null?null:pr({value:or(n?.value,20),label:or(n?.label,120)}),line:or(t.line),reviews:or(l?.label,200)===null||u===null?null:pr({label:or(l?.label,200),items:u}),checkoutLine:or(t.checkoutLine,300),why:or(i?.title,200)===null||c===null?null:pr({title:or(i?.title,200),rows:c,score:or(o?.text,200)===null||or(o?.value,20)===null?null:pr({text:or(o?.text,200),value:or(o?.value,20)})}),dose:or(a?.title,200)===null||d===null?null:pr({title:or(a?.title,200),stats:d,note:or(a?.note)}),doseLabel:or(t.doseLabel,120),ingredients:p===null?null:pr({label:or(s?.label,200),items:p}),proof:or(t.proof,300),trust:fr(t.trust,e=>{let t=ir(e),r=sr(t?.icon),n=or(t?.label,120);return r===null||n===null?null:pr({icon:r,label:n})},6),more:or(t.more,120),fine:or(t.fine),checkin:or(t.checkin,200),detail:er(t.detail)??null})}function vr(e){let t=ir(e),r=or(t?.title,200),n=fr(t?.items,e=>{let t=ir(e),r=or(t?.title,300),n=or(t?.body);return r===null||n===null?null:pr({title:r,body:n,urgent:t?.urgent===true?true:null,callVet:t?.callVet===true?true:null})});return r===null||n===null?null:pr({title:r,items:n})}function xr(e){let t=ir(e),r=or(t?.title,200),n=hr(t?.questions,12,300),l=or(t?.add,80),i=or(t?.added,80);return r===null||n===null||l===null||i===null?null:pr({title:r,questions:n,add:l,added:i})}function wr(e){let t=ir(e),r=or(t?.title,200),n=fr(t?.items,e=>{let t=ir(e),r=or(t?.key,tr),n=or(t?.title,300),l=or(t?.action,80),i=cr(t?.productId),o=or(t?.added,80)??(i!==null?l:null);return r===null||n===null||l===null||o===null?null:pr({key:r,productId:i,title:n,body:or(t?.body),price:or(t?.price,40),was:or(t?.was,40),tag:or(t?.tag,40),imageUrl:ur(t?.imageUrl),icon:sr(t?.icon),kind:ar(t?.kind),action:l,added:o,owned:t?.owned===true?true:null,detail:er(t?.detail)??null})},6);return r===null||n===null?null:pr({title:r,items:n})}function kr(e){let t=ir(e),r=or(t?.kicker,120),n=or(t?.title,120);return t===null||r===null||n===null?null:pr({kicker:r,title:n,icon:sr(t.icon),track:fr(t.track,e=>{let t=ir(e),r=or(t?.title,120),n=t?.state;return r===null?null:pr({title:r,detail:or(t?.detail,120),state:typeof n=="string"&&lr.has(n)?n:null,tag:or(t?.tag,40)})},6),heading:or(t.heading,200),rows:fr(t.rows,e=>{let t=ir(e),r=sr(t?.icon),n=or(t?.label,120);if(r===null||n===null)return null;if(t?.fromVet===true)return pr({icon:r,label:n,text:"",fromVet:true});let l=or(t?.text,300);return l===null?null:pr({icon:r,label:n,text:l})},6),note:or(t.note,300),action:or(t.action,80)})}function healthPlanFocusDesignFromWire(e){let t=ir(e),r=or(t?.title,300),n=yr(t?.pick);if(t===null||r===null||n===null)return null;let l=ir(t.byline);return pr({eyebrow:or(t.eyebrow,120),title:r,subtitle:or(t.subtitle,300),subtitleNoRecords:or(t.subtitleNoRecords,300),headImageUrl:ur(t.headImageUrl),byline:or(l?.name,120)===null?null:pr({name:or(l?.name,120),role:or(l?.role,120),imageUrl:ur(l?.imageUrl),shortName:or(l?.shortName,60)}),focus:br(t.focus),routine:mr(t.routine),pick:n,signs:vr(t.signs),checkup:xr(t.checkup),extras:wr(t.extras),wait:kr(t.wait),fine:or(t.fine),checkoutRows:fr(t.checkoutRows,e=>{let t=ir(e),r=sr(t?.icon),n=or(t?.label,60),l=or(t?.value,200);return r===null||n===null||l===null?null:pr({icon:r,label:n,value:l})},6)})}function healthPlanPageFromWire(e,petRef){let t=ir(e);if(t===null||!("page"in t))return null;let r=ir(t.pet),n=r?.sex;/* @__PURE__ */
14
+ return Object.freeze({petRef:or(t.pet_ref,tr)??petRef,pet:/* @__PURE__ */Object.freeze({name:or(r?.name,120),species:or(r?.species,60),sex:n==="female"||n==="male"?n:null,breed:or(r?.breed,120),weightKg:dr(r?.weight_kg),weightLb:dr(r?.weight_lb)}),checkout:t.checkout==="everfur_stripe"?"everfur_stripe":"partner",page:healthPlanFocusDesignFromWire(t.page),vetReviewed:t.vet_reviewed===true,trackingTextsEnabled:t.tracking_texts_enabled===true})}function Sr(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function Cr(e){return makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:`${e}: the response was not the expected shape`})}function jr(e){return makeEverfurError("runtimeDisposed",{retryable:false,wireMessage:`the Everfur runtime is disposed; ${e} was called after unmount`})}var Rr=e=>typeof e=="string"&&e.length>0&&e.length<=tr;function Tr(petRef){return`/widget/v1/pets/${encodeURIComponent(petRef)}/plan`}async function _r(e,petRef,t){if(!Rr(petRef))return err(Sr("petRef must be 1..128 characters"));let r=await e.send("healthPlan.page.read",{method:"GET",path:`${Tr(petRef)}/page`,...t?.signal?{signal:t.signal}:{}});if(!r.ok)return err(r.error);let n=healthPlanPageFromWire(r.value,petRef);return n===null?err(Cr("healthPlan.page.read")):ok(n)}var zr=/* @__PURE__ */new WeakMap;function Ir(e){let t=zr.get(e);if(t!==void 0)return t;let r=Pr(e);return zr.set(e,r),r}function Pr(e){return{getPage:(petRef,t)=>{if(e.isDisposed)return Promise.resolve(err(jr("getPage")));let{services:r}=e.registry,n=Gt(createRequestFunnel({auth:r.authFor(null),...r.errorPolicy?{errorPolicy:r.errorPolicy}:{}}));return _r(n,petRef,t)}}}function Er(e){let t=globalThis.console;try{t?.error?.("[everfur] A host callback threw; the SDK ignored it.",e)}catch{}}function Mr(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function"}function Ar(e,...t){if(typeof e=="function")try{let r=e(...t);return Mr(r)&&Promise.resolve(r).then(void 0,Er),r}catch(e){Er(e);return}}var Fr=/* @__PURE__ */new WeakMap;function Lr(e){if(typeof e!="function")return;let t=Fr.get(e);if(t!==void 0)return t;let r=(...t)=>{Ar(e,...t)};return Fr.set(e,r),r}function Or(e,...t){let r;try{r=e(...t)}catch(e){return Er(e),Promise.resolve({ok:false,error:e})}return Promise.resolve(r).then(e=>({ok:true,value:e}),e=>({ok:false,error:e}))}var Vr=6e4;function Dr({lifecycle:t,refreshKey:r,readyAt:n,revalidate:l,refresh:i,now:o=Date.now}){let a=e.useRef({readyAt:n,revalidate:l,refresh:i??l,now:o});a.current={readyAt:n,revalidate:l,refresh:i??l,now:o},e.useEffect(()=>{if(t==null)return;let e=Ar(()=>t.onForeground(()=>{let{readyAt:e,revalidate:t,now:r}=a.current;e!==null&&r()-e>=Vr&&t()}));return()=>{typeof e=="function"&&Ar(e)}},[t]);let s=e.useRef(r);e.useEffect(()=>{Object.is(s.current,r)||(s.current=r,a.current.refresh())},[r])}var Br=Vr,Hr=/* @__PURE__ */Symbol.for("@everfur/sdk#HealthPlanPageReads@v1");function Wr(){let e=globalThis,t=e[Hr];if(t instanceof WeakMap)return t;let r=/* @__PURE__ */new WeakMap;return e[Hr]=r,r}function Nr(e,t,userRef,petRef,r){let n=Wr(),l=n.get(t);l===void 0&&(l=/* @__PURE__ */new Map,n.set(t,l));let i=l,o=`${userRef}\0${petRef}`,a=i.get(o);if(!r&&a!==void 0&&(a.at===null||Date.now()-a.at<Br))return a.promise;let s={at:null,promise:e.getPage(petRef).then(e=>(i.get(o)===s&&(e.ok||Ut(e.error)?s.at=Date.now():i.delete(o)),e))};return i.set(o,s),s.promise}function useHealthPlanPage(t){let{userRef:userRef,runtime:r}=Le(),n=e.useMemo(()=>Ir(r),[r]),l=t.repository,i=l??n,o=e.useCallback((e,t)=>l!==void 0||userRef==null?i.getPage(e):Nr(n,r,userRef,e,t),[l,i,n,r,userRef]),{petRef:petRef}=t,a=t.enabled!==false&&userRef!=null&&petRef!==null,[s,u]=e.useState({phase:"idle",petRef:null,page:null,error:null}),c=e.useRef(0),d=e.useRef(0),p=e.useCallback(async e=>{let t=++c.current;if(!a||petRef===null){u(e=>e.phase==="idle"&&e.petRef===null?e:{phase:"idle",petRef:null,page:null,error:null});return}u(e=>({phase:"loading",petRef:petRef,page:e.petRef===petRef?e.page:null,error:null}));let r=await o(petRef,e);t===c.current&&(r.ok?u({phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}):Ut(r.error)?u({phase:"ready",petRef:petRef,page:null,error:null,missing:true,readyAt:Date.now()}):u({phase:"failed",petRef:petRef,page:null,error:r.error}))},[a,petRef,o]),f=e.useCallback(()=>p(true),[p]),h=s.phase==="ready"&&s.petRef===petRef,b=e.useCallback(async()=>{if(!a||petRef===null||!h)return;let e=c.current,t=++d.current,r=await o(petRef,true);e!==c.current||t!==d.current||!r.ok||u(e=>e.phase==="ready"&&e.petRef===petRef?{phase:"ready",petRef:petRef,page:r.value,error:null,readyAt:Date.now()}:e)},[a,petRef,h,o]);Dr({lifecycle:t.lifecycle,refreshKey:t.refreshKey,readyAt:h?s.readyAt??null:null,revalidate:()=>{b()},refresh:()=>{h?b():f()}}),e.useEffect(()=>(p(false),()=>{c.current+=1}),[p]);let g=a&&s.petRef!==petRef;return e.useMemo(()=>({phase:g?"loading":s.phase,page:g?null:s.page,error:g?null:s.error,missing:!g&&s.missing===true,refresh:f}),[g,s,f])}var Ur=/* @__PURE__ */Object.freeze({chat:/* @__PURE__ */Object.freeze(["chat.message.create"]),records:/* @__PURE__ */Object.freeze(["records.upload.create","records.record.read"]),recordsClinic:/* @__PURE__ */Object.freeze(["records.clinic.create"]),video:/* @__PURE__ */Object.freeze(["video.gait.execute"]),photo:/* @__PURE__ */Object.freeze(["photo.checkup.execute"]),animations:/* @__PURE__ */Object.freeze(["animations.state.read"]),televet:/* @__PURE__ */Object.freeze(["televet.visit.create"]),texting:/* @__PURE__ */Object.freeze(["sms.identity.read","sms.identity.update"]),healthPlan:/* @__PURE__ */Object.freeze(["shop.plan.read","shop.plan.update"])});function requires(e){return Ur[e]}function decideCapability(e,t,r){let n=requires(e),l=/* @__PURE__ */new Map;for(let e of t)l.set(e.resource,e);if(r?.isPending===true&&n.some(e=>!l.has(e)))return Gr({name:e,enabled:false,isPending:true,limits:{}});let i=$r(n,l);return n.filter(e=>l.get(e)?.granted!==true).length===0?Gr({name:e,enabled:true,isPending:false,limits:i}):Gr({name:e,enabled:false,isPending:false,limits:i,disabled:qr(n,l)})}function $r(e,t){let r={};for(let n of e){let e=t.get(n)?.limits;if(e)for(let[t,n]of Object.entries(e)){let e=r[t];r[t]=e===void 0?n:Math.min(e,n)}}return r}function qr(e,t){for(let r of e){let e=t.get(r)?.disabled;if(e)/* @__PURE__ */
14
15
  return Object.freeze({reason:e.reason,level:e.level,recoverable:e.recoverable})}/* @__PURE__ */
15
- return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function $r(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:/* @__PURE__ */Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),/* @__PURE__ */Object.freeze(t)}function useCapability(t){let{runtime:r}=Fe(),n=r.entitlements,l=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return e.useMemo(()=>decideCapability(t,l.decisions,{isPending:l.isPending}),[t,l])}function qr(t){let{runtime:r}=Fe(),n=r.entitlements,l=e.useCallback(e=>n===void 0?()=>{}:n.subscribe(e),[n]),i=e.useCallback(()=>{if(n===void 0)return false;let e=n.getSnapshot();return decideCapability(t,e.decisions,{isPending:e.isPending}).enabled},[n,t]);return e.useSyncExternalStore(l,i,i)}var Gr=()=>()=>{},Kr=()=>null;function Yr(t,r){return e.useSyncExternalStore(r?.subscribe??Gr,r?.get??Kr,r?.get??Kr)??t}var Qr=/* @__PURE__ */Object.freeze({branding:null}),Zr=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>Qr});function Jr(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function Xr(t){let{runtime:r}=Fe(),n=r?.entitlements??Zr,l=e.useCallback(()=>n.getSnapshot()?.branding??null,[n]),i=Yr(e.useSyncExternalStore(n.subscribe,l,l),r?.sdkConfigHost?.branding),o=Jr(t);return e.useMemo(()=>{let e=i?.lockedFields??null;return{presentation:resolvePresentation({server:i?.presentation??null,locked:e,client:t??null}),isLocked:t=>isPresentationFieldLocked(t,e)}},[i,o])}function en(e){let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]=n);return t}function tn(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}function rn(e){let t=pt(e);return t===null?null:{reached:je.capReached.replace("{cap}",String(t.limit)),guidance:t.emergencyGuidance??null}}function nn(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}function ln(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let e=nn(r),n=t==="web",l=rn(r);return{tone:"error",title:l!==null?l.reached:e?je.turnUnreachableTitle:n?je.turnFailedTitleWeb:je.turnFailedTitle,body:r.displayMessage,actionLabel:e?je.turnStartNewChat:n?je.retry:je.turnRetry,action:e?"startNew":"retry",...l!==null&&l.guidance!==null?{guidance:l.guidance}:{}}}return e.stopped===true?{tone:"neutral",title:je.turnStoppedTitle,body:je.turnStoppedBody,actionLabel:je.turnRetry,action:"retry"}:null}function on(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}var an=3,sn=/* @__PURE__ */Object.freeze([]);function un(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return sn;let r=/* @__PURE__ */new Set,n=[];for(let t of e.suggestedPrompts){let e=t.trim(),l=e.replace(/\s+/g," ").toLowerCase();if(!(l.length===0||r.has(l))&&(r.add(l),n.push(e),n.length===an))break}/* @__PURE__ */
16
- return Object.freeze(n)}var cn=5;function dn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function pn(e,t){if(t===void 0)return un(e);let r=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||r===void 0||r.role!=="assistant")return sn;let n=Math.max(1,Math.min(cn,Math.floor(t.count??an))),l=null;for(let t=e.messages.length-1;t>=0;t-=1){let r=e.messages[t];if(r!==void 0&&r.role==="user"){l=r.text;break}}let i=e=>e.trim().replace(/\s+/g," ").toLowerCase(),o=new Set(l===null?[]:[i(l)]),a=[],s=e=>{let r=e.trim(),l=i(r);a.length>=n||l.length===0||o.has(l)||dn(t.exclude,r)||(o.add(l),a.push(r))};for(let t of e.suggestedPrompts)s(t);let u=[];try{u=typeof t.fill=="function"?t.fill(l):t.fill??[]}catch{u=[]}for(let e of Array.isArray(u)?u:[])typeof e=="string"&&s(e);/* @__PURE__ */
17
- return Object.freeze(a)}function fn(e){return e.sender?.displayName??je.senderVet}function hn(petRef,conversationId){let e={};return petRef!==void 0&&(e.petRef=petRef),conversationId!==void 0&&(e.conversationId=conversationId),e}var bn=new RegExp([String.raw`\b(book|booking|schedule|scheduling|arrange|set\s+up)\s+(an?\s+|the\s+|her\s+|his\s+|their\s+|my\s+|your\s+)?(next\s+)?((vet|veterinary|video|virtual|televet|follow-up|follow up)\s+)?(visit|appointment|appt|consult|consultation|call|vet|checkup|check-up|exam)\b`,String.raw`\bmake\s+(an?\s+|the\s+)?((vet|veterinary|video|virtual|follow-up|follow up)\s+)?(appointment|appt)\b`,String.raw`\bneed\s+(an?\s+)?((vet|veterinary|video|virtual)\s+)?(appointment|appt|visit|consult|consultation)\b`,String.raw`\b(video|virtual)\s+(visit|appointment|appt|consult|consultation|call)s?\b`,String.raw`\b(televet|telehealth|telemedicine)\b`,String.raw`\b(talk|speak|chat)\s+(to|with)\s+(an?|the|your|my)\s+vet\b`,String.raw`\bsee\s+(an?|the|your|my)\s+vet\b`].join("|"),"i"),NONE=()=>true;function gn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function mn(e,t,r){let n=t.chatFollowUpsExcludeTelevet,l=e?.count!==void 0&&!r?e.count:t.chatFollowUpCount;if(e===void 0&&l===an&&!n)return;if(l<=0)return{...e??{},count:1,exclude:NONE,fill:[]};let i=e?.exclude,o=n?e=>bn.test(e)||gn(i,e):i;return{...e??{},count:l,...o!==void 0?{exclude:o}:{}}}function yn(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function vn(e){return[...e].length}var xn=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(xn,t)?xn[t]:null}var wn=50,kn=128,Sn=120,Cn=120,jn=2e3,Rn=120,Tn=80,_n=/* @__PURE__ */new Set(["male","female","unknown"]),zn=/* @__PURE__ */new Set(["day","month","year"]),In=/* @__PURE__ */new Set(["low","medium","high","athletic"]),Pn=/* @__PURE__ */new Set(["indoor","outdoor","both"]),En=/* @__PURE__ */new Set(["mild","moderate","severe"]),Mn=/^(\d{4})-(\d{2})-(\d{2})$/,Fn=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],An=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Fn,...An].map(([e])=>e));function Ln(e){let t=Mn.exec(e);if(t===null)return false;let[r,n,l]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,l));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===l}var On=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,Vn=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Dn=(e,t)=>typeof t=="string"&&Ln(t)?null:`${e} must be a real date written YYYY-MM-DD`,Bn=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(yn(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let l=t.trimmed?n.trim():n;if(t.required&&l.length===0)return`${r} is required and must not be blank`;let i=vn(l);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},Hn={sex:On(_n),spayedNeutered:Vn,birthDate:Dn,birthDatePrecision:On(zn),activityLevel:On(In),indoorOutdoor:On(Pn),foodBrand:Bn(Rn),foodType:Bn(Rn),microchipId:Bn(Tn)},Wn=["ref","ref",false,Bn(kn,{required:true,trimmed:true})],Nn=["notes","notes",false,Bn(jn,{trimmed:true})],Un=[Wn,["name","name",true,Bn(Sn,{required:true,trimmed:true})],["dose","dose",false,Bn(Cn,{trimmed:true})],["frequency","frequency",false,Bn(Cn,{trimmed:true})],["startDate","start_date",false,Dn],["endDate","end_date",false,Dn],Nn],$n={allergies:[Wn,["allergen","allergen",true,Bn(Sn,{required:true,trimmed:true})],["severity","severity",false,On(En)],Nn],medications:Un,supplements:Un,conditions:[Wn,["conditionName","condition_name",true,Bn(Sn,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Dn],Nn]};function qn(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let l=r,i={};for(let[t,r,o,a]of $n[e]){let e=l[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=a(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,a=i.end_date;return typeof o=="string"&&typeof a=="string"&&a<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function Gn(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>wn)return{error:`${e} has ${t.length} items; the server accepts at most ${wn}`};let r=[],n=/* @__PURE__ */new Set;for(let l=0;l<t.length;l+=1){let i=qn(e,l,t[l]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function Kn(e,t){let r=e,n={};for(let[e,t]of Fn){let l=r[e];if(l!==void 0){if(l!==null){let t=Hn[e](e,l);if(t!==null)return{error:t}}n[t]=l}}let l=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(l!==i||l&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of An){let l=r[e];if(l===void 0)continue;let i=Gn(e,l);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var Yn=e=>typeof e=="string"?e:null,Qn=(e,t)=>typeof t=="string"&&e.has(t)?t:null,Zn=e=>typeof e=="boolean"?e:null;function Jn(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function Xn(e){let t=Yn(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Yn(e.ref),name:t,dose:Yn(e.dose),frequency:Yn(e.frequency),startDate:Yn(e.start_date),endDate:Yn(e.end_date),notes:Yn(e.notes)})}function el(e){let t=e.profile_version;/* @__PURE__ */
18
- return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:Qn(_n,e.sex),spayedNeutered:Zn(e.spayed_neutered),birthDate:Yn(e.birth_date),birthDatePrecision:Qn(zn,e.birth_date_precision),activityLevel:Qn(In,e.activity_level),indoorOutdoor:Qn(Pn,e.indoor_outdoor),foodBrand:Yn(e.food_brand),foodType:Yn(e.food_type),microchipId:Yn(e.microchip_id),allergies:Jn(e.allergies,e=>{let t=Yn(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Yn(e.ref),allergen:t,severity:Qn(En,e.severity),notes:Yn(e.notes)})}),medications:Jn(e.medications,Xn),supplements:Jn(e.supplements,Xn),conditions:Jn(e.conditions,e=>{let t=Yn(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Yn(e.ref),conditionName:t,diagnosedDate:Yn(e.diagnosed_date),notes:Yn(e.notes)})})})}var tl=100,rl=50,nl=100,ll=50,il=500,ol=128,al=6e4;function sl(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function ul(e,t,r){if(typeof t!="string")return sl(`${e} must be a string`);let n=vn(t);return n<=r?null:sl(`${e} is ${n} characters; the server accepts at most ${r}`)}function cl(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:sl(`${e} must be a finite number between 0 and ${r}`)}function dl(petRef,e){if(typeof petRef!="string")return sl("pet_ref must be a string");if(petRef.trim().length===0)return sl("pet_ref must not be blank");if(yn(petRef))return sl("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return sl("profile must be an object");let t=[ul("pet_ref",petRef,ol)];return e?.name!==void 0&&t.push(ul("name",e.name,tl)),e?.species!==void 0&&t.push(ul("species",e.species,rl)),e?.breed!==void 0&&t.push(ul("breed",e.breed,nl)),e?.ageYears!==void 0&&t.push(cl("age_years",e.ageYears,ll)),e?.weightKg!==void 0&&t.push(cl("weight_kg",e.weightKg,il)),t.find(e=>e!==null)??null}function pl(e,t){let r=Kn(e,t);return"error"in r?{error:sl(r.error)}:r}function fl(e){if(typeof e!="object"||e===null)return{error:sl("patch must be an object")};let t=e,r=[["name","name",e=>ul("name",e,tl)],["species","species",e=>ul("species",e,rl)],["breed","breed",e=>ul("breed",e,nl)],["ageYears","age_years",e=>cl("age_years",e,ll)],["weightKg","weight_kg",e=>cl("weight_kg",e,il)]],n={};for(let[e,l,i]of r){let r=t[e];if(r!==void 0){if(r!==null){let e=i(r);if(e!==null)return{error:e}}n[l]=r}}let l=pl(t,t.species);return"error"in l?l:(Object.assign(n,l.body),Object.keys(n).length===0?{error:sl("patch must change at least one field")}:{body:n})}function hl(e){if(e==null)return{body:{}};let t=pl(e,e.species);return"error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}var bl=e=>typeof e=="string"?e:null,gl=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function ml(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
19
- return Object.freeze({petRef:bl(t.pet_ref)??petRef,name:bl(t.name),species:bl(t.species),breed:bl(t.breed),ageYears:gl(t.age_years),weightKg:gl(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=bl(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:bl(t.pet_id),petRef:petRef,name:bl(t.name),species:bl(t.species),breed:bl(t.breed),ageYears:gl(t.age_years),weightKg:gl(t.weight_kg),updatedAt:bl(t.updated_at)})}function yl(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...el(e)})}function vl(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
20
- return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return xl(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:al}))}function xl(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>dl(petRef,void 0)??`/widget/v1/pets/${encodeURIComponent(petRef)}`;return{async list(t){let n=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},t?.signal));return n.ok?ok(vl(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=dl(petRef,t);if(n!==null)return err(n);let l=hl(t);if("error"in l)return err(l.error);let i={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:l.body},o=await e.send("pets.registerPet",r?.signal?{...i,signal:r.signal}:i);return o.ok?ok(ml(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=fl(t);if("error"in o)return err(o.error);let a=await e.send("pets.updatePet",r({method:"PATCH",path:i,body:o.body},l?.signal));return a.ok?ok(ml(a.value,petRef)):err(a.error)},async getPetProfile(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.getPetProfile",r({method:"GET",path:`${l}/profile`},t?.signal));if(!i.ok)return err(i.error);let o=yl(i.value);return o===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(o)},async deletePet(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.deletePet",r({method:"DELETE",path:l},t?.signal));return i.ok?ok(void 0):err(i.error)},async eraseUserData(e){let n=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},e?.signal),{maxAttempts:1});return n.ok?ok(void 0):err(n.error)}}}var wl=/* @__PURE__ */new WeakMap,kl=/* @__PURE__ */new Map;function Sl(e,t,petRef,r){let n=wl.get(e);if(n===void 0)return null;let l;if(t.mode==="personalized"&&typeof t.userRef=="string")l=`u:${t.userRef}`;else if(t.mode==="anonymous"&&typeof t.sessionId=="string")l=`a:${t.sessionId}|${t.userRef??""}`;else return null;return`${n}|${l}|${petRef}|${jl(r)}`}function Cl(e,t){if(e===null)return t();let r=kl.get(e);if(r!==void 0)return r;let n=t().finally(()=>{kl.get(e)===n&&kl.delete(e)});return kl.set(e,n),n}function jl(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(jl).join(",")}]`:`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${jl(t)}`).join(",")}}`}var Rl="pet_not_registered";function Tl(e){return e!=null&&e.reasonCode===Rl}var _l=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function zl(petRef,t,r){let{runtime:n,userRef:userRef,scopeEpoch:l}=Fe(),i=e.useCallback((e,t)=>{let r=n.registry.services.authFor(userRef);return Cl(Sl(n,r,e,t),()=>createPetsRepository(r).registerPet(e,t))},[n,userRef,l]),o=e.useMemo(()=>t===void 0?null:jl(t),[t]),[a,s]=e.useState({key:null,status:"idle",error:null,registered:null}),u=e.useRef(0),c=e.useRef(r);c.current=r;let d=petRef===null||o===null?null:`${String(userRef)}|${l}|${petRef}|${o}`,p=e.useCallback(()=>{if(petRef===null||t===void 0||d===null)return;let e=++u.current;s({key:d,status:"registering",error:null,registered:null}),i(petRef,t).then(t=>{e===u.current&&(t.ok?(s({key:d,status:"registered",error:null,registered:t.value}),c.current?.()):s({key:d,status:"failed",error:t.error,registered:null}))})},[i,petRef,d]);e.useEffect(()=>{if(d===null){u.current+=1;return}return p(),()=>{u.current+=1}},[d,p]);let f=e.useCallback(()=>{a.status==="failed"&&p()},[a.status,p]);return e.useMemo(()=>d===null?_l:a.key!==d?{status:"registering",error:null,registered:null,retry:f}:{status:a.status,error:a.error,registered:a.registered,retry:f},[d,a,f])}var Il=/* @__PURE__ */Object.freeze({});function Pl(t){let[r,n]=e.useState(Il),l=e.useRef(null),i=e.useRef([]);i.current=t.map(e=>e.id),e.useEffect(()=>{if(t.length===0){l.current=null,n(e=>e===Il?e:Il);return}let e=l.current;if(e===null)return;let r=t.find(t=>t.role==="user"&&!e.known.has(t.id));r!==void 0&&(l.current=null,n(t=>({...t,[r.id]:e.images})))},[t]);let o=e.useCallback(e=>{l.current=e.length===0?null:{images:e,known:new Set(i.current)}},[]);return e.useMemo(()=>({byMessage:r,stage:o}),[r,o])}var El=/* @__PURE__ */new WeakSet;function Ml(){let e=makeEverfurError("internalError",{retryable:true});return El.add(e),err(e)}function Fl(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&El.has(t)}var Al=500;function Ll(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,Al):null}function Ol(t,r,n,l){let i=Ll(n),o=i===null?null:l!==void 0?`key:${String(l)}`:`prompt:${i}`,a=e.useRef(t);a.current=t;let s=e.useRef(null),u=e.useRef(null),c=e.useRef(o);c.current=o,e.useEffect(()=>{if(i===null||o===null||r||s.current===o||u.current===o)return;let e=a.current;if(e===void 0)return;u.current=o;let t=e=>{u.current===o&&(u.current=null),!Fl(e)&&c.current===o&&(s.current=o)};Promise.resolve(e(i)).then(t,()=>t(void 0))},[i,o,r,t])}var Vl=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),Dl=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),Bl=/* @__PURE__ */Object.freeze({...Vl,markRead:true}),Hl=/* @__PURE__ */Object.freeze({...Dl,markRead:true});function Wl(e,t){return e?t?Bl:Vl:t?Hl:Dl}function Nl(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:Er(()=>r()!==!1)===true}function Ul(t,r){let n=e.useRef({target:t,isVisible:r});n.current={target:t,isVisible:r};let l=e.useRef(t.isStreaming);e.useEffect(()=>{let e=l.current;if(l.current=t.isStreaming,!e||t.isStreaming)return;let{target:r,isVisible:i}=n.current;r.status!=="complete"||r.conversationId===null||r.unreadCount===null||!i()||r.markRead()},[t.isStreaming])}function $l(e,conversationId,t){if(e==="announced")return false;let r=t.lastRefresh;return r===null||r.conversationId!==conversationId?false:t.now-r.at<15e3}function ql(e,t){let conversationId=t.activeConversationId===null||t.activeConversationId.length===0?null:t.activeConversationId;return conversationId===null&&t.refreshesBlankThread!==true?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:$l(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var Gl=3e5;function Kl(e){if(e===null||typeof e!="object"||e.ok!==false)return false;let t=e.error;if(t===null||typeof t!="object")return false;if(t.category==="rateLimit"||t.category==="server")return true;let r=t.httpStatus;return typeof r=="number"&&(r===429||r>=500)}function Yl(t,r,n){let l=e.useRef(r);l.current=r;let i=e.useRef(null),o=e.useRef(null),a=e.useRef(false),s=e.useRef(0),u=e.useRef(0),c=e.useRef(3e4),d=()=>t?.isOffline===void 0?false:Er(()=>t.isOffline?.()===!0)===true,p=d(),f=e.useRef(()=>{});f.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:n}=l.current,p=ql(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:n===true,isOffline:d(),lastRefresh:i.current,now:Date.now()});if(p.action==="skip")return;if(p.action==="defer"){o.current!=="announced"&&(o.current=e);return}if(a.current){if(e==="poll")return;o.current!=="announced"&&(o.current=e);return}if(o.current=null,i.current={conversationId:p.conversationId,at:Date.now()},r===void 0)return;a.current=true;let h=e=>{a.current=false,Kl(e)?(s.current=Math.min(s.current===0?c.current*2:s.current*2,Gl),u.current=Date.now()+s.current):(s.current=0,u.current=0);let t=o.current;t!==null&&f.current(t)};Promise.resolve(r()).then(h,()=>h({ok:false,error:{category:"server"}}))},e.useEffect(()=>{if(r.isTurnInFlight||p)return;let e=o.current;e!==null&&f.current(e)},[r.isTurnInFlight,p]),e.useEffect(()=>{if(t===void 0)return;let e=[],r=(t,r)=>{if(t===void 0)return;let n=Er(()=>t(()=>{f.current(r)}));typeof n=="function"&&e.push(n)};return r(t.onForeground?.bind(t),"foreground"),r(t.onOnline?.bind(t),"foreground"),r(t.onAnnounced?.bind(t),"announced"),()=>{for(let t of e)Er(t)}},[t]);let h=n?.intervalMs??null,b=n?.isVisibleFallback;e.useEffect(()=>{if(t===void 0||h===null||!Number.isFinite(h)||h<=0)return;c.current=h;let e=setInterval(()=>{Date.now()<u.current||Nl(t,b)&&f.current("poll")},h);return()=>clearInterval(e)},[t,h,b])}var Ql=/^efch_[A-Za-z0-9_-]{43}$/,Zl="efch";function Jl(e){return typeof e=="string"&&Ql.test(e)}function chatHandoffTokenFromUrl(e){if(typeof e!="string")return null;let t=e.indexOf("#");if(t<0)return null;for(let r of e.slice(t+1).split("&")){if(!r.startsWith(`${Zl}=`))continue;let e=r.slice(Zl.length+1);return Jl(e)?e:null}return null}var Xl=/* @__PURE__ */Object.freeze(["better","same","worse"]),ei=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var ti="checkin",ri=/^\d{4}-\d{2}-\d{2}$/,ni="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==ni}function li(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==ti||n===void 0||l===void 0||!ei.test(n)||!ri.test(l)?null:{caseId:n,dueDay:l}}function ii(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}function oi(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var ai=128,si=/[\u0000-\u001f\u007f]/;function ui(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function ci(e){return typeof e!="string"||e.length===0||e.length>ai||si.test(e)||e.includes("://")?null:e}function di(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=ci(e.pet_ref);return typeof conversationId!="string"||!ii(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function pi(e,t,r){return Jl(t)?createRequestFunnel({auth:e,...r?{errorPolicy:r}:{}}).send("chat.redeemHandoff",{method:"POST",path:"/widget/v1/chat/handoffs/redeem",body:{token:t}},{maxAttempts:1}).then(e=>e.ok?ok(di(ui(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(oi("internalError",false))):Promise.resolve(ok(null))}function fi(t,r){let n=r?.runtime??null,userRef=r?.userRef??null,l=Jl(t)?t:null,i=l===null||userRef===null?null:`${String(userRef)}|${l}`,[o,a]=e.useState(null);return e.useEffect(()=>{if(i===null||l===null||userRef===null||n===null)return;let e=true,t=n.registry.services;return pi(t.authFor(userRef),l,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||a({key:i,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[i,n,l,userRef]),o!==null&&o.key===i?o.target:void 0}function hi(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function bi(t,r,n){let l=hi(r),i=r?.kind==="chat",o=r?.petRef??null,a=i&&!n.pinned&&o!==null&&n.petRef!==null&&o!==n.petRef,s=e.useRef({openCheckin:t,target:r,selectPet:n.selectPet});s.current={openCheckin:t,target:r,selectPet:n.selectPet};let u=e.useRef(null),c=e.useRef(null),petRef=n.petRef;e.useEffect(()=>{if(l===null||u.current===l)return;let{openCheckin:e,target:t,selectPet:r}=s.current;if(a&&o!==null){if(c.current?.key!==l){c.current={key:l,from:petRef},r(o);return}petRef!==c.current.from&&(u.current=l);return}i&&!n.ready||(u.current=l,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[l,i,a,o,petRef,n.ready])}var gi=/* @__PURE__ */Object.freeze({heading:"Chats",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No chats match that.",loading:"Loading your chats…",loadFailed:"Couldn’t load your chats",loadingMore:"Loading more…",untitled:"New conversation",newChat:"New chat",searchPlaceholder:"Search chats…",search:"Search chats",countLabel:"Chats and vet messages",countSeparator:" · ",newReply:"New reply · {date}",retry:"Try again",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages…",openConversation:"Open conversation",unreadPrefix:"Unread. "});function mi(e){let t=e?.replace(/\s+/g," ").trim();return t||gi.untitled}function yi(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function vi(e){let t=yi(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?gi.newReply.replace("{date}",t):t}function xi(e,t){return t?`${gi.countLabel}${gi.countSeparator}${e}`:gi.countLabel}function wi(e){return`${e.unreadCount!==null&&e.unreadCount>0?gi.unreadPrefix:""}${gi.openConversation} ${mi(e.title)}`}function ki(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function Si(e,t){let r=ki(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=ki(mi(t.title)),l=e.indexOf(r);if(l<0)continue;let i=l===0?0:e.charAt(l-1)===" "?1:2;n[i]?.push(t)}return n.flat()}function Ci(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function ji(t){let[r,n]=e.useState(false),[l,i]=e.useState(""),o=t.listConversations,a=e.useRef(0),[s,u]=e.useState(()=>Ci(o)),c=s.scope===o?s:Ci(o);e.useEffect(()=>(a.current+=1,n(false),i(""),u(Ci(o)),()=>{a.current+=1}),[o]);let d=e.useCallback(async e=>{let r=++a.current,n=e!==void 0;u(e=>({...e,scope:o,loading:!n,loadingMore:n,error:null}));let l=await t.listConversations(e?{cursor:e}:void 0);if(r===a.current){if(!l.ok){u(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}u(t=>{let r=e&&t.scope===o?t.rows:[],n=new Set(r.map(e=>e.id));return{scope:o,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===e?null:l.value.nextCursor}})}},[t.listConversations,o]),p=()=>{n(true),i(""),d()},f=()=>{a.current+=1,n(false)},h=async e=>{let r=++a.current;u(e=>({...e,loading:true,error:null}));let l=await t.resumeConversation(e);r===a.current&&(u(e=>({...e,loading:false,error:l.ok?null:l.error.displayMessage})),l.ok&&n(false))},b=async()=>{let e=a.current,r=await t.loadOlderMessages();e===a.current&&!r.ok&&u(e=>({...e,error:r.error.displayMessage}))},g=()=>{t.newConversation(),a.current+=1,n(false)},m=()=>{c.cursor===null||c.loading||c.loadingMore||l.trim().length>0||d(c.cursor)},y=e.useMemo(()=>Si(c.rows,l),[c.rows,l]),v=l.trim().length>0;return{...c,open:r,show:p,close:f,load:d,resume:h,earlier:b,newConversation:g,loadMore:m,query:l,setQuery:i,searching:v,filtered:y,emptyKind:c.rows.length===0?"empty":"noMatch"}}var Ri="#111111",Ti="#FFFFFF",_i=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:Ri,pillColor:Ti,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:Ri,pillColor:Ti,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Ri,pillColor:Ti,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:Ri,pillColor:Ti,showsVetAction:false})});function zi(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function Ii(e){return Re(je.urgencyGeneralReason,{petName:e?.trim()||je.emptyTitlePetFallback})}function Pi(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let l=n.urgencyLevel;return l?{messageId:n.id,level:l,reason:Ei(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Ii(t)}:null}return null}function Ei(e){return typeof e=="string"&&e.trim().length>0?e:null}function Mi(t){let r=t===null?null:zi(t),[n,l]=e.useState(null),[i,o]=e.useState(false);e.useEffect(()=>o(false),[r]);let a=t!==null&&(i||!(n!==null&&n===r)),s=t===null?null:_i[t.level],u=t!==null&&!a&&t.level!=="general",c=e.useCallback(()=>{r!==null&&l(r),o(false)},[r]),d=e.useCallback(()=>o(true),[]);return e.useMemo(()=>({source:t,tier:s,signature:r,showBanner:a,showCompactIcon:u,showVetAction:a&&s!==null&&s.showsVetAction,dismissLabel:s===null?null:Re(je.dismissBanner,{label:s.label}),dismiss:c,expand:d}),[t,s,r,a,u,c,d])}var Fi=()=>globalThis[/* @__PURE__ */Symbol.for("everfur.sdk.chatCards.v1")]??={loader:null,lazy:null};var Ai=Fi;function registerEverfurChatCards(t){let r=Ai();r.loader=t;let n=t&&Promise.resolve().then(t).then(e=>typeof e.ServerCards=="function"?e.ServerCards:NONE3,()=>NONE3);r.lazy=n&&e.lazy(async()=>({default:await n}))}var NONE3=()=>null,Li=e.createContext(null);function ServerCardsSlot({message:t}){let r=e.useContext(Li),n=Ai(),l=t.a2ui??n.frames?.get(t.responseId),i=n.lazy;return l===void 0||r===null||i===null?null:e.createElement(e.Suspense,{fallback:null},e.createElement(i,{message:t,a2ui:l,host:r}))}var Oi=class extends e.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:t,fallback:r,resetKey:n}){return e.createElement(Oi,{fallback:r,resetKey:n,children:e.createElement(RenderHost,{render:t})})}var Vi=48;function Di(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(r){let{capability:n,children:l,renderDisabled:i,renderPending:o,style:a}=r,s=useCapability(n),u=e.useMemo(()=>Di(s),[s]);switch(u){case"enabled":return l;case"pending":return o?/* @__PURE__ */t.jsx(HostRender,{render:o,fallback:/* @__PURE__ */t.jsx(PendingSkeleton,{capability:n,style:a})}):/* @__PURE__ */t.jsx(PendingSkeleton,{capability:n,style:a});case"disabled":return i?/* @__PURE__ */t.jsx(HostRender,{render:()=>i(s),fallback:/* @__PURE__ */t.jsx(OffState,{decision:s,style:a}),resetKey:s}):/* @__PURE__ */t.jsx(OffState,{decision:s,style:a});default:return assertNever(u)}}function PendingSkeleton({capability:r,style:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Bi(i),[i]);/* @__PURE__ */
21
- return t.jsx(n.View,{style:[o.offstate,l],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${r}`,children:/* @__PURE__ */t.jsx(n.View,{style:o.skeletonBar})})}function OffState({decision:r,style:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Bi(i),[i]),a=r.disabled?.reason??"";/* @__PURE__ */
22
- return t.jsx(n.View,{style:[o.offstate,l],accessible:true,accessibilityRole:"text",accessibilityLabel:a,children:a.length>0?/* @__PURE__ */t.jsx(Text,{style:o.offstateText,children:a}):null})}function Bi(e){let{color:t,space:r,radius:l,type:i}=e;return n.StyleSheet.create({offstate:{minHeight:Vi,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:l.md,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:l.xs,backgroundColor:t.brandSofter}})}var Hi="everfur.com",Wi=2048,Ni=/^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function Ui(e){if(!Array.isArray(e))return[];let t=/* @__PURE__ */new Set;for(let r of e){if(typeof r!="string")continue;let e=r.trim().toLowerCase();e.length<=253&&Ni.test(e)&&t.add(e)}/* @__PURE__ */
23
- return Object.freeze([...t])}function $i(e,t){if(e===Hi||e.endsWith(`.${Hi}`))return true;for(let r of t)if(r.startsWith("*.")?e.endsWith(r.slice(1)):e===r)return true;return false}function qi(e,t){if(typeof e!="string"||e.length===0||e.length>Wi||!/^https:\/\//i.test(e))return null;let r=ft(e);return r===null||r.protocol!=="https:"||r.username!==""||r.password!==""||r.port!==""?null:$i(r.hostname,t)?r.href:null}function Gi(e){try{Promise.resolve(n.Linking.openURL(e)).catch(()=>{})}catch{}}var Ki=e.createContext(null);function Yi(){return e.useContext(Ki)??void 0}function MessageLinksScope({linkHosts:t,onOpenUrl:r,children:n}){let l=t===false?null:Array.isArray(t)?t.join(`\n`):"",i=e.useMemo(()=>{if(l===null)return null;let e=Ui(l===""?[]:l.split(`\n`));/* @__PURE__ */
24
- return Object.freeze({hosts:e,open:r!==void 0?e=>{Er(r,e,"message")}:Gi})},[l,r]);return e.createElement(Ki.Provider,{value:i},n)}var Qi={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function Zi(e){return{width:e,height:e,alignItems:"center",justifyContent:"center"}}function Ji(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}function MenuGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l),o={width:e*.82,height:i,borderRadius:i,backgroundColor:r};/* @__PURE__ */
25
- return t.jsxs(n.View,{style:[Zi(e),{gap:e*.22}],...Qi,children:[
16
+ return Object.freeze({reason:userFacingError("accessDenied"),level:"user_entitlement",recoverable:false})}function Gr(e){let t={name:e.name,enabled:e.enabled,isPending:e.isPending,limits:/* @__PURE__ */Object.freeze({...e.limits})};return e.disabled!==void 0&&(t.disabled=e.disabled),/* @__PURE__ */Object.freeze(t)}function useCapability(t){let{runtime:r}=Le(),n=r.entitlements,l=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return e.useMemo(()=>decideCapability(t,l.decisions,{isPending:l.isPending}),[t,l])}function Kr(t){let{runtime:r}=Le(),n=r.entitlements,l=e.useCallback(e=>n===void 0?()=>{}:n.subscribe(e),[n]),i=e.useCallback(()=>{if(n===void 0)return false;let e=n.getSnapshot();return decideCapability(t,e.decisions,{isPending:e.isPending}).enabled},[n,t]);return e.useSyncExternalStore(l,i,i)}var Yr=()=>()=>{},Qr=()=>null;function Zr(t,r){return e.useSyncExternalStore(r?.subscribe??Yr,r?.get??Qr,r?.get??Qr)??t}var Jr=/* @__PURE__ */Object.freeze({branding:null}),Xr=/* @__PURE__ */Object.freeze({subscribe:()=>()=>{},getSnapshot:()=>Jr});function en(e){return e?Object.keys(e).sort().map(t=>`${t}=${String(e[t])}`).join("&"):""}function tn(t){let{runtime:r}=Le(),n=r?.entitlements??Xr,l=e.useCallback(()=>n.getSnapshot()?.branding??null,[n]),i=Zr(e.useSyncExternalStore(n.subscribe,l,l),r?.sdkConfigHost?.branding),o=en(t);return e.useMemo(()=>{let e=i?.lockedFields??null;return{presentation:resolvePresentation({server:i?.presentation??null,locked:e,client:t??null}),isLocked:t=>isPresentationFieldLocked(t,e)}},[i,o])}function rn(e){let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]=n);return t}function nn(e){return e.isBootstrapping?"loading":e.status==="error"&&e.error&&e.messages.length===0?"error":e.messages.length===0?"empty":"populated"}function ln(e){let t=ht(e);return t===null?null:{reached:Te.capReached.replace("{cap}",String(t.limit)),guidance:t.emergencyGuidance??null}}function on(e){return e.code==="accessDenied"||e.code==="conversationNotFound"}function an(e,t="native"){if(e.messages.length===0)return null;let r=e.status==="error"?e.error:null;if(r!==null){let e=on(r),n=t==="web",l=ln(r);return{tone:"error",title:l!==null?l.reached:e?Te.turnUnreachableTitle:n?Te.turnFailedTitleWeb:Te.turnFailedTitle,body:r.displayMessage,actionLabel:e?Te.turnStartNewChat:n?Te.retry:Te.turnRetry,action:e?"startNew":"retry",...l!==null&&l.guidance!==null?{guidance:l.guidance}:{}}}return e.stopped===true?{tone:"neutral",title:Te.turnStoppedTitle,body:Te.turnStoppedBody,actionLabel:Te.turnRetry,action:"retry"}:null}function sn(e,t){let r=e[e.length-1];return t&&(r===void 0||r.role==="user")}var un=3,cn=/* @__PURE__ */Object.freeze([]);function dn(e){let t=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||t===void 0||t.role!=="assistant")return cn;let r=/* @__PURE__ */new Set,n=[];for(let t of e.suggestedPrompts){let e=t.trim(),l=e.replace(/\s+/g," ").toLowerCase();if(!(l.length===0||r.has(l))&&(r.add(l),n.push(e),n.length===un))break}/* @__PURE__ */
17
+ return Object.freeze(n)}var pn=5;function fn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function hn(e,t){if(t===void 0)return dn(e);let r=e.messages[e.messages.length-1];if(e.isStreaming||e.status==="error"||r===void 0||r.role!=="assistant")return cn;let n=Math.max(1,Math.min(pn,Math.floor(t.count??un))),l=null;for(let t=e.messages.length-1;t>=0;t-=1){let r=e.messages[t];if(r!==void 0&&r.role==="user"){l=r.text;break}}let i=e=>e.trim().replace(/\s+/g," ").toLowerCase(),o=new Set(l===null?[]:[i(l)]),a=[],s=e=>{let r=e.trim(),l=i(r);a.length>=n||l.length===0||o.has(l)||fn(t.exclude,r)||(o.add(l),a.push(r))};for(let t of e.suggestedPrompts)s(t);let u=[];try{u=typeof t.fill=="function"?t.fill(l):t.fill??[]}catch{u=[]}for(let e of Array.isArray(u)?u:[])typeof e=="string"&&s(e);/* @__PURE__ */
18
+ return Object.freeze(a)}function bn(e){return e.sender?.displayName??Te.senderVet}function gn(petRef,conversationId){let e={};return petRef!==void 0&&(e.petRef=petRef),conversationId!==void 0&&(e.conversationId=conversationId),e}var mn=new RegExp([String.raw`\b(book|booking|schedule|scheduling|arrange|set\s+up)\s+(an?\s+|the\s+|her\s+|his\s+|their\s+|my\s+|your\s+)?(next\s+)?((vet|veterinary|video|virtual|televet|follow-up|follow up)\s+)?(visit|appointment|appt|consult|consultation|call|vet|checkup|check-up|exam)\b`,String.raw`\bmake\s+(an?\s+|the\s+)?((vet|veterinary|video|virtual|follow-up|follow up)\s+)?(appointment|appt)\b`,String.raw`\bneed\s+(an?\s+)?((vet|veterinary|video|virtual)\s+)?(appointment|appt|visit|consult|consultation)\b`,String.raw`\b(video|virtual)\s+(visit|appointment|appt|consult|consultation|call)s?\b`,String.raw`\b(televet|telehealth|telemedicine)\b`,String.raw`\b(talk|speak|chat)\s+(to|with)\s+(an?|the|your|my)\s+vet\b`,String.raw`\bsee\s+(an?|the|your|my)\s+vet\b`].join("|"),"i"),NONE=()=>true;function yn(e,t){if(e===void 0)return false;if(typeof e=="function")try{return e(t)===!0}catch{return false}return e.lastIndex=0,e.test(t)}function vn(e,t,r){let n=t.chatFollowUpsExcludeTelevet,l=e?.count!==void 0&&!r?e.count:t.chatFollowUpCount;if(e===void 0&&l===un&&!n)return;if(l<=0)return{...e??{},count:1,exclude:NONE,fill:[]};let i=e?.exclude,o=n?e=>mn.test(e)||yn(i,e):i;return{...e??{},count:l,...o!==void 0?{exclude:o}:{}}}function xn(e){for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let r=e.charCodeAt(t+1);if(!(r>=56320&&r<=57343))return true;t+=1}else if(r>=56320&&r<=57343)return true}return false}function wn(e){return[...e].length}var kn=/* @__PURE__ */Object.freeze({dog:"dog",canine:"dog",k9:"dog",puppy:"dog",cat:"cat",feline:"cat",kitten:"cat"});function canonicalPetSpecies(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.prototype.hasOwnProperty.call(kn,t)?kn[t]:null}var Sn=50,Cn=128,jn=120,Rn=120,Tn=2e3,_n=120,zn=80,In=/* @__PURE__ */new Set(["male","female","unknown"]),Pn=/* @__PURE__ */new Set(["day","month","year"]),En=/* @__PURE__ */new Set(["low","medium","high","athletic"]),Mn=/* @__PURE__ */new Set(["indoor","outdoor","both"]),An=/* @__PURE__ */new Set(["mild","moderate","severe"]),Fn=/^(\d{4})-(\d{2})-(\d{2})$/,Ln=[["sex","sex"],["spayedNeutered","spayed_neutered"],["birthDate","birth_date"],["birthDatePrecision","birth_date_precision"],["activityLevel","activity_level"],["indoorOutdoor","indoor_outdoor"],["foodBrand","food_brand"],["foodType","food_type"],["microchipId","microchip_id"]],On=[["allergies","allergies"],["medications","medications"],["supplements","supplements"],["conditions","conditions"]];/* @__PURE__ */Object.freeze([...Ln,...On].map(([e])=>e));function Vn(e){let t=Fn.exec(e);if(t===null)return false;let[r,n,l]=[Number(t[1]),Number(t[2]),Number(t[3])],i=new Date(Date.UTC(r,n-1,l));return i.getUTCFullYear()===r&&i.getUTCMonth()===n-1&&i.getUTCDate()===l}var Dn=e=>(t,r)=>typeof r=="string"&&e.has(r)?null:`${t} must be one of ${[...e].join(", ")}`,Bn=(e,t)=>typeof t=="boolean"?null:`${e} must be true or false`,Hn=(e,t)=>typeof t=="string"&&Vn(t)?null:`${e} must be a real date written YYYY-MM-DD`,Wn=(e,t={})=>(r,n)=>{if(typeof n!="string")return`${r} must be a string`;if(xn(n))return`${r} contains an unpaired surrogate and cannot be encoded`;let l=t.trimmed?n.trim():n;if(t.required&&l.length===0)return`${r} is required and must not be blank`;let i=wn(l);return i<=e?null:`${r} is ${i} characters; the server accepts at most ${e}`},Nn={sex:Dn(In),spayedNeutered:Bn,birthDate:Hn,birthDatePrecision:Dn(Pn),activityLevel:Dn(En),indoorOutdoor:Dn(Mn),foodBrand:Wn(_n),foodType:Wn(_n),microchipId:Wn(zn)},Un=["ref","ref",false,Wn(Cn,{required:true,trimmed:true})],$n=["notes","notes",false,Wn(Tn,{trimmed:true})],qn=[Un,["name","name",true,Wn(jn,{required:true,trimmed:true})],["dose","dose",false,Wn(Rn,{trimmed:true})],["frequency","frequency",false,Wn(Rn,{trimmed:true})],["startDate","start_date",false,Hn],["endDate","end_date",false,Hn],$n],Gn={allergies:[Un,["allergen","allergen",true,Wn(jn,{required:true,trimmed:true})],["severity","severity",false,Dn(An)],$n],medications:qn,supplements:qn,conditions:[Un,["conditionName","condition_name",true,Wn(jn,{required:true,trimmed:true})],["diagnosedDate","diagnosed_date",false,Hn],$n]};function Kn(e,t,r){let n=`${e}[${t}]`;if(typeof r!="object"||r===null||Array.isArray(r))return{error:`${n} must be an object`};let l=r,i={};for(let[t,r,o,a]of Gn[e]){let e=l[t];if(e==null){if(o)return{error:`${n}.${t} is required`};e===null&&(i[r]=null);continue}let s=a(`${n}.${t}`,e);if(s!==null)return{error:s};i[r]=e}let o=i.start_date,a=i.end_date;return typeof o=="string"&&typeof a=="string"&&a<o?{error:`${n}.endDate must not be before startDate`}:{item:i}}function Yn(e,t){if(!Array.isArray(t))return{error:`${e} must be an array (send [] to clear it)`};if(t.length>Sn)return{error:`${e} has ${t.length} items; the server accepts at most ${Sn}`};let r=[],n=/* @__PURE__ */new Set;for(let l=0;l<t.length;l+=1){let i=Kn(e,l,t[l]);if("error"in i)return i;let o=i.item.ref;if(typeof o=="string"){let t=o.trim();if(n.has(t))return{error:`${e}: ref ${JSON.stringify(t)} is used twice; a ref names one item`};n.add(t)}r.push(i.item)}return{items:r}}function Qn(e,t){let r=e,n={};for(let[e,t]of Ln){let l=r[e];if(l!==void 0){if(l!==null){let t=Nn[e](e,l);if(t!==null)return{error:t}}n[t]=l}}let l=r.birthDate!==void 0,i=r.birthDatePrecision!==void 0;if(l!==i||l&&r.birthDate===null!=(r.birthDatePrecision===null))return{error:"birthDate and birthDatePrecision must be sent together, both set or both null"};for(let[e,t]of On){let l=r[e];if(l===void 0)continue;let i=Yn(e,l);if("error"in i)return i;n[t]=i.items}return Object.keys(n).length>0&&t!==void 0&&canonicalPetSpecies(t)===null?{error:"health fields need a pet Everfur reads as a dog or a cat (dog, canine, k9, puppy, cat, feline, kitten)"}:{body:n}}var Zn=e=>typeof e=="string"?e:null,Jn=(e,t)=>typeof t=="string"&&e.has(t)?t:null,Xn=e=>typeof e=="boolean"?e:null;function el(e,t){return Array.isArray(e)?/* @__PURE__ */Object.freeze(e.flatMap(e=>{if(typeof e!="object"||e===null||Array.isArray(e))return[];let r=t(e);return r===null?[]:[r]})):/* @__PURE__ */Object.freeze([])}function tl(e){let t=Zn(e.name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Zn(e.ref),name:t,dose:Zn(e.dose),frequency:Zn(e.frequency),startDate:Zn(e.start_date),endDate:Zn(e.end_date),notes:Zn(e.notes)})}function rl(e){let t=e.profile_version;/* @__PURE__ */
19
+ return Object.freeze({profileVersion:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:0,sex:Jn(In,e.sex),spayedNeutered:Xn(e.spayed_neutered),birthDate:Zn(e.birth_date),birthDatePrecision:Jn(Pn,e.birth_date_precision),activityLevel:Jn(En,e.activity_level),indoorOutdoor:Jn(Mn,e.indoor_outdoor),foodBrand:Zn(e.food_brand),foodType:Zn(e.food_type),microchipId:Zn(e.microchip_id),allergies:el(e.allergies,e=>{let t=Zn(e.allergen);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Zn(e.ref),allergen:t,severity:Jn(An,e.severity),notes:Zn(e.notes)})}),medications:el(e.medications,tl),supplements:el(e.supplements,tl),conditions:el(e.conditions,e=>{let t=Zn(e.condition_name);return t===null||t.length===0?null:/* @__PURE__ */Object.freeze({ref:Zn(e.ref),conditionName:t,diagnosedDate:Zn(e.diagnosed_date),notes:Zn(e.notes)})})})}var nl=100,ll=50,il=100,ol=50,al=500,sl=128,ul=6e4;function cl(e){return makeEverfurError("validationFailed",{retryable:false,wireMessage:e})}function dl(e,t,r){if(typeof t!="string")return cl(`${e} must be a string`);let n=wn(t);return n<=r?null:cl(`${e} is ${n} characters; the server accepts at most ${r}`)}function pl(e,t,r){return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=r?null:cl(`${e} must be a finite number between 0 and ${r}`)}function fl(petRef,e){if(typeof petRef!="string")return cl("pet_ref must be a string");if(petRef.trim().length===0)return cl("pet_ref must not be blank");if(xn(petRef))return cl("pet_ref contains an unpaired surrogate and cannot be encoded");if(e!=null&&typeof e!="object")return cl("profile must be an object");let t=[dl("pet_ref",petRef,sl)];return e?.name!==void 0&&t.push(dl("name",e.name,nl)),e?.species!==void 0&&t.push(dl("species",e.species,ll)),e?.breed!==void 0&&t.push(dl("breed",e.breed,il)),e?.ageYears!==void 0&&t.push(pl("age_years",e.ageYears,ol)),e?.weightKg!==void 0&&t.push(pl("weight_kg",e.weightKg,al)),t.find(e=>e!==null)??null}function hl(e,t){let r=Qn(e,t);return"error"in r?{error:cl(r.error)}:r}function bl(e){if(typeof e!="object"||e===null)return{error:cl("patch must be an object")};let t=e,r=[["name","name",e=>dl("name",e,nl)],["species","species",e=>dl("species",e,ll)],["breed","breed",e=>dl("breed",e,il)],["ageYears","age_years",e=>pl("age_years",e,ol)],["weightKg","weight_kg",e=>pl("weight_kg",e,al)]],n={};for(let[e,l,i]of r){let r=t[e];if(r!==void 0){if(r!==null){let e=i(r);if(e!==null)return{error:e}}n[l]=r}}let l=hl(t,t.species);return"error"in l?l:(Object.assign(n,l.body),Object.keys(n).length===0?{error:cl("patch must change at least one field")}:{body:n})}function gl(e){if(e==null)return{body:{}};let t=hl(e,e.species);return"error"in t?t:{body:{...e.name!==void 0?{name:e.name}:{},...e.species!==void 0?{species:e.species}:{},...e.breed!==void 0?{breed:e.breed}:{},...e.ageYears!==void 0?{age_years:e.ageYears}:{},...e.weightKg!==void 0?{weight_kg:e.weightKg}:{},...t.body}}}var ml=e=>typeof e=="string"?e:null,yl=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function vl(e,petRef){let t=typeof e=="object"&&e!==null?e:{};/* @__PURE__ */
20
+ return Object.freeze({petRef:ml(t.pet_ref)??petRef,name:ml(t.name),species:ml(t.species),breed:ml(t.breed),ageYears:yl(t.age_years),weightKg:yl(t.weight_kg)})}function widgetPetFromWire(e){if(typeof e!="object"||e===null)return null;let t=e,petRef=ml(t.pet_ref);return petRef===null||petRef.length===0?null:/* @__PURE__ */Object.freeze({petId:ml(t.pet_id),petRef:petRef,name:ml(t.name),species:ml(t.species),breed:ml(t.breed),ageYears:yl(t.age_years),weightKg:yl(t.weight_kg),updatedAt:ml(t.updated_at)})}function xl(e){let t=widgetPetFromWire(e);return t===null?null:/* @__PURE__ */Object.freeze({...t,...rl(e)})}function wl(e){let t=Array.isArray(e)?e:typeof e=="object"&&e!==null&&Array.isArray(e.pets)?e.pets:[];/* @__PURE__ */
21
+ return Object.freeze(t.flatMap(e=>{let t=widgetPetFromWire(e);return t===null?[]:[t]}))}function createPetsRepository(e){return kl(createRequestFunnel({auth:e}),createRequestFunnel({auth:e,unaryTimeoutMs:ul}))}function kl(e,t=e){let r=(e,t)=>t?{...e,signal:t}:e,n=petRef=>fl(petRef,void 0)??`/widget/v1/pets/${encodeURIComponent(petRef)}`;return{async list(t){let n=await e.send("pets.list",r({method:"GET",path:"/widget/v1/pets"},t?.signal));return n.ok?ok(wl(n.value)):err(n.error)},async registerPet(petRef,t,r){let n=fl(petRef,t);if(n!==null)return err(n);let l=gl(t);if("error"in l)return err(l.error);let i={method:"POST",path:`/widget/v1/pets/${encodeURIComponent(petRef)}`,body:l.body},o=await e.send("pets.registerPet",r?.signal?{...i,signal:r.signal}:i);return o.ok?ok(vl(o.value,petRef)):err(o.error)},async updatePet(petRef,t,l){let i=n(petRef);if(typeof i!="string")return err(i);let o=bl(t);if("error"in o)return err(o.error);let a=await e.send("pets.updatePet",r({method:"PATCH",path:i,body:o.body},l?.signal));return a.ok?ok(vl(a.value,petRef)):err(a.error)},async getPetProfile(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.getPetProfile",r({method:"GET",path:`${l}/profile`},t?.signal));if(!i.ok)return err(i.error);let o=xl(i.value);return o===null?err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the pet profile response carried no pet_ref"})):ok(o)},async deletePet(petRef,t){let l=n(petRef);if(typeof l!="string")return err(l);let i=await e.send("pets.deletePet",r({method:"DELETE",path:l},t?.signal));return i.ok?ok(void 0):err(i.error)},async eraseUserData(e){let n=await t.send("pets.eraseUserData",r({method:"DELETE",path:"/widget/v1/me"},e?.signal),{maxAttempts:1});return n.ok?ok(void 0):err(n.error)}}}var Sl=/* @__PURE__ */new WeakMap,Cl=/* @__PURE__ */new Map;function jl(e,t,petRef,r){let n=Sl.get(e);if(n===void 0)return null;let l;if(t.mode==="personalized"&&typeof t.userRef=="string")l=`u:${t.userRef}`;else if(t.mode==="anonymous"&&typeof t.sessionId=="string")l=`a:${t.sessionId}|${t.userRef??""}`;else return null;return`${n}|${l}|${petRef}|${Tl(r)}`}function Rl(e,t){if(e===null)return t();let r=Cl.get(e);if(r!==void 0)return r;let n=t().finally(()=>{Cl.get(e)===n&&Cl.delete(e)});return Cl.set(e,n),n}function Tl(e){return e===null||typeof e!="object"?JSON.stringify(e)??"undefined":Array.isArray(e)?`[${e.map(Tl).join(",")}]`:`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${Tl(t)}`).join(",")}}`}var _l="pet_not_registered";function zl(e){return e!=null&&e.reasonCode===_l}var Il=/* @__PURE__ */Object.freeze({status:"idle",error:null,registered:null,retry:()=>{}});function Pl(petRef,t,r){let{runtime:n,userRef:userRef,scopeEpoch:l}=Le(),i=e.useCallback((e,t)=>{let r=n.registry.services.authFor(userRef);return Rl(jl(n,r,e,t),()=>createPetsRepository(r).registerPet(e,t))},[n,userRef,l]),o=e.useMemo(()=>t===void 0?null:Tl(t),[t]),[a,s]=e.useState({key:null,status:"idle",error:null,registered:null}),u=e.useRef(0),c=e.useRef(r);c.current=r;let d=petRef===null||o===null?null:`${String(userRef)}|${l}|${petRef}|${o}`,p=e.useCallback(()=>{if(petRef===null||t===void 0||d===null)return;let e=++u.current;s({key:d,status:"registering",error:null,registered:null}),i(petRef,t).then(t=>{e===u.current&&(t.ok?(s({key:d,status:"registered",error:null,registered:t.value}),c.current?.()):s({key:d,status:"failed",error:t.error,registered:null}))})},[i,petRef,d]);e.useEffect(()=>{if(d===null){u.current+=1;return}return p(),()=>{u.current+=1}},[d,p]);let f=e.useCallback(()=>{a.status==="failed"&&p()},[a.status,p]);return e.useMemo(()=>d===null?Il:a.key!==d?{status:"registering",error:null,registered:null,retry:f}:{status:a.status,error:a.error,registered:a.registered,retry:f},[d,a,f])}var El=/* @__PURE__ */Object.freeze({});function Ml(t){let[r,n]=e.useState(El),l=e.useRef(null),i=e.useRef([]);i.current=t.map(e=>e.id),e.useEffect(()=>{if(t.length===0){l.current=null,n(e=>e===El?e:El);return}let e=l.current;if(e===null)return;let r=t.find(t=>t.role==="user"&&!e.known.has(t.id));r!==void 0&&(l.current=null,n(t=>({...t,[r.id]:e.images})))},[t]);let o=e.useCallback(e=>{l.current=e.length===0?null:{images:e,known:new Set(i.current)}},[]);return e.useMemo(()=>({byMessage:r,stage:o}),[r,o])}var Al=/* @__PURE__ */new WeakSet;function Fl(){let e=makeEverfurError("internalError",{retryable:true});return Al.add(e),err(e)}function Ll(e){if(typeof e!="object"||e===null||e.ok!==false)return false;let t=e.error;return typeof t=="object"&&t!==null&&Al.has(t)}var Ol=500;function Vl(e){if(!e)return null;let t=e.replace(/[\u0000-\u001F\u007F-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g," ").replace(/\s+/g," ").trim();return t?t.slice(0,Ol):null}function Dl(t,r,n,l){let i=Vl(n),o=i===null?null:l!==void 0?`key:${String(l)}`:`prompt:${i}`,a=e.useRef(t);a.current=t;let s=e.useRef(null),u=e.useRef(null),c=e.useRef(o);c.current=o,e.useEffect(()=>{if(i===null||o===null||r||s.current===o||u.current===o)return;let e=a.current;if(e===void 0)return;u.current=o;let t=e=>{u.current===o&&(u.current=null),!Ll(e)&&c.current===o&&(s.current=o)};Promise.resolve(e(i)).then(t,()=>t(void 0))},[i,o,r,t])}var Bl=/* @__PURE__ */Object.freeze({openUnreadHead:true,reportLoadFailures:true}),Hl=/* @__PURE__ */Object.freeze({reportLoadFailures:true}),Wl=/* @__PURE__ */Object.freeze({...Bl,markRead:true}),Nl=/* @__PURE__ */Object.freeze({...Hl,markRead:true});function Ul(e,t){return e?t?Wl:Bl:t?Nl:Hl}function $l(e,t){let r=e?.isVisible===void 0?t:e.isVisible.bind(e);return r===void 0?true:Ar(()=>r()!==!1)===true}function ql(t,r){let n=e.useRef({target:t,isVisible:r});n.current={target:t,isVisible:r};let l=e.useRef(t.isStreaming);e.useEffect(()=>{let e=l.current;if(l.current=t.isStreaming,!e||t.isStreaming)return;let{target:r,isVisible:i}=n.current;r.status!=="complete"||r.conversationId===null||r.unreadCount===null||!i()||r.markRead()},[t.isStreaming])}function Gl(e,conversationId,t){if(e==="announced")return false;let r=t.lastRefresh;return r===null||r.conversationId!==conversationId?false:t.now-r.at<15e3}function Kl(e,t){let conversationId=t.activeConversationId===null||t.activeConversationId.length===0?null:t.activeConversationId;return conversationId===null&&t.refreshesBlankThread!==true?{action:"skip",reason:"no_thread"}:t.isTurnInFlight?{action:"defer",reason:"turn_in_flight"}:t.isOffline?{action:"defer",reason:"offline"}:Gl(e,conversationId,t)?{action:"skip",reason:"coalesced"}:{action:"refresh",conversationId:conversationId}}var Yl=3e5;function Ql(e){if(e===null||typeof e!="object"||e.ok!==false)return false;let t=e.error;if(t===null||typeof t!="object")return false;if(t.category==="rateLimit"||t.category==="server")return true;let r=t.httpStatus;return typeof r=="number"&&(r===429||r>=500)}function Zl(t,r,n){let l=e.useRef(r);l.current=r;let i=e.useRef(null),o=e.useRef(null),a=e.useRef(false),s=e.useRef(0),u=e.useRef(0),c=e.useRef(3e4),d=()=>t?.isOffline===void 0?false:Ar(()=>t.isOffline?.()===!0)===true,p=d(),f=e.useRef(()=>{});f.current=e=>{let{conversationId:conversationId,isTurnInFlight:t,refresh:r,refreshesBlankThread:n}=l.current,p=Kl(e,{activeConversationId:conversationId,isTurnInFlight:t,refreshesBlankThread:n===true,isOffline:d(),lastRefresh:i.current,now:Date.now()});if(p.action==="skip")return;if(p.action==="defer"){o.current!=="announced"&&(o.current=e);return}if(a.current){if(e==="poll")return;o.current!=="announced"&&(o.current=e);return}if(o.current=null,i.current={conversationId:p.conversationId,at:Date.now()},r===void 0)return;a.current=true;let h=e=>{a.current=false,Ql(e)?(s.current=Math.min(s.current===0?c.current*2:s.current*2,Yl),u.current=Date.now()+s.current):(s.current=0,u.current=0);let t=o.current;t!==null&&f.current(t)};Promise.resolve(r()).then(h,()=>h({ok:false,error:{category:"server"}}))},e.useEffect(()=>{if(r.isTurnInFlight||p)return;let e=o.current;e!==null&&f.current(e)},[r.isTurnInFlight,p]),e.useEffect(()=>{if(t===void 0)return;let e=[],r=(t,r)=>{if(t===void 0)return;let n=Ar(()=>t(()=>{f.current(r)}));typeof n=="function"&&e.push(n)};return r(t.onForeground?.bind(t),"foreground"),r(t.onOnline?.bind(t),"foreground"),r(t.onAnnounced?.bind(t),"announced"),()=>{for(let t of e)Ar(t)}},[t]);let h=n?.intervalMs??null,b=n?.isVisibleFallback;e.useEffect(()=>{if(t===void 0||h===null||!Number.isFinite(h)||h<=0)return;c.current=h;let e=setInterval(()=>{Date.now()<u.current||$l(t,b)&&f.current("poll")},h);return()=>clearInterval(e)},[t,h,b])}var Jl=/^efch_[A-Za-z0-9_-]{43}$/,Xl="efch";function ei(e){return typeof e=="string"&&Jl.test(e)}function chatHandoffTokenFromUrl(e){if(typeof e!="string")return null;let t=e.indexOf("#");if(t<0)return null;for(let r of e.slice(t+1).split("&")){if(!r.startsWith(`${Xl}=`))continue;let e=r.slice(Xl.length+1);return ei(e)?e:null}return null}var ti=/* @__PURE__ */Object.freeze(["better","same","worse"]),ri=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var ni="checkin",li=/^\d{4}-\d{2}-\d{2}$/,ii="watching";function isCheckinSettled(e){return e.status!=null&&e.status!==ii}function oi(e){if(typeof e!="string")return null;let t=e.split(":");if(t.length!==3)return null;let[r,n,l]=t;return r!==ni||n===void 0||l===void 0||!ri.test(n)||!li.test(l)?null:{caseId:n,dueDay:l}}function ai(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}function si(e,t,r){return makeEverfurError(e,{retryable:t,...{}})}var ui=128,ci=/[\u0000-\u001f\u007f]/;function di(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function pi(e){return typeof e!="string"||e.length===0||e.length>ui||ci.test(e)||e.includes("://")?null:e}function fi(e){if(e===null)return null;let conversationId=e.conversation_id,petRef=pi(e.pet_ref);return typeof conversationId!="string"||!ai(conversationId)||petRef===null?null:{conversationId:conversationId,petRef:petRef}}function hi(e,t,r){return ei(t)?createRequestFunnel({auth:e,...r?{errorPolicy:r}:{}}).send("chat.redeemHandoff",{method:"POST",path:"/widget/v1/chat/handoffs/redeem",body:{token:t}},{maxAttempts:1}).then(e=>e.ok?ok(fi(di(e.value))):e.error.httpStatus===404?ok(null):err(e.error),()=>err(si("internalError",false))):Promise.resolve(ok(null))}function bi(t,r){let n=r?.runtime??null,userRef=r?.userRef??null,l=ei(t)?t:null,i=l===null||userRef===null?null:`${String(userRef)}|${l}`,[o,a]=e.useState(null);return e.useEffect(()=>{if(i===null||l===null||userRef===null||n===null)return;let e=true,t=n.registry.services;return hi(t.authFor(userRef),l,t.errorPolicy).then(t=>{!e||!t.ok||t.value===null||a({key:i,target:/* @__PURE__ */Object.freeze({kind:"chat",conversationId:t.value.conversationId,petRef:t.value.petRef})})}),()=>{e=false}},[i,n,l,userRef]),o!==null&&o.key===i?o.target:void 0}function gi(e){if(e===void 0)return null;let conversationId=e.conversationId??"",petRef=e.petRef??"";return conversationId===""&&petRef===""?null:`${String(conversationId)}|${String(petRef)}`}function mi(t,r,n){let l=gi(r),i=r?.kind==="chat",o=r?.petRef??null,a=i&&!n.pinned&&o!==null&&n.petRef!==null&&o!==n.petRef,s=e.useRef({openCheckin:t,target:r,selectPet:n.selectPet});s.current={openCheckin:t,target:r,selectPet:n.selectPet};let u=e.useRef(null),c=e.useRef(null),petRef=n.petRef;e.useEffect(()=>{if(l===null||u.current===l)return;let{openCheckin:e,target:t,selectPet:r}=s.current;if(a&&o!==null){if(c.current?.key!==l){c.current={key:l,from:petRef},r(o);return}petRef!==c.current.from&&(u.current=l);return}i&&!n.ready||(u.current=l,!(e===void 0||t===void 0)&&Promise.resolve(e(t)).catch(()=>{}))},[l,i,a,o,petRef,n.ready])}var yi=/* @__PURE__ */Object.freeze({heading:"Chats",empty:"No chats yet",emptyBody:"Start a new conversation to see it here.",noMatch:"No chats match that.",loading:"Loading your chats…",loadFailed:"Couldn’t load your chats",loadingMore:"Loading more…",untitled:"New conversation",newChat:"New chat",searchPlaceholder:"Search chats…",search:"Search chats",countLabel:"Chats and vet messages",countSeparator:" · ",newReply:"New reply · {date}",retry:"Try again",close:"Close",closeA11y:"Close history",more:"Load more",earlier:"Load earlier messages",loadingEarlier:"Loading earlier messages…",openConversation:"Open conversation",unreadPrefix:"Unread. "});function vi(e){let t=e?.replace(/\s+/g," ").trim();return t||yi.untitled}function xi(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString([],{month:"short",day:"numeric"})}function wi(e){let t=xi(e.updatedAt);return t===null?null:e.unreadCount!==null&&e.unreadCount>0?yi.newReply.replace("{date}",t):t}function ki(e,t){return t?`${yi.countLabel}${yi.countSeparator}${e}`:yi.countLabel}function Si(e){return`${e.unreadCount!==null&&e.unreadCount>0?yi.unreadPrefix:""}${yi.openConversation} ${vi(e.title)}`}function Ci(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2018\u2019]/g,"'").replace(/[\u201c\u201d]/g,'"').toLowerCase().trim().replace(/\s+/g," ")}function ji(e,t){let r=Ci(t);if(r.length===0)return e;let n=[[],[],[]];for(let t of e){let e=Ci(vi(t.title)),l=e.indexOf(r);if(l<0)continue;let i=l===0?0:e.charAt(l-1)===" "?1:2;n[i]?.push(t)}return n.flat()}function Ri(e){return{scope:e,rows:[],cursor:null,loading:false,loadingMore:false,error:null}}function Ti(t){let[r,n]=e.useState(false),[l,i]=e.useState(""),o=t.listConversations,a=e.useRef(0),[s,u]=e.useState(()=>Ri(o)),c=s.scope===o?s:Ri(o);e.useEffect(()=>(a.current+=1,n(false),i(""),u(Ri(o)),()=>{a.current+=1}),[o]);let d=e.useCallback(async e=>{let r=++a.current,n=e!==void 0;u(e=>({...e,scope:o,loading:!n,loadingMore:n,error:null}));let l=await t.listConversations(e?{cursor:e}:void 0);if(r===a.current){if(!l.ok){u(e=>({...e,loading:false,loadingMore:false,error:l.error.displayMessage}));return}u(t=>{let r=e&&t.scope===o?t.rows:[],n=new Set(r.map(e=>e.id));return{scope:o,loading:false,loadingMore:false,error:null,rows:[...r,...l.value.conversations.filter(e=>!n.has(e.id))],cursor:l.value.nextCursor===e?null:l.value.nextCursor}})}},[t.listConversations,o]),p=()=>{n(true),i(""),d()},f=()=>{a.current+=1,n(false)},h=async e=>{let r=++a.current;u(e=>({...e,loading:true,error:null}));let l=await t.resumeConversation(e);r===a.current&&(u(e=>({...e,loading:false,error:l.ok?null:l.error.displayMessage})),l.ok&&n(false))},b=async()=>{let e=a.current,r=await t.loadOlderMessages();e===a.current&&!r.ok&&u(e=>({...e,error:r.error.displayMessage}))},g=()=>{t.newConversation(),a.current+=1,n(false)},m=()=>{c.cursor===null||c.loading||c.loadingMore||l.trim().length>0||d(c.cursor)},y=e.useMemo(()=>ji(c.rows,l),[c.rows,l]),v=l.trim().length>0;return{...c,open:r,show:p,close:f,load:d,resume:h,earlier:b,newConversation:g,loadMore:m,query:l,setQuery:i,searching:v,filtered:y,emptyKind:c.rows.length===0?"empty":"noMatch"}}var _i="#111111",zi="#FFFFFF",Ii=/* @__PURE__ */Object.freeze({emergency:/* @__PURE__ */Object.freeze({level:"emergency",label:"Call a vet now",borderColor:"#FCA5A5",backgroundColor:"#FEF2F2",textColor:"#991B1B",reasonColor:_i,pillColor:zi,showsVetAction:true}),schedule_soon:/* @__PURE__ */Object.freeze({level:"schedule_soon",label:"Vet care suggested soon",borderColor:"#FCD34D",backgroundColor:"#FFFBEB",textColor:"#92400E",reasonColor:_i,pillColor:zi,showsVetAction:true}),home_care:/* @__PURE__ */Object.freeze({level:"home_care",label:"Monitor at home",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:_i,pillColor:zi,showsVetAction:false}),general:/* @__PURE__ */Object.freeze({level:"general",label:"Good to know",borderColor:"#86EFAC",backgroundColor:"#F0FDF4",textColor:"#166534",reasonColor:_i,pillColor:zi,showsVetAction:false})});function Pi(e){return`${e.messageId}:${e.level}:${e.reason??""}`}function Ei(e){return _e(Te.urgencyGeneralReason,{petName:e?.trim()||Te.emptyTitlePetFallback})}function Mi(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n?.role!=="assistant"||n.responseId===void 0)continue;let l=n.urgencyLevel;return l?{messageId:n.id,level:l,reason:Ai(n.urgencyReason)}:n.urgencyProvided===true?{messageId:n.id,level:"general",reason:Ei(t)}:null}return null}function Ai(e){return typeof e=="string"&&e.trim().length>0?e:null}function Fi(t){let r=t===null?null:Pi(t),[n,l]=e.useState(null),[i,o]=e.useState(false);e.useEffect(()=>o(false),[r]);let a=t!==null&&(i||!(n!==null&&n===r)),s=t===null?null:Ii[t.level],u=t!==null&&!a&&t.level!=="general",c=e.useCallback(()=>{r!==null&&l(r),o(false)},[r]),d=e.useCallback(()=>o(true),[]);return e.useMemo(()=>({source:t,tier:s,signature:r,showBanner:a,showCompactIcon:u,showVetAction:a&&s!==null&&s.showsVetAction,dismissLabel:s===null?null:_e(Te.dismissBanner,{label:s.label}),dismiss:c,expand:d}),[t,s,r,a,u,c,d])}var Li=()=>globalThis[/* @__PURE__ */Symbol.for("everfur.sdk.chatCards.v1")]??={loader:null,lazy:null};var Oi=Li;function registerEverfurChatCards(t){let r=Oi();r.loader=t;let n=t&&Promise.resolve().then(t).then(e=>typeof e.ServerCards=="function"?e.ServerCards:NONE3,()=>NONE3);r.lazy=n&&e.lazy(async()=>({default:await n}))}var NONE3=()=>null,Vi=e.createContext(null);function ServerCardsSlot({message:t}){let r=e.useContext(Vi),n=Oi(),l=t.a2ui??n.frames?.get(t.responseId),i=n.lazy;return l===void 0||r===null||i===null?null:e.createElement(e.Suspense,{fallback:null},e.createElement(i,{message:t,a2ui:l,host:r}))}var Di=class extends e.Component{constructor(){super(...arguments);this.state={failed:false,key:this.props.resetKey}}static getDerivedStateFromError(){return{failed:true}}static getDerivedStateFromProps(e,t){return Object.is(e.resetKey,t.key)?null:{failed:false,key:e.resetKey}}render(){return this.state.failed?this.props.fallback:this.props.children}};function RenderHost({render:e}){return e()}function HostRender({render:t,fallback:r,resetKey:n}){return e.createElement(Di,{fallback:r,resetKey:n,children:e.createElement(RenderHost,{render:t})})}var Bi=48;function Hi(e){return e.isPending?"pending":e.enabled?"enabled":"disabled"}function CapabilityGate(r){let{capability:n,children:l,renderDisabled:i,renderPending:o,style:a}=r,s=useCapability(n),u=e.useMemo(()=>Hi(s),[s]);switch(u){case"enabled":return l;case"pending":return o?/* @__PURE__ */t.jsx(HostRender,{render:o,fallback:/* @__PURE__ */t.jsx(PendingSkeleton,{capability:n,style:a})}):/* @__PURE__ */t.jsx(PendingSkeleton,{capability:n,style:a});case"disabled":return i?/* @__PURE__ */t.jsx(HostRender,{render:()=>i(s),fallback:/* @__PURE__ */t.jsx(OffState,{decision:s,style:a}),resetKey:s}):/* @__PURE__ */t.jsx(OffState,{decision:s,style:a});default:return assertNever(u)}}function PendingSkeleton({capability:r,style:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Wi(i),[i]);/* @__PURE__ */
22
+ return t.jsx(n.View,{style:[o.offstate,l],accessible:true,accessibilityState:{busy:true},accessibilityLabel:`Loading ${r}`,children:/* @__PURE__ */t.jsx(n.View,{style:o.skeletonBar})})}function OffState({decision:r,style:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Wi(i),[i]),a=r.disabled?.reason??"";/* @__PURE__ */
23
+ return t.jsx(n.View,{style:[o.offstate,l],accessible:true,accessibilityRole:"text",accessibilityLabel:a,children:a.length>0?/* @__PURE__ */t.jsx(Text,{style:o.offstateText,children:a}):null})}function Wi(e){let{color:t,space:r,radius:l,type:i}=e;return n.StyleSheet.create({offstate:{minHeight:Bi,justifyContent:"center",paddingHorizontal:r.lg,paddingVertical:r.md,backgroundColor:t.surfaceCream,borderRadius:l.md,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.brandBorder},offstateText:{...face(e,"regular"),fontSize:i.size.body,lineHeight:Math.round(i.size.body*i.lineHeight.normal),color:t.text.muted},skeletonBar:{height:r.md,borderRadius:l.xs,backgroundColor:t.brandSofter}})}var Ni="everfur.com",Ui=2048,$i=/^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function qi(e){if(!Array.isArray(e))return[];let t=/* @__PURE__ */new Set;for(let r of e){if(typeof r!="string")continue;let e=r.trim().toLowerCase();e.length<=253&&$i.test(e)&&t.add(e)}/* @__PURE__ */
24
+ return Object.freeze([...t])}function Gi(e,t){if(e===Ni||e.endsWith(`.${Ni}`))return true;for(let r of t)if(r.startsWith("*.")?e.endsWith(r.slice(1)):e===r)return true;return false}function Ki(e,t){if(typeof e!="string"||e.length===0||e.length>Ui||!/^https:\/\//i.test(e))return null;let r=bt(e);return r===null||r.protocol!=="https:"||r.username!==""||r.password!==""||r.port!==""?null:Gi(r.hostname,t)?r.href:null}function Yi(e){try{Promise.resolve(n.Linking.openURL(e)).catch(()=>{})}catch{}}var Qi=e.createContext(null);function Zi(){return e.useContext(Qi)??void 0}function MessageLinksScope({linkHosts:t,onOpenUrl:r,children:n}){let l=t===false?null:Array.isArray(t)?t.join(`\n`):"",i=e.useMemo(()=>{if(l===null)return null;let e=qi(l===""?[]:l.split(`\n`));/* @__PURE__ */
25
+ return Object.freeze({hosts:e,open:r!==void 0?e=>{Ar(r,e,"message")}:Yi})},[l,r]);return e.createElement(Qi.Provider,{value:i},n)}var Ji={pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"};function Xi(e){return{width:e,height:e,alignItems:"center",justifyContent:"center"}}function eo(e,t){return t??Math.max(1.5,Math.round(e/11*10)/10)}function MenuGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l),o={width:e*.82,height:i,borderRadius:i,backgroundColor:r};/* @__PURE__ */
26
+ return t.jsxs(n.View,{style:[Xi(e),{gap:e*.22}],...Ji,children:[
26
27
  /* @__PURE__ */t.jsx(n.View,{style:o}),
27
28
  /* @__PURE__ */t.jsx(n.View,{style:o}),
28
- /* @__PURE__ */t.jsx(n.View,{style:o})]})}function Cross({size:e,color:r,strokeWidth:l,rotate:i}){let o=Ji(e,l),a=e*.78;/* @__PURE__ */
29
- return t.jsxs(n.View,{style:[Zi(e),{transform:[{rotate:i}]}],...Qi,children:[
29
+ /* @__PURE__ */t.jsx(n.View,{style:o})]})}function Cross({size:e,color:r,strokeWidth:l,rotate:i}){let o=eo(e,l),a=e*.78;/* @__PURE__ */
30
+ return t.jsxs(n.View,{style:[Xi(e),{transform:[{rotate:i}]}],...Ji,children:[
30
31
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",width:a,height:o,borderRadius:o,backgroundColor:r}}),
31
32
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",width:o,height:a,borderRadius:o,backgroundColor:r}})]})}function PlusGlyph(e){/* @__PURE__ */
32
33
  return t.jsx(Cross,{...e,rotate:"0deg"})}function CloseGlyph(e){/* @__PURE__ */
33
- return t.jsx(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l);/* @__PURE__ */
34
- return t.jsx(n.View,{style:Zi(e),...Qi,children:/* @__PURE__ */t.jsx(n.View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:i,borderRightWidth:i,borderColor:r,transform:[{rotate:"45deg"}]}})})}var Xi={down:{rotate:"45deg",marginTop:-.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-.4}};function ChevronGlyph({size:e,color:r,strokeWidth:l,direction:i}){let o=Ji(e,l),a=e*.46,s=Xi[i];/* @__PURE__ */
35
- return t.jsx(n.View,{style:Zi(e),...Qi,children:/* @__PURE__ */t.jsx(n.View,{style:{width:a,height:a,borderRightWidth:o,borderBottomWidth:o,borderColor:r,marginTop:a*s.marginTop,marginLeft:a*s.marginLeft,transform:[{rotate:s.rotate}]}})})}function BookGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l),o={width:e*.42,height:e*.7,borderWidth:i,borderColor:r,borderRadius:i};/* @__PURE__ */
36
- return t.jsxs(n.View,{style:[Zi(e),{flexDirection:"row",gap:1}],...Qi,children:[
34
+ return t.jsx(Cross,{...e,rotate:"45deg"})}function CheckGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l);/* @__PURE__ */
35
+ return t.jsx(n.View,{style:Xi(e),...Ji,children:/* @__PURE__ */t.jsx(n.View,{style:{width:e*.36,height:e*.66,marginTop:-e*.14,borderBottomWidth:i,borderRightWidth:i,borderColor:r,transform:[{rotate:"45deg"}]}})})}var to={down:{rotate:"45deg",marginTop:-.4,marginLeft:0},up:{rotate:"225deg",marginTop:.4,marginLeft:0},right:{rotate:"-45deg",marginTop:0,marginLeft:-.4}};function ChevronGlyph({size:e,color:r,strokeWidth:l,direction:i}){let o=eo(e,l),a=e*.46,s=to[i];/* @__PURE__ */
36
+ return t.jsx(n.View,{style:Xi(e),...Ji,children:/* @__PURE__ */t.jsx(n.View,{style:{width:a,height:a,borderRightWidth:o,borderBottomWidth:o,borderColor:r,marginTop:a*s.marginTop,marginLeft:a*s.marginLeft,transform:[{rotate:s.rotate}]}})})}function BookGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l),o={width:e*.42,height:e*.7,borderWidth:i,borderColor:r,borderRadius:i};/* @__PURE__ */
37
+ return t.jsxs(n.View,{style:[Xi(e),{flexDirection:"row",gap:1}],...Ji,children:[
37
38
  /* @__PURE__ */t.jsx(n.View,{style:[o,{borderTopLeftRadius:e*.2}]}),
38
- /* @__PURE__ */t.jsx(n.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l),o=e*.5;/* @__PURE__ */
39
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
39
+ /* @__PURE__ */t.jsx(n.View,{style:[o,{borderTopRightRadius:e*.2}]})]})}function ArrowUpRightGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l),o=e*.5;/* @__PURE__ */
40
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
40
41
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",width:e*.78,height:i,borderRadius:i,backgroundColor:r,transform:[{rotate:"-45deg"}]}}),
41
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:i,borderRightWidth:i,borderColor:r}})]})}function CopyGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l),o=e*.6,a={position:"absolute",width:o,height:o,borderWidth:i,borderColor:r,borderRadius:e*.14};/* @__PURE__ */
42
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
42
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.16,right:e*.16,width:o,height:o,borderTopWidth:i,borderRightWidth:i,borderColor:r}})]})}function CopyGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l),o=e*.6,a={position:"absolute",width:o,height:o,borderWidth:i,borderColor:r,borderRadius:e*.14};/* @__PURE__ */
43
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
43
44
  /* @__PURE__ */t.jsx(n.View,{style:[a,{top:0,left:0}]}),
44
- /* @__PURE__ */t.jsx(n.View,{style:[a,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:r,strokeWidth:l,active:i,rotate:o}){let a=Ji(e,l),s=i?r:"transparent";/* @__PURE__ */
45
- return t.jsxs(n.View,{style:[Zi(e),{transform:[{rotate:o}]}],...Qi,children:[
45
+ /* @__PURE__ */t.jsx(n.View,{style:[a,{bottom:0,right:0}]})]})}function ThumbGlyph({size:e,color:r,strokeWidth:l,active:i,rotate:o}){let a=eo(e,l),s=i?r:"transparent";/* @__PURE__ */
46
+ return t.jsxs(n.View,{style:[Xi(e),{transform:[{rotate:o}]}],...Ji,children:[
46
47
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:e*.08,left:e*.12,width:e*.62,height:e*.5,borderWidth:a,borderColor:r,backgroundColor:s,borderRadius:e*.12,borderTopLeftRadius:e*.04}}),
47
48
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.04,left:e*.4,width:e*.3,height:e*.5,borderWidth:a,borderColor:r,backgroundColor:s,borderRadius:e*.15,transform:[{rotate:"-20deg"}]}}),
48
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:a,borderColor:r,backgroundColor:s,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l);/* @__PURE__ */
49
- return t.jsxs(n.View,{style:[Zi(e),{borderRadius:e/2,borderWidth:i,borderColor:r}],...Qi,children:[
49
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:e*.08,left:0,width:e*.2,height:e*.5,borderWidth:a,borderColor:r,backgroundColor:s,borderRadius:e*.05}})]})}function InfoGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l);/* @__PURE__ */
50
+ return t.jsxs(n.View,{style:[Xi(e),{borderRadius:e/2,borderWidth:i,borderColor:r}],...Ji,children:[
50
51
  /* @__PURE__ */t.jsx(n.View,{style:{width:i,height:i,borderRadius:i,backgroundColor:r,marginBottom:e*.1}}),
51
- /* @__PURE__ */t.jsx(n.View,{style:{width:i,height:e*.34,borderRadius:i,backgroundColor:r}})]})}function UploadGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l),o=e*.34;/* @__PURE__ */
52
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
52
+ /* @__PURE__ */t.jsx(n.View,{style:{width:i,height:e*.34,borderRadius:i,backgroundColor:r}})]})}function UploadGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l),o=e*.34;/* @__PURE__ */
53
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
53
54
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.06,width:o,height:o,borderTopWidth:i,borderLeftWidth:i,borderColor:r,transform:[{rotate:"45deg"}]}}),
54
55
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.1,width:i,height:e*.56,borderRadius:i,backgroundColor:r}}),
55
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:i,borderLeftWidth:i,borderRightWidth:i,borderColor:r,borderBottomLeftRadius:i,borderBottomRightRadius:i}})]})}function PhotoGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l);/* @__PURE__ */
56
- return t.jsxs(n.View,{style:[Zi(e),{borderWidth:i,borderColor:r,borderRadius:e*.14,overflow:"hidden"}],...Qi,children:[
56
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:0,width:e*.84,height:e*.3,borderBottomWidth:i,borderLeftWidth:i,borderRightWidth:i,borderColor:r,borderBottomLeftRadius:i,borderBottomRightRadius:i}})]})}function PhotoGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l);/* @__PURE__ */
57
+ return t.jsxs(n.View,{style:[Xi(e),{borderWidth:i,borderColor:r,borderRadius:e*.14,overflow:"hidden"}],...Ji,children:[
57
58
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.16,left:e*.18,width:e*.16,height:e*.16,borderRadius:e,backgroundColor:r}}),
58
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:i,borderLeftWidth:i,borderColor:r,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l);/* @__PURE__ */
59
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
59
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:-e*.3,right:-e*.1,width:e*.7,height:e*.7,borderTopWidth:i,borderLeftWidth:i,borderColor:r,transform:[{rotate:"45deg"}]}})]})}function CameraGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l);/* @__PURE__ */
60
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
60
61
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.08,width:e*.34,height:e*.2,borderTopWidth:i,borderLeftWidth:i,borderRightWidth:i,borderColor:r,borderTopLeftRadius:i,borderTopRightRadius:i}}),
61
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:i,borderColor:r,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */t.jsx(n.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:i,borderColor:r}})})]})}function SearchGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l),o=e/24,a=16*o+i,s=11*o-a/2,u=11+8/Math.SQRT2,c=(21-u)*Math.SQRT2*o,d=(u+21)/2*o;/* @__PURE__ */
62
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
62
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.22,width:e*.92,height:e*.66,borderWidth:i,borderColor:r,borderRadius:e*.16,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */t.jsx(n.View,{style:{width:e*.3,height:e*.3,borderRadius:e,borderWidth:i,borderColor:r}})})]})}function SearchGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l),o=e/24,a=16*o+i,s=11*o-a/2,u=11+8/Math.SQRT2,c=(21-u)*Math.SQRT2*o,d=(u+21)/2*o;/* @__PURE__ */
63
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
63
64
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:s,left:s,width:a,height:a,borderRadius:a,borderWidth:i,borderColor:r}}),
64
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:d-i/2,left:d-(c+i)/2,width:c+i,height:i,borderRadius:i,backgroundColor:r,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l);/* @__PURE__ */
65
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
65
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:d-i/2,left:d-(c+i)/2,width:c+i,height:i,borderRadius:i,backgroundColor:r,transform:[{rotate:"45deg"}]}})]})}function EditGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l);/* @__PURE__ */
66
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
66
67
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",width:e*.3,height:e*.82,borderWidth:i,borderColor:r,borderRadius:i,transform:[{rotate:"45deg"}]}}),
67
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:i,borderRadius:i,backgroundColor:r}})]})}function MapPinGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l),o=e*.62;/* @__PURE__ */
68
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
68
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:0,left:0,width:e*.4,height:i,borderRadius:i,backgroundColor:r}})]})}function MapPinGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l),o=e*.62;/* @__PURE__ */
69
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
69
70
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:0,width:o,height:o,borderRadius:o,borderWidth:i,borderColor:r,alignItems:"center",justifyContent:"center"},children:/* @__PURE__ */t.jsx(n.View,{style:{width:i*1.4,height:i*1.4,borderRadius:i,backgroundColor:r}})}),
70
71
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:e*.04,width:o*.5,height:o*.5,borderRightWidth:i,borderBottomWidth:i,borderColor:r,transform:[{rotate:"45deg"}]}})]})}function SendGlyph({size:e,color:r,testID:l}){let i=e*.36;/* @__PURE__ */
71
- return t.jsx(n.View,{style:Zi(e),testID:l,...Qi,children:/* @__PURE__ */t.jsx(n.View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:i,borderBottomWidth:i,borderLeftColor:r,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}function StopGlyph({size:e,color:r,testID:l}){/* @__PURE__ */
72
- return t.jsx(n.View,{style:Zi(e),testID:l,...Qi,children:/* @__PURE__ */t.jsx(n.View,{style:{width:e*.5,height:e*.5,backgroundColor:r}})})}function MicGlyph({size:e,color:r,strokeWidth:l,testID:i}){let o=Ji(e,l);/* @__PURE__ */
73
- return t.jsxs(n.View,{style:Zi(e),testID:i,...Qi,children:[
72
+ return t.jsx(n.View,{style:Xi(e),testID:l,...Ji,children:/* @__PURE__ */t.jsx(n.View,{style:{width:0,height:0,marginLeft:e*.12,borderLeftWidth:e*.78,borderTopWidth:i,borderBottomWidth:i,borderLeftColor:r,borderTopColor:"transparent",borderBottomColor:"transparent",transform:[{rotate:"-45deg"}]}})})}function StopGlyph({size:e,color:r,testID:l}){/* @__PURE__ */
73
+ return t.jsx(n.View,{style:Xi(e),testID:l,...Ji,children:/* @__PURE__ */t.jsx(n.View,{style:{width:e*.5,height:e*.5,backgroundColor:r}})})}function MicGlyph({size:e,color:r,strokeWidth:l,testID:i}){let o=eo(e,l);/* @__PURE__ */
74
+ return t.jsxs(n.View,{style:Xi(e),testID:i,...Ji,children:[
74
75
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.08,width:e*.26,height:e*.48,borderWidth:o,borderColor:r,borderRadius:e*.13}}),
75
76
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.38,width:e*.56,height:e*.36,borderBottomWidth:o,borderLeftWidth:o,borderRightWidth:o,borderColor:r,borderBottomLeftRadius:e*.28,borderBottomRightRadius:e*.28}}),
76
77
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.74,width:o,height:e*.18,backgroundColor:r}})]})}function Ring({size:e,strokeWidth:r,color:l,children:i}){/* @__PURE__ */
77
- return t.jsx(n.View,{style:[Zi(e),{borderRadius:e/2,borderWidth:r??n.StyleSheet.hairlineWidth,borderColor:l}],children:i})}function ArrowUpGlyph({size:e,color:r,strokeWidth:l,testID:i}){let o=Ji(e,l),a=e*.46;/* @__PURE__ */
78
- return t.jsxs(n.View,{style:Zi(e),testID:i,...Qi,children:[
78
+ return t.jsx(n.View,{style:[Xi(e),{borderRadius:e/2,borderWidth:r??n.StyleSheet.hairlineWidth,borderColor:l}],children:i})}function ArrowUpGlyph({size:e,color:r,strokeWidth:l,testID:i}){let o=eo(e,l),a=e*.46;/* @__PURE__ */
79
+ return t.jsxs(n.View,{style:Xi(e),testID:i,...Ji,children:[
79
80
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.16,bottom:e*.12,width:o,borderRadius:o,backgroundColor:r}}),
80
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.16+o/2,width:a,height:a,borderLeftWidth:o,borderTopWidth:o,borderColor:r,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l);/* @__PURE__ */
81
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
81
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.16+o/2,width:a,height:a,borderLeftWidth:o,borderTopWidth:o,borderColor:r,transform:[{rotate:"45deg"}]}})]})}function ChatBubbleGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l);/* @__PURE__ */
82
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
82
83
  /* @__PURE__ */t.jsx(n.View,{style:{width:e*.8,height:e*.6,marginTop:-e*.12,borderWidth:i,borderColor:r,borderRadius:e*.14}}),
83
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:i,borderBottomWidth:i,borderColor:r}})]})}function HistoryGlyph({size:e,color:r,strokeWidth:l}){let i=Ji(e,l),o=e*.72,a=e/2;/* @__PURE__ */
84
- return t.jsxs(n.View,{style:Zi(e),...Qi,children:[
84
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",bottom:e*.1,left:e*.22,width:e*.2,height:e*.2,borderLeftWidth:i,borderBottomWidth:i,borderColor:r}})]})}function HistoryGlyph({size:e,color:r,strokeWidth:l}){let i=eo(e,l),o=e*.72,a=e/2;/* @__PURE__ */
85
+ return t.jsxs(n.View,{style:Xi(e),...Ji,children:[
85
86
  /* @__PURE__ */t.jsx(n.View,{style:{width:o,height:o,borderRadius:o/2,borderWidth:i,borderColor:r,borderLeftColor:"transparent",transform:[{rotate:"45deg"}]}}),
86
87
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:e*.16,left:e*.12,width:e*.2,height:e*.2,borderLeftWidth:i,borderBottomWidth:i,borderColor:r}}),
87
88
  /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:a-e*.2,left:a-i/2,width:i,height:e*.2+i/2,borderRadius:i,backgroundColor:r}}),
88
- /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:a-i/2,left:a-i/2,width:e*.15+i/2,height:i,borderRadius:i,backgroundColor:r}})]})}var eo=/* @__PURE__ */Object.freeze({standard:G.standard,emphasized:G.emphasized,exit:G.exit,outQuad:/* @__PURE__ */Object.freeze([.25,.46,.45,.94]),out:/* @__PURE__ */Object.freeze([.23,1,.32,1])});var to=/* @__PURE__ */Object.freeze({layoutMs:220,messageInMs:200,bannerInMs:220,bannerOutMs:160,iconInMs:180,iconOutMs:120,followUpInMs:180,followUpStaggerMs:70,citationsInMs:220,citationsRisePx:6,drawerMs:220,pressScale:.97,pressMs:140,revealTickMs:24,revealDivisor:12,dotsCycleMs:520,dotsMinOpacity:.44,dotsLiftPx:3.5,dotsStagger:/* @__PURE__ */Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,bubbleInMs:280,bubbleFromScale:.94,bubbleRisePx:6,promptRisePx:8,reduced:false}),ro=/* @__PURE__ */Object.freeze({...to,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,bubbleInMs:0,bubbleFromScale:1,bubbleRisePx:0,promptRisePx:0,reduced:true});function no(e){return e.motion.reducedMotion?ro:to}function lo(e,t){return Math.max(0,t)*e.followUpStaggerMs}function io(e,t,r){if(e.reduced||t>=r)return r;let n=Math.max(1,Math.ceil((r-t)/e.revealDivisor));return Math.min(r,t+n)}function oo(){let e=useEverfurTheme();return no(e)}var ao=8;function so(e,t,r){return((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}function uo(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}function co(e){let[t,r,n,l]=e;return e=>{if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let r=0;r<ao;r+=1){let r=uo(i,t,n);if(r===0)break;i-=(so(i,t,n)-e)/r}return so(Math.min(1,Math.max(0,i)),r,l)}}var po=co(eo.standard),fo=co(eo.outQuad),ho=co(eo.out);function bo(t){let r=e.useRef(null);return r.current===null&&(r.current=new n.Animated.Value(t)),r.current}function go(t,r={}){let l=r.risePx??0,i=r.delayMs??0,o=bo(t>0?0:1);return e.useEffect(()=>{if(t<=0){o.setValue(1);return}let e=n.Animated.timing(o,{toValue:1,duration:t,easing:fo,useNativeDriver:true}),r=i>0?n.Animated.sequence([n.Animated.delay(i),e]):e;return r.start(),()=>r.stop()},[o,t,i]),e.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[l,0]})}]}),[o,l])}function FadePresence({visible:r,inMs:l,outMs:i,style:o,children:a}){let[s,u]=e.useState(r),c=bo(r&&l<=0?1:0);return e.useEffect(()=>{if(r){u(true);let e=n.Animated.timing(c,{toValue:1,duration:Math.max(0,l),easing:po,useNativeDriver:true});return e.start(),()=>e.stop()}if(!s)return;if(i<=0){u(false);return}let e=n.Animated.timing(c,{toValue:0,duration:i,easing:po,useNativeDriver:true});return e.start(({finished:e})=>{e&&u(false)}),()=>e.stop()},[r,s,l,i,c]),!s&&!r?null:/* @__PURE__ */t.jsx(n.Animated.View,{style:[o,{opacity:c}],children:a})}var mo=/* @__PURE__ */Object.freeze({opacity:1,transform:/* @__PURE__ */Object.freeze([{translateY:0},{scale:1}])});function yo(t,r){let[l]=e.useState(()=>t?r.bubbleInMs:0),i=l>0,o=bo(i?0:1);e.useEffect(()=>{if(l<=0)return;let e=n.Animated.timing(o,{toValue:1,duration:l,easing:ho,useNativeDriver:true});return e.start(),()=>e.stop()},[l,o]);let a=r.bubbleFromScale,s=r.bubbleRisePx;return e.useMemo(()=>i?{opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[s,0]})},{scale:o.interpolate({inputRange:[0,1],outputRange:[a,1]})}]}:mo,[i,o,s,a])}function vo(t){let r=e.useRef(null),n=e.useRef(null),l=t[0]?.id??null;if(r.current===null||n.current!==l){let e=r.current===null;r.current=new Map(t.map(t=>[t.id,e&&t.pending===true])),n.current=l}let i=r.current;for(let e of t)i.has(e.id)||i.set(e.id,true);return e.useCallback(e=>i.get(e)===true,[i])}var xo=12;function PressScale({style:r,containerStyle:l,children:i,onPressIn:o,onPressOut:a,hitSlop:s,...u}){let c=oo(),d=bo(1),p=e.useCallback(e=>{c.pressMs<=0||c.pressScale===1||n.Animated.timing(d,{toValue:e,duration:c.pressMs,easing:po,useNativeDriver:true}).start()},[d,c.pressMs,c.pressScale]);/* @__PURE__ */
89
- return t.jsx(n.Pressable,{...u,hitSlop:s??xo,style:l,onPressIn:e=>{p(c.pressScale),o?.(e)},onPressOut:e=>{p(1),a?.(e)},children:/* @__PURE__ */t.jsx(n.Animated.View,{style:[r,{transform:[{scale:d}]}],children:i})})}function wo(t,r,n){let l=r&&n.revealTickMs>0,[i,o]=e.useState(0),a=e.useRef(t);return a.current=t,e.useEffect(()=>{if(!l)return;let e=setInterval(()=>{o(e=>io(n,e,a.current.length))},n.revealTickMs);return()=>clearInterval(e)},[l,n]),l?t.slice(0,Math.min(i,t.length)):t}var ko=false;function So(e){e.layoutMs<=0||(ko||(ko=true,n.Platform.OS==="android"&&typeof n.UIManager.setLayoutAnimationEnabledExperimental=="function"&&n.UIManager.setLayoutAnimationEnabledExperimental(true)),n.LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}))}function Co(t,r){let n=e.useRef(t);n.current!==t&&(n.current=t,So(r))}var jo=36,Ro=22,To=12,_o=12,zo=16,Io="#000",Po="rgba(0,0,0,0.45)";function AttachmentImageLightbox({uri:e,label:r,onClose:i}){let o=useEverfurTheme(),a=l.useSafeAreaInsets();return e===null?null:/* @__PURE__ */t.jsxs(n.Modal,{visible:true,animationType:o.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:i,children:[
90
- /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:je.closePreview,style:Eo.backdrop,onPress:i,children:/* @__PURE__ */t.jsx(n.Image,{source:{uri:e},style:Eo.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:r,accessibilityIgnoresInvertColors:true})}),
91
- /* @__PURE__ */t.jsx(n.View,{pointerEvents:"box-none",style:[Eo.closeWrap,{top:a.top+_o}],children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:je.closePreview,hitSlop:To,style:Eo.closeButton,onPress:i,children:/* @__PURE__ */t.jsx(CloseGlyph,{size:Ro,color:o.color.surface,strokeWidth:2})})})]})}var Eo=n.StyleSheet.create({backdrop:{flex:1,backgroundColor:Io,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:zo},closeButton:{width:jo,height:jo,borderRadius:jo/2,backgroundColor:Po,alignItems:"center",justifyContent:"center"}});var Mo=()=>{};function Fo(){try{return n.AppState.currentState==="active"}catch{return false}}function createAppStateLifecycle(){return{onForeground(e){let t;try{let r=n.AppState.currentState==="background";t=n.AppState.addEventListener("change",t=>{t==="background"?r=!0:t==="active"&&r&&(r=!1,e())})}catch{return Mo}return()=>t.remove()},isVisible:Fo}}function Ao(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function Lo(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}function Oo(e){return e?.textColor===void 0?{}:{color:e.textColor}}var Vo=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Do(e){return e!==Vo}var Bo=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function Ho(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let l={handle:void 0},i=()=>{r.clearTimeout(l.handle),t.removeEventListener("abort",i),n()};l.handle=r.setTimeout(i,e),t.addEventListener("abort",i,{once:true})})}var Wo=4e3;var No=4e3;var Uo=/* @__PURE__ */Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var $o=10*1024*1024,qo=5,Go=120,Ko="/widget/v1/uploads/initiate";function isAttachmentMime(e){return typeof e=="string"&&Uo.includes(e.trim().toLowerCase())}function sanitizeFilename(e){if(!e)return"attachment";let t=e.replace(/[\\/]+/g," ").replace(/[\x00-\x1f\x7f"]/g,"").replace(/\s+/g," ").trim();if(!t)return"attachment";if(t.length<=Go)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,Go);let n=t.slice(r);return n.length>=Go?t.slice(0,Go):`${t.slice(0,r).slice(0,Go-n.length)}${n}`}function formatBytes(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Yo=e=>/* @__PURE__ */Object.freeze({ok:true,value:e}),Qo=e=>/* @__PURE__ */Object.freeze({ok:false,error:e});function Zo(e,t,r,n){/* @__PURE__ */
92
- return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}function attachmentSize(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}function validateAttachment(e){let t=sanitizeFilename(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!isAttachmentMime(r))return Qo(Zo("unsupported_type",false,t));let n=attachmentSize(e);return n===null?Qo(Zo("unknown",false,t)):n>$o?Qo(Zo("too_large",false,t,{sizeBytes:n})):Yo(/* @__PURE__ */Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}function Jo(e){if(typeof e!="object"||e===null)return null;let t=e,r=e=>typeof e=="string"&&e.length>0?e:null,n=e=>typeof e=="number"&&Number.isFinite(e)?e:null,l=r(t.upload_id),i=r(t.upload_url),o=r(t.s3_key);if(l===null||i===null||o===null)return null;let a={},s=t.upload_fields;if(typeof s=="object"&&s!==null)for(let[e,t]of Object.entries(s))typeof t=="string"&&(a[e]=t);/* @__PURE__ */
93
- return Object.freeze({upload_id:l,upload_url:i,upload_fields:/* @__PURE__ */Object.freeze(a),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??$o,s3_key:o,purpose:r(t.purpose)})}function Xo(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return Zo("quota_exceeded",false,t,{cause:e});case"rateLimited":return Zo("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return Zo("idempotency_conflict",true,t,{cause:e});case"validationFailed":return Zo("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return Zo("network",true,t,{cause:e});default:return r===429?Zo("rate_limited",true,t,{cause:e}):r===503?Zo("network",true,t,{cause:e}):r===void 0?Zo("network",true,t,{cause:e}):Zo("server",e.retryable,t,{httpStatus:r,cause:e})}}async function initiateAttachmentUpload(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:Ko,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Qo(Xo(n.error,t.filename));let l=Jo(n.value);return l===null?Qo(Zo("server",false,t.filename)):Yo(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return Qo(Zo("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),Yo(void 0)}catch{return l()?Qo(Zo("cancelled",true,r.filename)):Qo(Zo("server",true,r.filename))}}var ea=2,ta=3,ra=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),na=0;function la(){return na+=1,`attachment-${na}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??ea),r=Math.max(1,e.maxAttempts??ta),n=e.backoffMs??ra,l=Math.max(1,e.maxPerMessage??qo),i=e.timers??Bo,o=e.newId??la,a=Do(e.transport),s=/* @__PURE__ */new Map,u=[],c=[],d=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,b=()=>{f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze(u.flatMap(e=>{let t=s.get(e);return t===void 0?[]:[t.state]}))});for(let e of p)e()},g=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),b()},m=()=>{for(;!h&&d.size<t&&c.length>0;){let e=c.shift(),t=s.get(e);t!==void 0&&(d.add(e),y(t).finally(()=>{d.delete(e),m()}))}},y=async t=>{let{attachment:l}=t;for(;t.attempts<r;){if(h||t.controller.signal.aborted)return;t.attempts+=1;let o=t.controller.signal;g(t,{status:"uploading",error:null,progress:0});let a=await initiateAttachmentUpload(e.funnel,l,{signal:o});if(h||o.aborted)return;let s;if(!a.ok)s=Qo(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&g(t,{progress:ia(e)})}});if(h||o.aborted)return;s=r.ok?Yo(a.value.s3_key):Qo(r.error)}if(s.ok){g(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,c=u.retryable&&t.attempts<r;if(g(t,{status:c?"uploading":"failed",error:u,progress:0}),!c)return;let d=n[Math.min(t.attempts-1,n.length-1)]??0;await Ho(d,o,i)}},v=e=>{c.push(e.state.id),m()},x={available:a,subscribe(e){return p.add(e),()=>{p.delete(e)}},getSnapshot:()=>f,get uploading(){return f.attachments.some(e=>e.status==="uploading")},get s3Keys(){return f.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[])},add(e){let t=validateAttachment(e);if(!t.ok)return t;if(h||u.length>=l)return Qo(Zo("too_many",false,t.value.filename));let r=o(),n={attachment:t.value,controller:new AbortController,attempts:0,state:/* @__PURE__ */Object.freeze({id:r,filename:t.value.filename,previewUri:e.uri,contentType:t.value.contentType,sizeBytes:t.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return s.set(r,n),u.push(r),b(),v(n),Yo(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,g(t,{status:"uploading",error:null,progress:0,s3Key:null}),v(t))},remove(e){let t=s.get(e);if(t===void 0)return;t.controller.abort(),s.delete(e);let r=u.indexOf(e);r>=0&&u.splice(r,1);let n=c.indexOf(e);n>=0&&c.splice(n,1),b()},clear(){for(let e of[...u])x.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,c.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return x}function ia(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function oa(e){switch(e.code){case"too_large":return Re(je.attachmentTooLarge,{max:formatBytes($o),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return Re(je.attachmentTooMany,{max:qo});case"unsupported_type":return Re(je.attachmentUnsupported,{filename:e.filename});case"network":return je.attachmentNetwork;case"server":return Re(je.attachmentServer,{status:""});case"cancelled":return je.attachmentCancelled;case"rate_limited":return je.attachmentRateLimited;case"quota_exceeded":return je.attachmentQuota;case"idempotency_conflict":return je.attachmentConflict;case"unknown":return je.attachmentUnknown}}function aa(e,t){return Re(e>=t?je.attachmentsFull:je.addAttachment,{used:e,total:t})}var sa=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(t={}){let{runtime:r,userRef:userRef,scopeEpoch:n}=Fe(),l=t.maxPerMessage??qo,i=e.useCallback(()=>{let{services:e}=r.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:e.authFor(userRef),...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),transport:t.transport??e.uploadTransport,maxPerMessage:l})},[r,userRef,n,l,t.transport]),o=e.useMemo(()=>t.queue??i(),[t.queue,i]),a=e.useRef(/* @__PURE__ */new WeakSet),[s,u]=e.useState(null),c=s!==null&&s.of===o?s.queue:o;e.useEffect(()=>{if(c!==t.queue){if(a.current.has(c)){u({of:o,queue:i()});return}return()=>{c.dispose(),a.current.add(c)}}},[c,o,i,t.queue]);let d=e.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>sa),[p,f]=e.useState(null),h=e.useCallback(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>c.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&f(r.error),t},[c,f]),b=e.useCallback(e=>c.retry(e),[c]),g=e.useCallback(e=>c.remove(e),[c]),m=e.useCallback(()=>c.clear(),[c]),y=e.useCallback(()=>f(null),[f]),v=d.attachments.some(e=>e.status==="uploading"),x=d.attachments.some(e=>e.status==="failed");return e.useMemo(()=>({available:c.available,attachments:d.attachments,maxPerMessage:l,uploading:v,failed:x,blocked:v||x,s3Keys:d.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:p,add:h,retry:b,remove:g,clear:m,dismissRejected:y}),[c.available,d,l,v,x,p,h,b,g,m,y])}var ua=6e3;function ca(e,t,r){let n=t.trim();if(!n)return e;let l=e===""||/\s$/.test(e)?"":" ",i=`${e}${l}${n}`;return typeof r=="number"&&r>0?i.slice(0,r):i}function da(e){let t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${r}:${n.toString().padStart(2,"0")}`}function pa(e){switch(e){case"permissionDenied":return je.micBlocked;case"noSpeech":return je.noSpeech;case"unavailable":return je.dictationUnavailable}}function fa(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var ha=["Apoquel","Cytopoint","Bravecto","NexGard","Simparica Trio","Credelio","Revolution","Heartgard","Interceptor","Sentinel","ProHeart","Rimadyl","carprofen","meloxicam","Metacam","Galliprant","gabapentin","trazodone","Librela","Solensia","Zenrelia","prednisone","prednisolone","amoxicillin","Clavamox","cephalexin","Convenia","metronidazole","doxycycline","Cerenia","maropitant","famotidine","omeprazole","Proin","Vetmedin","pimobendan","enalapril","furosemide","levothyroxine","methimazole","Vetsulin","fluoxetine","Sileo","tramadol","buprenorphine","Denamarin","Dasuquin","Cosequin","parvovirus","distemper","Bordetella","leptospirosis","heartworm","giardia","coccidia","pancreatitis","hypothyroidism","Cushing's disease","Addison's disease","IVDD","cruciate ligament","luxating patella","hip dysplasia","pyometra","kennel cough","otitis","FIV","FeLV","DHPP","FVRCP","Labrador Retriever","Golden Retriever","French Bulldog","German Shepherd","Dachshund","Cavalier King Charles Spaniel","Shih Tzu","Pomeranian","Chihuahua","Yorkshire Terrier","Bichon Frise","Havanese","Cockapoo","Goldendoodle","Labradoodle","Weimaraner","Vizsla","Shiba Inu","Springer Spaniel","Miniature Schnauzer","Corgi","Australian Shepherd","Border Collie","Siberian Husky","Beagle","Maine Coon","Ragdoll","Sphynx","Bengal cat","British Shorthair"];function ba(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...ha]){let e=(n??"").trim();if(!e)continue;let l=e.toLowerCase();if(!t.has(l)&&(t.add(l),r.push(e),r.length>=100))break}return r}function ga(t,conversationId,r){let[n,l]=e.useState({send:t,conversationId:conversationId,text:r??"",seeded:r??null}),i=n.send===t&&(n.conversationId===null||n.conversationId===conversationId);e.useEffect(()=>{l(e=>{let n=e.send===t&&(e.conversationId===null||e.conversationId===conversationId),l=n?e.text:"",i=n?e.seeded:null,o=r!=null&&r!==i&&l.length===0;return{send:t,conversationId:conversationId,text:o?r:l,seeded:o?r:i}})},[t,conversationId,r]);let o=e.useCallback(e=>l(r=>({send:t,conversationId:conversationId,text:e,seeded:r.seeded})),[t,conversationId]);return[i?n.text:"",o]}function ma(t,conversationId,r,n,l=false){let i=e.useRef({draft:r,setDraft:n});i.current={draft:r,setDraft:n};let o=e.useRef(null),[a,s]=e.useState(null);e.useEffect(()=>{if(t===void 0)return;let e=`${conversationId??""}`;if(o.current===e)return;o.current=e;let r=true;return(async()=>{let n=await Ar(()=>t.read(conversationId));if(!r)return;let l=n.ok&&typeof n.value=="string"?n.value:"";l.length>0&&i.current.draft.length===0&&i.current.setDraft(l),s(e)})(),()=>{r=false}},[t,conversationId]),e.useEffect(()=>{t===void 0||l||a!==`${conversationId??""}`||Er(()=>t.write(conversationId,r))},[t,conversationId,r,a,l])}function ya(e){if(!(n.Platform.OS!=="ios"||e===""))try{let t=n.AccessibilityInfo?.announceForAccessibility;typeof t=="function"&&t.call(n.AccessibilityInfo,e)}catch{}}function AnnounceLine({line:t}){return e.useEffect(()=>{ya(t)},[t]),null}var va=12,xa=80,wa=44,ka=22,Sa=.14,Ca=18,ja=8,Ra=/* @__PURE__ */Object.freeze({photo:je.attachmentPhoto,camera:je.attachmentCamera});function AttachmentPickerPopover({sources:r,full:l,onPick:i,onClose:o}){let a=useEverfurTheme(),s=e.useMemo(()=>Ta(a),[a]);/* @__PURE__ */
89
+ /* @__PURE__ */t.jsx(n.View,{style:{position:"absolute",top:a-i/2,left:a-i/2,width:e*.15+i/2,height:i,borderRadius:i,backgroundColor:r}})]})}var ro=/* @__PURE__ */Object.freeze({standard:G.standard,emphasized:G.emphasized,exit:G.exit,outQuad:/* @__PURE__ */Object.freeze([.25,.46,.45,.94]),out:/* @__PURE__ */Object.freeze([.23,1,.32,1])});var no=/* @__PURE__ */Object.freeze({layoutMs:220,messageInMs:200,bannerInMs:220,bannerOutMs:160,iconInMs:180,iconOutMs:120,followUpInMs:180,followUpStaggerMs:70,citationsInMs:220,citationsRisePx:6,drawerMs:220,pressScale:.97,pressMs:140,revealTickMs:24,revealDivisor:12,dotsCycleMs:520,dotsMinOpacity:.44,dotsLiftPx:3.5,dotsStagger:/* @__PURE__ */Object.freeze([0,.18,.36]),copiedMs:1500,uploadFlashMs:600,bubbleInMs:280,bubbleFromScale:.94,bubbleRisePx:6,promptRisePx:8,reduced:false}),lo=/* @__PURE__ */Object.freeze({...no,layoutMs:0,messageInMs:0,bannerInMs:0,bannerOutMs:0,iconInMs:0,iconOutMs:0,followUpInMs:0,followUpStaggerMs:0,citationsInMs:0,citationsRisePx:0,drawerMs:0,pressScale:1,pressMs:0,revealTickMs:0,dotsCycleMs:0,dotsMinOpacity:1,dotsLiftPx:0,bubbleInMs:0,bubbleFromScale:1,bubbleRisePx:0,promptRisePx:0,reduced:true});function io(e){return e.motion.reducedMotion?lo:no}function oo(e,t){return Math.max(0,t)*e.followUpStaggerMs}function ao(e,t,r){if(e.reduced||t>=r)return r;let n=Math.max(1,Math.ceil((r-t)/e.revealDivisor));return Math.min(r,t+n)}function so(){let e=useEverfurTheme();return io(e)}var uo=8;function co(e,t,r){return((1-3*r+3*t)*e+(3*r-6*t))*e*e+3*t*e}function po(e,t,r){return 3*(1-3*r+3*t)*e*e+2*(3*r-6*t)*e+3*t}function fo(e){let[t,r,n,l]=e;return e=>{if(e<=0)return 0;if(e>=1)return 1;let i=e;for(let r=0;r<uo;r+=1){let r=po(i,t,n);if(r===0)break;i-=(co(i,t,n)-e)/r}return co(Math.min(1,Math.max(0,i)),r,l)}}var ho=fo(ro.standard),bo=fo(ro.outQuad),go=fo(ro.out);function mo(t){let r=e.useRef(null);return r.current===null&&(r.current=new n.Animated.Value(t)),r.current}function yo(t,r={}){let l=r.risePx??0,i=r.delayMs??0,o=mo(t>0?0:1);return e.useEffect(()=>{if(t<=0){o.setValue(1);return}let e=n.Animated.timing(o,{toValue:1,duration:t,easing:bo,useNativeDriver:true}),r=i>0?n.Animated.sequence([n.Animated.delay(i),e]):e;return r.start(),()=>r.stop()},[o,t,i]),e.useMemo(()=>({opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[l,0]})}]}),[o,l])}function FadePresence({visible:r,inMs:l,outMs:i,style:o,children:a}){let[s,u]=e.useState(r),c=mo(r&&l<=0?1:0);return e.useEffect(()=>{if(r){u(true);let e=n.Animated.timing(c,{toValue:1,duration:Math.max(0,l),easing:ho,useNativeDriver:true});return e.start(),()=>e.stop()}if(!s)return;if(i<=0){u(false);return}let e=n.Animated.timing(c,{toValue:0,duration:i,easing:ho,useNativeDriver:true});return e.start(({finished:e})=>{e&&u(false)}),()=>e.stop()},[r,s,l,i,c]),!s&&!r?null:/* @__PURE__ */t.jsx(n.Animated.View,{style:[o,{opacity:c}],children:a})}var vo=/* @__PURE__ */Object.freeze({opacity:1,transform:/* @__PURE__ */Object.freeze([{translateY:0},{scale:1}])});function xo(t,r){let[l]=e.useState(()=>t?r.bubbleInMs:0),i=l>0,o=mo(i?0:1);e.useEffect(()=>{if(l<=0)return;let e=n.Animated.timing(o,{toValue:1,duration:l,easing:go,useNativeDriver:true});return e.start(),()=>e.stop()},[l,o]);let a=r.bubbleFromScale,s=r.bubbleRisePx;return e.useMemo(()=>i?{opacity:o,transform:[{translateY:o.interpolate({inputRange:[0,1],outputRange:[s,0]})},{scale:o.interpolate({inputRange:[0,1],outputRange:[a,1]})}]}:vo,[i,o,s,a])}function wo(t){let r=e.useRef(null),n=e.useRef(null),l=t[0]?.id??null;if(r.current===null||n.current!==l){let e=r.current===null;r.current=new Map(t.map(t=>[t.id,e&&t.pending===true])),n.current=l}let i=r.current;for(let e of t)i.has(e.id)||i.set(e.id,true);return e.useCallback(e=>i.get(e)===true,[i])}var ko=12;function PressScale({style:r,containerStyle:l,children:i,onPressIn:o,onPressOut:a,hitSlop:s,...u}){let c=so(),d=mo(1),p=e.useCallback(e=>{c.pressMs<=0||c.pressScale===1||n.Animated.timing(d,{toValue:e,duration:c.pressMs,easing:ho,useNativeDriver:true}).start()},[d,c.pressMs,c.pressScale]);/* @__PURE__ */
90
+ return t.jsx(n.Pressable,{...u,hitSlop:s??ko,style:l,onPressIn:e=>{p(c.pressScale),o?.(e)},onPressOut:e=>{p(1),a?.(e)},children:/* @__PURE__ */t.jsx(n.Animated.View,{style:[r,{transform:[{scale:d}]}],children:i})})}function So(t,r,n){let l=r&&n.revealTickMs>0,[i,o]=e.useState(0),a=e.useRef(t);return a.current=t,e.useEffect(()=>{if(!l)return;let e=setInterval(()=>{o(e=>ao(n,e,a.current.length))},n.revealTickMs);return()=>clearInterval(e)},[l,n]),l?t.slice(0,Math.min(i,t.length)):t}var Co=false;function jo(e){e.layoutMs<=0||(Co||(Co=true,n.Platform.OS==="android"&&typeof n.UIManager.setLayoutAnimationEnabledExperimental=="function"&&n.UIManager.setLayoutAnimationEnabledExperimental(true)),n.LayoutAnimation.configureNext({duration:e.layoutMs,create:{type:"easeInEaseOut",property:"opacity"},update:{type:"easeInEaseOut"},delete:{type:"easeInEaseOut",property:"opacity"}}))}function Ro(t,r){let n=e.useRef(t);n.current!==t&&(n.current=t,jo(r))}var To=36,_o=22,zo=12,Io=12,Po=16,Eo="#000",Mo="rgba(0,0,0,0.45)";function AttachmentImageLightbox({uri:e,label:r,onClose:i}){let o=useEverfurTheme(),a=l.useSafeAreaInsets();return e===null?null:/* @__PURE__ */t.jsxs(n.Modal,{visible:true,animationType:o.motion.reducedMotion?"none":"fade",transparent:false,statusBarTranslucent:true,onRequestClose:i,children:[
91
+ /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:Te.closePreview,style:Ao.backdrop,onPress:i,children:/* @__PURE__ */t.jsx(n.Image,{source:{uri:e},style:Ao.image,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:r,accessibilityIgnoresInvertColors:true})}),
92
+ /* @__PURE__ */t.jsx(n.View,{pointerEvents:"box-none",style:[Ao.closeWrap,{top:a.top+Io}],children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Te.closePreview,hitSlop:zo,style:Ao.closeButton,onPress:i,children:/* @__PURE__ */t.jsx(CloseGlyph,{size:_o,color:o.color.surface,strokeWidth:2})})})]})}var Ao=n.StyleSheet.create({backdrop:{flex:1,backgroundColor:Eo,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"},closeWrap:{position:"absolute",right:Po},closeButton:{width:To,height:To,borderRadius:To/2,backgroundColor:Mo,alignItems:"center",justifyContent:"center"}});var Fo=()=>{};function Lo(){try{return n.AppState.currentState==="active"}catch{return false}}function createAppStateLifecycle(){return{onForeground(e){let t;try{let r=n.AppState.currentState==="background";t=n.AppState.addEventListener("change",t=>{t==="background"?r=!0:t==="active"&&r&&(r=!1,e())})}catch{return Fo}return()=>t.remove()},isVisible:Lo}}function Oo(e,t){if(e===void 0)return{};let r={};return e.backgroundColor!==void 0&&(r.backgroundColor=e.backgroundColor),e.borderColor!==void 0&&(r.borderColor=e.borderColor,r.borderWidth=t??1),e.borderRadius!==void 0&&(r.borderRadius=e.borderRadius),r}function Vo(e){return e===void 0||e.backgroundColor!==void 0?e:e.borderRadius===void 0?void 0:{borderRadius:e.borderRadius}}function Do(e){return e?.textColor===void 0?{}:{color:e.textColor}}var Bo=/* @__PURE__ */Object.freeze({postMultipart(){return Promise.reject(new Error("UploadTransport is unavailable; no records upload adapter was injected"))}});function Ho(e){return e!==Bo}var Wo=/* @__PURE__ */Object.freeze({setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()});function No(e,t,r){return new Promise(n=>{if(t.aborted){n();return}let l={handle:void 0},i=()=>{r.clearTimeout(l.handle),t.removeEventListener("abort",i),n()};l.handle=r.setTimeout(i,e),t.addEventListener("abort",i,{once:true})})}var Uo=4e3;var $o=4e3;var qo=/* @__PURE__ */Object.freeze(["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp"]);var Go=10*1024*1024,Ko=5,Yo=120,Qo="/widget/v1/uploads/initiate";function isAttachmentMime(e){return typeof e=="string"&&qo.includes(e.trim().toLowerCase())}function sanitizeFilename(e){if(!e)return"attachment";let t=e.replace(/[\\/]+/g," ").replace(/[\x00-\x1f\x7f"]/g,"").replace(/\s+/g," ").trim();if(!t)return"attachment";if(t.length<=Yo)return t;let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return t.slice(0,Yo);let n=t.slice(r);return n.length>=Yo?t.slice(0,Yo):`${t.slice(0,r).slice(0,Yo-n.length)}${n}`}function formatBytes(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Zo=e=>/* @__PURE__ */Object.freeze({ok:true,value:e}),Jo=e=>/* @__PURE__ */Object.freeze({ok:false,error:e});function Xo(e,t,r,n){/* @__PURE__ */
93
+ return Object.freeze({code:e,retryable:t,filename:r,...n??{}})}function attachmentSize(e){if(typeof e.sizeBytes=="number"&&Number.isFinite(e.sizeBytes)&&e.sizeBytes>=0)return e.sizeBytes;let t=e.blob;return t!==void 0&&typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}function validateAttachment(e){let t=sanitizeFilename(e.name),r=typeof e.mimeType=="string"?e.mimeType.trim().toLowerCase():"";if(!isAttachmentMime(r))return Jo(Xo("unsupported_type",false,t));let n=attachmentSize(e);return n===null?Jo(Xo("unknown",false,t)):n>Go?Jo(Xo("too_large",false,t,{sizeBytes:n})):Zo(/* @__PURE__ */Object.freeze({file:e,filename:t,contentType:r,sizeBytes:n}))}function ea(e){if(typeof e!="object"||e===null)return null;let t=e,r=e=>typeof e=="string"&&e.length>0?e:null,n=e=>typeof e=="number"&&Number.isFinite(e)?e:null,l=r(t.upload_id),i=r(t.upload_url),o=r(t.s3_key);if(l===null||i===null||o===null)return null;let a={},s=t.upload_fields;if(typeof s=="object"&&s!==null)for(let[e,t]of Object.entries(s))typeof t=="string"&&(a[e]=t);/* @__PURE__ */
94
+ return Object.freeze({upload_id:l,upload_url:i,upload_fields:/* @__PURE__ */Object.freeze(a),expires_in_seconds:n(t.expires_in_seconds)??0,max_content_length:n(t.max_content_length)??Go,s3_key:o,purpose:r(t.purpose)})}function ta(e,t){let r=e.httpStatus;switch(e.code){case"quotaExceeded":return Xo("quota_exceeded",false,t,{cause:e});case"rateLimited":return Xo("rate_limited",true,t,{cause:e});case"idempotencyConflict":case"idempotencyInFlight":return Xo("idempotency_conflict",true,t,{cause:e});case"validationFailed":return Xo("unsupported_type",false,t,{cause:e});case"serviceUnavailable":case"streamTimeout":return Xo("network",true,t,{cause:e});default:return r===429?Xo("rate_limited",true,t,{cause:e}):r===503?Xo("network",true,t,{cause:e}):r===void 0?Xo("network",true,t,{cause:e}):Xo("server",e.retryable,t,{httpStatus:r,cause:e})}}async function initiateAttachmentUpload(e,t,r){let n=await e.send("chat.attachments.initiate",{method:"POST",path:Qo,body:{filename:t.filename,content_type:t.contentType,file_size:t.sizeBytes},...r?.signal?{signal:r.signal}:{}});if(!n.ok)return Jo(ta(n.error,t.filename));let l=ea(n.value);return l===null?Jo(Xo("server",false,t.filename)):Zo(l)}async function uploadAttachmentBytes(e,t,r,n){let l=()=>n?.signal?.aborted===true;if(l())return Jo(Xo("cancelled",true,r.filename));try{return await e.postMultipart(t,r.file,{...n?.signal?{signal:n.signal}:{},...n?.onProgress?{onProgress:n.onProgress}:{}}),Zo(void 0)}catch{return l()?Jo(Xo("cancelled",true,r.filename)):Jo(Xo("server",true,r.filename))}}var ra=2,na=3,la=/* @__PURE__ */Object.freeze([1e3,2e3,4e3]),ia=0;function oa(){return ia+=1,`attachment-${ia}`}function createAttachmentQueue(e){let t=Math.max(1,e.concurrency??ra),r=Math.max(1,e.maxAttempts??na),n=e.backoffMs??la,l=Math.max(1,e.maxPerMessage??Ko),i=e.timers??Wo,o=e.newId??oa,a=Ho(e.transport),s=/* @__PURE__ */new Map,u=[],c=[],d=/* @__PURE__ */new Set,p=/* @__PURE__ */new Set,f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])}),h=false,b=()=>{f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze(u.flatMap(e=>{let t=s.get(e);return t===void 0?[]:[t.state]}))});for(let e of p)e()},g=(e,t)=>{e.state=/* @__PURE__ */Object.freeze({...e.state,...t}),b()},m=()=>{for(;!h&&d.size<t&&c.length>0;){let e=c.shift(),t=s.get(e);t!==void 0&&(d.add(e),y(t).finally(()=>{d.delete(e),m()}))}},y=async t=>{let{attachment:l}=t;for(;t.attempts<r;){if(h||t.controller.signal.aborted)return;t.attempts+=1;let o=t.controller.signal;g(t,{status:"uploading",error:null,progress:0});let a=await initiateAttachmentUpload(e.funnel,l,{signal:o});if(h||o.aborted)return;let s;if(!a.ok)s=Jo(a.error);else{let r=await uploadAttachmentBytes(e.transport,a.value,l,{signal:o,onProgress:e=>{!o.aborted&&t.state.status==="uploading"&&g(t,{progress:aa(e)})}});if(h||o.aborted)return;s=r.ok?Zo(a.value.s3_key):Jo(r.error)}if(s.ok){g(t,{status:"uploaded",s3Key:s.value,error:null,progress:1});return}let u=s.error,c=u.retryable&&t.attempts<r;if(g(t,{status:c?"uploading":"failed",error:u,progress:0}),!c)return;let d=n[Math.min(t.attempts-1,n.length-1)]??0;await No(d,o,i)}},v=e=>{c.push(e.state.id),m()},x={available:a,subscribe(e){return p.add(e),()=>{p.delete(e)}},getSnapshot:()=>f,get uploading(){return f.attachments.some(e=>e.status==="uploading")},get s3Keys(){return f.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[])},add(e){let t=validateAttachment(e);if(!t.ok)return t;if(h||u.length>=l)return Jo(Xo("too_many",false,t.value.filename));let r=o(),n={attachment:t.value,controller:new AbortController,attempts:0,state:/* @__PURE__ */Object.freeze({id:r,filename:t.value.filename,previewUri:e.uri,contentType:t.value.contentType,sizeBytes:t.value.sizeBytes,status:"uploading",s3Key:null,error:null,progress:0})};return s.set(r,n),u.push(r),b(),v(n),Zo(n.state)},retry(e){let t=s.get(e);t===void 0||h||t.state.status!=="failed"||(t.controller=new AbortController,t.attempts=0,g(t,{status:"uploading",error:null,progress:0,s3Key:null}),v(t))},remove(e){let t=s.get(e);if(t===void 0)return;t.controller.abort(),s.delete(e);let r=u.indexOf(e);r>=0&&u.splice(r,1);let n=c.indexOf(e);n>=0&&c.splice(n,1),b()},clear(){for(let e of[...u])x.remove(e)},dispose(){h=true;for(let e of s.values())e.controller.abort();s.clear(),u.length=0,c.length=0,p.clear(),f=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])})}};return x}function aa(e){return Number.isNaN(e)||e<0?0:e>1?1:e}function sa(e){switch(e.code){case"too_large":return _e(Te.attachmentTooLarge,{max:formatBytes(Go),filename:e.filename,size:formatBytes(e.sizeBytes??0)});case"too_many":return _e(Te.attachmentTooMany,{max:Ko});case"unsupported_type":return _e(Te.attachmentUnsupported,{filename:e.filename});case"network":return Te.attachmentNetwork;case"server":return _e(Te.attachmentServer,{status:""});case"cancelled":return Te.attachmentCancelled;case"rate_limited":return Te.attachmentRateLimited;case"quota_exceeded":return Te.attachmentQuota;case"idempotency_conflict":return Te.attachmentConflict;case"unknown":return Te.attachmentUnknown}}function ua(e,t){return _e(e>=t?Te.attachmentsFull:Te.addAttachment,{used:e,total:t})}var ca=/* @__PURE__ */Object.freeze({attachments:/* @__PURE__ */Object.freeze([])});function useChatAttachments(t={}){let{runtime:r,userRef:userRef,scopeEpoch:n}=Le(),l=t.maxPerMessage??Ko,i=e.useCallback(()=>{let{services:e}=r.registry;return createAttachmentQueue({funnel:createRequestFunnel({auth:e.authFor(userRef),...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),transport:t.transport??e.uploadTransport,maxPerMessage:l})},[r,userRef,n,l,t.transport]),o=e.useMemo(()=>t.queue??i(),[t.queue,i]),a=e.useRef(/* @__PURE__ */new WeakSet),[s,u]=e.useState(null),c=s!==null&&s.of===o?s.queue:o;e.useEffect(()=>{if(c!==t.queue){if(a.current.has(c)){u({of:o,queue:i()});return}return()=>{c.dispose(),a.current.add(c)}}},[c,o,i,t.queue]);let d=e.useSyncExternalStore(c.subscribe,c.getSnapshot,()=>ca),[p,f]=e.useState(null),h=e.useCallback(e=>{let t=(Array.isArray(e)?e:[e]).map(e=>c.add(e)),r=t.find(e=>!e.ok);return r!==void 0&&!r.ok&&f(r.error),t},[c,f]),b=e.useCallback(e=>c.retry(e),[c]),g=e.useCallback(e=>c.remove(e),[c]),m=e.useCallback(()=>c.clear(),[c]),y=e.useCallback(()=>f(null),[f]),v=d.attachments.some(e=>e.status==="uploading"),x=d.attachments.some(e=>e.status==="failed");return e.useMemo(()=>({available:c.available,attachments:d.attachments,maxPerMessage:l,uploading:v,failed:x,blocked:v||x,s3Keys:d.attachments.flatMap(e=>e.status==="uploaded"&&e.s3Key!==null?[e.s3Key]:[]),rejected:p,add:h,retry:b,remove:g,clear:m,dismissRejected:y}),[c.available,d,l,v,x,p,h,b,g,m,y])}var da=6e3;function pa(e,t,r){let n=t.trim();if(!n)return e;let l=e===""||/\s$/.test(e)?"":" ",i=`${e}${l}${n}`;return typeof r=="number"&&r>0?i.slice(0,r):i}function fa(e){let t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${r}:${n.toString().padStart(2,"0")}`}function ha(e){switch(e){case"permissionDenied":return Te.micBlocked;case"noSpeech":return Te.noSpeech;case"unavailable":return Te.dictationUnavailable}}function ba(e,t,r){if(e)try{e.track(t,{...r})}catch{}}var ga=["Apoquel","Cytopoint","Bravecto","NexGard","Simparica Trio","Credelio","Revolution","Heartgard","Interceptor","Sentinel","ProHeart","Rimadyl","carprofen","meloxicam","Metacam","Galliprant","gabapentin","trazodone","Librela","Solensia","Zenrelia","prednisone","prednisolone","amoxicillin","Clavamox","cephalexin","Convenia","metronidazole","doxycycline","Cerenia","maropitant","famotidine","omeprazole","Proin","Vetmedin","pimobendan","enalapril","furosemide","levothyroxine","methimazole","Vetsulin","fluoxetine","Sileo","tramadol","buprenorphine","Denamarin","Dasuquin","Cosequin","parvovirus","distemper","Bordetella","leptospirosis","heartworm","giardia","coccidia","pancreatitis","hypothyroidism","Cushing's disease","Addison's disease","IVDD","cruciate ligament","luxating patella","hip dysplasia","pyometra","kennel cough","otitis","FIV","FeLV","DHPP","FVRCP","Labrador Retriever","Golden Retriever","French Bulldog","German Shepherd","Dachshund","Cavalier King Charles Spaniel","Shih Tzu","Pomeranian","Chihuahua","Yorkshire Terrier","Bichon Frise","Havanese","Cockapoo","Goldendoodle","Labradoodle","Weimaraner","Vizsla","Shiba Inu","Springer Spaniel","Miniature Schnauzer","Corgi","Australian Shepherd","Border Collie","Siberian Husky","Beagle","Maine Coon","Ragdoll","Sphynx","Bengal cat","British Shorthair"];function ma(e={}){let t=/* @__PURE__ */new Set,r=[];for(let n of[e.name,e.breed,...ga]){let e=(n??"").trim();if(!e)continue;let l=e.toLowerCase();if(!t.has(l)&&(t.add(l),r.push(e),r.length>=100))break}return r}function ya(t,conversationId,r){let[n,l]=e.useState({send:t,conversationId:conversationId,text:r??"",seeded:r??null}),i=n.send===t&&(n.conversationId===null||n.conversationId===conversationId);e.useEffect(()=>{l(e=>{let n=e.send===t&&(e.conversationId===null||e.conversationId===conversationId),l=n?e.text:"",i=n?e.seeded:null,o=r!=null&&r!==i&&l.length===0;return{send:t,conversationId:conversationId,text:o?r:l,seeded:o?r:i}})},[t,conversationId,r]);let o=e.useCallback(e=>l(r=>({send:t,conversationId:conversationId,text:e,seeded:r.seeded})),[t,conversationId]);return[i?n.text:"",o]}function va(t,conversationId,r,n,l=false){let i=e.useRef({draft:r,setDraft:n});i.current={draft:r,setDraft:n};let o=e.useRef(null),[a,s]=e.useState(null);e.useEffect(()=>{if(t===void 0)return;let e=`${conversationId??""}`;if(o.current===e)return;o.current=e;let r=true;return(async()=>{let n=await Or(()=>t.read(conversationId));if(!r)return;let l=n.ok&&typeof n.value=="string"?n.value:"";l.length>0&&i.current.draft.length===0&&i.current.setDraft(l),s(e)})(),()=>{r=false}},[t,conversationId]),e.useEffect(()=>{t===void 0||l||a!==`${conversationId??""}`||Ar(()=>t.write(conversationId,r))},[t,conversationId,r,a,l])}function xa(e){if(!(n.Platform.OS!=="ios"||e===""))try{let t=n.AccessibilityInfo?.announceForAccessibility;typeof t=="function"&&t.call(n.AccessibilityInfo,e)}catch{}}function AnnounceLine({line:t}){return e.useEffect(()=>{xa(t)},[t]),null}var wa=12,ka=80,Sa=44,Ca=22,ja=.14,Ra=18,Ta=8,_a=/* @__PURE__ */Object.freeze({photo:Te.attachmentPhoto,camera:Te.attachmentCamera});function AttachmentPickerPopover({sources:r,full:l,onPick:i,onClose:o}){let a=useEverfurTheme(),s=e.useMemo(()=>za(a),[a]);/* @__PURE__ */
94
95
  return t.jsxs(n.View,{style:s.anchor,pointerEvents:"box-none",children:[
95
- /* @__PURE__ */t.jsx(n.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:je.closeAttachmentPicker,onPress:o}),
96
+ /* @__PURE__ */t.jsx(n.Pressable,{style:s.dismissLayer,accessibilityRole:"button",accessibilityLabel:Te.closeAttachmentPicker,onPress:o}),
96
97
  /* @__PURE__ */t.jsxs(n.View,{style:s.bubble,children:[
97
- /* @__PURE__ */t.jsx(n.View,{style:s.tilesRow,children:r.map(e=>/* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:Ra[e],accessibilityState:{disabled:l},disabled:l,containerStyle:s.tile,style:s.tileInner,onPress:()=>i(e),children:[
98
- /* @__PURE__ */t.jsx(n.View,{style:s.tileIconWrap,children:e==="photo"?/* @__PURE__ */t.jsx(PhotoGlyph,{size:ka,color:a.color.brandInk,strokeWidth:1.5}):/* @__PURE__ */t.jsx(CameraGlyph,{size:ka,color:a.color.brandInk,strokeWidth:1.5})}),
99
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:s.tileLabel,children:Ra[e]})]},e))}),
98
+ /* @__PURE__ */t.jsx(n.View,{style:s.tilesRow,children:r.map(e=>/* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:_a[e],accessibilityState:{disabled:l},disabled:l,containerStyle:s.tile,style:s.tileInner,onPress:()=>i(e),children:[
99
+ /* @__PURE__ */t.jsx(n.View,{style:s.tileIconWrap,children:e==="photo"?/* @__PURE__ */t.jsx(PhotoGlyph,{size:Ca,color:a.color.brandInk,strokeWidth:1.5}):/* @__PURE__ */t.jsx(CameraGlyph,{size:Ca,color:a.color.brandInk,strokeWidth:1.5})}),
100
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:s.tileLabel,children:_a[e]})]},e))}),
100
101
  /* @__PURE__ */t.jsx(n.View,{style:s.tail}),
101
- /* @__PURE__ */t.jsx(n.View,{style:s.tailFill})]})]})}function Ta(e){let t=e.color,r=e.radius;return n.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:Sa,shadowRadius:Ca,shadowOffset:{width:0,height:ja},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:xa,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:wa,height:wa,borderRadius:wa/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...face(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-va/2,width:va,height:va,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:va+4,height:2,backgroundColor:t.surfaceCream}})}function parseColor(e){let t=_a(e);return t===null?null:Aa(t)}function _a(e){if(typeof e=="number")return Pa(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return za(t.slice(1));if(t.toLowerCase().startsWith("0x"))return za(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Ia(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=za(t);if(e!==null)return e}return/^\d+$/.test(t)?Pa(Number.parseInt(t,10)):null}function za(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:Ma(t[0]),g:Ma(t[1]),b:Ma(t[2]),a:1};if(t.length===6)return{r:Ea(t,0),g:Ea(t,2),b:Ea(t,4),a:1};if(t.length===8){let e=Ea(t,0);return{r:Ea(t,2),g:Ea(t,4),b:Ea(t,6),a:e/255}}return null}function Ia(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(e=>e.trim());if(n.length<3)return null;let l=Fa(Number(n[0])),i=Fa(Number(n[1])),o=Fa(Number(n[2]));if(l===null||i===null||o===null)return null;let a=1;if(n.length>=4){let e=Number(n[3]);if(!Number.isFinite(e))return null;a=Math.min(1,Math.max(0,e))}return{r:l,g:i,b:o,a:a}}function Pa(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}function Ea(e,t){return Number.parseInt(e.slice(t,t+2),16)}function Ma(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function Fa(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function Aa(e){if(e.a>=1)return La(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function La(e,t,r){return`#${Oa(e)}${Oa(t)}${Oa(r)}`.toUpperCase()}function Oa(e){return e.toString(16).padStart(2,"0")}var Va="#111111",Da="#FFFFFF",Ba="#000000";function readableOn(e){let t=_a(e);if(t===null)return Da;let r=Na(t),n=Na({r:17,g:17,b:17}),l=Na({r:255,g:255,b:255});return $a(r,l)>=$a(r,n)?Da:Va}function Ha(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(Da,e)>=contrastRatio(Ba,e)?Da:Ba}function Wa(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(Da)>=t(Ba)?Da:Ba}function Na(e){let t=Ua(e.r/255),r=Ua(e.g/255),n=Ua(e.b/255);return.2126*t+.7152*r+.0722*n}function Ua(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function $a(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=_a(e),n=_a(t);if(r===null||n===null)return 1;let l=n.a>=1?n:{...n},i=r.a>=1?r:qa(r,l);return $a(Na(i),Na(l))}function qa(e,t){let r=e.a,n=(e,t)=>Math.round(e*r+t*(1-r));return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function Ga(e,t){let r=_a(e),n=_a(t);if(r===null||n===null)return null;let l=r.a>=1?r:qa(r,{...n});return La(l.r,l.g,l.b)}function Ka(e,t){let r=_a(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}var Ya=.05;function Qa(e,t,r,n){let l=t[0];if(l===void 0)return r;let i=e=>t.every(t=>contrastRatio(e,t)>=n);if(_a(e)===null)return r;if(i(e))return e;let o=Ga(e,l),a=o===null?null:_a(o),s=_a(r);if(a===null||s===null)return r;for(let e=1;e<1/Ya;e+=1){let t=e*Ya,r=(e,r)=>Math.round(e+(r-e)*t),n=La(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(i(n))return n}return r}var Za=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var Ja=56,Xa=12,es=14,ts=10,rs=.45,ns="rgba(7,193,104,0.55)",ls="rgba(185,28,28,0.55)",is=200,os=300,as=20,ss=22,us=12,cs="rgba(0,0,0,0.78)",ds=220,ps=100,fs="rgba(255,255,255,0.15)";function AttachmentStrip({attachments:r,rejected:l,uploadFailed:i=false,onRetry:o,onRemove:a,onPreview:s,style:u}){let c=useEverfurTheme(),d=e.useMemo(()=>hs(c),[c]);return r.length===0&&l===null?null:/* @__PURE__ */t.jsxs(n.View,{style:[d.strip,u],children:[r.length>0?/* @__PURE__ */t.jsx(n.View,{style:d.cards,children:r.map(e=>/* @__PURE__ */t.jsx(PreviewCard,{row:e,styles:d,onRetry:o,onRemove:a,onPreview:s},e.id))}):null,i?/* @__PURE__ */t.jsx(Text,{style:d.rejected,accessibilityRole:"alert",children:je.attachmentsFailedBlocked}):null,l!==null?/* @__PURE__ */t.jsx(Text,{style:d.rejected,accessibilityRole:"alert",children:oa(l)}):null]})}function PreviewCard({row:r,styles:l,onRetry:i,onRemove:o,onPreview:a}){let s=useEverfurTheme(),u=r.status==="uploading",c=r.status==="failed",d=r.status==="uploaded",p=e.useRef(r.status),[f,h]=e.useState(false);return e.useEffect(()=>{let e=p.current;p.current=r.status,r.status==="uploaded"&&e==="uploading"&&h(true)},[r.status]),/* @__PURE__ */t.jsxs(n.View,{style:l.card,children:[
102
- /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:d?"button":"image",accessibilityLabel:d?Re(je.previewAttachment,{filename:r.filename}):r.filename,accessibilityState:{busy:u,disabled:!d},disabled:!d,style:l.thumbHit,onPress:()=>a(r),children:/* @__PURE__ */t.jsxs(n.View,{style:l.thumb,children:[
103
- /* @__PURE__ */t.jsx(n.Image,{source:{uri:r.previewUri},style:l.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */t.jsx(n.View,{style:l.uploadingOverlay,children:/* @__PURE__ */t.jsx(n.ActivityIndicator,{size:"small",color:s.color.surface})}):null,f?/* @__PURE__ */t.jsx(SuccessFlash,{styles:l,onDone:()=>h(false)}):null]})}),c?/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:Re(je.retryUpload,{filename:r.filename}),style:l.failedOverlay,onPress:()=>i(r.id),children:/* @__PURE__ */t.jsx(n.View,{style:l.failedInner,children:/* @__PURE__ */t.jsx(CloseGlyph,{size:as,color:s.color.surface,strokeWidth:2})})}):null,
104
- /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Re(je.removeAttachment,{filename:r.filename}),hitSlop:6,containerStyle:l.removeSlot,style:l.removeButton,onPress:()=>o(r.id),children:/* @__PURE__ */t.jsx(CloseGlyph,{size:us,color:s.color.surface,strokeWidth:1.5})})]})}function SuccessFlash({styles:r,onDone:l}){let i=useEverfurTheme(),o=oo(),a=e.useRef(null);a.current===null&&(a.current=new n.Animated.Value(0));let s=a.current;return e.useEffect(()=>{let e=n.Animated.sequence([n.Animated.timing(s,{toValue:1,duration:is,useNativeDriver:true}),n.Animated.delay(o.uploadFlashMs),n.Animated.timing(s,{toValue:0,duration:os,useNativeDriver:true})]);return e.start(({finished:e})=>{e&&l()}),()=>e.stop()},[s,o.uploadFlashMs,l]),/* @__PURE__ */t.jsx(n.Animated.View,{pointerEvents:"none",style:[r.successOverlay,{opacity:s}],children:/* @__PURE__ */t.jsx(CheckGlyph,{size:as,color:i.color.surface,strokeWidth:2})})}function SentImages({images:r,onPreview:l}){let i=useEverfurTheme(),o=e.useMemo(()=>hs(i),[i]);if(r.length===0)return null;let a=r.length===1;/* @__PURE__ */
105
- return t.jsx(n.View,{style:a?o.sentSingle:o.sentGrid,children:r.map((e,r)=>/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:Re(je.attachedImage,{filename:e.filename}),onPress:()=>l(e),children:/* @__PURE__ */t.jsx(n.Image,{source:{uri:e.uri},style:a?o.singleImage:o.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${r}`))})}function hs(e){let t=e.color,r=e.type;return n.StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:Ja,height:Ja,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:Xa,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Za,alignItems:"center",justifyContent:"center",backgroundColor:Ka(e.color.brandInk,rs)??e.color.brandSofter},successOverlay:{...Za,alignItems:"center",justifyContent:"center",backgroundColor:ns},failedOverlay:{...Za,borderRadius:Xa,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:ls},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:ss,height:ss,borderRadius:ss/2,backgroundColor:cs,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...face(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:ds,height:ds,borderRadius:es,backgroundColor:fs},gridImage:{width:ps,height:ps,borderRadius:ts,backgroundColor:fs}})}var bs="file",gs="multipart upload failed";function ms(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(bs,e.file)}catch{return Promise.reject(new Error(gs))}return e.fetch!==void 0?xs(e.fetch,e.url,t,e.signal):vs(e.url,t,e.signal)}function ys(e){return e>=200&&e<300}function vs(e,t,r){return new Promise((n,l)=>{let i=globalThis.XMLHttpRequest;if(typeof i!="function"||r?.aborted===true){l(new Error(gs));return}let o=null,a=()=>{o!==null&&r?.removeEventListener("abort",o)},s=()=>{a(),l(new Error(gs))};try{let l=new i;l.open("POST",e),l.withCredentials=!1,l.onload=()=>{a(),n(ys(l.status))},l.onerror=s,l.ontimeout=s,l.onabort=s,r!==void 0&&(o=()=>{try{l.abort()}finally{s()}},r.addEventListener("abort",o,{once:!0})),l.send(t)}catch{s()}})}function xs(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(e=>e.ok)}var ws="chat attachment upload: the file handle has no uri",ks="chat attachment upload failed";function Ss(e){return{uri:e.uri,name:sanitizeFilename(e.name),type:e.mimeType}}function createRnChatAttachmentTransport(e={}){/* @__PURE__ */
106
- return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(ws));let{signal:l,onProgress:i}=n,o=()=>Promise.reject(new Error(ks));return l?.aborted===true?o():ms({url:t.upload_url,fields:t.upload_fields,file:Ss(r),signal:l,fetch:e.fetch}).then(e=>{if(!e)return o();i?.(1)},o)}})}var Cs=300,js=3e3,Rs=120,Ts=44,_s=120,zs="88%",Is=520,Ps=2,Es=.5,Ms=1.5,Fs=1.6,As=.6,Ls=56,Os=1.5,Vs=5,Ds=5,Bs=36,Hs=20,Ws=14,Ns=Ts,Us=4,$s=24,qs=22,Gs=.4,Ks=Ts,Ys=20,Qs=.4,Zs=480,Js=12,Xs=.72,eu=48,tu=1.5,ru=1.3,nu=1,lu=1,iu="12%",ou=14,au=16,su=28,uu=18,cu="84%",du=10,pu=15,fu=1.42,hu=4,bu=3,gu=14,mu=20;function yu(){let t=useEverfurTheme(),r=e.useMemo(()=>vu(t),[t]);return{theme:t,styles:r}}function vu(e){let t=e.color,r=e.space,l=e.radius,i=e.type,o=Math.round(i.size.body*Ms),a=Math.round(i.size.body*Fs),s=Math.round(Hs*i.size.body/Ws),u=t.borderRingCream,c=e.slots;return n.StyleSheet.create({container:{flex:1,minHeight:Rs,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:Rs,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},homeEmpty:{flexGrow:1},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:iu,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:Zs,gap:r.lg},errorText:{...face(e,"regular"),fontSize:i.size.subtitle,lineHeight:i.size.subtitle*i.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:Ts,minWidth:Ts,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:l.pill,backgroundColor:t.brand,...Ao(c.primaryButton)},retryLabel:{...face(e,"medium"),color:t.onPrimary,fontSize:i.size.body,...Oo(c.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...face(e,"regular"),color:t.danger,fontSize:i.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:l.md,backgroundColor:t.surfaceCream,borderWidth:lu,borderColor:t.borderRingCream,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...face(e,"bold"),color:t.text.primary,fontSize:i.size.bodyTight},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...face(e,"regular"),color:t.text.muted,fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal},turnNoticeAction:{minHeight:Ts,justifyContent:"center"},turnNoticeActionLabel:{...face(e,"bold"),color:t.brandInk,fontSize:i.size.bodyTight},setupNoticeAction:{...face(e,"medium"),color:t.brandInk,fontSize:i.size.caption},reconnectingCaption:{...face(e,"medium"),color:t.text.secondary,fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},readingBox:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingVertical:r.md,paddingHorizontal:r.md+r.xs/2,backgroundColor:t.surfaceSubtle,borderRadius:l.md},readingDot:{width:6,height:6,borderRadius:l.pill,backgroundColor:t.brandInk},readingInline:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:bu,minHeight:gu},readingDotInline:{width:hu,height:hu,borderRadius:l.pill,backgroundColor:t.text.muted},list:{flex:1},earlierButton:{alignSelf:"center",minHeight:Ts,justifyContent:"center",paddingHorizontal:r.md+r.xs/2},earlierLabel:{...face(e,"monoBold"),color:t.linkInk,fontSize:i.size.caption},listContent:{padding:r.lg,gap:r.xl},listContentCards:{paddingTop:ou,paddingHorizontal:au,paddingBottom:su,gap:uu},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:zs,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:Is,paddingVertical:r.md,paddingHorizontal:r.lg+Ps,backgroundColor:t.bubbleUser,...t.primaryEdge!==t.primary&&t.bubbleUser===t.primary?{borderWidth:Es,borderColor:t.primaryEdge}:{},borderRadius:l.lg,borderBottomRightRadius:l.xs,...Ao(c.userBubble,Es)},bubbleAssistant:c.assistantBubble?.backgroundColor===void 0?{...Ao(c.assistantBubble,Es)}:{paddingVertical:r.md,paddingHorizontal:r.lg+Ps,borderRadius:l.lg,...Ao(c.assistantBubble,Es)},bubbleVet:{maxWidth:Is,paddingVertical:r.md,paddingHorizontal:r.lg+Ps,backgroundColor:t.bubbleVet,borderRadius:l.lg,borderTopLeftRadius:l.xs,...Ao(c.vetBubble,Es)},bubbleCards:{maxWidth:cu},bubbleUserCards:{paddingVertical:du,paddingHorizontal:pu},bubbleTextUserCards:{fontSize:textRole(e,"message").fontSize,lineHeight:Math.round(textRole(e,"message").fontSize*fu)},bubblePending:{opacity:As},bubbleTextUser:{...face(e,"regular"),color:t.onPrimary,fontSize:i.size.body,lineHeight:o,...Oo(c.userBubble)},bubbleTextAssistant:{...face(e,"regular"),color:t.text.primary,fontSize:i.size.body,lineHeight:a,...Oo(c.assistantBubble)},bubbleTextVet:{...face(e,"regular"),color:t.onBubbleVet,fontSize:i.size.body,lineHeight:o,...Oo(c.vetBubble)},assistantName:{...face(e,"bold"),color:t.brandInk,fontSize:i.size.bodyTight,marginBottom:r.xs},assistantSender:{flexDirection:"row",alignItems:"center",gap:r.sm,marginBottom:r.xs},assistantAvatar:{width:mu,height:mu,borderRadius:mu/2},assistantNameInRow:{marginBottom:0},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...face(e,"bold"),color:t.text.primary,fontSize:i.size.bodyTight},vetTime:{...face(e,"regular"),color:t.text.muted,fontSize:i.size.caption},bubbleBold:face(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:face(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.md},followUpsHeading:{...face(e,"monoBold"),color:t.text.muted,fontSize:Js,textTransform:"uppercase",letterSpacing:Xs,paddingBottom:r.sm,borderBottomWidth:nu,borderBottomColor:u},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:nu,borderTopColor:u},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:eu,paddingVertical:r.sm+Ps,...c.chip?.backgroundColor!==void 0||c.chip?.borderColor!==void 0?{paddingHorizontal:r.md}:{},...Ao(c.chip)},followUpText:{...face(e,"bold"),flex:1,color:t.brandInk,fontSize:i.size.bodyTight,...Oo(c.chip)},askChips:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,marginTop:r.md},askChip:{minHeight:Ts,maxWidth:"100%",justifyContent:"center",paddingVertical:r.sm,paddingHorizontal:r.lg,borderRadius:l.pill,borderWidth:tu,borderColor:t.brandInk,backgroundColor:t.chatGround,...Ao(c.chip,tu)},askChipText:{...face(e,"bold"),color:t.brandInk,fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*ru),...Oo(c.chip)},composerOuter:{position:"relative"},askEntry:{marginHorizontal:r.md,marginTop:r.xs},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:Ls,justifyContent:"center",paddingLeft:r.sm,paddingRight:Vs,paddingVertical:Ds,backgroundColor:t.composerFill,borderWidth:Os,borderColor:t.composerBorder,borderRadius:l.pill,...Ao(c.composerInput,Os)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:Bs},dictationError:{...face(e,"regular"),fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal,color:t.danger,paddingHorizontal:r.xs},attachControl:{width:Ks,height:Ks,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:Qs},input:{flex:1,minHeight:Bs,maxHeight:_s,paddingHorizontal:0,paddingVertical:0,...face(e,"regular"),fontSize:i.size.body,lineHeight:s,color:t.text.primary,...Oo(c.composerInput)},sendControl:{minHeight:Ns,minWidth:Ns,alignItems:"center",justifyContent:"center"},sendDisc:{width:Ns,height:Ns,borderRadius:Ns/2,alignItems:"center",justifyContent:"center",...Ao(c.sendButton)},sendControlDisabled:{opacity:Gs},poweredBy:{...face(e,"regular"),color:t.text.muted,fontSize:i.size.micro,textAlign:"center",paddingBottom:r.xs}})}var xu=18,wu=28,ku=6,Su=1200,Cu=.4,ju=.4;function DictationButton({active:r,listening:l,elapsedMs:i,disabled:o=false,onToggle:a}){let s=useEverfurTheme(),u=e.useMemo(()=>Ru(s),[s]);return e.useEffect(()=>{if(l)try{n.AccessibilityInfo.announceForAccessibility(je.listening)}catch{}},[l]),/* @__PURE__ */t.jsxs(n.View,{style:u.wrap,children:[l?/* @__PURE__ */t.jsx(Text,{style:u.timer,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"everfur-dictation-timer",children:da(i)}):null,
107
- /* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>a(),disabled:o,accessibilityRole:"button",accessibilityLabel:r?je.stopDictation:je.dictate,accessibilityState:{selected:r,disabled:o},style:[u.button,o?u.buttonDisabled:null],testID:"everfur-dictation-button",children:r?/* @__PURE__ */t.jsxs(t.Fragment,{children:[
102
+ /* @__PURE__ */t.jsx(n.View,{style:s.tailFill})]})]})}function za(e){let t=e.color,r=e.radius;return n.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:"100%",paddingHorizontal:8,paddingBottom:10,alignItems:"flex-start"},dismissLayer:{position:"absolute",left:-1e3,right:-1e3,top:-2e3,bottom:0},bubble:{backgroundColor:t.surfaceCream,borderRadius:r.lg,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:6,paddingVertical:8,shadowColor:t.shadow,shadowOpacity:ja,shadowRadius:Ra,shadowOffset:{width:0,height:Ta},elevation:8},tilesRow:{flexDirection:"row",alignItems:"stretch"},tile:{minWidth:ka,borderRadius:r.md},tileInner:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:10,paddingVertical:8,gap:6},tileIconWrap:{width:Sa,height:Sa,borderRadius:Sa/2,backgroundColor:t.brandSoft,alignItems:"center",justifyContent:"center"},tileLabel:{...face(e,"medium"),fontSize:12,lineHeight:14,color:t.text.primary},tail:{position:"absolute",left:24,bottom:-wa/2,width:wa,height:wa,backgroundColor:t.surfaceCream,borderRightWidth:1,borderBottomWidth:1,borderColor:t.brandBorderStrong,transform:[{rotate:"45deg"}]},tailFill:{position:"absolute",left:22,bottom:0,width:wa+4,height:2,backgroundColor:t.surfaceCream}})}function parseColor(e){let t=Ia(e);return t===null?null:Oa(t)}function Ia(e){if(typeof e=="number")return Ma(e);if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;if(t.startsWith("#"))return Pa(t.slice(1));if(t.toLowerCase().startsWith("0x"))return Pa(t.slice(2));if(t.toLowerCase().startsWith("rgb"))return Ea(t);if(/^[0-9a-fA-F]+$/.test(t)){let e=Pa(t);if(e!==null)return e}return/^\d+$/.test(t)?Ma(Number.parseInt(t,10)):null}function Pa(e){let t=e.trim();if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===3)return{r:Fa(t[0]),g:Fa(t[1]),b:Fa(t[2]),a:1};if(t.length===6)return{r:Aa(t,0),g:Aa(t,2),b:Aa(t,4),a:1};if(t.length===8){let e=Aa(t,0);return{r:Aa(t,2),g:Aa(t,4),b:Aa(t,6),a:e/255}}return null}function Ea(e){let t=e.indexOf("("),r=e.indexOf(")");if(t<0||r<0||r<t)return null;let n=e.slice(t+1,r).split(",").map(e=>e.trim());if(n.length<3)return null;let l=La(Number(n[0])),i=La(Number(n[1])),o=La(Number(n[2]));if(l===null||i===null||o===null)return null;let a=1;if(n.length>=4){let e=Number(n[3]);if(!Number.isFinite(e))return null;a=Math.min(1,Math.max(0,e))}return{r:l,g:i,b:o,a:a}}function Ma(e){if(!Number.isFinite(e))return null;let t=Math.trunc(e)>>>0,r=t>>>24&255;return{r:t>>>16&255,g:t>>>8&255,b:t&255,a:r===0?1:r/255}}function Aa(e,t){return Number.parseInt(e.slice(t,t+2),16)}function Fa(e){return Number.parseInt(`${e??"0"}${e??"0"}`,16)}function La(e){return Number.isFinite(e)?Math.min(255,Math.max(0,Math.round(e))):null}function Oa(e){if(e.a>=1)return Va(e.r,e.g,e.b);let t=Math.round(e.a*1e3)/1e3;return`rgba(${e.r},${e.g},${e.b},${t})`}function Va(e,t,r){return`#${Da(e)}${Da(t)}${Da(r)}`.toUpperCase()}function Da(e){return e.toString(16).padStart(2,"0")}var Ba="#111111",Ha="#FFFFFF",Wa="#000000";function readableOn(e){let t=Ia(e);if(t===null)return Ha;let r=$a(t),n=$a({r:17,g:17,b:17}),l=$a({r:255,g:255,b:255});return Ga(r,l)>=Ga(r,n)?Ha:Ba}function Na(e,t){let r=readableOn(e);return contrastRatio(r,e)>=t?r:contrastRatio(Ha,e)>=contrastRatio(Wa,e)?Ha:Wa}function Ua(e){let t=t=>e.reduce((e,r)=>Math.min(e,contrastRatio(t,r)),Number.POSITIVE_INFINITY);return t(Ha)>=t(Wa)?Ha:Wa}function $a(e){let t=qa(e.r/255),r=qa(e.g/255),n=qa(e.b/255);return.2126*t+.7152*r+.0722*n}function qa(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ga(e,t){let r=Math.max(e,t),n=Math.min(e,t);return(r+.05)/(n+.05)}function contrastRatio(e,t){let r=Ia(e),n=Ia(t);if(r===null||n===null)return 1;let l=n.a>=1?n:{...n},i=r.a>=1?r:Ka(r,l);return Ga($a(i),$a(l))}function Ka(e,t){let r=e.a,n=(e,t)=>Math.round(e*r+t*(1-r));return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function Ya(e,t){let r=Ia(e),n=Ia(t);if(r===null||n===null)return null;let l=r.a>=1?r:Ka(r,{...n});return Va(l.r,l.g,l.b)}function Qa(e,t){let r=Ia(e);if(r===null)return null;let n=Math.min(1,Math.max(0,t));return`rgba(${r.r}, ${r.g}, ${r.b}, ${n})`}var Za=.05;function Ja(e,t,r,n){let l=t[0];if(l===void 0)return r;let i=e=>t.every(t=>contrastRatio(e,t)>=n);if(Ia(e)===null)return r;if(i(e))return e;let o=Ya(e,l),a=o===null?null:Ia(o),s=Ia(r);if(a===null||s===null)return r;for(let e=1;e<1/Za;e+=1){let t=e*Za,r=(e,r)=>Math.round(e+(r-e)*t),n=Va(r(a.r,s.r),r(a.g,s.g),r(a.b,s.b));if(i(n))return n}return r}var Xa=/* @__PURE__ */Object.freeze({position:"absolute",top:0,right:0,bottom:0,left:0});var es=56,ts=12,rs=14,ns=10,ls=.45,is="rgba(7,193,104,0.55)",os="rgba(185,28,28,0.55)",as=200,ss=300,us=20,cs=22,ds=12,ps="rgba(0,0,0,0.78)",fs=220,hs=100,bs="rgba(255,255,255,0.15)";function AttachmentStrip({attachments:r,rejected:l,uploadFailed:i=false,onRetry:o,onRemove:a,onPreview:s,style:u}){let c=useEverfurTheme(),d=e.useMemo(()=>gs(c),[c]);return r.length===0&&l===null?null:/* @__PURE__ */t.jsxs(n.View,{style:[d.strip,u],children:[r.length>0?/* @__PURE__ */t.jsx(n.View,{style:d.cards,children:r.map(e=>/* @__PURE__ */t.jsx(PreviewCard,{row:e,styles:d,onRetry:o,onRemove:a,onPreview:s},e.id))}):null,i?/* @__PURE__ */t.jsx(Text,{style:d.rejected,accessibilityRole:"alert",children:Te.attachmentsFailedBlocked}):null,l!==null?/* @__PURE__ */t.jsx(Text,{style:d.rejected,accessibilityRole:"alert",children:sa(l)}):null]})}function PreviewCard({row:r,styles:l,onRetry:i,onRemove:o,onPreview:a}){let s=useEverfurTheme(),u=r.status==="uploading",c=r.status==="failed",d=r.status==="uploaded",p=e.useRef(r.status),[f,h]=e.useState(false);return e.useEffect(()=>{let e=p.current;p.current=r.status,r.status==="uploaded"&&e==="uploading"&&h(true)},[r.status]),/* @__PURE__ */t.jsxs(n.View,{style:l.card,children:[
103
+ /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:d?"button":"image",accessibilityLabel:d?_e(Te.previewAttachment,{filename:r.filename}):r.filename,accessibilityState:{busy:u,disabled:!d},disabled:!d,style:l.thumbHit,onPress:()=>a(r),children:/* @__PURE__ */t.jsxs(n.View,{style:l.thumb,children:[
104
+ /* @__PURE__ */t.jsx(n.Image,{source:{uri:r.previewUri},style:l.thumbImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true}),u?/* @__PURE__ */t.jsx(n.View,{style:l.uploadingOverlay,children:/* @__PURE__ */t.jsx(n.ActivityIndicator,{size:"small",color:s.color.surface})}):null,f?/* @__PURE__ */t.jsx(SuccessFlash,{styles:l,onDone:()=>h(false)}):null]})}),c?/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:_e(Te.retryUpload,{filename:r.filename}),style:l.failedOverlay,onPress:()=>i(r.id),children:/* @__PURE__ */t.jsx(n.View,{style:l.failedInner,children:/* @__PURE__ */t.jsx(CloseGlyph,{size:us,color:s.color.surface,strokeWidth:2})})}):null,
105
+ /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:_e(Te.removeAttachment,{filename:r.filename}),hitSlop:6,containerStyle:l.removeSlot,style:l.removeButton,onPress:()=>o(r.id),children:/* @__PURE__ */t.jsx(CloseGlyph,{size:ds,color:s.color.surface,strokeWidth:1.5})})]})}function SuccessFlash({styles:r,onDone:l}){let i=useEverfurTheme(),o=so(),a=e.useRef(null);a.current===null&&(a.current=new n.Animated.Value(0));let s=a.current;return e.useEffect(()=>{let e=n.Animated.sequence([n.Animated.timing(s,{toValue:1,duration:as,useNativeDriver:true}),n.Animated.delay(o.uploadFlashMs),n.Animated.timing(s,{toValue:0,duration:ss,useNativeDriver:true})]);return e.start(({finished:e})=>{e&&l()}),()=>e.stop()},[s,o.uploadFlashMs,l]),/* @__PURE__ */t.jsx(n.Animated.View,{pointerEvents:"none",style:[r.successOverlay,{opacity:s}],children:/* @__PURE__ */t.jsx(CheckGlyph,{size:us,color:i.color.surface,strokeWidth:2})})}function SentImages({images:r,onPreview:l}){let i=useEverfurTheme(),o=e.useMemo(()=>gs(i),[i]);if(r.length===0)return null;let a=r.length===1;/* @__PURE__ */
106
+ return t.jsx(n.View,{style:a?o.sentSingle:o.sentGrid,children:r.map((e,r)=>/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:_e(Te.attachedImage,{filename:e.filename}),onPress:()=>l(e),children:/* @__PURE__ */t.jsx(n.Image,{source:{uri:e.uri},style:a?o.singleImage:o.gridImage,resizeMode:"cover",accessibilityIgnoresInvertColors:true})},`${e.uri}-${r}`))})}function gs(e){let t=e.color,r=e.type;return n.StyleSheet.create({strip:{gap:6,paddingBottom:8},cards:{flexDirection:"row",flexWrap:"wrap",gap:8},card:{width:es,height:es,overflow:"visible"},thumbHit:{width:"100%",height:"100%"},thumb:{width:"100%",height:"100%",borderRadius:ts,overflow:"hidden",backgroundColor:t.composerFill,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.brandBorder},thumbImage:{width:"100%",height:"100%"},uploadingOverlay:{...Xa,alignItems:"center",justifyContent:"center",backgroundColor:Qa(e.color.brandInk,ls)??e.color.brandSofter},successOverlay:{...Xa,alignItems:"center",justifyContent:"center",backgroundColor:is},failedOverlay:{...Xa,borderRadius:ts,overflow:"hidden"},failedInner:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:os},removeSlot:{position:"absolute",top:4,right:4},removeButton:{width:cs,height:cs,borderRadius:cs/2,backgroundColor:ps,borderWidth:1.5,borderColor:t.surface,alignItems:"center",justifyContent:"center"},rejected:{...face(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},sentSingle:{marginBottom:6},sentGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,marginBottom:6},singleImage:{width:fs,height:fs,borderRadius:rs,backgroundColor:bs},gridImage:{width:hs,height:hs,borderRadius:ns,backgroundColor:bs}})}var ms="file",ys="multipart upload failed";function vs(e){let t;try{t=new FormData;for(let[r,n]of Object.entries(e.fields))t.append(r,n);t.append(ms,e.file)}catch{return Promise.reject(new Error(ys))}return e.fetch!==void 0?ks(e.fetch,e.url,t,e.signal):ws(e.url,t,e.signal)}function xs(e){return e>=200&&e<300}function ws(e,t,r){return new Promise((n,l)=>{let i=globalThis.XMLHttpRequest;if(typeof i!="function"||r?.aborted===true){l(new Error(ys));return}let o=null,a=()=>{o!==null&&r?.removeEventListener("abort",o)},s=()=>{a(),l(new Error(ys))};try{let l=new i;l.open("POST",e),l.withCredentials=!1,l.onload=()=>{a(),n(xs(l.status))},l.onerror=s,l.ontimeout=s,l.onabort=s,r!==void 0&&(o=()=>{try{l.abort()}finally{s()}},r.addEventListener("abort",o,{once:!0})),l.send(t)}catch{s()}})}function ks(e,t,r,n){return Promise.resolve().then(()=>e(t,{method:"POST",body:r,credentials:"omit",...n?{signal:n}:{}})).then(e=>e.ok)}var Ss="chat attachment upload: the file handle has no uri",Cs="chat attachment upload failed";function js(e){return{uri:e.uri,name:sanitizeFilename(e.name),type:e.mimeType}}function createRnChatAttachmentTransport(e={}){/* @__PURE__ */
107
+ return Object.freeze({postMultipart(t,r,n){if(typeof r.uri!="string"||r.uri.length===0)return Promise.reject(new Error(Ss));let{signal:l,onProgress:i}=n,o=()=>Promise.reject(new Error(Cs));return l?.aborted===true?o():vs({url:t.upload_url,fields:t.upload_fields,file:js(r),signal:l,fetch:e.fetch}).then(e=>{if(!e)return o();i?.(1)},o)}})}var Rs=300,Ts=3e3,_s=120,zs=44,Is=120,Ps="88%",Es=520,Ms=2,As=.5,Fs=1.5,Ls=1.6,Os=.6,Vs=56,Ds=1.5,Bs=5,Hs=5,Ws=36,Ns=20,Us=14,$s=zs,qs=4,Gs=24,Ks=22,Ys=.4,Qs=zs,Zs=20,Js=.4,Xs=480,eu=12,tu=.72,ru=48,nu=1.5,lu=1.3,iu=1,ou=1,au="12%",su=14,uu=16,cu=28,du=18,pu="84%",fu=10,hu=15,bu=1.42,gu=4,mu=3,yu=14,vu=20;function xu(){let t=useEverfurTheme(),r=e.useMemo(()=>wu(t),[t]);return{theme:t,styles:r}}function wu(e){let t=e.color,r=e.space,l=e.radius,i=e.type,o=Math.round(i.size.body*Fs),a=Math.round(i.size.body*Ls),s=Math.round(Ns*i.size.body/Us),u=t.borderRingCream,c=e.slots;return n.StyleSheet.create({container:{flex:1,minHeight:_s,backgroundColor:t.chatGround},body:{flex:1},centered:{minHeight:_s,flexGrow:1,alignItems:"center",justifyContent:"center",padding:r.xl},homeEmpty:{flexGrow:1},emptyContent:{flexGrow:1,alignItems:"stretch",justifyContent:"flex-start",paddingTop:au,paddingHorizontal:r.lg,paddingBottom:r.lg,minHeight:Xs,gap:r.lg},errorText:{...face(e,"regular"),fontSize:i.size.subtitle,lineHeight:i.size.subtitle*i.lineHeight.snug,color:t.danger,textAlign:"center",marginBottom:r.md},retryButton:{minHeight:zs,minWidth:zs,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:l.pill,backgroundColor:t.brand,...Oo(c.primaryButton)},retryLabel:{...face(e,"medium"),color:t.onPrimary,fontSize:i.size.body,...Do(c.primaryButton)},setupNotice:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.sm,backgroundColor:t.surfaceCream},setupNoticeText:{...face(e,"regular"),color:t.danger,fontSize:i.size.caption,flexShrink:1},turnNotice:{gap:r.xs,padding:r.md,borderRadius:l.md,backgroundColor:t.surfaceCream,borderWidth:ou,borderColor:t.borderRingCream,alignItems:"flex-start"},turnNoticeError:{borderColor:t.danger},turnNoticeTitle:{...face(e,"bold"),color:t.text.primary,fontSize:i.size.bodyTight},turnNoticeTitleError:{color:t.danger},turnNoticeBody:{...face(e,"regular"),color:t.text.muted,fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal},turnNoticeAction:{minHeight:zs,justifyContent:"center"},turnNoticeActionLabel:{...face(e,"bold"),color:t.brandInk,fontSize:i.size.bodyTight},setupNoticeAction:{...face(e,"medium"),color:t.brandInk,fontSize:i.size.caption},reconnectingCaption:{...face(e,"medium"),color:t.text.secondary,fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal,textTransform:"uppercase",letterSpacing:.5},readingBox:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:r.xs,paddingVertical:r.md,paddingHorizontal:r.md+r.xs/2,backgroundColor:t.surfaceSubtle,borderRadius:l.md},readingDot:{width:6,height:6,borderRadius:l.pill,backgroundColor:t.brandInk},readingInline:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:mu,minHeight:yu},readingDotInline:{width:gu,height:gu,borderRadius:l.pill,backgroundColor:t.text.muted},list:{flex:1},earlierButton:{alignSelf:"center",minHeight:zs,justifyContent:"center",paddingHorizontal:r.md+r.xs/2},earlierLabel:{...face(e,"monoBold"),color:t.linkInk,fontSize:i.size.caption},listContent:{padding:r.lg,gap:r.xl},listContentCards:{paddingTop:su,paddingHorizontal:uu,paddingBottom:cu,gap:du},rowBlock:{gap:r.sm},rowBlockUser:{},rowBlockAssistant:{paddingRight:r.xl},row:{flexDirection:"row"},rowUser:{justifyContent:"flex-end"},rowAssistant:{justifyContent:"flex-start"},bubble:{maxWidth:Ps,alignItems:"flex-start"},bubbleSideUser:{alignItems:"flex-end"},bubbleUser:{maxWidth:Es,paddingVertical:r.md,paddingHorizontal:r.lg+Ms,backgroundColor:t.bubbleUser,...t.primaryEdge!==t.primary&&t.bubbleUser===t.primary?{borderWidth:As,borderColor:t.primaryEdge}:{},borderRadius:l.lg,borderBottomRightRadius:l.xs,...Oo(c.userBubble,As)},bubbleAssistant:c.assistantBubble?.backgroundColor===void 0?{...Oo(c.assistantBubble,As)}:{paddingVertical:r.md,paddingHorizontal:r.lg+Ms,borderRadius:l.lg,...Oo(c.assistantBubble,As)},bubbleVet:{maxWidth:Es,paddingVertical:r.md,paddingHorizontal:r.lg+Ms,backgroundColor:t.bubbleVet,borderRadius:l.lg,borderTopLeftRadius:l.xs,...Oo(c.vetBubble,As)},bubbleCards:{maxWidth:pu},bubbleUserCards:{paddingVertical:fu,paddingHorizontal:hu},bubbleTextUserCards:{fontSize:textRole(e,"message").fontSize,lineHeight:Math.round(textRole(e,"message").fontSize*bu)},bubblePending:{opacity:Os},bubbleTextUser:{...face(e,"regular"),color:t.onPrimary,fontSize:i.size.body,lineHeight:o,...Do(c.userBubble)},bubbleTextAssistant:{...face(e,"regular"),color:t.text.primary,fontSize:i.size.body,lineHeight:a,...Do(c.assistantBubble)},bubbleTextVet:{...face(e,"regular"),color:t.onBubbleVet,fontSize:i.size.body,lineHeight:o,...Do(c.vetBubble)},assistantName:{...face(e,"bold"),color:t.brandInk,fontSize:i.size.bodyTight,marginBottom:r.xs},assistantSender:{flexDirection:"row",alignItems:"center",gap:r.sm,marginBottom:r.xs},assistantAvatar:{width:vu,height:vu,borderRadius:vu/2},assistantNameInRow:{marginBottom:0},vetHeader:{flexDirection:"row",alignItems:"baseline",gap:r.sm,marginBottom:r.xs},vetSender:{...face(e,"bold"),color:t.text.primary,fontSize:i.size.bodyTight},vetTime:{...face(e,"regular"),color:t.text.muted,fontSize:i.size.caption},bubbleBold:face(e,"bold"),bubbleItalic:{fontStyle:"italic"},bubbleCode:face(e,"mono"),followUps:{alignSelf:"stretch",marginTop:r.md},followUpsHeading:{...face(e,"monoBold"),color:t.text.muted,fontSize:eu,textTransform:"uppercase",letterSpacing:tu,paddingBottom:r.sm,borderBottomWidth:iu,borderBottomColor:u},followUpSlot:{alignSelf:"stretch"},followUpSlotRuled:{borderTopWidth:iu,borderTopColor:u},followUpRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.md,minHeight:ru,paddingVertical:r.sm+Ms,...c.chip?.backgroundColor!==void 0||c.chip?.borderColor!==void 0?{paddingHorizontal:r.md}:{},...Oo(c.chip)},followUpText:{...face(e,"bold"),flex:1,color:t.brandInk,fontSize:i.size.bodyTight,...Do(c.chip)},askChips:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,marginTop:r.md},askChip:{minHeight:zs,maxWidth:"100%",justifyContent:"center",paddingVertical:r.sm,paddingHorizontal:r.lg,borderRadius:l.pill,borderWidth:nu,borderColor:t.brandInk,backgroundColor:t.chatGround,...Oo(c.chip,nu)},askChipText:{...face(e,"bold"),color:t.brandInk,fontSize:i.size.bodyTight,lineHeight:Math.round(i.size.bodyTight*lu),...Do(c.chip)},composerOuter:{position:"relative"},askEntry:{marginHorizontal:r.md,marginTop:r.xs},composer:{marginHorizontal:r.md,marginTop:r.xs,minHeight:Vs,justifyContent:"center",paddingLeft:r.sm,paddingRight:Bs,paddingVertical:Hs,backgroundColor:t.composerFill,borderWidth:Ds,borderColor:t.composerBorder,borderRadius:l.pill,...Oo(c.composerInput,Ds)},composerRow:{flexDirection:"row",alignItems:"center",gap:r.xs,minHeight:Ws},dictationError:{...face(e,"regular"),fontSize:i.size.caption,lineHeight:i.size.caption*i.lineHeight.normal,color:t.danger,paddingHorizontal:r.xs},attachControl:{width:Qs,height:Qs,alignItems:"center",justifyContent:"center"},attachControlDisabled:{opacity:Js},input:{flex:1,minHeight:Ws,maxHeight:Is,paddingHorizontal:0,paddingVertical:0,...face(e,"regular"),fontSize:i.size.body,lineHeight:s,color:t.text.primary,...Do(c.composerInput)},sendControl:{minHeight:$s,minWidth:$s,alignItems:"center",justifyContent:"center"},sendDisc:{width:$s,height:$s,borderRadius:$s/2,alignItems:"center",justifyContent:"center",...Oo(c.sendButton)},sendControlDisabled:{opacity:Ys},poweredBy:{...face(e,"regular"),color:t.text.muted,fontSize:i.size.micro,textAlign:"center",paddingBottom:r.xs}})}var ku=18,Su=28,Cu=6,ju=1200,Ru=.4,Tu=.4;function DictationButton({active:r,listening:l,elapsedMs:i,disabled:o=false,onToggle:a}){let s=useEverfurTheme(),u=e.useMemo(()=>_u(s),[s]);return e.useEffect(()=>{if(l)try{n.AccessibilityInfo.announceForAccessibility(Te.listening)}catch{}},[l]),/* @__PURE__ */t.jsxs(n.View,{style:u.wrap,children:[l?/* @__PURE__ */t.jsx(Text,{style:u.timer,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",testID:"everfur-dictation-timer",children:fa(i)}):null,
108
+ /* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>a(),disabled:o,accessibilityRole:"button",accessibilityLabel:r?Te.stopDictation:Te.dictate,accessibilityState:{selected:r,disabled:o},style:[u.button,o?u.buttonDisabled:null],testID:"everfur-dictation-button",children:r?/* @__PURE__ */t.jsxs(t.Fragment,{children:[
108
109
  /* @__PURE__ */t.jsx(Pulse,{style:u.pulse,reduced:s.motion.reducedMotion}),
109
- /* @__PURE__ */t.jsx(StopGlyph,{size:wu,color:s.color.brandInk,testID:"everfur-dictation-stop"})]}):/* @__PURE__ */t.jsx(MicGlyph,{size:xu,color:s.color.brandInk,testID:"everfur-dictation-mic"})})]})}function Pulse({style:r,reduced:l}){let i=e.useRef(new n.Animated.Value(1)).current;return e.useEffect(()=>{if(l)return;let e=n.Animated.loop(n.Animated.sequence([n.Animated.timing(i,{toValue:Cu,duration:Su/2,useNativeDriver:true}),n.Animated.timing(i,{toValue:1,duration:Su/2,useNativeDriver:true})]));return e.start(),()=>e.stop()},[i,l]),/* @__PURE__ */t.jsx(n.Animated.View,{style:[r,{opacity:i}],accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"})}function Ru(e){let t=e.color,r=e.type.tierSizes.compact.micro;return n.StyleSheet.create({wrap:{flexDirection:"row",flexShrink:0,alignItems:"center",gap:e.space.xs},timer:{...face(e,"mono"),fontSize:r,lineHeight:r+2,fontVariant:["tabular-nums"],color:t.text.muted},button:{width:Ts,height:Ts,borderRadius:e.radius.pill,alignItems:"center",justifyContent:"center"},buttonDisabled:{opacity:ju},pulse:{position:"absolute",top:ku,right:ku,bottom:ku,left:ku,borderRadius:e.radius.pill,backgroundColor:t.brandSofter}})}function optionalModule(e,t,r){let n;try{n=t()}catch(t){return _u(`optional peer '${e}' is not installed: ${zu(t)}`)}let l=Tu(n);return l==null?_u(`optional peer '${e}' resolved to no module`):r&&!r(l)?_u(`optional peer '${e}' is present but failed its shape check`):/* @__PURE__ */Object.freeze({available:true,module:l})}function Tu(e){return typeof e=="object"&&e!==null&&"default"in e&&Object.keys(e).length<=2?e.default:e}function _u(e){/* @__PURE__ */
110
- return Object.freeze({available:false,module:null,reason:e})}function zu(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown load error"}var Iu=/* @__PURE__ */Symbol.for("@everfur/sdk/rn-dictation");function Pu(){let e=globalThis,t=e[Iu];if(t!==void 0)return t;let r={loader:null,memo:void 0};return e[Iu]=r,r}function registerEverfurDictation(e){let t=Pu();t.loader=e,t.memo=void 0,t.version=(t.version??0)+1;for(let e of[...t.listeners??[]])try{e()}catch{}}function Eu(){return Pu().version??0}function Mu(e){let t=Pu(),r=t.listeners??/* @__PURE__ */new Set;t.listeners=r;let n=()=>e();return r.add(n),()=>{r.delete(n)}}function Fu(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.start=="function"&&typeof t.isRecognitionAvailable=="function"&&typeof t.addListener=="function"}function Au(e){return typeof e!="object"||e===null?null:e.ExpoSpeechRecognitionModule??e}function Lu(){let e=Pu();if(e.memo!==void 0)return e.memo;e.memo=null;let t=e.loader;if(t===null||n.Platform.OS!=="ios"&&n.Platform.OS!=="android")return e.memo;let r=optionalModule("expo-speech-recognition",()=>({box:Au(t())}),e=>typeof e=="object"&&e!==null&&Fu(e.box));return r.available&&(e.memo=r.module.box),e.memo}function Ou(e){if(e===null)return false;try{return e.isRecognitionAvailable()===!0}catch{return false}}function Vu(){try{return Intl.DateTimeFormat().resolvedOptions().locale||Bu}catch{return Bu}}function Du(e){return e.replace(/_/g,"-").toLowerCase()}var Bu="en-US";function Hu(e=Vu()){let[t=""]=e.replace(/_/g,"-").split("-u-"),r=t.split("-");if(r[0]?.toLowerCase()!=="en")return Bu;let n=r.slice(1).find(e=>/^[A-Za-z]{2}$/.test(e));return n?`en-${n.toUpperCase()}`:Bu}function Wu(e,t){if(t.length===0)return null;let r=e=>t.find(t=>Du(t)===Du(e));return r(e)??r(Bu)??t.find(e=>Du(e).startsWith("en-"))??null}async function Nu(e,t){if(n.Platform.OS!=="ios")return t;try{let{locales:r}=await e.getSupportedLocales({});return Wu(t,r??[])??t}catch{return t}}async function Uu(e,t){let r=false;try{r=e.supportsOnDeviceRecognition()===!0}catch{r=false}if(!r)return"network";if(n.Platform.OS!=="android")return"on_device";try{let{installedLocales:r}=await e.getSupportedLocales({}),n=Du(t);return(r??[]).some(e=>Du(e)===n)?"on_device":"network"}catch{return"network"}}function $u(){return n.Platform.OS!=="android"?true:Number(n.Platform.Version)>=qu}var qu=33;function Gu(e,t,r){return{lang:t,interimResults:true,continuous:$u(),maxAlternatives:1,addsPunctuation:true,requiresOnDeviceRecognition:e==="on_device",contextualStrings:r.slice(0,100),iosTaskHint:"dictation"}}var Ku=/* @__PURE__ */new Set(["not-allowed","no-speech","speech-timeout","aborted","interrupted"]),Yu=/* @__PURE__ */new Set(["busy","client","network","audio-capture","too-many-requests","unknown"]);function Qu(e){return Yu.has(e)}var Zu=600,Ju=3;function Xu(e,t,r){if(Ku.has(r))return null;let n=Qu(r)?Zu:0;return r==="language-not-supported"&&Du(t)!==Du(Bu)?{mode:"network",lang:Bu,delayMs:n}:e==="on_device"?{mode:"network",lang:t,delayMs:n}:n>0?{mode:"network",lang:t,delayMs:n}:null}function ec(e){return e==="not-allowed"?"permissionDenied":e==="no-speech"||e==="speech-timeout"?"noSpeech":"unavailable"}async function tc(e){try{if((await e.getPermissionsAsync()).granted)return"granted"}catch{}try{return(await e.requestPermissionsAsync()).granted?"granted":"denied"}catch{return"error"}}var rc=55e3,nc=3e3,lc=1e3;function ic(e){return oc.has(e)||Qu(e)}var oc=/* @__PURE__ */new Set(["no-speech","speech-timeout","aborted","interrupted"]),ac=/* @__PURE__ */Object.freeze({committed:/* @__PURE__ */Object.freeze([]),interim:""});function sc(e){return e.replace(/\s+/g," ").trim()}function uc(e,t,r){let n=sc(t);return r?n?{committed:[...e.committed,n],interim:""}:{committed:e.committed,interim:""}:{committed:e.committed,interim:n}}function cc(e){return sc([...e.committed,e.interim].join(" "))}function dc(e,t,r,n=Date.now){let l=0,i=null,o=Number.NEGATIVE_INFINITY,a=e=>i!==null&&i.token===e?i:null;function s(e){for(let t of e.subscriptions)try{t.remove()}catch{}e.subscriptions=[]}function u(e){s(e),e.autoStopTimer!==null&&clearTimeout(e.autoStopTimer),e.graceTimer!==null&&clearTimeout(e.graceTimer),e.retryTimer!==null&&clearTimeout(e.retryTimer),e.autoStopTimer=null,e.graceTimer=null,e.retryTimer=null,i===e&&(i=null)}function c(e){return!e.sawStart&&e.errorCode===null&&e.pendingRetry===null&&cc(e.transcript)===""&&e.launchedAt-o<lc}function d(e){return e.mode??"none"}function p(e,t){fa(r(),"chat_dictation_completed",{mode:d(e),duration_ms:e.startedAt===null?0:Math.max(0,n()-e.startedAt),char_count:t.length})}function f(e,n){fa(r(),"chat_dictation_failed",{mode:d(e),error:n}),t.onStatus("idle"),t.onError(n)}function h(e){if(a(e.token)===null)return;u(e);let r=cc(e.transcript),n=e.errorCode;if(n!==null&&!(r&&ic(n))){f(e,ec(n));return}if(!r){f(e,"noSpeech");return}p(e,r),t.onStatus("idle")}function b(l){l.subscriptions=[e.addListener("start",()=>{a(l.token)!==null&&(l.sawStart=true,l.startedAt===null&&(l.startedAt=n()),fa(r(),"chat_dictation_started",{mode:d(l)}),t.onStatus("listening"))}),e.addListener("result",e=>{if(a(l.token)===null)return;let r=e?.results?.[0]?.transcript??"";l.transcript=uc(l.transcript,r,e?.isFinal===true),t.onText(cc(l.transcript))}),e.addListener("error",e=>{if(a(l.token)===null)return;let t=e?.error??"unknown";if(l.userStopped&&(t==="aborted"||Qu(t)))return;let r=cc(l.transcript)==="",n=l.mode!==null&&!l.userStopped&&r&&l.retries<Ju?Xu(l.mode,l.lang,t):null;if(n!==null){l.pendingRetry=n;return}l.errorCode===null&&(l.errorCode=t)}),e.addListener("end",()=>{if(a(l.token)!==null&&!c(l)){if(l.pendingRetry!==null){let e=l.pendingRetry;if(l.pendingRetry=null,l.retries+=1,l.lang=e.lang,e.delayMs<=0){g(l,e.mode);return}s(l),l.retryTimer=setTimeout(()=>{l.retryTimer=null,!(a(l.token)===null||l.userStopped)&&g(l,e.mode)},e.delayMs);return}h(l)}})]}function g(t,r){s(t),t.mode=r,t.sawStart=false,t.launchedAt=n(),t.transcript=ac,t.errorCode=null,b(t);try{e.start(Gu(r,t.lang,t.phrases))}catch{t.errorCode="unknown",h(t)}}async function m(t){let r=await tc(e);if(a(t.token)===null)return;if(r!=="granted"){u(t),f(t,r==="denied"?"permissionDenied":"unavailable");return}if(t.lang=await Nu(e,t.lang),a(t.token)===null)return;let n=await Uu(e,t.lang);a(t.token)!==null&&(t.autoStopTimer=setTimeout(()=>y(t),rc),g(t,n))}function y(r){if(!(a(r.token)===null||r.userStopped)){if(r.userStopped=true,r.pendingRetry=null,r.mode===null||r.retryTimer!==null){u(r),t.onStatus("idle");return}r.graceTimer=setTimeout(()=>h(r),nc);try{e.stop()}catch{h(r)}}}return{start(e){if(i!==null)return;let r={token:++l,phrases:e,lang:Hu(),mode:null,retries:0,pendingRetry:null,userStopped:false,transcript:ac,errorCode:null,startedAt:null,sawStart:false,launchedAt:0,subscriptions:[],autoStopTimer:null,graceTimer:null,retryTimer:null};i=r,t.onStatus("starting"),m(r)},stop(){i!==null&&y(i)},cancel(){let r=i;if(r===null)return;let l=r.mode!==null&&r.retryTimer===null,a=cc(r.transcript);if(u(r),t.onStatus("idle"),!!l){a&&p(r,a),o=n();try{e.abort()}catch{}}},isActive:()=>i!==null,isPreparing:()=>i!==null&&i.mode===null}}function pc({enabled:t,input:r,setInput:l,phrases:i,maxLength:o,telemetry:a}){let s=e.useSyncExternalStore(Mu,Eu,Eu),u=e.useMemo(()=>t?Lu():null,[t,s]),c=e.useMemo(()=>Ou(u),[u]),[d,p]=e.useState("idle"),[f,h]=e.useState(null),[b,g]=e.useState(0),m=e.useRef(r);m.current=r;let y=e.useRef(l);y.current=l;let v=e.useRef(a);v.current=a;let x=e.useRef(""),w=e.useRef(o);w.current=o;let k=e.useRef(null);u!==null&&k.current?.mod!==u&&(k.current?.controller.cancel(),k.current={mod:u,controller:dc(u,{onStatus:e=>{p(t=>e==="idle"&&t==="error"?t:e)},onText:e=>y.current(ca(x.current,e,w.current)),onError:e=>{h(e),p("error")}},()=>v.current)});let S=u===null?null:k.current?.controller??null,C=e.useCallback(()=>{S?.cancel()},[S]),j=e.useCallback(()=>{if(S!==null){if(S.isActive()){S.stop();return}h(null),g(0),x.current=m.current,S.start(i)}},[S,i]);e.useEffect(()=>{if(d!=="listening")return;let e=Date.now();g(0);let t=setInterval(()=>g(Date.now()-e),1e3);return()=>clearInterval(t)},[d]),e.useEffect(()=>{if(d!=="error")return;let e=setTimeout(()=>{h(null),p("idle")},ua);return()=>clearTimeout(e)},[d]),e.useEffect(()=>{if(S===null)return;let e=null;try{e=n.AppState.addEventListener("change",e=>{e==="background"&&!S.isPreparing()&&S.cancel()})}catch{}return()=>{e?.remove(),S.cancel()}},[S]);let R=t&&c;return e.useEffect(()=>{R||S?.cancel()},[R,S]),{supported:R,status:d,active:d==="starting"||d==="listening",error:f,elapsedMs:b,toggle:j,cancel:C}}var fc=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatPaneShown");function hc(){let t=globalThis,r=t[fc];if(r!==void 0)return r;let n=e.createContext(true);return t[fc]=n,n}var bc=hc();function gc(){return e.useContext(bc)}var mc=/* @__PURE__ */Object.freeze(["photo"]),yc=52,vc=1.5,xc=10,wc=14,kc=10,Sc=40,Cc=20,jc=.3,Rc=2.5,Tc=1,_c=1.5,zc=38,Ic=22,Pc=3;function Ec(e,t,r,n="ask",l=false){let i=typeof t=="string"&&t.trim()!=="";return r&&i&&n!=="urgent"?_e(je.placeholder,t):e!==null?!l||!e.includes("{pet}")?e:i?e.split("{pet}").join(t.trim()):_e(je.placeholder,t):n==="urgent"?je.placeholderUrgentWeb:n==="followUp"?je.placeholderFollowUpWeb:_e(je.placeholder,t)}function ComposerWithAttachments({attachments:r,...n}){let l=e.useMemo(()=>createRnChatAttachmentTransport(),[]),i=useChatAttachments({maxPerMessage:r.maxPerMessage??qo,transport:l}),o=e.useMemo(()=>({state:i,sources:r.sources??mc,pick:r.pick}),[i,r.sources,r.pick]);/* @__PURE__ */
111
- return t.jsx(Composer,{...n,attachments:o})}function Composer({send:r,stop:l,isStreaming:i,conversationId:conversationId,attachments:o,seed:a,draftStore:s,onStage:u,onPreview:c,petName:d,petBreed:p=null,mood:f="ask",dictation:h=false,telemetry:b=null,compact:g=false,petPlaceholder:m=false,dimEmptySend:y=false}){let{theme:v,styles:x}=yu(),w=e.useMemo(()=>Vc(v),[v]),k=e.useMemo(()=>Dc(v),[v]),S=oo(),[C,j]=ga(r,conversationId,a),[R,T]=e.useState(false),[_,z]=e.useState(false),I=e.useCallback(()=>z(true),[]),P=e.useCallback(()=>z(false),[]),[E,M]=e.useState(false);e.useEffect(()=>{M(false)},[conversationId]);let F=Ec(v.meta.placeholder,d,m,f,v.meta.placeholderFillsPet===true),A=e.useMemo(()=>ba({name:d,breed:p}),[d,p]),L=pc({enabled:h,input:C,setInput:j,phrases:A,maxLength:No,telemetry:b}),O=L.cancel,V=L.active;ma(s,conversationId===null?null:String(conversationId),C,j,V);let D=e.useRef(conversationId);e.useEffect(()=>{D.current!==conversationId&&(D.current=conversationId,O())},[conversationId,O]);let B=gc();e.useEffect(()=>{B||O()},[B,O]);let H=o?.state.uploading??false,W=o?.state.failed??false,N=H||W,U=o?.state.attachments??Mc;Co(U.length,S);let $=e.useCallback(()=>{let e=C.trim();if(e.length===0||N||[...e].length>No)return;V&&O();let t=o?.state.s3Keys??Fc;o!==null&&t.length>0?(u(o.state.attachments.filter(e=>e.status==="uploaded").map(e=>({uri:e.previewUri,filename:e.filename}))),r(e,{imageS3Keys:t}),o.state.clear()):r(e),j(""),M(false)},[C,r,N,V,O,o,u]),q=e.useCallback(e=>{V&&O(),j(e)},[V,O,j]),G=e.useCallback(()=>{l()},[l]),K=e.useCallback(e=>{T(false),o!==null&&(M(false),o.state.dismissRejected(),Ar(o.pick,e).then(e=>{if(!e.ok){M(true);return}e.value!==null&&o.state.add(e.value)}))},[o]),Y=e.useMemo(()=>[...C.trim()].length>No,[C]),Q=Y||N||C.trim().length===0,Z=Y||N||y&&C.trim().length===0,J=o!==null&&U.length>=o.state.maxPerMessage,X=v.slots.sendButton?.textColor??v.color.brandInk,ee=v.slots.sendButton?.textColor??v.color.surface;/* @__PURE__ */
112
- return t.jsxs(n.View,{style:x.composerOuter,children:[o!==null&&R?/* @__PURE__ */t.jsx(AttachmentPickerPopover,{sources:o.sources,full:J,onPick:K,onClose:()=>T(false)}):null,o!==null?/* @__PURE__ */t.jsx(AttachmentStrip,{attachments:U,rejected:E?Oc:o.state.rejected,uploadFailed:W,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:e=>c({uri:e.previewUri,label:e.filename}),style:g?w.tray:k.tray}):null,
113
- /* @__PURE__ */t.jsxs(n.View,{style:g?[x.composer,w.bar,_?w.barFocused:null]:x.composer,children:[L.supported&&L.error!==null?/* @__PURE__ */t.jsxs(t.Fragment,{children:[
114
- /* @__PURE__ */t.jsx(Text,{style:x.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:pa(L.error)}),
115
- /* @__PURE__ */t.jsx(AnnounceLine,{line:pa(L.error)})]}):null,
116
- /* @__PURE__ */t.jsxs(n.View,{style:x.composerRow,children:[o!==null?/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:J?aa(U.length,o.state.maxPerMessage):je.attachPhotoOrFileNative,accessibilityState:{disabled:J,expanded:R},disabled:J,style:[x.attachControl,g?w.add:null,J?x.attachControlDisabled:null],hitSlop:g?Pc:void 0,onPress:()=>T(e=>!e),children:/* @__PURE__ */t.jsx(UploadGlyph,{size:g?Ic:Ys,color:J?v.color.text.muted:g?v.color.text.primary:v.color.brandInk,strokeWidth:1.75})}):null,
117
- /* @__PURE__ */t.jsx(ne,{style:g?[x.input,w.input]:x.input,onFocus:I,onBlur:P,value:C,onChangeText:q,placeholder:F,placeholderTextColor:v.slots.composerInput?.textColor??v.color.text.placeholder,accessibilityLabel:je.composerLabel,onSubmitEditing:$,returnKeyType:"send",...Ac,...g?Lc:null,blurOnSubmit:false,multiline:true,editable:true}),L.supported?/* @__PURE__ */t.jsx(DictationButton,{active:L.active,listening:L.status==="listening",elapsedMs:L.elapsedMs,onToggle:L.toggle}):null,i?/* @__PURE__ */t.jsx(n.Pressable,{onPress:G,accessibilityRole:"button",accessibilityLabel:je.stop,style:x.sendControl,children:/* @__PURE__ */t.jsx(n.View,{style:g?w.disc:x.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */t.jsx(StopGlyph,{size:g?Cc:qs,color:g?ee:X,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */t.jsx(n.Pressable,{onPress:$,disabled:Q,accessibilityRole:"button",accessibilityLabel:je.send,accessibilityState:{disabled:Q,busy:H},style:[x.sendControl,Z?g?w.dimmed:x.sendControlDisabled:null],children:g?/* @__PURE__ */t.jsx(n.View,{style:w.disc,testID:"everfur-send-disc",children:/* @__PURE__ */t.jsx(ArrowUpGlyph,{size:Cc,color:ee,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */t.jsx(n.View,{style:x.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */t.jsx(SendGlyph,{size:$s,color:X,testID:"everfur-send-glyph"})})})]})]})]})}var Mc=/* @__PURE__ */Object.freeze([]),Fc=/* @__PURE__ */Object.freeze([]),Ac=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),Lc=/* @__PURE__ */Object.freeze(n.Platform.OS==="web"?{rows:1}:{}),Oc=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function Vc(e){let t=e.color,r=e.slots.sendButton,l=textRole(e,"body").fontSize+Tc;return n.StyleSheet.create({bar:{marginTop:xc,marginHorizontal:wc,marginBottom:kc,minHeight:yc,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:vc,borderColor:e.slots.composerInput?.borderColor??t.text.primary},barFocused:{borderWidth:Rc,paddingLeft:8-(Rc-vc),paddingRight:6-(Rc-vc)},input:{fontSize:l,lineHeight:Math.round(l*_c),minHeight:Math.round(l*_c),...n.Platform.OS==="web"?{outlineStyle:"none"}:null},add:{width:zc,height:zc,borderRadius:zc/2},disc:{width:Sc,height:Sc,borderRadius:Sc/2,alignItems:"center",justifyContent:"center",backgroundColor:r?.backgroundColor??t.text.primary,...Ao(r)},dimmed:{opacity:jc},tray:{marginHorizontal:wc,marginTop:xc,paddingBottom:0}})}function Dc(e){return n.StyleSheet.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var Bc=/* @__PURE__ */new WeakMap;function Hc(e,t){let r=Bc.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,Bc.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:t,userRef:userRef,activePet:r,scopeEpoch:n}=Fe(),l=e.useMemo(()=>createPetsRepository(t.registry.services.authFor(userRef)),[t,userRef,n]),[i,o]=e.useState({repository:l,pets:[],loading:true,error:null}),a=i.repository===l?i:{pets:[],loading:true,error:null},s=e.useRef(0),u=e.useCallback(async()=>{let e=++s.current;o(e=>({...e,repository:l,loading:true,error:null,pets:e.repository===l?e.pets:[]}));let t=await l.list();e===s.current&&o(t.ok?{repository:l,pets:t.value,loading:false,error:null}:e=>({repository:l,pets:e.repository===l?e.pets:[],loading:false,error:t.error}))},[l]);e.useEffect(()=>(u(),()=>{s.current+=1}),[u]),e.useEffect(()=>Hc(t,()=>{u()}),[t,u]);let c=e.useMemo(()=>r===null?null:a.pets.find(e=>e.petRef===r)??null,[r,a.pets]);return e.useMemo(()=>({pets:a.pets,activePet:c,loading:a.loading,error:a.error,refresh:u}),[a.pets,a.loading,a.error,c,u])}function Wc(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var Nc=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var Uc=false;function $c(e,t){return t!==void 0?(Er(t,e),"onStartInApp"):h(e)==="presented"?"presenter":y(e)?"experience":(Uc||(Uc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var qc=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&qc.includes(e)}var Gc="/widget/v1/televet/handoffs",Kc="/widget/v1/televet/availability",Yc="/widget/v1/televet/chat-entry",Qc=/^[a-z0-9][a-z0-9_-]{0,39}$/,Zc=/^[A-Za-z0-9_-]{22}$/;var Jc=32,Xc=128,ed=64;function vetVisitErrorReasonOf(e){let t=e.httpStatus;switch(e.code){case"sessionRequired":return"sessionRequired";case"authExpired":case"authRejected":return"authRejected";case"sdkUpdateRequired":return"sdkUpdateRequired";case"validationFailed":return"invalidRequest";case"rateLimited":case"quotaExceeded":return"rateLimited"}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}function td(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function rd(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function nd(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!Qc.test(r))return{ok:false,message:"returnTo must be a registered return destination key"};t.return_to=r}let n=e?.entry;if(n!=null){if(n!=="chat"||petRef===void 0)return{ok:false,message:"entry 'chat' needs the pet the chat is about"};t.entry=n}let l=e?.visitRef,i=e?.intent,o=l!=null;if(o){let e=typeof l=="string"?l.trim():"";if(e.length<1||[...e].length>ed)return{ok:false,message:`visitRef must be 1..${ed} characters`};t.visit_ref=e}if(i!=null){if(!o)return{ok:false,message:"intent needs the visitRef it opens"};if(!isVetVisitIntent(i))return{ok:false,message:`intent must be one of ${qc.join(", ")}`};t.intent=i}return{ok:true,body:t}}function ld(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!isVetVisitIntent(r)?null:/* @__PURE__ */Object.freeze({visitRef:t,intent:r})}function id(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(dd(r,"televet.visit.handoff_failed",{reason:vetVisitErrorReasonOf(e)}),err(e));return{async createHandoff(petRef,e){let l;if(petRef!=null){let e=typeof petRef=="string"?[...petRef].length:0;if(e<1||e>Xc)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${Xc} characters`}));l=petRef}let i=nd(l,e);if(!i.ok){let e=td(i.message);return e.ok?e:n(e.error)}let o=i.body,a=await t.send("televet.visit.handoff",{method:"POST",path:Gc,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=od(a.value),u=o.return_to!==void 0,c=u?a.value?.flow_id:void 0;if(u&&(typeof c!="string"||!Zc.test(c))){let e=rd("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let d=o.visit_ref!==void 0,p=d?ld(a.value?.visit):null;if(d&&p===null){let e=rd("the handoff response did not confirm the visit it opens");return e.ok?e:n(e.error)}let f=s===null?null:/* @__PURE__ */Object.freeze({...s,...u?{flowId:c}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(dd(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>Jc)return td(`state must be at most ${Jc} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:Kc,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?rd("the availability response carried no usable answer"):ok(/* @__PURE__ */Object.freeze({available:n}))},async chatEntryOpen(){try{let e=await t.send("televet.visit.chat_entry",{method:"GET",path:Yc},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function od(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!cd(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var ad=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),sd=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,ud=/[\s\u0000-\u001f\u007f]/;function cd(e){if(ud.test(e))return false;let t=sd.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let l=n.replace(/:\d+$/,"").toLowerCase(),i=r==="https",o=r==="http"&&ad.has(l);if(!i&&!o)return false;let a=e.indexOf("#");if(a<0)return false;let s=e.slice(a);return s.startsWith("#h=")&&s.length>3}function dd(e,t,r){if(e)try{e.track(t,r)}catch{}}var pd=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function fd(t,r,n){let{usState:l,chat:i,scope:o}=n,a=r&&(l!==null||i),s=`${l??""}|${i?"chat":""}`,[u,c]=e.useState(null);if(e.useEffect(()=>{if(!a)return;let e=true,r=t.current;return c(null),(async()=>{try{if(i&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(l===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(l);return e.ok&&e.value.available}catch{return false}})().then(t=>{e&&c({key:s,open:t})}),()=>{e=false}},[a,s,l,i,o,t]),!a)return null;let d=u!==null&&u.key===s;return{open:d&&u.open,pending:!d}}var hd=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function bd(t,r={}){let{runtime:n,userRef:userRef,scopeEpoch:l}=Fe(),i=useCapability("televet"),o=i.enabled&&userRef!==null,a=r.usState??null,s=r.entry==="chat",u=r.petRef??null,c=r.prefer==="redirect",d=e.useMemo(()=>{if(r.controller)return r.controller;let{services:e}=n.registry;return id({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[n,userRef,l,r.controller]),p=e.useRef(d);p.current=d;let f=e.useMemo(()=>({runtime:n,userRef:userRef,scopeEpoch:l}),[n,userRef,l]),h=fd(p,o,{usState:a,chat:s,scope:f}),b=o&&(h===null||h.open)&&(!s||u!==null),g=r.returnTo??null,[m,y]=e.useState(pd),v=e.useRef(null),x=e.useRef({runtime:n,userRef:userRef,scopeEpoch:l});x.current={runtime:n,userRef:userRef,scopeEpoch:l};let w=e.useRef(d);w.current=d;let k=e.useRef(b);k.current=b;let S=e.useCallback((petRef,e)=>{if(v.current)return v.current;let r=(e,t)=>(y({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!k.current)return Promise.resolve(r("unavailable",null));let n=t.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=x.current,i=w.current;y(hd);let o=(async()=>{let o,a={...g!==null?{returnTo:g}:{},...s?{entry:"chat"}:{},...e!==null?{visitRef:e.visitRef}:{},...e!==null&&e.intent!==null&&e.intent!==void 0?{intent:e.intent}:{}},c=Object.keys(a).length===0?void 0:a,d=petRef===void 0?u:petRef;try{o=await(c===void 0?i.createHandoff(d):i.createHandoff(d,c))}catch{return t.abandon(n.value),r("unknown",null)}let p=x.current;if(p.runtime!==l.runtime||p.userRef!==l.userRef||p.scopeEpoch!==l.scopeEpoch)return t.abandon(n.value),r("cancelled",null);if(!o.ok)return t.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await t.finish(n.value,o.value);return f!==null?r(f,null):(y(pd),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{v.current===o&&(v.current=null)});return v.current=o,o},[t,u,g,s]),C=e.useCallback((petRef,e)=>{if(!k.current)return y({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?u:petRef,r={...t!==null?{petRef:t}:{},...a!==null?{usState:a}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return $c(r)===null?(y({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(y(pd),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[u,a]),j=e.useCallback(petRef=>c?S(petRef,null):C(petRef,null),[c,S,C]),R=e.useCallback((e,t)=>c?S(void 0,{visitRef:e,intent:t??null}):C(void 0,{visitRef:e,intent:t??null}),[c,S,C]),T=e.useCallback(e=>c?S(void 0,null):C(void 0,{consultId:e.trim()}),[c,S,C]);return{available:b,isPending:i.isPending||(h?.pending??false),status:m.status,error:m.error,errorReason:m.errorReason,open:j,openVisit:R,joinVisit:T}}var gd=e=>n.Linking.openURL(e);function useVetVisit(t={}){let{openUrl:r,...n}=t,l=e.useMemo(()=>{let e=r??gd;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[r]);return bd(l,n)}var md=44,yd=.6;function VetVisitButtonCore(r){let{petRef:petRef,label:l,openUrl:i,onOpened:o,onError:a,style:s,labelStyle:u,controller:c,returnTo:d,usState:p,entry:f,visitRef:h,intent:b,onStartInApp:g,prefer:m}=r,y=m==="redirect",v=useVetVisit({...d!==void 0?{returnTo:d}:{},...p!==void 0?{usState:p}:{},...f!==void 0?{entry:f}:{},...petRef!==void 0?{petRef:petRef}:{},...i!==void 0?{openUrl:i}:{},...c!==void 0?{controller:c}:{},prefer:y?"redirect":"in-app"}),x=useEverfurTheme(),w=e.useMemo(()=>vd(x),[x]),k=e.useRef(false);if(!v.available)/* @__PURE__ */
110
+ /* @__PURE__ */t.jsx(StopGlyph,{size:Su,color:s.color.brandInk,testID:"everfur-dictation-stop"})]}):/* @__PURE__ */t.jsx(MicGlyph,{size:ku,color:s.color.brandInk,testID:"everfur-dictation-mic"})})]})}function Pulse({style:r,reduced:l}){let i=e.useRef(new n.Animated.Value(1)).current;return e.useEffect(()=>{if(l)return;let e=n.Animated.loop(n.Animated.sequence([n.Animated.timing(i,{toValue:Ru,duration:ju/2,useNativeDriver:true}),n.Animated.timing(i,{toValue:1,duration:ju/2,useNativeDriver:true})]));return e.start(),()=>e.stop()},[i,l]),/* @__PURE__ */t.jsx(n.Animated.View,{style:[r,{opacity:i}],accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"})}function _u(e){let t=e.color,r=e.type.tierSizes.compact.micro;return n.StyleSheet.create({wrap:{flexDirection:"row",flexShrink:0,alignItems:"center",gap:e.space.xs},timer:{...face(e,"mono"),fontSize:r,lineHeight:r+2,fontVariant:["tabular-nums"],color:t.text.muted},button:{width:zs,height:zs,borderRadius:e.radius.pill,alignItems:"center",justifyContent:"center"},buttonDisabled:{opacity:Tu},pulse:{position:"absolute",top:Cu,right:Cu,bottom:Cu,left:Cu,borderRadius:e.radius.pill,backgroundColor:t.brandSofter}})}function optionalModule(e,t,r){let n;try{n=t()}catch(t){return Iu(`optional peer '${e}' is not installed: ${Pu(t)}`)}let l=zu(n);return l==null?Iu(`optional peer '${e}' resolved to no module`):r&&!r(l)?Iu(`optional peer '${e}' is present but failed its shape check`):/* @__PURE__ */Object.freeze({available:true,module:l})}function zu(e){return typeof e=="object"&&e!==null&&"default"in e&&Object.keys(e).length<=2?e.default:e}function Iu(e){/* @__PURE__ */
111
+ return Object.freeze({available:false,module:null,reason:e})}function Pu(e){return e instanceof Error?e.message:typeof e=="string"?e:"unknown load error"}var Eu=/* @__PURE__ */Symbol.for("@everfur/sdk/rn-dictation");function Mu(){let e=globalThis,t=e[Eu];if(t!==void 0)return t;let r={loader:null,memo:void 0};return e[Eu]=r,r}function registerEverfurDictation(e){let t=Mu();t.loader=e,t.memo=void 0,t.version=(t.version??0)+1;for(let e of[...t.listeners??[]])try{e()}catch{}}function Au(){return Mu().version??0}function Fu(e){let t=Mu(),r=t.listeners??/* @__PURE__ */new Set;t.listeners=r;let n=()=>e();return r.add(n),()=>{r.delete(n)}}function Lu(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.start=="function"&&typeof t.isRecognitionAvailable=="function"&&typeof t.addListener=="function"}function Ou(e){return typeof e!="object"||e===null?null:e.ExpoSpeechRecognitionModule??e}function Vu(){let e=Mu();if(e.memo!==void 0)return e.memo;e.memo=null;let t=e.loader;if(t===null||n.Platform.OS!=="ios"&&n.Platform.OS!=="android")return e.memo;let r=optionalModule("expo-speech-recognition",()=>({box:Ou(t())}),e=>typeof e=="object"&&e!==null&&Lu(e.box));return r.available&&(e.memo=r.module.box),e.memo}function Du(e){if(e===null)return false;try{return e.isRecognitionAvailable()===!0}catch{return false}}function Bu(){try{return Intl.DateTimeFormat().resolvedOptions().locale||Wu}catch{return Wu}}function Hu(e){return e.replace(/_/g,"-").toLowerCase()}var Wu="en-US";function Nu(e=Bu()){let[t=""]=e.replace(/_/g,"-").split("-u-"),r=t.split("-");if(r[0]?.toLowerCase()!=="en")return Wu;let n=r.slice(1).find(e=>/^[A-Za-z]{2}$/.test(e));return n?`en-${n.toUpperCase()}`:Wu}function Uu(e,t){if(t.length===0)return null;let r=e=>t.find(t=>Hu(t)===Hu(e));return r(e)??r(Wu)??t.find(e=>Hu(e).startsWith("en-"))??null}async function $u(e,t){if(n.Platform.OS!=="ios")return t;try{let{locales:r}=await e.getSupportedLocales({});return Uu(t,r??[])??t}catch{return t}}async function qu(e,t){let r=false;try{r=e.supportsOnDeviceRecognition()===!0}catch{r=false}if(!r)return"network";if(n.Platform.OS!=="android")return"on_device";try{let{installedLocales:r}=await e.getSupportedLocales({}),n=Hu(t);return(r??[]).some(e=>Hu(e)===n)?"on_device":"network"}catch{return"network"}}function Gu(){return n.Platform.OS!=="android"?true:Number(n.Platform.Version)>=Ku}var Ku=33;function Yu(e,t,r){return{lang:t,interimResults:true,continuous:Gu(),maxAlternatives:1,addsPunctuation:true,requiresOnDeviceRecognition:e==="on_device",contextualStrings:r.slice(0,100),iosTaskHint:"dictation"}}var Qu=/* @__PURE__ */new Set(["not-allowed","no-speech","speech-timeout","aborted","interrupted"]),Zu=/* @__PURE__ */new Set(["busy","client","network","audio-capture","too-many-requests","unknown"]);function Ju(e){return Zu.has(e)}var Xu=600,ec=3;function tc(e,t,r){if(Qu.has(r))return null;let n=Ju(r)?Xu:0;return r==="language-not-supported"&&Hu(t)!==Hu(Wu)?{mode:"network",lang:Wu,delayMs:n}:e==="on_device"?{mode:"network",lang:t,delayMs:n}:n>0?{mode:"network",lang:t,delayMs:n}:null}function rc(e){return e==="not-allowed"?"permissionDenied":e==="no-speech"||e==="speech-timeout"?"noSpeech":"unavailable"}async function nc(e){try{if((await e.getPermissionsAsync()).granted)return"granted"}catch{}try{return(await e.requestPermissionsAsync()).granted?"granted":"denied"}catch{return"error"}}var lc=55e3,ic=3e3,oc=1e3;function ac(e){return sc.has(e)||Ju(e)}var sc=/* @__PURE__ */new Set(["no-speech","speech-timeout","aborted","interrupted"]),uc=/* @__PURE__ */Object.freeze({committed:/* @__PURE__ */Object.freeze([]),interim:""});function cc(e){return e.replace(/\s+/g," ").trim()}function dc(e,t,r){let n=cc(t);return r?n?{committed:[...e.committed,n],interim:""}:{committed:e.committed,interim:""}:{committed:e.committed,interim:n}}function pc(e){return cc([...e.committed,e.interim].join(" "))}function fc(e,t,r,n=Date.now){let l=0,i=null,o=Number.NEGATIVE_INFINITY,a=e=>i!==null&&i.token===e?i:null;function s(e){for(let t of e.subscriptions)try{t.remove()}catch{}e.subscriptions=[]}function u(e){s(e),e.autoStopTimer!==null&&clearTimeout(e.autoStopTimer),e.graceTimer!==null&&clearTimeout(e.graceTimer),e.retryTimer!==null&&clearTimeout(e.retryTimer),e.autoStopTimer=null,e.graceTimer=null,e.retryTimer=null,i===e&&(i=null)}function c(e){return!e.sawStart&&e.errorCode===null&&e.pendingRetry===null&&pc(e.transcript)===""&&e.launchedAt-o<oc}function d(e){return e.mode??"none"}function p(e,t){ba(r(),"chat_dictation_completed",{mode:d(e),duration_ms:e.startedAt===null?0:Math.max(0,n()-e.startedAt),char_count:t.length})}function f(e,n){ba(r(),"chat_dictation_failed",{mode:d(e),error:n}),t.onStatus("idle"),t.onError(n)}function h(e){if(a(e.token)===null)return;u(e);let r=pc(e.transcript),n=e.errorCode;if(n!==null&&!(r&&ac(n))){f(e,rc(n));return}if(!r){f(e,"noSpeech");return}p(e,r),t.onStatus("idle")}function b(l){l.subscriptions=[e.addListener("start",()=>{a(l.token)!==null&&(l.sawStart=true,l.startedAt===null&&(l.startedAt=n()),ba(r(),"chat_dictation_started",{mode:d(l)}),t.onStatus("listening"))}),e.addListener("result",e=>{if(a(l.token)===null)return;let r=e?.results?.[0]?.transcript??"";l.transcript=dc(l.transcript,r,e?.isFinal===true),t.onText(pc(l.transcript))}),e.addListener("error",e=>{if(a(l.token)===null)return;let t=e?.error??"unknown";if(l.userStopped&&(t==="aborted"||Ju(t)))return;let r=pc(l.transcript)==="",n=l.mode!==null&&!l.userStopped&&r&&l.retries<ec?tc(l.mode,l.lang,t):null;if(n!==null){l.pendingRetry=n;return}l.errorCode===null&&(l.errorCode=t)}),e.addListener("end",()=>{if(a(l.token)!==null&&!c(l)){if(l.pendingRetry!==null){let e=l.pendingRetry;if(l.pendingRetry=null,l.retries+=1,l.lang=e.lang,e.delayMs<=0){g(l,e.mode);return}s(l),l.retryTimer=setTimeout(()=>{l.retryTimer=null,!(a(l.token)===null||l.userStopped)&&g(l,e.mode)},e.delayMs);return}h(l)}})]}function g(t,r){s(t),t.mode=r,t.sawStart=false,t.launchedAt=n(),t.transcript=uc,t.errorCode=null,b(t);try{e.start(Yu(r,t.lang,t.phrases))}catch{t.errorCode="unknown",h(t)}}async function m(t){let r=await nc(e);if(a(t.token)===null)return;if(r!=="granted"){u(t),f(t,r==="denied"?"permissionDenied":"unavailable");return}if(t.lang=await $u(e,t.lang),a(t.token)===null)return;let n=await qu(e,t.lang);a(t.token)!==null&&(t.autoStopTimer=setTimeout(()=>y(t),lc),g(t,n))}function y(r){if(!(a(r.token)===null||r.userStopped)){if(r.userStopped=true,r.pendingRetry=null,r.mode===null||r.retryTimer!==null){u(r),t.onStatus("idle");return}r.graceTimer=setTimeout(()=>h(r),ic);try{e.stop()}catch{h(r)}}}return{start(e){if(i!==null)return;let r={token:++l,phrases:e,lang:Nu(),mode:null,retries:0,pendingRetry:null,userStopped:false,transcript:uc,errorCode:null,startedAt:null,sawStart:false,launchedAt:0,subscriptions:[],autoStopTimer:null,graceTimer:null,retryTimer:null};i=r,t.onStatus("starting"),m(r)},stop(){i!==null&&y(i)},cancel(){let r=i;if(r===null)return;let l=r.mode!==null&&r.retryTimer===null,a=pc(r.transcript);if(u(r),t.onStatus("idle"),!!l){a&&p(r,a),o=n();try{e.abort()}catch{}}},isActive:()=>i!==null,isPreparing:()=>i!==null&&i.mode===null}}function hc({enabled:t,input:r,setInput:l,phrases:i,maxLength:o,telemetry:a}){let s=e.useSyncExternalStore(Fu,Au,Au),u=e.useMemo(()=>t?Vu():null,[t,s]),c=e.useMemo(()=>Du(u),[u]),[d,p]=e.useState("idle"),[f,h]=e.useState(null),[b,g]=e.useState(0),m=e.useRef(r);m.current=r;let y=e.useRef(l);y.current=l;let v=e.useRef(a);v.current=a;let x=e.useRef(""),w=e.useRef(o);w.current=o;let k=e.useRef(null);u!==null&&k.current?.mod!==u&&(k.current?.controller.cancel(),k.current={mod:u,controller:fc(u,{onStatus:e=>{p(t=>e==="idle"&&t==="error"?t:e)},onText:e=>y.current(pa(x.current,e,w.current)),onError:e=>{h(e),p("error")}},()=>v.current)});let S=u===null?null:k.current?.controller??null,C=e.useCallback(()=>{S?.cancel()},[S]),j=e.useCallback(()=>{if(S!==null){if(S.isActive()){S.stop();return}h(null),g(0),x.current=m.current,S.start(i)}},[S,i]);e.useEffect(()=>{if(d!=="listening")return;let e=Date.now();g(0);let t=setInterval(()=>g(Date.now()-e),1e3);return()=>clearInterval(t)},[d]),e.useEffect(()=>{if(d!=="error")return;let e=setTimeout(()=>{h(null),p("idle")},da);return()=>clearTimeout(e)},[d]),e.useEffect(()=>{if(S===null)return;let e=null;try{e=n.AppState.addEventListener("change",e=>{e==="background"&&!S.isPreparing()&&S.cancel()})}catch{}return()=>{e?.remove(),S.cancel()}},[S]);let R=t&&c;return e.useEffect(()=>{R||S?.cancel()},[R,S]),{supported:R,status:d,active:d==="starting"||d==="listening",error:f,elapsedMs:b,toggle:j,cancel:C}}var bc=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatTabsAsk.v1");function gc(){let t=globalThis;return t[bc]??=e.createContext(null)}var mc=gc();function yc(){return e.useContext(mc)}var vc=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatPaneShown");function xc(){let t=globalThis,r=t[vc];if(r!==void 0)return r;let n=e.createContext(true);return t[vc]=n,n}var wc=xc();function kc(){return e.useContext(wc)}var Sc=/* @__PURE__ */Object.freeze(["photo"]),Cc=52,jc=1.5,Rc=10,Tc=14,_c=10,zc=40,Ic=20,Pc=.3,Ec=2.5,Mc=1,Ac=1.5,Fc=38,Lc=22,Oc=3;function Vc(e,t,r,n="ask",l=false){let i=typeof t=="string"&&t.trim()!=="";return r&&i&&n!=="urgent"?Ie(Te.placeholder,t):e!==null?!l||!e.includes("{pet}")?e:i?e.split("{pet}").join(t.trim()):Ie(Te.placeholder,t):n==="urgent"?Te.placeholderUrgentWeb:n==="followUp"?Te.placeholderFollowUpWeb:Ie(Te.placeholder,t)}function ComposerWithAttachments({attachments:r,...n}){let l=e.useMemo(()=>createRnChatAttachmentTransport(),[]),i=useChatAttachments({maxPerMessage:r.maxPerMessage??Ko,transport:l}),o=e.useMemo(()=>({state:i,sources:r.sources??Sc,pick:r.pick}),[i,r.sources,r.pick]);/* @__PURE__ */
112
+ return t.jsx(Composer,{...n,attachments:o})}function Composer({send:r,stop:l,isStreaming:i,conversationId:conversationId,attachments:o,seed:a,draftStore:s,onStage:u,onPreview:c,petName:d,petBreed:p=null,mood:f="ask",dictation:h=false,telemetry:b=null,compact:g=false,petPlaceholder:m=false,dimEmptySend:y=false}){let{theme:v,styles:x}=xu(),w=yc(),k=g||w!==null,S=e.useMemo(()=>Uc(v),[v]),C=w?.paint.composer??null,j=e.useMemo(()=>Gc(v),[v]),R=so(),[T,_]=ya(r,conversationId,a),[z,I]=e.useState(false),[P,E]=e.useState(false),M=e.useCallback(()=>E(true),[]),A=e.useCallback(()=>E(false),[]),[F,L]=e.useState(false);e.useEffect(()=>{L(false)},[conversationId]);let O=Vc(v.meta.placeholder,d,m,f,v.meta.placeholderFillsPet===true),V=w?.paint.placeholder(O,f!=="ask")??O,D=e.useMemo(()=>ma({name:d,breed:p}),[d,p]),B=hc({enabled:h,input:T,setInput:_,phrases:D,maxLength:$o,telemetry:b}),H=B.cancel,W=B.active;va(s,conversationId===null?null:String(conversationId),T,_,W);let N=e.useRef(conversationId);e.useEffect(()=>{N.current!==conversationId&&(N.current=conversationId,H())},[conversationId,H]);let U=kc();e.useEffect(()=>{U||H()},[U,H]);let $=o?.state.uploading??false,q=o?.state.failed??false,G=$||q,K=o?.state.attachments??Dc;Ro(K.length,R);let Y=e.useCallback(()=>{let e=T.trim();if(e.length===0||G||[...e].length>$o)return;W&&H();let t=o?.state.s3Keys??Bc;o!==null&&t.length>0?(u(o.state.attachments.filter(e=>e.status==="uploaded").map(e=>({uri:e.previewUri,filename:e.filename}))),r(e,{imageS3Keys:t}),o.state.clear()):r(e),_(""),L(false)},[T,r,G,W,H,o,u]),Q=e.useCallback(e=>{W&&H(),_(e)},[W,H,_]),Z=e.useCallback(()=>{l()},[l]),J=e.useCallback(e=>{I(false),o!==null&&(L(false),o.state.dismissRejected(),Or(o.pick,e).then(e=>{if(!e.ok){L(true);return}e.value!==null&&o.state.add(e.value)}))},[o]),X=e.useMemo(()=>[...T.trim()].length>$o,[T]),ee=X||G||T.trim().length===0,te=X||G||y&&T.trim().length===0,re=o!==null&&K.length>=o.state.maxPerMessage,le=v.slots.sendButton?.textColor??v.color.brandInk,ie=v.slots.sendButton?.textColor??v.color.surface;/* @__PURE__ */
113
+ return t.jsxs(n.View,{style:x.composerOuter,children:[o!==null&&z?/* @__PURE__ */t.jsx(AttachmentPickerPopover,{sources:o.sources,full:re,onPick:J,onClose:()=>I(false)}):null,o!==null?/* @__PURE__ */t.jsx(AttachmentStrip,{attachments:K,rejected:F?Nc:o.state.rejected,uploadFailed:q,onRetry:o.state.retry,onRemove:o.state.remove,onPreview:e=>c({uri:e.previewUri,label:e.filename}),style:k?S.tray:j.tray}):null,
114
+ /* @__PURE__ */t.jsxs(n.View,{style:k?[x.composer,S.bar,P?S.barFocused:null,C?.bar]:x.composer,children:[B.supported&&B.error!==null?/* @__PURE__ */t.jsxs(t.Fragment,{children:[
115
+ /* @__PURE__ */t.jsx(Text,{style:x.dictationError,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:ha(B.error)}),
116
+ /* @__PURE__ */t.jsx(AnnounceLine,{line:ha(B.error)})]}):null,
117
+ /* @__PURE__ */t.jsxs(n.View,{style:x.composerRow,children:[o!==null?/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:re?ua(K.length,o.state.maxPerMessage):Te.attachPhotoOrFileNative,accessibilityState:{disabled:re,expanded:z},disabled:re,style:[x.attachControl,k?S.add:null,re?x.attachControlDisabled:null],hitSlop:k?Oc:void 0,onPress:()=>I(e=>!e),children:w!==null?/* @__PURE__ */t.jsx(w.paint.Icon,{name:"upload",size:$c,color:re?v.color.text.muted:w.paint.accent}):/* @__PURE__ */t.jsx(UploadGlyph,{size:k?Lc:Zs,color:re?v.color.text.muted:k?v.color.text.primary:v.color.brandInk,strokeWidth:1.75})}):null,
118
+ /* @__PURE__ */t.jsx(ne,{style:k?[x.input,S.input,C?.input]:x.input,onFocus:M,onBlur:A,value:T,onChangeText:Q,placeholder:V,placeholderTextColor:w?.paint.muted??v.slots.composerInput?.textColor??v.color.text.placeholder,accessibilityLabel:Te.composerLabel,onSubmitEditing:Y,returnKeyType:"send",...Hc,...k?Wc:null,blurOnSubmit:false,multiline:true,editable:true}),B.supported?/* @__PURE__ */t.jsx(DictationButton,{active:B.active,listening:B.status==="listening",elapsedMs:B.elapsedMs,onToggle:B.toggle}):null,i?/* @__PURE__ */t.jsx(n.Pressable,{onPress:Z,accessibilityRole:"button",accessibilityLabel:Te.stop,style:x.sendControl,children:/* @__PURE__ */t.jsx(n.View,{style:k?[S.disc,C?.stopDisc]:x.sendDisc,testID:"everfur-stop-disc",children:/* @__PURE__ */t.jsx(StopGlyph,{size:k?Ic:Ks,color:k?ie:le,testID:"everfur-stop-glyph"})})}):/* @__PURE__ */t.jsx(n.Pressable,{onPress:Y,disabled:ee,accessibilityRole:"button",accessibilityLabel:Te.send,accessibilityState:{disabled:ee,busy:$},style:[x.sendControl,te?k?S.dimmed:x.sendControlDisabled:null],children:w!==null&&C!==null?/* @__PURE__ */t.jsx(n.View,{style:C.send,testID:"everfur-send-disc",children:/* @__PURE__ */t.jsx(w.paint.Icon,{name:"send",size:qc,color:w.paint.accent})}):k?/* @__PURE__ */t.jsx(n.View,{style:S.disc,testID:"everfur-send-disc",children:/* @__PURE__ */t.jsx(ArrowUpGlyph,{size:Ic,color:ie,strokeWidth:2.25,testID:"everfur-send-arrow"})}):/* @__PURE__ */t.jsx(n.View,{style:x.sendDisc,testID:"everfur-send-disc",children:/* @__PURE__ */t.jsx(SendGlyph,{size:Gs,color:le,testID:"everfur-send-glyph"})})})]})]})]})}var Dc=/* @__PURE__ */Object.freeze([]),Bc=/* @__PURE__ */Object.freeze([]),Hc=/* @__PURE__ */Object.freeze({submitBehavior:"submit"}),Wc=/* @__PURE__ */Object.freeze(n.Platform.OS==="web"?{rows:1}:{}),Nc=/* @__PURE__ */Object.freeze({code:"unknown",retryable:true,filename:""});function Uc(e){let t=e.color,r=e.slots.sendButton,l=textRole(e,"body").fontSize+Mc;return n.StyleSheet.create({bar:{marginTop:Rc,marginHorizontal:Tc,marginBottom:_c,minHeight:Cc,paddingLeft:8,paddingRight:6,paddingVertical:0,borderWidth:jc,borderColor:e.slots.composerInput?.borderColor??t.text.primary},barFocused:{borderWidth:Ec,paddingLeft:8-(Ec-jc),paddingRight:6-(Ec-jc)},input:{fontSize:l,lineHeight:Math.round(l*Ac),minHeight:Math.round(l*Ac),...n.Platform.OS==="web"?{outlineStyle:"none"}:null},add:{width:Fc,height:Fc,borderRadius:Fc/2},disc:{width:zc,height:zc,borderRadius:zc/2,alignItems:"center",justifyContent:"center",backgroundColor:r?.backgroundColor??t.text.primary,...Oo(r)},dimmed:{opacity:Pc},tray:{marginHorizontal:Tc,marginTop:Rc,paddingBottom:0}})}var $c=20,qc=22;function Gc(e){return n.StyleSheet.create({tray:{marginHorizontal:e.space.md,marginTop:e.space.xs,paddingBottom:0}})}var Kc=/* @__PURE__ */new WeakMap;function Yc(e,t){let r=Kc.get(e);return r===void 0&&(r=/* @__PURE__ */new Set,Kc.set(e,r)),r.add(t),()=>{r?.delete(t)}}function useEverfurPets(){let{runtime:t,userRef:userRef,activePet:r,scopeEpoch:n}=Le(),l=e.useMemo(()=>createPetsRepository(t.registry.services.authFor(userRef)),[t,userRef,n]),[i,o]=e.useState({repository:l,pets:[],loading:true,error:null}),a=i.repository===l?i:{pets:[],loading:true,error:null},s=e.useRef(0),u=e.useCallback(async()=>{let e=++s.current;o(e=>({...e,repository:l,loading:true,error:null,pets:e.repository===l?e.pets:[]}));let t=await l.list();e===s.current&&o(t.ok?{repository:l,pets:t.value,loading:false,error:null}:e=>({repository:l,pets:e.repository===l?e.pets:[],loading:false,error:t.error}))},[l]);e.useEffect(()=>(u(),()=>{s.current+=1}),[u]),e.useEffect(()=>Yc(t,()=>{u()}),[t,u]);let c=e.useMemo(()=>r===null?null:a.pets.find(e=>e.petRef===r)??null,[r,a.pets]);return e.useMemo(()=>({pets:a.pets,activePet:c,loading:a.loading,error:a.error,refresh:u}),[a.pets,a.loading,a.error,c,u])}function Qc(e,t){if(t!==null){let r=e.find(e=>e.petRef===t);if(r!==void 0)return r}return e[0]??null}var Zc=/* @__PURE__ */Object.freeze({visitButton:"Vet"});var Jc=false;function Xc(e,t){return t!==void 0?(Ar(t,e),"onStartInApp"):h(e)==="presented"?"presenter":y(e)?"experience":(Jc||(Jc=true,console.warn("[everfur] A vet visit had nowhere to open: mount <EverfurTelevetHost /> in your EverfurProvider, or pass prefer: 'redirect'.")),null)}var ed=/* @__PURE__ */Object.freeze(["visit","join","summary","messages"]);function isVetVisitIntent(e){return typeof e=="string"&&ed.includes(e)}var td="/widget/v1/televet/handoffs",rd="/widget/v1/televet/availability",nd="/widget/v1/televet/chat-entry",ld=/^[a-z0-9][a-z0-9_-]{0,39}$/,id=/^[A-Za-z0-9_-]{22}$/;var od=32,ad=128,sd=64;function vetVisitErrorReasonOf(e){let t=e.httpStatus;switch(e.code){case"sessionRequired":return"sessionRequired";case"authExpired":case"authRejected":return"authRejected";case"sdkUpdateRequired":return"sdkUpdateRequired";case"validationFailed":return"invalidRequest";case"rateLimited":case"quotaExceeded":return"rateLimited"}return t===void 0?e.code==="internalError"?"network":"unknown":t===429?"rateLimited":t===404?"unavailable":t===403?"accessDenied":t===401?"authRejected":t===400||t===422?"invalidRequest":t>=500?"serverError":"unknown"}function ud(e){return err(makeEverfurError("validationFailed",{retryable:false,wireMessage:e}))}function cd(e){return err(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:e}))}function dd(petRef,e){let t={};petRef!==void 0&&(t.pet_ref=petRef);let r=e?.returnTo;if(r!=null){if(typeof r!="string"||!ld.test(r))return{ok:false,message:"returnTo must be a registered return destination key"};t.return_to=r}let n=e?.entry;if(n!=null){if(n!=="chat"||petRef===void 0)return{ok:false,message:"entry 'chat' needs the pet the chat is about"};t.entry=n}let l=e?.visitRef,i=e?.intent,o=l!=null;if(o){let e=typeof l=="string"?l.trim():"";if(e.length<1||[...e].length>sd)return{ok:false,message:`visitRef must be 1..${sd} characters`};t.visit_ref=e}if(i!=null){if(!o)return{ok:false,message:"intent needs the visitRef it opens"};if(!isVetVisitIntent(i))return{ok:false,message:`intent must be one of ${ed.join(", ")}`};t.intent=i}return{ok:true,body:t}}function pd(e){if(typeof e!="object"||e===null)return null;let{visit_ref:t,intent:r}=e;return typeof t!="string"||t.length===0||!isVetVisitIntent(r)?null:/* @__PURE__ */Object.freeze({visitRef:t,intent:r})}function fd(e){let t=e.funnel??createRequestFunnel({auth:e.auth,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}}),r=e.telemetry,n=e=>(vd(r,"televet.visit.handoff_failed",{reason:vetVisitErrorReasonOf(e)}),err(e));return{async createHandoff(petRef,e){let l;if(petRef!=null){let e=typeof petRef=="string"?[...petRef].length:0;if(e<1||e>ad)return n(makeEverfurError("validationFailed",{retryable:false,wireMessage:`pet_ref must be 1..${ad} characters`}));l=petRef}let i=dd(l,e);if(!i.ok){let e=ud(i.message);return e.ok?e:n(e.error)}let o=i.body,a=await t.send("televet.visit.handoff",{method:"POST",path:td,body:o},{idempotent:false,maxAttempts:1});if(!a.ok)return n(a.error);let s=hd(a.value),u=o.return_to!==void 0,c=u?a.value?.flow_id:void 0;if(u&&(typeof c!="string"||!id.test(c))){let e=cd("the handoff response carried no usable return flow id");return e.ok?e:n(e.error)}let d=o.visit_ref!==void 0,p=d?pd(a.value?.visit):null;if(d&&p===null){let e=cd("the handoff response did not confirm the visit it opens");return e.ok?e:n(e.error)}let f=s===null?null:/* @__PURE__ */Object.freeze({...s,...u?{flowId:c}:{},...p!==null?{visit:p}:{}});return f===null?n(makeEverfurError("internalError",{retryable:false,httpStatus:502,wireMessage:"the handoff response carried no usable visit url"})):(vd(r,"televet.visit.handoff_created",{pet_scoped:o.pet_ref!==void 0}),ok(f))},async checkAvailability(e){if(typeof e!="string"||e.length>od)return ud(`state must be at most ${od} characters`);let r=await t.send("televet.visit.availability",{method:"POST",path:rd,body:{state:e}},{idempotent:false,maxAttempts:1});if(!r.ok)return err(r.error);let n=r.value?.available;return typeof n!="boolean"?cd("the availability response carried no usable answer"):ok(/* @__PURE__ */Object.freeze({available:n}))},async chatEntryOpen(){try{let e=await t.send("televet.visit.chat_entry",{method:"GET",path:nd},{maxAttempts:1});return e.ok&&e.value?.open===!0}catch{return false}}}}function hd(e){if(typeof e!="object"||e===null)return null;let{url:t,expires_at:r}=e;return typeof t!="string"||typeof r!="string"||r.length===0||!yd(t)?null:/* @__PURE__ */Object.freeze({url:t,expiresAt:r})}var bd=/* @__PURE__ */new Set(["localhost","127.0.0.1","[::1]"]),gd=/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)/,md=/[\s\u0000-\u001f\u007f]/;function yd(e){if(md.test(e))return false;let t=gd.exec(e);if(t===null)return false;let r=(t[1]??"").toLowerCase(),n=t[2]??"";if(n.length===0||n.includes("@"))return false;let l=n.replace(/:\d+$/,"").toLowerCase(),i=r==="https",o=r==="http"&&bd.has(l);if(!i&&!o)return false;let a=e.indexOf("#");if(a<0)return false;let s=e.slice(a);return s.startsWith("#h=")&&s.length>3}function vd(e,t,r){if(e)try{e.track(t,r)}catch{}}var xd=/* @__PURE__ */Object.freeze({status:"idle",error:null,errorReason:null});function wd(t,r,n){let{usState:l,chat:i,scope:o}=n,a=r&&(l!==null||i),s=`${l??""}|${i?"chat":""}`,[u,c]=e.useState(null);if(e.useEffect(()=>{if(!a)return;let e=true,r=t.current;return c(null),(async()=>{try{if(i&&!(r.chatEntryOpen&&await r.chatEntryOpen()))return!1;if(l===null)return!0;if(!r.checkAvailability)return!1;let e=await r.checkAvailability(l);return e.ok&&e.value.available}catch{return false}})().then(t=>{e&&c({key:s,open:t})}),()=>{e=false}},[a,s,l,i,o,t]),!a)return null;let d=u!==null&&u.key===s;return{open:d&&u.open,pending:!d}}var kd=/* @__PURE__ */Object.freeze({status:"opening",error:null,errorReason:null});function Sd(t,r={}){let{runtime:n,userRef:userRef,scopeEpoch:l}=Le(),i=useCapability("televet"),o=i.enabled&&userRef!==null,a=r.usState??null,s=r.entry==="chat",u=r.petRef??null,c=r.prefer==="redirect",d=e.useMemo(()=>{if(r.controller)return r.controller;let{services:e}=n.registry;return fd({auth:e.authFor(userRef),telemetry:e.telemetry,...e.errorPolicy?{errorPolicy:e.errorPolicy}:{}})},[n,userRef,l,r.controller]),p=e.useRef(d);p.current=d;let f=e.useMemo(()=>({runtime:n,userRef:userRef,scopeEpoch:l}),[n,userRef,l]),h=wd(p,o,{usState:a,chat:s,scope:f}),b=o&&(h===null||h.open)&&(!s||u!==null),g=r.returnTo??null,[m,y]=e.useState(xd),v=e.useRef(null),x=e.useRef({runtime:n,userRef:userRef,scopeEpoch:l});x.current={runtime:n,userRef:userRef,scopeEpoch:l};let w=e.useRef(d);w.current=d;let k=e.useRef(b);k.current=b;let S=e.useCallback((petRef,e)=>{if(v.current)return v.current;let r=(e,t)=>(y({status:e==="cancelled"?"idle":"error",error:t,errorReason:e==="cancelled"?null:e}),/* @__PURE__ */Object.freeze({opened:false,reason:e,error:t}));if(!k.current)return Promise.resolve(r("unavailable",null));let n=t.prepare();if(!n.ok)return Promise.resolve(r(n.reason,null));let l=x.current,i=w.current;y(kd);let o=(async()=>{let o,a={...g!==null?{returnTo:g}:{},...s?{entry:"chat"}:{},...e!==null?{visitRef:e.visitRef}:{},...e!==null&&e.intent!==null&&e.intent!==void 0?{intent:e.intent}:{}},c=Object.keys(a).length===0?void 0:a,d=petRef===void 0?u:petRef;try{o=await(c===void 0?i.createHandoff(d):i.createHandoff(d,c))}catch{return t.abandon(n.value),r("unknown",null)}let p=x.current;if(p.runtime!==l.runtime||p.userRef!==l.userRef||p.scopeEpoch!==l.scopeEpoch)return t.abandon(n.value),r("cancelled",null);if(!o.ok)return t.abandon(n.value),r(vetVisitErrorReasonOf(o.error),o.error);let f=await t.finish(n.value,o.value);return f!==null?r(f,null):(y(xd),/* @__PURE__ */Object.freeze(o.value.flowId===void 0?{opened:true}:{opened:true,flowId:o.value.flowId}))})().finally(()=>{v.current===o&&(v.current=null)});return v.current=o,o},[t,u,g,s]),C=e.useCallback((petRef,e)=>{if(!k.current)return y({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}));let t=petRef===void 0?u:petRef,r={...t!==null?{petRef:t}:{},...a!==null?{usState:a}:{},...e!==null&&"consultId"in e?{consultId:e.consultId}:{},...e!==null&&"visitRef"in e?{visitRef:e.visitRef,intent:e.intent}:{}};return Xc(r)===null?(y({status:"error",error:null,errorReason:"unavailable"}),Promise.resolve(/* @__PURE__ */Object.freeze({opened:false,reason:"unavailable",error:null}))):(y(xd),Promise.resolve(/* @__PURE__ */Object.freeze({opened:true})))},[u,a]),j=e.useCallback(petRef=>c?S(petRef,null):C(petRef,null),[c,S,C]),R=e.useCallback((e,t)=>c?S(void 0,{visitRef:e,intent:t??null}):C(void 0,{visitRef:e,intent:t??null}),[c,S,C]),T=e.useCallback(e=>c?S(void 0,null):C(void 0,{consultId:e.trim()}),[c,S,C]);return{available:b,isPending:i.isPending||(h?.pending??false),status:m.status,error:m.error,errorReason:m.errorReason,open:j,openVisit:R,joinVisit:T}}var Cd=e=>n.Linking.openURL(e);function useVetVisit(t={}){let{openUrl:r,...n}=t,l=e.useMemo(()=>{let e=r??Cd;return{prepare:()=>({ok:true,value:null}),async finish(t,r){try{return await e(r.url),null}catch{return"openFailed"}},abandon:()=>{}}},[r]);return Sd(l,n)}var jd=44,Rd=.6;function VetVisitButtonCore(r){let{petRef:petRef,label:l,openUrl:i,onOpened:o,onError:a,style:s,labelStyle:u,controller:c,returnTo:d,usState:p,entry:f,visitRef:h,intent:b,onStartInApp:g,prefer:m}=r,y=m==="redirect",v=useVetVisit({...d!==void 0?{returnTo:d}:{},...p!==void 0?{usState:p}:{},...f!==void 0?{entry:f}:{},...petRef!==void 0?{petRef:petRef}:{},...i!==void 0?{openUrl:i}:{},...c!==void 0?{controller:c}:{},prefer:y?"redirect":"in-app"}),x=useEverfurTheme(),w=e.useMemo(()=>Td(x),[x]),k=e.useRef(false);if(!v.available)/* @__PURE__ */
118
119
  return t.jsxs(t.Fragment,{children:[null,
119
- /* @__PURE__ */t.jsx(TelevetHostOutlet,{})]});let S=v.status==="opening",C=l??Nc.visitButton;/* @__PURE__ */
120
+ /* @__PURE__ */t.jsx(TelevetHostOutlet,{})]});let S=v.status==="opening",C=l??Zc.visitButton;/* @__PURE__ */
120
121
  return t.jsxs(t.Fragment,{children:[
121
- /* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>{if(!(S||k.current)){if(!y){let e={...petRef!==void 0?{petRef:petRef}:{},...p!==void 0?{usState:p}:{},...h!=null?{visitRef:h,intent:b??null}:{}};$c(e,g)===null&&Er(a,"unavailable",null);return}k.current=true,(h==null?v.open():v.openVisit(h,b??null)).then(e=>{e.opened?Er(o,e.flowId??null):e.reason!=="cancelled"&&Er(a,e.reason,e.error)}).finally(()=>{k.current=false})}},accessibilityRole:"button",accessibilityLabel:C,accessibilityState:{busy:S,disabled:S},style:[w.button,S?w.busy:null,s],children:/* @__PURE__ */t.jsx(Text,{style:[w.label,u],children:C})}),
122
- /* @__PURE__ */t.jsx(TelevetHostOutlet,{})]})}function vd(e){let{color:t,space:r,radius:l,type:i,slots:o}=e;return n.StyleSheet.create({button:{minHeight:md,minWidth:md,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:l.pill,backgroundColor:t.primary,...Ao(o.vetVisitButton)},busy:{opacity:yd},label:{...face(e,"medium"),color:t.onPrimary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.snug,...Oo(o.vetVisitButton)}})}function xd(t){let[r,n]=e.useState(null);return{shown:t!==null&&r!==t,onError:()=>n(t)}}function BrandImage({uri:e,label:r,decorative:l=false,style:i,resizeMode:o="contain",fallback:a=null,onError:s,testID:u}){let c=xd(e);if(e===null||!c.shown)return a;let d=l?{accessible:false,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}:{accessible:true,accessibilityRole:"image",...r===void 0?{}:{accessibilityLabel:r}};/* @__PURE__ */
123
- return t.jsx(n.Image,{source:{uri:e},style:i,resizeMode:o,...d,onError:()=>{c.onError(),s?.()},...u===void 0?{}:{testID:u}})}function BrandLogo({logoUrl:e,name:r,barStyle:l,logoStyle:i,testID:o}){let a=xd(e);return e===null||!a.shown?null:/* @__PURE__ */t.jsx(n.View,{style:l,...o===void 0?{}:{testID:o},children:/* @__PURE__ */t.jsx(n.Image,{source:{uri:e},style:i,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:r,onError:a.onError})})}var wd=/* @__PURE__ */Object.freeze({row:null,leading:null,trailing:null}),kd=/* @__PURE__ */Object.freeze({leading:void 0,trailing:void 0});function Sd(e,t,r){if(e.row===null||e.leading===null||e.trailing===null)return kd;let n=Math.abs(e.leading-e.trailing);if(n<.5)return kd;let l=e.row-t-e.leading-e.trailing,i=Math.min(n,Math.max(0,l-r));return i<.5?kd:e.leading<e.trailing?{leading:e.leading+i,trailing:void 0}:{leading:void 0,trailing:e.trailing+i}}function Cd(e,t,r){let n=e[t];return n!==null&&Math.abs(n-r)<.5?e:{...e,[t]:r}}function jd(e){return[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}function Rd(e){if(e.brightness!=="light")return false;let t=Q.color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t),l=new Set(jd(t));return n(r.brand,t.brand)&&n(r.accent,t.accent)&&jd(r).every(e=>l.has(e))}function Td(e){let t=(e.brightness==="dark"?J:Q).color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t);return{success:!n(r.success,t.success),warning:!n(r.warningStrong,t.warningStrong)||!n(r.cautionAccent,t.cautionAccent),info:!(n(r.info,r.brandInk)&&n(r.badgeBgInfo,r.brandSoft)&&n(r.infoEdge,r.structureEdge))}}function _d(e){return canonicalPetSpecies(e)==="cat"?"cat":"dog"}function zd(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}function Id(e){let t=zd(e.ageYears),r=_d(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return`${r} · ${n}`}var Pd=/* @__PURE__ */Object.freeze([
122
+ /* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>{if(!(S||k.current)){if(!y){let e={...petRef!==void 0?{petRef:petRef}:{},...p!==void 0?{usState:p}:{},...h!=null?{visitRef:h,intent:b??null}:{}};Xc(e,g)===null&&Ar(a,"unavailable",null);return}k.current=true,(h==null?v.open():v.openVisit(h,b??null)).then(e=>{e.opened?Ar(o,e.flowId??null):e.reason!=="cancelled"&&Ar(a,e.reason,e.error)}).finally(()=>{k.current=false})}},accessibilityRole:"button",accessibilityLabel:C,accessibilityState:{busy:S,disabled:S},style:[w.button,S?w.busy:null,s],children:/* @__PURE__ */t.jsx(Text,{style:[w.label,u],children:C})}),
123
+ /* @__PURE__ */t.jsx(TelevetHostOutlet,{})]})}function Td(e){let{color:t,space:r,radius:l,type:i,slots:o}=e;return n.StyleSheet.create({button:{minHeight:jd,minWidth:jd,alignItems:"center",justifyContent:"center",paddingHorizontal:r.xl,paddingVertical:r.sm,borderRadius:l.pill,backgroundColor:t.primary,...Oo(o.vetVisitButton)},busy:{opacity:Rd},label:{...face(e,"medium"),color:t.onPrimary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.snug,...Do(o.vetVisitButton)}})}function _d(t){let[r,n]=e.useState(null);return{shown:t!==null&&r!==t,onError:()=>n(t)}}function BrandImage({uri:e,label:r,decorative:l=false,style:i,resizeMode:o="contain",fallback:a=null,onError:s,testID:u}){let c=_d(e);if(e===null||!c.shown)return a;let d=l?{accessible:false,accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants"}:{accessible:true,accessibilityRole:"image",...r===void 0?{}:{accessibilityLabel:r}};/* @__PURE__ */
124
+ return t.jsx(n.Image,{source:{uri:e},style:i,resizeMode:o,...d,onError:()=>{c.onError(),s?.()},...u===void 0?{}:{testID:u}})}function BrandLogo({logoUrl:e,name:r,barStyle:l,logoStyle:i,testID:o}){let a=_d(e);return e===null||!a.shown?null:/* @__PURE__ */t.jsx(n.View,{style:l,...o===void 0?{}:{testID:o},children:/* @__PURE__ */t.jsx(n.Image,{source:{uri:e},style:i,resizeMode:"contain",accessible:true,accessibilityRole:"image",accessibilityLabel:r,onError:a.onError})})}var zd=/* @__PURE__ */Object.freeze({row:null,leading:null,trailing:null}),Id=/* @__PURE__ */Object.freeze({leading:void 0,trailing:void 0});function Pd(e,t,r){if(e.row===null||e.leading===null||e.trailing===null)return Id;let n=Math.abs(e.leading-e.trailing);if(n<.5)return Id;let l=e.row-t-e.leading-e.trailing,i=Math.min(n,Math.max(0,l-r));return i<.5?Id:e.leading<e.trailing?{leading:e.leading+i,trailing:void 0}:{leading:void 0,trailing:e.trailing+i}}function Ed(e,t,r){let n=e[t];return n!==null&&Math.abs(n-r)<.5?e:{...e,[t]:r}}function Md(e){return[e.surface,e.surfaceCream,e.surfaceSubtle,e.background,e.chatGround,e.composerFill]}function Ad(e){if(e.brightness!=="light")return false;let t=Q.color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t),l=new Set(Md(t));return n(r.brand,t.brand)&&n(r.accent,t.accent)&&Md(r).every(e=>l.has(e))}function Fd(e){let t=(e.brightness==="dark"?J:Q).color,r=e.color,n=(e,t)=>parseColor(e)===parseColor(t);return{success:!n(r.success,t.success),warning:!n(r.warningStrong,t.warningStrong)||!n(r.cautionAccent,t.cautionAccent),info:!(n(r.info,r.brandInk)&&n(r.badgeBgInfo,r.brandSoft)&&n(r.infoEdge,r.structureEdge))}}function Ld(e){return canonicalPetSpecies(e)==="cat"?"cat":"dog"}function Od(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:Math.floor(e)}function Vd(e){let t=Od(e.ageYears),r=Ld(e.species)==="cat"?"Cat":"Dog";if(t==null)return r;let n=t===1?"1 yr":`${t} yrs`;return`${r} · ${n}`}var Dd=/* @__PURE__ */Object.freeze([
124
125
  /* @__PURE__ */Object.freeze({background:"#ffbdbd",foreground:"#6d1d14"}),
125
126
  /* @__PURE__ */Object.freeze({background:"#a0c4f6",foreground:"#0b3a73"}),
126
127
  /* @__PURE__ */Object.freeze({background:"#fbc558",foreground:"#10462e"}),
127
128
  /* @__PURE__ */Object.freeze({background:"#bde7c5",foreground:"#0e3b22"}),
128
129
  /* @__PURE__ */Object.freeze({background:"#dcc7f4",foreground:"#3a1d6a"}),
129
- /* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function Ed(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Pd[t%Pd.length]}function Md(e){let t=(e??"").trim();return(Array.from(t)[0]??"?").toUpperCase()}function Fd(e){return{...Ed(e.petRef),initial:Md(e.name)}}function Ad(e,t,r){let n=Fd(e);return t?n:{background:r.fill,foreground:r.ink,initial:n.initial}}function Ld(e){return Math.max(12,Math.round(e*.42))}function PetDisc({pet:r,size:l,ringStroke:i}){let o=useEverfurTheme(),a=e.useMemo(()=>Od(o),[o]),s=l-i*2,u=r===null?null:Ad(r,Rd(o),{fill:o.color.highlight,ink:o.color.onHighlight}),c=Ld(s);/* @__PURE__ */
130
- return t.jsx(Ring,{size:l,strokeWidth:i,color:o.color.mark,children:/* @__PURE__ */t.jsx(n.View,{style:[a.disc,{width:s,height:s,borderRadius:s/2},u===null?a.discEmpty:{backgroundColor:u.background}],children:/* @__PURE__ */t.jsx(Text,{tier:"badge",style:[a.letter,{fontSize:c,lineHeight:Math.round(c*1.2),color:u===null?o.color.text.muted:u.foreground}],children:u===null?Md(null):u.initial})})})}function Od(e){return n.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...face(e,"bold"),textAlign:"center",includeFontPadding:false}})}function Vd(e,t){let{borderRadius:r,...n}=Ao(e,t);return r===void 0?n:{...n,borderTopLeftRadius:r,borderTopRightRadius:r}}function Dd(e,t){let{backgroundColor:r,borderColor:n,borderWidth:l,borderRadius:i}=Ao(e,t);return{...r===void 0?{}:{backgroundColor:r},...n===void 0?{}:{borderRightColor:n,borderRightWidth:l??1},...i===void 0?{}:{borderTopRightRadius:i,borderBottomRightRadius:i}}}var Bd=48,Hd=2,Wd=320,Nd="80%",Ud="rgba(17,17,17,0.45)",$d=18,qd=22,Gd=12,Kd=.4,Yd=44;function Qd(e){return e?.name?.trim()||je.yourPet}function PetSwitcherSheet({visible:r,pets:l,activePetRef:i,onSelect:o,onAddPet:a=null,onClose:s}){let u=useEverfurTheme(),c=e.useMemo(()=>Zd(u),[u]),d=de();return r?/* @__PURE__ */t.jsx(n.Modal,{visible:true,transparent:true,animationType:u.motion.reducedMotion?"none":"fade",onRequestClose:s,children:/* @__PURE__ */t.jsxs(n.View,{style:c.root,children:[
131
- /* @__PURE__ */t.jsx(n.Pressable,{style:Za,onPress:s,accessibilityRole:"button",accessibilityLabel:je.close,children:/* @__PURE__ */t.jsx(n.View,{style:c.backdrop})}),
130
+ /* @__PURE__ */Object.freeze({background:"#ffd8a8",foreground:"#5a2a04"})]);function Bd(e){let t=0;for(let r=0;r<e.length;r+=1)t=t*31+e.charCodeAt(r)>>>0;return Dd[t%Dd.length]}function Hd(e){let t=(e??"").trim();return(Array.from(t)[0]??"?").toUpperCase()}function Wd(e){return{...Bd(e.petRef),initial:Hd(e.name)}}function Nd(e,t,r){let n=Wd(e);return t?n:{background:r.fill,foreground:r.ink,initial:n.initial}}function Ud(e){return Math.max(12,Math.round(e*.42))}function PetDisc({pet:r,size:l,ringStroke:i}){let o=useEverfurTheme(),a=e.useMemo(()=>$d(o),[o]),s=l-i*2,u=r===null?null:Nd(r,Ad(o),{fill:o.color.highlight,ink:o.color.onHighlight}),c=Ud(s);/* @__PURE__ */
131
+ return t.jsx(Ring,{size:l,strokeWidth:i,color:o.color.mark,children:/* @__PURE__ */t.jsx(n.View,{style:[a.disc,{width:s,height:s,borderRadius:s/2},u===null?a.discEmpty:{backgroundColor:u.background}],children:/* @__PURE__ */t.jsx(Text,{tier:"badge",style:[a.letter,{fontSize:c,lineHeight:Math.round(c*1.2),color:u===null?o.color.text.muted:u.foreground}],children:u===null?Hd(null):u.initial})})})}function $d(e){return n.StyleSheet.create({disc:{alignItems:"center",justifyContent:"center",overflow:"hidden"},discEmpty:{backgroundColor:e.color.brandSoft},letter:{...face(e,"bold"),textAlign:"center",includeFontPadding:false}})}function qd(e,t){let{borderRadius:r,...n}=Oo(e,t);return r===void 0?n:{...n,borderTopLeftRadius:r,borderTopRightRadius:r}}function Gd(e,t){let{backgroundColor:r,borderColor:n,borderWidth:l,borderRadius:i}=Oo(e,t);return{...r===void 0?{}:{backgroundColor:r},...n===void 0?{}:{borderRightColor:n,borderRightWidth:l??1},...i===void 0?{}:{borderTopRightRadius:i,borderBottomRightRadius:i}}}var Kd=48,Yd=2,Qd=320,Zd="80%",Jd="rgba(17,17,17,0.45)",Xd=18,ep=22,tp=12,rp=.4,np=44;function lp(e){return e?.name?.trim()||Te.yourPet}function PetSwitcherSheet({visible:r,pets:l,activePetRef:i,onSelect:o,onAddPet:a=null,onClose:s}){let u=useEverfurTheme(),c=e.useMemo(()=>ip(u),[u]),d=de();return r?/* @__PURE__ */t.jsx(n.Modal,{visible:true,transparent:true,animationType:u.motion.reducedMotion?"none":"fade",onRequestClose:s,children:/* @__PURE__ */t.jsxs(n.View,{style:c.root,children:[
132
+ /* @__PURE__ */t.jsx(n.Pressable,{style:Xa,onPress:s,accessibilityRole:"button",accessibilityLabel:Te.close,children:/* @__PURE__ */t.jsx(n.View,{style:c.backdrop})}),
132
133
  /* @__PURE__ */t.jsxs(n.View,{style:pe(c.panel,d),accessibilityViewIsModal:true,children:[
133
- /* @__PURE__ */t.jsx(Text,{tier:"heading",style:c.title,accessibilityRole:"header",children:je.yourPets}),
134
- /* @__PURE__ */t.jsx(n.ScrollView,{style:c.list,contentContainerStyle:c.listContent,showsVerticalScrollIndicator:true,children:l.map(e=>{let r=e.petRef===i,l=Qd(e),a=Id(e);/* @__PURE__ */
135
- return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:Re(r?je.petCurrentlyActive:je.switchToPet,{name:l}),accessibilityState:{selected:r},style:[c.row,r?c.rowActive:null],onPress:()=>o(e.petRef),children:[
136
- /* @__PURE__ */t.jsx(PetDisc,{pet:e,size:Bd,ringStroke:Hd}),
134
+ /* @__PURE__ */t.jsx(Text,{tier:"heading",style:c.title,accessibilityRole:"header",children:Te.yourPets}),
135
+ /* @__PURE__ */t.jsx(n.ScrollView,{style:c.list,contentContainerStyle:c.listContent,showsVerticalScrollIndicator:true,children:l.map(e=>{let r=e.petRef===i,l=lp(e),a=Vd(e);/* @__PURE__ */
136
+ return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:_e(r?Te.petCurrentlyActive:Te.switchToPet,{name:l}),accessibilityState:{selected:r},style:[c.row,r?c.rowActive:null],onPress:()=>o(e.petRef),children:[
137
+ /* @__PURE__ */t.jsx(PetDisc,{pet:e,size:Kd,ringStroke:Yd}),
137
138
  /* @__PURE__ */t.jsxs(n.View,{style:c.copy,children:[
138
139
  /* @__PURE__ */t.jsx(Text,{style:c.name,numberOfLines:1,children:l}),
139
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:c.meta,numberOfLines:1,children:r?`${je.activePrefix}${a}`:a})]}),r?/* @__PURE__ */t.jsx(CheckGlyph,{size:$d,color:u.color.brandInk}):null]},e.petRef)})}),a!==null?/* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:je.addAnotherPet,style:c.addRow,onPress:a,children:[
140
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:c.meta,numberOfLines:1,children:r?`${Te.activePrefix}${a}`:a})]}),r?/* @__PURE__ */t.jsx(CheckGlyph,{size:Xd,color:u.color.brandInk}):null]},e.petRef)})}),a!==null?/* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:Te.addAnotherPet,style:c.addRow,onPress:a,children:[
140
141
  /* @__PURE__ */t.jsx(n.View,{style:c.addDisc,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:c.addPlus,children:"+"})}),
141
- /* @__PURE__ */t.jsx(Text,{style:c.addLabel,children:je.addAnotherPet})]}):null,
142
- /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:je.close,containerStyle:c.closeSlot,style:c.closeButton,onPress:s,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:c.closeText,children:je.close})})]})]})}):null}function Zd(e){let t=e.color,r=e.radius,l=Oo(e.slots.dialog);return n.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:Ud},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:qd,borderTopRightRadius:qd,gap:14,maxHeight:Nd,...Vd(e.slots.dialog)},title:{...headingFace(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk,...l},list:{maxHeight:Wd,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:Yd,paddingHorizontal:8},addDisc:{width:Bd,height:Bd,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Hd,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...face(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...face(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary,...l},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:r.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},rowActive:{borderColor:t.brandInk,backgroundColor:t.brandSoft},copy:{flex:1,gap:2},name:{...face(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...face(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:Kd},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:Gd,backgroundColor:t.brandSoft},closeText:{...face(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:Kd}})}var Jd=44,Xd=36,ep=22,tp=20,rp=9,np=1.5,lp=6,ip=35,op=1.75,ap=12.4,sp=.5,up=8,cp=28,dp=160,pp=16,fp=8;function hp(e,petRef){return Wc(e,petRef)}function ChatHeader({pets:r,petRef:petRef,historyUnread:l,onOpenHistory:i,onNewChat:o,onPetChange:a,onAddPet:s,vet:u,textingEntry:c=null}){let d=useEverfurTheme(),p=e.useMemo(()=>bp(d),[d]),[f,h]=e.useState(false),b=hp(r.pets,petRef),g=b!==null&&(r.pets.length>=2||s!==void 0),m=petRef??b?.petRef??null,y=Qd(b),[v,x]=e.useState(wd),w=e.useCallback(e=>t=>{let r=t.nativeEvent.layout.width;x(t=>Cd(t,e,r))},[]),k=e.useMemo(()=>w("row"),[w]),S=e.useMemo(()=>w("leading"),[w]),C=e.useMemo(()=>w("trailing"),[w]),j=2*pp+2*(d.slots.header?.borderColor!==void 0?1:0)+2*fp,R=Sd(v,j,dp),T=e=>{h(false),r.setActivePet(e),Er(a,e)},_=s===void 0?null:()=>{h(false),Er(s)};/* @__PURE__ */
142
+ /* @__PURE__ */t.jsx(Text,{style:c.addLabel,children:Te.addAnotherPet})]}):null,
143
+ /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Te.close,containerStyle:c.closeSlot,style:c.closeButton,onPress:s,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:c.closeText,children:Te.close})})]})]})}):null}function ip(e){let t=e.color,r=e.radius,l=Do(e.slots.dialog);return n.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{flex:1,backgroundColor:Jd},panel:{backgroundColor:t.surface,paddingHorizontal:20,paddingTop:20,paddingBottom:32,borderTopLeftRadius:ep,borderTopRightRadius:ep,gap:14,maxHeight:Zd,...qd(e.slots.dialog)},title:{...headingFace(e,"bold"),fontSize:18,lineHeight:22,color:t.brandInk,...l},list:{maxHeight:Qd,flexShrink:1},listContent:{gap:10},addRow:{flexDirection:"row",alignItems:"center",gap:12,minHeight:np,paddingHorizontal:8},addDisc:{width:Kd,height:Kd,borderRadius:r.pill,alignItems:"center",justifyContent:"center",borderWidth:Yd,borderStyle:"dashed",borderColor:t.brandBorder,backgroundColor:t.surfaceCream},addPlus:{...face(e,"bold"),fontSize:20,lineHeight:22,color:t.brandInk},addLabel:{...face(e,"bold"),fontSize:15,lineHeight:20,color:t.text.primary,...l},row:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:r.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface},rowActive:{borderColor:t.brandInk,backgroundColor:t.brandSoft},copy:{flex:1,gap:2},name:{...face(e,"bold"),fontSize:15,lineHeight:18,color:t.text.primary},meta:{...face(e,"monoBold"),fontSize:11,lineHeight:13,color:t.text.muted,textTransform:"uppercase",letterSpacing:rp},closeSlot:{alignSelf:"flex-end"},closeButton:{paddingHorizontal:18,paddingVertical:10,borderRadius:tp,backgroundColor:t.brandSoft},closeText:{...face(e,"bold"),color:t.brandInk,fontSize:13,lineHeight:16,letterSpacing:rp}})}var op=44,ap=36,sp=22,up=20,cp=9,dp=1.5,pp=6,fp=35,hp=1.75,bp=12.4,gp=.5,mp=8,yp=28,vp=160,xp=16,wp=8;function kp(e,petRef){return Qc(e,petRef)}function ChatHeader({pets:r,petRef:petRef,historyUnread:l,onOpenHistory:i,onNewChat:o,onPetChange:a,onAddPet:s,vet:u,textingEntry:c=null}){let d=useEverfurTheme(),p=e.useMemo(()=>Sp(d),[d]),[f,h]=e.useState(false),b=kp(r.pets,petRef),g=b!==null&&(r.pets.length>=2||s!==void 0),m=petRef??b?.petRef??null,y=lp(b),[v,x]=e.useState(zd),w=e.useCallback(e=>t=>{let r=t.nativeEvent.layout.width;x(t=>Ed(t,e,r))},[]),k=e.useMemo(()=>w("row"),[w]),S=e.useMemo(()=>w("leading"),[w]),C=e.useMemo(()=>w("trailing"),[w]),j=2*xp+2*(d.slots.header?.borderColor!==void 0?1:0)+2*wp,R=Pd(v,j,vp),T=e=>{h(false),r.setActivePet(e),Ar(a,e)},_=s===void 0?null:()=>{h(false),Ar(s)};/* @__PURE__ */
143
144
  return t.jsxs(t.Fragment,{children:[
144
145
  /* @__PURE__ */t.jsxs(n.View,{style:p.row,onLayout:k,children:[
145
- /* @__PURE__ */t.jsx(n.View,{style:[p.leading,R.leading===void 0?null:{minWidth:R.leading}],children:/* @__PURE__ */t.jsxs(n.View,{style:p.sideContent,onLayout:S,children:[o!==void 0?/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:gi.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:o,children:/* @__PURE__ */t.jsx(EditGlyph,{size:tp,color:d.slots.header?.textColor??d.color.text.primary,strokeWidth:2})}):null,
146
- /* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:l?`${je.openHistoryNative}${je.newReplySuffix}`:je.openHistoryNative,containerStyle:p.iconSlot,style:p.iconButton,onPress:i,children:[
147
- /* @__PURE__ */t.jsx(MenuGlyph,{size:ep,color:d.slots.header?.textColor??d.color.text.primary,strokeWidth:2}),l?/* @__PURE__ */t.jsx(n.View,{style:p.unreadDot,pointerEvents:"none"}):null]})]})}),
146
+ /* @__PURE__ */t.jsx(n.View,{style:[p.leading,R.leading===void 0?null:{minWidth:R.leading}],children:/* @__PURE__ */t.jsxs(n.View,{style:p.sideContent,onLayout:S,children:[o!==void 0?/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:yi.newChat,containerStyle:p.iconSlot,style:p.iconButton,onPress:o,children:/* @__PURE__ */t.jsx(EditGlyph,{size:up,color:d.slots.header?.textColor??d.color.text.primary,strokeWidth:2})}):null,
147
+ /* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:l?`${Te.openHistoryNative}${Te.newReplySuffix}`:Te.openHistoryNative,containerStyle:p.iconSlot,style:p.iconButton,onPress:i,children:[
148
+ /* @__PURE__ */t.jsx(MenuGlyph,{size:sp,color:d.slots.header?.textColor??d.color.text.primary,strokeWidth:2}),l?/* @__PURE__ */t.jsx(n.View,{style:p.unreadDot,pointerEvents:"none"}):null]})]})}),
148
149
  /* @__PURE__ */t.jsx(n.View,{style:p.centre,pointerEvents:"box-none",children:/* @__PURE__ */t.jsx(BrandLogo,{logoUrl:d.meta.logoUrl,name:d.meta.displayName,barStyle:p.logoBar,logoStyle:p.logo})}),
149
150
  /* @__PURE__ */t.jsx(n.View,{style:[p.trailing,R.trailing===void 0?null:{minWidth:R.trailing}],children:/* @__PURE__ */t.jsxs(n.View,{style:p.trailingContent,onLayout:C,children:[m===null?null:/* @__PURE__ */t.jsx(VetVisitButtonCore,{entry:"chat",petRef:m,...u?.returnTo!==void 0?{returnTo:u.returnTo}:{},...u?.usState!==void 0?{usState:u.usState}:{},...u?.prefer!==void 0?{prefer:u.prefer}:{},style:p.vetEntry,labelStyle:p.vetEntryLabel}),
150
- /* @__PURE__ */t.jsx(n.View,{style:p.right,children:g?/* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:Re(je.switchActivePet,{name:y}),containerStyle:p.avatarSlot,style:p.avatarWrap,onPress:()=>h(true),children:[
151
- /* @__PURE__ */t.jsx(PetDisc,{pet:b,size:ip,ringStroke:op}),
152
- /* @__PURE__ */t.jsx(n.View,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */t.jsx(PlusGlyph,{size:up,color:d.color.brandInk,strokeWidth:2})})]}):r.loading&&b===null?
153
- /* @__PURE__ */t.jsx(n.View,{style:p.avatarWrap,accessible:true,accessibilityLabel:je.yourPet,children:/* @__PURE__ */t.jsx(Ring,{size:ip,strokeWidth:op,color:d.color.mark,children:/* @__PURE__ */t.jsx(n.View,{style:p.placeholderDisc})})}):/* @__PURE__ */t.jsx(n.View,{style:p.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:b===null?je.yourPet:y,children:/* @__PURE__ */t.jsx(PetDisc,{pet:b,size:ip,ringStroke:op})})})]})}),
154
- /* @__PURE__ */t.jsx(PetSwitcherSheet,{visible:f,pets:r.pets,activePetRef:b?.petRef??null,onSelect:T,onAddPet:_,onClose:()=>h(false)})]}),c===null?null:/* @__PURE__ */t.jsx(TextingEntryRow,{entry:c,place:"header"})]})}function TextingEntryRow({entry:r,place:l}){let i=useEverfurTheme(),o=e.useMemo(()=>bp(i),[i]);/* @__PURE__ */
155
- return t.jsx(n.View,{style:l==="header"?o.textingEntryRowHeader:o.textingEntryRowThread,children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:r.label,containerStyle:o.textingEntrySlot,style:o.vetEntry,onPress:r.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:o.vetEntryLabel,numberOfLines:1,children:r.label})})})}function bp(e){let t=e.color,r=ip-op*2,l=e.slots.header;return n.StyleSheet.create({vetEntry:{minHeight:Jd,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.controlEdge},vetEntryLabel:{...face(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},textingEntrySlot:{borderRadius:e.radius.pill,maxWidth:"100%"},textingEntryRowHeader:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:pp,paddingBottom:10,backgroundColor:l?.backgroundColor??t.surface},textingEntryRowThread:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:pp,paddingTop:e.space.md,paddingBottom:e.space.xs},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:pp,paddingVertical:10,backgroundColor:t.surface,...Ao(l)},iconSlot:{borderRadius:Xd/2},iconButton:{width:Xd,height:Xd,borderRadius:Xd/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:lp,right:lp,width:rp,height:rp,borderRadius:rp,backgroundColor:t.danger,borderWidth:np,borderColor:l?.backgroundColor??t.surface},leading:{flexShrink:0,alignItems:"flex-start"},trailing:{flexShrink:0,alignItems:"flex-end"},sideContent:{flexDirection:"row",alignItems:"center"},trailingContent:{flexDirection:"row",alignItems:"center",gap:e.space.sm},centre:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,marginHorizontal:fp,alignItems:"center",justifyContent:"center"},logoBar:{alignSelf:"stretch",alignItems:"center"},logo:{height:cp,width:dp,maxWidth:"100%"},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:ip/2},avatarWrap:{width:ip,height:ip,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:ap,height:ap,borderRadius:ap/2,borderWidth:sp,borderColor:t.mark,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}var gp=/* @__PURE__ */Object.freeze([
156
- /* @__PURE__ */Object.freeze({key:"inaccurate",label:je.feedbackReasonInaccurate,feedbackType:"wrong"}),
157
- /* @__PURE__ */Object.freeze({key:"outdated",label:je.feedbackReasonOutdated,feedbackType:"outdated"}),
158
- /* @__PURE__ */Object.freeze({key:"unsafe",label:je.feedbackReasonUnsafe,feedbackType:"dangerous"}),
159
- /* @__PURE__ */Object.freeze({key:"unclear",label:je.feedbackReasonUnclear,feedbackType:"unclear"}),
160
- /* @__PURE__ */Object.freeze({key:"other",label:je.feedbackReasonOther,feedbackType:"not_helpful"})]),mp=/* @__PURE__ */Object.freeze([
161
- /* @__PURE__ */Object.freeze({sentiment:"up",label:je.feedbackHelpful}),
162
- /* @__PURE__ */Object.freeze({sentiment:"down",label:je.feedbackNotHelpful})]);function yp(e){switch(e){case"up":return"helpful";case"neutral":return"neutral";case"down":return"not_helpful"}}function vp(e,t){if(e==="down"&&t!==null){let e=gp.find(e=>e.key===t);if(e!==void 0)return e.feedbackType}return yp(e)}var xp=44,wp="rgba(17,17,17,0.55)",kp=26,Sp=36,Cp=4,jp=20,Rp=38,Tp=18,_p=12;function FeedbackReasons({visible:r,onSubmit:l,onSkip:i}){let o=useEverfurTheme(),a=e.useMemo(()=>zp(o),[o]),s=de(),[u,c]=e.useState(null),[d,p]=e.useState(""),[f,h]=e.useState(false),[b,g]=e.useState(false),m=()=>{c(null),p(""),h(false),g(false)},y=()=>{f||(m(),i())},v=async()=>{if(f)return;h(true),g(false);let e=d.trim();await l(u,e.length>0?e:null)?m():(h(false),g(true))};if(!r)return null;let x=[...d].length>Wo;/* @__PURE__ */
151
+ /* @__PURE__ */t.jsx(n.View,{style:p.right,children:g?/* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:_e(Te.switchActivePet,{name:y}),containerStyle:p.avatarSlot,style:p.avatarWrap,onPress:()=>h(true),children:[
152
+ /* @__PURE__ */t.jsx(PetDisc,{pet:b,size:fp,ringStroke:hp}),
153
+ /* @__PURE__ */t.jsx(n.View,{style:p.addBadge,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */t.jsx(PlusGlyph,{size:mp,color:d.color.brandInk,strokeWidth:2})})]}):r.loading&&b===null?
154
+ /* @__PURE__ */t.jsx(n.View,{style:p.avatarWrap,accessible:true,accessibilityLabel:Te.yourPet,children:/* @__PURE__ */t.jsx(Ring,{size:fp,strokeWidth:hp,color:d.color.mark,children:/* @__PURE__ */t.jsx(n.View,{style:p.placeholderDisc})})}):/* @__PURE__ */t.jsx(n.View,{style:p.avatarWrap,accessible:true,accessibilityRole:"image",accessibilityLabel:b===null?Te.yourPet:y,children:/* @__PURE__ */t.jsx(PetDisc,{pet:b,size:fp,ringStroke:hp})})})]})}),
155
+ /* @__PURE__ */t.jsx(PetSwitcherSheet,{visible:f,pets:r.pets,activePetRef:b?.petRef??null,onSelect:T,onAddPet:_,onClose:()=>h(false)})]}),c===null?null:/* @__PURE__ */t.jsx(TextingEntryRow,{entry:c,place:"header"})]})}function TextingEntryRow({entry:r,place:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Sp(i),[i]);/* @__PURE__ */
156
+ return t.jsx(n.View,{style:l==="header"?o.textingEntryRowHeader:o.textingEntryRowThread,children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:r.label,containerStyle:o.textingEntrySlot,style:o.vetEntry,onPress:r.onOpen,testID:"everfur-texting-entry",children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:o.vetEntryLabel,numberOfLines:1,children:r.label})})})}function Sp(e){let t=e.color,r=fp-hp*2,l=e.slots.header;return n.StyleSheet.create({vetEntry:{minHeight:op,justifyContent:"center",paddingHorizontal:12,borderRadius:e.radius.pill,backgroundColor:t.surfaceCream,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.controlEdge},vetEntryLabel:{...face(e,"bold"),color:t.brandInk,fontSize:e.type.size.caption},textingEntrySlot:{borderRadius:e.radius.pill,maxWidth:"100%"},textingEntryRowHeader:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:xp,paddingBottom:10,backgroundColor:l?.backgroundColor??t.surface},textingEntryRowThread:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:xp,paddingTop:e.space.md,paddingBottom:e.space.xs},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:xp,paddingVertical:10,backgroundColor:t.surface,...Oo(l)},iconSlot:{borderRadius:ap/2},iconButton:{width:ap,height:ap,borderRadius:ap/2,alignItems:"center",justifyContent:"center"},unreadDot:{position:"absolute",top:pp,right:pp,width:cp,height:cp,borderRadius:cp,backgroundColor:t.danger,borderWidth:dp,borderColor:l?.backgroundColor??t.surface},leading:{flexShrink:0,alignItems:"flex-start"},trailing:{flexShrink:0,alignItems:"flex-end"},sideContent:{flexDirection:"row",alignItems:"center"},trailingContent:{flexDirection:"row",alignItems:"center",gap:e.space.sm},centre:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:0,marginHorizontal:wp,alignItems:"center",justifyContent:"center"},logoBar:{alignSelf:"stretch",alignItems:"center"},logo:{height:yp,width:vp,maxWidth:"100%"},right:{alignItems:"flex-end"},avatarSlot:{borderRadius:fp/2},avatarWrap:{width:fp,height:fp,position:"relative"},placeholderDisc:{width:r,height:r,borderRadius:r/2,backgroundColor:t.brandSoft},addBadge:{position:"absolute",bottom:0,right:0,width:bp,height:bp,borderRadius:bp/2,borderWidth:gp,borderColor:t.mark,backgroundColor:t.surface,alignItems:"center",justifyContent:"center"}})}var Cp=/* @__PURE__ */Object.freeze([
157
+ /* @__PURE__ */Object.freeze({key:"inaccurate",label:Te.feedbackReasonInaccurate,feedbackType:"wrong"}),
158
+ /* @__PURE__ */Object.freeze({key:"outdated",label:Te.feedbackReasonOutdated,feedbackType:"outdated"}),
159
+ /* @__PURE__ */Object.freeze({key:"unsafe",label:Te.feedbackReasonUnsafe,feedbackType:"dangerous"}),
160
+ /* @__PURE__ */Object.freeze({key:"unclear",label:Te.feedbackReasonUnclear,feedbackType:"unclear"}),
161
+ /* @__PURE__ */Object.freeze({key:"other",label:Te.feedbackReasonOther,feedbackType:"not_helpful"})]),jp=/* @__PURE__ */Object.freeze([
162
+ /* @__PURE__ */Object.freeze({sentiment:"up",label:Te.feedbackHelpful}),
163
+ /* @__PURE__ */Object.freeze({sentiment:"down",label:Te.feedbackNotHelpful})]);function Rp(e){switch(e){case"up":return"helpful";case"neutral":return"neutral";case"down":return"not_helpful"}}function Tp(e,t){if(e==="down"&&t!==null){let e=Cp.find(e=>e.key===t);if(e!==void 0)return e.feedbackType}return Rp(e)}var _p=44,zp="rgba(17,17,17,0.55)",Ip=26,Pp=36,Ep=4,Mp=20,Ap=38,Fp=18,Lp=12;function FeedbackReasons({visible:r,onSubmit:l,onSkip:i}){let o=useEverfurTheme(),a=e.useMemo(()=>Op(o),[o]),s=de(),[u,c]=e.useState(null),[d,p]=e.useState(""),[f,h]=e.useState(false),[b,g]=e.useState(false),m=()=>{c(null),p(""),h(false),g(false)},y=()=>{f||(m(),i())},v=async()=>{if(f)return;h(true),g(false);let e=d.trim();await l(u,e.length>0?e:null)?m():(h(false),g(true))};if(!r)return null;let x=[...d].length>Uo;/* @__PURE__ */
163
164
  return t.jsx(n.Modal,{visible:true,transparent:true,animationType:o.motion.reducedMotion?"none":"slide",onRequestClose:y,children:/* @__PURE__ */t.jsxs(n.KeyboardAvoidingView,{behavior:n.Platform.OS==="ios"?"padding":void 0,style:a.root,children:[
164
- /* @__PURE__ */t.jsx(n.Pressable,{style:a.scrim,onPress:y,accessibilityRole:"button",accessibilityLabel:je.feedbackSkipA11y}),
165
+ /* @__PURE__ */t.jsx(n.Pressable,{style:a.scrim,onPress:y,accessibilityRole:"button",accessibilityLabel:Te.feedbackSkipA11y}),
165
166
  /* @__PURE__ */t.jsxs(n.View,{style:pe(a.sheet,s),accessibilityViewIsModal:true,accessibilityLiveRegion:"polite",children:[
166
167
  /* @__PURE__ */t.jsx(n.View,{style:a.handle}),
167
168
  /* @__PURE__ */t.jsxs(n.View,{style:a.header,children:[
168
- /* @__PURE__ */t.jsx(n.View,{style:a.iconBadge,children:/* @__PURE__ */t.jsx(ThumbGlyph,{size:Tp,color:o.color.brandInk,active:false,rotate:"180deg"})}),
169
+ /* @__PURE__ */t.jsx(n.View,{style:a.iconBadge,children:/* @__PURE__ */t.jsx(ThumbGlyph,{size:Fp,color:o.color.brandInk,active:false,rotate:"180deg"})}),
169
170
  /* @__PURE__ */t.jsxs(n.View,{style:a.headerText,children:[
170
- /* @__PURE__ */t.jsx(Text,{tier:"heading",style:a.title,accessibilityRole:"header",children:je.feedbackTitle}),
171
- /* @__PURE__ */t.jsx(Text,{style:a.subtitle,children:je.feedbackSubtitle})]})]}),
172
- /* @__PURE__ */t.jsx(n.View,{style:a.options,children:gp.map(e=>{let r=u===e.key;/* @__PURE__ */
171
+ /* @__PURE__ */t.jsx(Text,{tier:"heading",style:a.title,accessibilityRole:"header",children:Te.feedbackTitle}),
172
+ /* @__PURE__ */t.jsx(Text,{style:a.subtitle,children:Te.feedbackSubtitle})]})]}),
173
+ /* @__PURE__ */t.jsx(n.View,{style:a.options,children:Cp.map(e=>{let r=u===e.key;/* @__PURE__ */
173
174
  return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,accessibilityState:{selected:r},style:[a.option,r?a.optionSelected:null],onPress:()=>c(t=>t===e.key?null:e.key),children:[
174
175
  /* @__PURE__ */t.jsx(Text,{style:[a.optionLabel,r?a.optionLabelSelected:null],children:e.label}),
175
- /* @__PURE__ */t.jsx(n.View,{style:[a.radio,r?a.radioSelected:null],children:r?/* @__PURE__ */t.jsx(CheckGlyph,{size:_p,color:o.color.surface,strokeWidth:2}):null})]},e.key)})}),
176
+ /* @__PURE__ */t.jsx(n.View,{style:[a.radio,r?a.radioSelected:null],children:r?/* @__PURE__ */t.jsx(CheckGlyph,{size:Lp,color:o.color.surface,strokeWidth:2}):null})]},e.key)})}),
176
177
  /* @__PURE__ */t.jsxs(n.View,{style:a.inputWrap,children:[
177
- /* @__PURE__ */t.jsx(ne,{style:a.input,placeholder:je.feedbackNotesPlaceholder,placeholderTextColor:o.color.text.placeholder,accessibilityLabel:je.feedbackNotesPlaceholder,value:d,onChangeText:p,multiline:true,editable:!f}),d.length>0?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:[a.counter,x?a.counterOver:null],children:`${[...d].length}/${Wo}`}):null]}),b?/* @__PURE__ */t.jsx(Text,{style:a.failed,accessibilityRole:"alert",children:je.feedbackFailed}):null,
178
+ /* @__PURE__ */t.jsx(ne,{style:a.input,placeholder:Te.feedbackNotesPlaceholder,placeholderTextColor:o.color.text.placeholder,accessibilityLabel:Te.feedbackNotesPlaceholder,value:d,onChangeText:p,multiline:true,editable:!f}),d.length>0?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:[a.counter,x?a.counterOver:null],children:`${[...d].length}/${Uo}`}):null]}),b?/* @__PURE__ */t.jsx(Text,{style:a.failed,accessibilityRole:"alert",children:Te.feedbackFailed}):null,
178
179
  /* @__PURE__ */t.jsxs(n.View,{style:a.actions,children:[
179
- /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:je.feedbackSubmit,accessibilityState:{busy:f,disabled:f||x},disabled:f||x,style:[a.submit,f||x?a.submitDisabled:null],onPress:()=>{v()},children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:a.submitLabel,children:je.feedbackSubmit})}),
180
- /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:je.feedbackSkipA11y,hitSlop:8,onPress:y,style:a.skip,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:a.skipLabel,children:je.feedbackSkip})})]})]})]})})}function zp(e){let t=e.color,r=e.type,l=e.radius,i=e.slots,o=Oo(i.dialog);return n.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...Za,backgroundColor:wp},sheet:{backgroundColor:t.surface,borderTopLeftRadius:kp,borderTopRightRadius:kp,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14,...Vd(i.dialog)},handle:{alignSelf:"center",width:Sp,height:Cp,borderRadius:Cp/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Rp,height:Rp,borderRadius:Rp/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...headingFace(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight,...o},subtitle:{...face(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted,...o},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:l.md,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.controlEdge,backgroundColor:t.surface,...Ao(i.chip,n.StyleSheet.hairlineWidth)},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.primary,...Oo(i.chip)},optionLabelSelected:{color:t.brandInk},radio:{width:jp,height:jp,borderRadius:jp/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:l.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...face(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top",...Ao(i.input,1),...Oo(i.input)},counter:{...face(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...face(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:xp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:l.pill,backgroundColor:t.brand,...Ao(i.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Oo(i.primaryButton)},skip:{minHeight:xp,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}var Ip=/* @__PURE__ */Symbol.for("everfur.sdk.rn.askHome");function Pp(){let t=globalThis,r=t[Ip];if(r!==void 0)return r;let n={factory:e.createContext(null),home:e.createContext(null)};return t[Ip]=n,n}var Ep=Pp().factory,Mp=Pp().home;function Fp(){return e.useContext(Ep)}function Ap(){return e.useContext(Mp)?.kit??null}function Lp(){return e.useContext(Mp)}var Op=15,Vp=8;function HistoryBar({bar:r,history:l,empty:i,unread:o,extra:a}){let s=useEverfurTheme(),u=Ap(),c=e.useMemo(()=>u!==null?Hp(s,u):Wp(s),[s,u]),d=l.cursor===null?l.rows.length:0,p=e=>{let l=r.renderIcon;if(l!==void 0)/* @__PURE__ */return t.jsx(HostRender,{render:()=>l(e),fallback:null});if(u===null)return null;let i=String(n.StyleSheet.flatten(c.label).color??s.color.linkInk);return e==="history"?/* @__PURE__ */t.jsx(HistoryGlyph,{size:Bp,color:i,strokeWidth:1.8}):/* @__PURE__ */t.jsx(EditGlyph,{size:Bp,color:i,strokeWidth:1.8})};/* @__PURE__ */
181
- return t.jsxs(n.View,{style:c.bar,testID:"everfur-history-bar",children:[
182
- /* @__PURE__ */t.jsxs(n.Pressable,{accessibilityRole:"button",accessibilityLabel:d>0?`${r.chats} ${d}`:r.chats,accessibilityState:{expanded:l.open},onPress:l.open?l.close:l.show,style:c.control,hitSlop:u!==null?Dp:void 0,children:[p("history"),
183
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:c.label,children:r.chats}),d>0?/* @__PURE__ */t.jsx(n.View,{style:c.count,children:/* @__PURE__ */t.jsx(Text,{tier:"badge",style:c.countText,children:String(d)})}):null,o?/* @__PURE__ */t.jsx(n.View,{style:c.dot,testID:"everfur-chat-history-bar-unread"}):null]}),r.extra??null,a??null,
184
- /* @__PURE__ */t.jsx(n.View,{style:c.spacer}),i?null:/* @__PURE__ */t.jsxs(n.Pressable,{accessibilityRole:"button",accessibilityLabel:r.newChat,onPress:l.newConversation,style:c.control,hitSlop:u!==null?Dp:void 0,children:[p("edit"),
185
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:c.label,children:r.newChat})]})]})}var Dp=4,Bp=18;function Hp(e,t){return{...Wp(e),bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.sm},control:t.view(".thread__hist"),label:t.text(".thread__hist"),count:t.view(".thread__count"),countText:t.text(".thread__count")}}function Wp(e){let t=e.color,r=e.space;return n.StyleSheet.create({bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.xs},control:{flexDirection:"row",alignItems:"center",gap:6,minHeight:Ts},label:{...face(e,"bold"),fontSize:Op,color:t.brandInk},count:{minWidth:22,paddingHorizontal:7,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,alignItems:"center"},countText:{...face(e,"bold"),fontSize:e.type.size.caption,color:t.text.primary},dot:{width:Vp,height:Vp,borderRadius:Vp/2,backgroundColor:t.danger},spacer:{flexGrow:1}})}var Np=.88,Up=420,$p=58,qp="rgba(17,17,17,0.28)",Gp=.15,Kp=14,Yp=12,Qp=44,Zp=16,Jp=14,Xp=12,ef=14,tf=8,rf=2,nf=.5,lf=co(eo.standard);function of(e){return Math.min(Math.round(e*Np),Up)}function HistoryDrawer({chat:r,history:n}){let[l,i]=e.useState(n.open),o=e.useCallback(()=>i(false),[]);return n.open&&!l&&i(true),l?/* @__PURE__ */t.jsx(DrawerModal,{chat:r,history:n,onHidden:o}):null}function DrawerModal({chat:r,history:i,onHidden:o}){let a=useEverfurTheme(),s=e.useMemo(()=>af(a),[a]),u=oo(),c=l.useSafeAreaInsets(),{width:d}=n.useWindowDimensions(),p=of(d),f=i.open,h=e.useRef(null);h.current===null&&(h.current=new n.Animated.Value(u.drawerMs<=0&&f?1:0));let b=h.current;e.useEffect(()=>{if(!f&&u.drawerMs<=0){o();return}let e=n.Animated.timing(b,{toValue:f?1:0,duration:u.drawerMs,easing:lf,useNativeDriver:true});return e.start(({finished:e})=>{e&&!f&&o()}),()=>e.stop()},[f,b,u.drawerMs,o]);let g=b.interpolate({inputRange:[0,1],outputRange:[-p,0]}),m=i.filtered,y=i.rows.length===0,v=i.cursor===null&&!i.loading&&i.error===null,x=y&&i.loading?/* @__PURE__ */t.jsxs(n.View,{style:s.emptyCard,accessibilityLabel:gi.loading,accessibilityState:{busy:true},children:[
180
+ /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Te.feedbackSubmit,accessibilityState:{busy:f,disabled:f||x},disabled:f||x,style:[a.submit,f||x?a.submitDisabled:null],onPress:()=>{v()},children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:a.submitLabel,children:Te.feedbackSubmit})}),
181
+ /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:Te.feedbackSkipA11y,hitSlop:8,onPress:y,style:a.skip,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:a.skipLabel,children:Te.feedbackSkip})})]})]})]})})}function Op(e){let t=e.color,r=e.type,l=e.radius,i=e.slots,o=Do(i.dialog);return n.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{...Xa,backgroundColor:zp},sheet:{backgroundColor:t.surface,borderTopLeftRadius:Ip,borderTopRightRadius:Ip,paddingHorizontal:22,paddingTop:12,paddingBottom:34,gap:14,...qd(i.dialog)},handle:{alignSelf:"center",width:Pp,height:Ep,borderRadius:Ep/2,backgroundColor:t.brandBorder,marginBottom:2},header:{flexDirection:"row",alignItems:"center",gap:12},iconBadge:{width:Ap,height:Ap,borderRadius:Ap/2,alignItems:"center",justifyContent:"center",backgroundColor:t.brandSoft},headerText:{flex:1,gap:2},title:{...headingFace(e,"bold"),fontSize:20,lineHeight:28,color:t.text.primary,letterSpacing:r.letterSpacing.tight,...o},subtitle:{...face(e,"regular"),fontSize:r.size.body,lineHeight:r.size.body*r.lineHeight.relaxed,color:t.text.muted,...o},options:{gap:8},option:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:14,paddingVertical:13,borderRadius:l.md,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.controlEdge,backgroundColor:t.surface,...Oo(i.chip,n.StyleSheet.hairlineWidth)},optionSelected:{borderColor:t.brandInk,backgroundColor:t.brandSoft},optionLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.primary,...Do(i.chip)},optionLabelSelected:{color:t.brandInk},radio:{width:Mp,height:Mp,borderRadius:Mp/2,borderWidth:2,borderColor:t.brandBorderStrong,alignItems:"center",justifyContent:"center"},radioSelected:{borderColor:t.brandInk,backgroundColor:t.brandInk},inputWrap:{gap:4},input:{minHeight:72,maxHeight:132,borderRadius:l.md,borderWidth:1,borderColor:t.brandBorderStrong,paddingHorizontal:14,paddingTop:12,paddingBottom:12,...face(e,"regular"),fontSize:r.size.body,color:t.text.primary,textAlignVertical:"top",...Oo(i.input,1),...Do(i.input)},counter:{...face(e,"mono"),alignSelf:"flex-end",fontSize:r.size.caption,letterSpacing:.3,color:t.text.placeholder},counterOver:{color:t.danger},failed:{...face(e,"regular"),fontSize:r.size.caption,lineHeight:r.size.caption*r.lineHeight.normal,color:t.danger},actions:{gap:10,alignItems:"center"},submit:{alignSelf:"stretch",minHeight:_p,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.xl,borderRadius:l.pill,backgroundColor:t.brand,...Oo(i.primaryButton)},submitDisabled:{opacity:.6},submitLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.onPrimary,...Do(i.primaryButton)},skip:{minHeight:_p,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},skipLabel:{...face(e,"medium"),fontSize:r.size.body,color:t.text.muted}})}var Vp=/* @__PURE__ */Symbol.for("everfur.sdk.rn.askHome");function Dp(){let t=globalThis,r=t[Vp];if(r!==void 0)return r;let n={factory:e.createContext(null),home:e.createContext(null)};return t[Vp]=n,n}var Bp=Dp().factory,Hp=Dp().home;function Wp(){return e.useContext(Bp)}function Np(){return e.useContext(Hp)?.kit??null}function Up(){return e.useContext(Hp)}var $p=15,qp=8;function HistoryBar({bar:r,history:l,empty:i,unread:o,extra:a}){let s=useEverfurTheme(),u=Np(),c=yc(),d=e.useMemo(()=>c!==null?{...Qp(s),...c.paint.history}:u!==null?Yp(s,u):Qp(s),[s,u,c]),p=c===null&&l.cursor===null?l.rows.length:0,f=c!==null||u!==null,h=e=>{let l=r.renderIcon;if(l!==void 0)/* @__PURE__ */return t.jsx(HostRender,{render:()=>l(e),fallback:null});if(!f)return null;let i=String(n.StyleSheet.flatten(d.label).color??s.color.linkInk);return c!==null?/* @__PURE__ */t.jsx(c.paint.Icon,{name:e==="history"?"clock":"pen",size:20,color:i}):e==="history"?/* @__PURE__ */t.jsx(HistoryGlyph,{size:Kp,color:i,strokeWidth:1.8}):/* @__PURE__ */t.jsx(EditGlyph,{size:Kp,color:i,strokeWidth:1.8})};/* @__PURE__ */
182
+ return t.jsxs(n.View,{style:d.bar,testID:"everfur-history-bar",children:[
183
+ /* @__PURE__ */t.jsxs(n.Pressable,{accessibilityRole:"button",accessibilityLabel:p>0?`${r.chats} ${p}`:r.chats,accessibilityState:{expanded:l.open},onPress:l.open?l.close:l.show,style:d.control,hitSlop:f?Gp:void 0,children:[h("history"),
184
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:d.label,children:r.chats}),p>0?/* @__PURE__ */t.jsx(n.View,{style:d.count,children:/* @__PURE__ */t.jsx(Text,{tier:"badge",style:d.countText,children:String(p)})}):null,o?/* @__PURE__ */t.jsx(n.View,{style:d.dot,testID:"everfur-chat-history-bar-unread"}):null]}),r.extra??null,a??null,
185
+ /* @__PURE__ */t.jsx(n.View,{style:d.spacer}),i?null:/* @__PURE__ */t.jsxs(n.Pressable,{accessibilityRole:"button",accessibilityLabel:r.newChat,onPress:l.newConversation,style:d.control,hitSlop:f?Gp:void 0,children:[h("edit"),
186
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:d.label,children:r.newChat})]})]})}var Gp=4,Kp=18;function Yp(e,t){return{...Qp(e),bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.sm},control:t.view(".thread__hist"),label:t.text(".thread__hist"),count:t.view(".thread__count"),countText:t.text(".thread__count")}}function Qp(e){let t=e.color,r=e.space;return n.StyleSheet.create({bar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm,paddingHorizontal:r.lg,paddingVertical:r.xs},control:{flexDirection:"row",alignItems:"center",gap:6,minHeight:zs},label:{...face(e,"bold"),fontSize:$p,color:t.brandInk},count:{minWidth:22,paddingHorizontal:7,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,alignItems:"center"},countText:{...face(e,"bold"),fontSize:e.type.size.caption,color:t.text.primary},dot:{width:qp,height:qp,borderRadius:qp/2,backgroundColor:t.danger},spacer:{flexGrow:1}})}var Zp=.88,Jp=420,Xp=58,ef="rgba(17,17,17,0.28)",tf=.15,rf=14,nf=12,lf=44,of=16,af=14,sf=12,uf=14,cf=8,df=2,pf=.5,ff=fo(ro.standard);function hf(e){return Math.min(Math.round(e*Zp),Jp)}function HistoryDrawer({chat:r,history:n}){let[l,i]=e.useState(n.open),o=e.useCallback(()=>i(false),[]);return n.open&&!l&&i(true),l?/* @__PURE__ */t.jsx(DrawerModal,{chat:r,history:n,onHidden:o}):null}function DrawerModal({chat:r,history:i,onHidden:o}){let a=useEverfurTheme(),s=e.useMemo(()=>bf(a),[a]),u=so(),c=l.useSafeAreaInsets(),{width:d}=n.useWindowDimensions(),p=hf(d),f=i.open,h=e.useRef(null);h.current===null&&(h.current=new n.Animated.Value(u.drawerMs<=0&&f?1:0));let b=h.current;e.useEffect(()=>{if(!f&&u.drawerMs<=0){o();return}let e=n.Animated.timing(b,{toValue:f?1:0,duration:u.drawerMs,easing:ff,useNativeDriver:true});return e.start(({finished:e})=>{e&&!f&&o()}),()=>e.stop()},[f,b,u.drawerMs,o]);let g=b.interpolate({inputRange:[0,1],outputRange:[-p,0]}),m=i.filtered,y=i.rows.length===0,v=i.cursor===null&&!i.loading&&i.error===null,x=y&&i.loading?/* @__PURE__ */t.jsxs(n.View,{style:s.emptyCard,accessibilityLabel:yi.loading,accessibilityState:{busy:true},children:[
186
187
  /* @__PURE__ */t.jsx(n.ActivityIndicator,{color:s.emptyTitle.color}),
187
- /* @__PURE__ */t.jsx(Text,{style:s.emptyBody,children:gi.loading})]}):y&&i.error!==null?/* @__PURE__ */t.jsxs(n.View,{style:s.emptyCard,children:[
188
- /* @__PURE__ */t.jsx(Text,{style:s.emptyTitle,accessibilityRole:"alert",children:gi.loadFailed}),
188
+ /* @__PURE__ */t.jsx(Text,{style:s.emptyBody,children:yi.loading})]}):y&&i.error!==null?/* @__PURE__ */t.jsxs(n.View,{style:s.emptyCard,children:[
189
+ /* @__PURE__ */t.jsx(Text,{style:s.emptyTitle,accessibilityRole:"alert",children:yi.loadFailed}),
189
190
  /* @__PURE__ */t.jsx(Text,{style:s.emptyBody,children:i.error}),
190
- /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:gi.retry,containerStyle:s.retrySlot,style:s.retryButton,onPress:()=>{i.load()},children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:s.retryText,children:gi.retry})})]}):i.emptyKind==="empty"?/* @__PURE__ */t.jsxs(n.View,{style:s.emptyCard,children:[
191
- /* @__PURE__ */t.jsx(Text,{style:s.emptyTitle,children:gi.empty}),
192
- /* @__PURE__ */t.jsx(Text,{style:s.emptyBody,children:gi.emptyBody})]}):
193
- /* @__PURE__ */t.jsx(Text,{style:s.noMatch,children:gi.noMatch}),w=!i.searching&&i.loadingMore?/* @__PURE__ */t.jsx(n.View,{style:s.loadMoreFooter,children:/* @__PURE__ */t.jsx(Text,{style:s.loadMoreLabel,children:gi.loadingMore})}):null;/* @__PURE__ */
191
+ /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:yi.retry,containerStyle:s.retrySlot,style:s.retryButton,onPress:()=>{i.load()},children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:s.retryText,children:yi.retry})})]}):i.emptyKind==="empty"?/* @__PURE__ */t.jsxs(n.View,{style:s.emptyCard,children:[
192
+ /* @__PURE__ */t.jsx(Text,{style:s.emptyTitle,children:yi.empty}),
193
+ /* @__PURE__ */t.jsx(Text,{style:s.emptyBody,children:yi.emptyBody})]}):
194
+ /* @__PURE__ */t.jsx(Text,{style:s.noMatch,children:yi.noMatch}),w=!i.searching&&i.loadingMore?/* @__PURE__ */t.jsx(n.View,{style:s.loadMoreFooter,children:/* @__PURE__ */t.jsx(Text,{style:s.loadMoreLabel,children:yi.loadingMore})}):null;/* @__PURE__ */
194
195
  return t.jsx(n.Modal,{visible:true,transparent:true,animationType:"none",onRequestClose:i.close,children:/* @__PURE__ */t.jsxs(n.View,{style:s.root,children:[
195
- /* @__PURE__ */t.jsx(n.Pressable,{style:Za,onPress:i.close,accessibilityRole:"button",accessibilityLabel:gi.closeA11y,children:/* @__PURE__ */t.jsx(n.Animated.View,{style:[s.backdrop,{opacity:b}]})}),
196
- /* @__PURE__ */t.jsx(n.Animated.View,{style:[s.panel,{width:p,paddingTop:Math.max($p,c.top+a.space.md),transform:[{translateX:g}]}],accessibilityViewIsModal:true,children:/* @__PURE__ */t.jsxs(n.KeyboardAvoidingView,{style:s.keyboardAvoider,behavior:n.Platform.OS==="ios"?"padding":"height",children:[
196
+ /* @__PURE__ */t.jsx(n.Pressable,{style:Xa,onPress:i.close,accessibilityRole:"button",accessibilityLabel:yi.closeA11y,children:/* @__PURE__ */t.jsx(n.Animated.View,{style:[s.backdrop,{opacity:b}]})}),
197
+ /* @__PURE__ */t.jsx(n.Animated.View,{style:[s.panel,{width:p,paddingTop:Math.max(Xp,c.top+a.space.md),transform:[{translateX:g}]}],accessibilityViewIsModal:true,children:/* @__PURE__ */t.jsxs(n.KeyboardAvoidingView,{style:s.keyboardAvoider,behavior:n.Platform.OS==="ios"?"padding":"height",children:[
197
198
  /* @__PURE__ */t.jsxs(n.View,{style:s.header,children:[
198
- /* @__PURE__ */t.jsx(Text,{tier:"heading",style:s.heading,accessibilityRole:"header",children:gi.heading}),
199
- /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:gi.newChat,style:s.newChat,onPress:i.newConversation,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:s.newChatLabel,children:gi.newChat})}),
200
- /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:gi.close,hitSlop:0,style:s.closeButton,onPress:i.close,children:/* @__PURE__ */t.jsx(CloseGlyph,{size:Zp,color:a.color.text.muted,strokeWidth:1.75})})]}),
199
+ /* @__PURE__ */t.jsx(Text,{tier:"heading",style:s.heading,accessibilityRole:"header",children:yi.heading}),
200
+ /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:yi.newChat,style:s.newChat,onPress:i.newConversation,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:s.newChatLabel,children:yi.newChat})}),
201
+ /* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:yi.close,hitSlop:0,style:s.closeButton,onPress:i.close,children:/* @__PURE__ */t.jsx(CloseGlyph,{size:of,color:a.color.text.muted,strokeWidth:1.75})})]}),
201
202
  /* @__PURE__ */t.jsxs(n.View,{style:s.searchPill,children:[
202
- /* @__PURE__ */t.jsx(SearchGlyph,{size:ef,color:a.color.text.muted,strokeWidth:1.5}),
203
- /* @__PURE__ */t.jsx(ne,{value:i.query,onChangeText:e=>i.setQuery(e.replace(/^\s+/,"")),style:s.searchInput,placeholder:gi.searchPlaceholder,placeholderTextColor:a.color.text.placeholder,accessibilityLabel:gi.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),
204
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:s.countLabel,children:xi(i.rows.length,v)}),i.error!==null&&!y?/* @__PURE__ */t.jsx(n.View,{style:s.errorCard,children:/* @__PURE__ */t.jsx(Text,{style:s.errorText,accessibilityRole:"alert",children:i.error})}):null,
205
- /* @__PURE__ */t.jsx(n.FlatList,{data:m,keyExtractor:e=>e.id,renderItem:({item:e})=>/* @__PURE__ */t.jsx(Row,{row:e,active:e.id===r.conversationId,disabled:i.loading,styles:s,onPress:()=>{i.resume(e.id)}}),contentContainerStyle:m.length===0?s.listEmpty:s.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:x,ListFooterComponent:w,onEndReached:i.loadMore,onEndReachedThreshold:nf})]})})]})})}function Row({row:e,active:r,disabled:l,styles:i,onPress:o}){let a=e.unreadCount!==null&&e.unreadCount>0,s=vi(e);/* @__PURE__ */
206
- return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:wi(e),accessibilityState:{selected:r,disabled:l},disabled:l,style:[i.item,r?i.itemActive:null],onPress:o,children:[
203
+ /* @__PURE__ */t.jsx(SearchGlyph,{size:uf,color:a.color.text.muted,strokeWidth:1.5}),
204
+ /* @__PURE__ */t.jsx(ne,{value:i.query,onChangeText:e=>i.setQuery(e.replace(/^\s+/,"")),style:s.searchInput,placeholder:yi.searchPlaceholder,placeholderTextColor:a.color.text.placeholder,accessibilityLabel:yi.search,autoCorrect:false,autoCapitalize:"none",returnKeyType:"search"})]}),
205
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:s.countLabel,children:ki(i.rows.length,v)}),i.error!==null&&!y?/* @__PURE__ */t.jsx(n.View,{style:s.errorCard,children:/* @__PURE__ */t.jsx(Text,{style:s.errorText,accessibilityRole:"alert",children:i.error})}):null,
206
+ /* @__PURE__ */t.jsx(n.FlatList,{data:m,keyExtractor:e=>e.id,renderItem:({item:e})=>/* @__PURE__ */t.jsx(Row,{row:e,active:e.id===r.conversationId,disabled:i.loading,styles:s,onPress:()=>{i.resume(e.id)}}),contentContainerStyle:m.length===0?s.listEmpty:s.list,keyboardShouldPersistTaps:"handled",ListEmptyComponent:x,ListFooterComponent:w,onEndReached:i.loadMore,onEndReachedThreshold:pf})]})})]})})}function Row({row:e,active:r,disabled:l,styles:i,onPress:o}){let a=e.unreadCount!==null&&e.unreadCount>0,s=wi(e);/* @__PURE__ */
207
+ return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:Si(e),accessibilityState:{selected:r,disabled:l},disabled:l,style:[i.item,r?i.itemActive:null],onPress:o,children:[
207
208
  /* @__PURE__ */t.jsxs(n.View,{style:i.itemRow,children:[
208
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:i.itemTitle,numberOfLines:1,children:mi(e.title)}),a?/* @__PURE__ */t.jsx(n.View,{style:i.unreadDot}):null]}),s!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:i.itemMeta,numberOfLines:1,children:s}):null]})}function af(e){let t=e.color,r=e.space,l=e.type,i=e.slots,o=t.text.primary,a=Oo(i.card);return n.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:qp},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:n.StyleSheet.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md,...Dd(i.dialog,n.StyleSheet.hairlineWidth)},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...headingFace(e,"bold"),flex:1,fontSize:l.size.subtitle,color:o,...Oo(i.dialog)},newChat:{minHeight:Qp,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...face(e,"bold"),fontSize:Kp,color:t.brandInk},closeButton:{width:Qp,height:Qp,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,paddingHorizontal:r.md+rf,paddingVertical:r.sm+rf,borderWidth:1,borderColor:t.borderRingCream,...Ao(i.input,1)},searchInput:{...face(e,"regular"),flex:1,fontSize:l.size.bodyTight,color:t.text.primary,padding:0,...Oo(i.input)},countLabel:{...face(e,"mono"),fontSize:Yp,color:t.text.muted},list:{gap:r.xs,paddingBottom:r.xl},listEmpty:{flexGrow:1},item:{paddingVertical:r.sm+rf,paddingHorizontal:r.sm,borderRadius:e.radius.md,gap:rf},itemActive:{backgroundColor:Ka(t.highlight,Gp)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...face(e,"bold"),flex:1,fontSize:l.size.bodyTight,color:o},itemMeta:{...face(e,"regular"),fontSize:l.size.caption,color:t.text.muted},unreadDot:{width:tf,height:tf,borderRadius:tf/2,backgroundColor:t.danger},errorCard:{borderRadius:Xp,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...face(e,"regular"),fontSize:l.size.caption,color:t.danger},emptyCard:{borderRadius:Jp,padding:r.md+rf,gap:r.xs+rf,backgroundColor:t.surfaceSubtle,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.borderRingCream,...Ao(i.card,n.StyleSheet.hairlineWidth)},emptyTitle:{...headingFace(e,"bold"),fontSize:l.size.bodyTight,color:o,...a},emptyBody:{...face(e,"regular"),fontSize:l.size.caption,color:t.text.secondary,...a},noMatch:{...face(e,"regular"),fontSize:l.size.bodyTight,color:t.text.muted,paddingVertical:r.sm},retrySlot:{marginTop:r.sm,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:r.md+rf,paddingVertical:r.sm,borderWidth:1,borderColor:t.brandInk,...Ao(i.primaryButton)},retryText:{...face(e,"bold"),fontSize:l.size.caption,color:t.brandInk,...Oo(i.primaryButton)},loadMoreFooter:{paddingVertical:r.md+rf,alignItems:"center"},loadMoreLabel:{...face(e,"regular"),fontSize:l.size.caption,color:t.text.muted}})}function sf(e,t=/* @__PURE__ */new Date,r){let n=new Date(e);if(Number.isNaN(n.getTime()))return null;let l=new Date(t);l.setHours(0,0,0,0);let i=new Date(n);i.setHours(0,0,0,0);let o=Math.round((l.getTime()-i.getTime())/864e5);if(o===0||o===1)try{let e=new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(-o,"day");return e.charAt(0).toLocaleUpperCase(r)+e.slice(1)}catch{}return n.toLocaleDateString(r,{month:"short",day:"numeric"})}function uf(e,t){let r=new Date(e);return Number.isNaN(r.getTime())?null:r.toLocaleTimeString(t,{hour:"numeric",minute:"2-digit"})}function cf(e,t=/* @__PURE__ */new Date){let r=[];for(let n of e){let e=sf(n.updatedAt,t)??"",l=r[r.length-1];l!==void 0&&l.day===e?l.rows.push(n):r.push({day:e,rows:[n]})}return r}var df="rgba(38,37,35,0.38)",pf=28,ff=40,hf=5,bf=11,gf=10.5,mf=36,yf=11,vf=14,xf=15,wf=13.5,kf=48,Sf=2,Cf=1.3,jf=.12,Rf=16,Tf=8,_f="80%";function zf(e,r,n){let l=e?.renderIcon;return l===void 0?n:/* @__PURE__ */t.jsx(HostRender,{render:()=>l(r),fallback:n})}function HistorySheet({chat:r,history:i,sheet:o}){let a=useEverfurTheme(),s=e.useMemo(()=>If(a),[a]),u=l.useSafeAreaInsets(),c=e.useMemo(()=>cf(i.rows),[i.rows]),d=de();if(!i.open)return null;let p=a.color,f=o?.title?.trim(),h=f!==void 0&&f!==""?f:gi.heading;/* @__PURE__ */
209
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:i.itemTitle,numberOfLines:1,children:vi(e.title)}),a?/* @__PURE__ */t.jsx(n.View,{style:i.unreadDot}):null]}),s!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:i.itemMeta,numberOfLines:1,children:s}):null]})}function bf(e){let t=e.color,r=e.space,l=e.type,i=e.slots,o=t.text.primary,a=Do(i.card);return n.StyleSheet.create({root:{flex:1},backdrop:{flex:1,backgroundColor:ef},panel:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:t.surface,paddingHorizontal:r.lg,borderRightWidth:n.StyleSheet.hairlineWidth,borderRightColor:t.borderRingCream,gap:r.md,...Gd(i.dialog,n.StyleSheet.hairlineWidth)},keyboardAvoider:{flex:1,gap:r.md},header:{flexDirection:"row",alignItems:"center",gap:r.sm},heading:{...headingFace(e,"bold"),flex:1,fontSize:l.size.subtitle,color:o,...Do(i.dialog)},newChat:{minHeight:lf,justifyContent:"center",paddingHorizontal:r.xs},newChatLabel:{...face(e,"bold"),fontSize:rf,color:t.brandInk},closeButton:{width:lf,height:lf,alignItems:"center",justifyContent:"center"},searchPill:{flexDirection:"row",alignItems:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,paddingHorizontal:r.md+df,paddingVertical:r.sm+df,borderWidth:1,borderColor:t.borderRingCream,...Oo(i.input,1)},searchInput:{...face(e,"regular"),flex:1,fontSize:l.size.bodyTight,color:t.text.primary,padding:0,...Do(i.input)},countLabel:{...face(e,"mono"),fontSize:nf,color:t.text.muted},list:{gap:r.xs,paddingBottom:r.xl},listEmpty:{flexGrow:1},item:{paddingVertical:r.sm+df,paddingHorizontal:r.sm,borderRadius:e.radius.md,gap:df},itemActive:{backgroundColor:Qa(t.highlight,tf)??t.surfaceSubtle},itemRow:{flexDirection:"row",alignItems:"center",gap:r.sm},itemTitle:{...face(e,"bold"),flex:1,fontSize:l.size.bodyTight,color:o},itemMeta:{...face(e,"regular"),fontSize:l.size.caption,color:t.text.muted},unreadDot:{width:cf,height:cf,borderRadius:cf/2,backgroundColor:t.danger},errorCard:{borderRadius:sf,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.danger,backgroundColor:t.surface,padding:r.md},errorText:{...face(e,"regular"),fontSize:l.size.caption,color:t.danger},emptyCard:{borderRadius:af,padding:r.md+df,gap:r.xs+df,backgroundColor:t.surfaceSubtle,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.borderRingCream,...Oo(i.card,n.StyleSheet.hairlineWidth)},emptyTitle:{...headingFace(e,"bold"),fontSize:l.size.bodyTight,color:o,...a},emptyBody:{...face(e,"regular"),fontSize:l.size.caption,color:t.text.secondary,...a},noMatch:{...face(e,"regular"),fontSize:l.size.bodyTight,color:t.text.muted,paddingVertical:r.sm},retrySlot:{marginTop:r.sm,alignSelf:"flex-start"},retryButton:{borderRadius:e.radius.pill,paddingHorizontal:r.md+df,paddingVertical:r.sm,borderWidth:1,borderColor:t.brandInk,...Oo(i.primaryButton)},retryText:{...face(e,"bold"),fontSize:l.size.caption,color:t.brandInk,...Do(i.primaryButton)},loadMoreFooter:{paddingVertical:r.md+df,alignItems:"center"},loadMoreLabel:{...face(e,"regular"),fontSize:l.size.caption,color:t.text.muted}})}function gf(e,t=/* @__PURE__ */new Date,r){let n=new Date(e);if(Number.isNaN(n.getTime()))return null;let l=new Date(t);l.setHours(0,0,0,0);let i=new Date(n);i.setHours(0,0,0,0);let o=Math.round((l.getTime()-i.getTime())/864e5);if(o===0||o===1)try{let e=new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(-o,"day");return e.charAt(0).toLocaleUpperCase(r)+e.slice(1)}catch{}return n.toLocaleDateString(r,{month:"short",day:"numeric"})}function mf(e,t){let r=new Date(e);return Number.isNaN(r.getTime())?null:r.toLocaleTimeString(t,{hour:"numeric",minute:"2-digit"})}function yf(e,t=/* @__PURE__ */new Date){let r=[];for(let n of e){let e=gf(n.updatedAt,t)??"",l=r[r.length-1];l!==void 0&&l.day===e?l.rows.push(n):r.push({day:e,rows:[n]})}return r}var vf="rgba(38,37,35,0.38)",xf=28,wf=40,kf=5,Sf=11,Cf=10.5,jf=36,Rf=11,Tf=14,_f=15,zf=13.5,If=48,Pf=2,Ef=1.3,Mf=.12,Af=16,Ff=8,Lf="80%";function Of(e,r,n){let l=e?.renderIcon;return l===void 0?n:/* @__PURE__ */t.jsx(HostRender,{render:()=>l(r),fallback:n})}function HistorySheet({chat:r,history:i,sheet:o}){let a=useEverfurTheme(),s=e.useMemo(()=>Vf(a),[a]),u=l.useSafeAreaInsets(),c=e.useMemo(()=>yf(i.rows),[i.rows]),d=de();if(!i.open)return null;let p=a.color,f=o?.title?.trim(),h=f!==void 0&&f!==""?f:yi.heading;/* @__PURE__ */
209
210
  return t.jsx(n.Modal,{visible:true,transparent:true,animationType:"slide",onRequestClose:i.close,children:/* @__PURE__ */t.jsxs(n.View,{style:s.root,children:[
210
- /* @__PURE__ */t.jsx(n.Pressable,{style:[Za,s.scrim],onPress:i.close,accessibilityRole:"button",accessibilityLabel:gi.closeA11y}),
211
+ /* @__PURE__ */t.jsx(n.Pressable,{style:[Xa,s.scrim],onPress:i.close,accessibilityRole:"button",accessibilityLabel:yi.closeA11y}),
211
212
  /* @__PURE__ */t.jsxs(n.View,{style:pe([s.sheet,{paddingBottom:Math.max(40,u.bottom+a.space.lg)}],d),accessibilityViewIsModal:true,testID:"everfur-history-sheet",children:[
212
213
  /* @__PURE__ */t.jsx(n.View,{style:s.grab}),
213
214
  /* @__PURE__ */t.jsxs(n.View,{style:s.top,children:[
214
215
  /* @__PURE__ */t.jsx(Text,{tier:"compact",style:s.kicker,accessibilityRole:"header",children:h}),
215
- /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:gi.closeA11y,onPress:i.close,style:s.close,children:zf(o,"close",/* @__PURE__ */t.jsx(CloseGlyph,{size:22,color:p.text.primary,strokeWidth:2}))})]}),
216
- /* @__PURE__ */t.jsxs(n.ScrollView,{style:s.scroll,contentContainerStyle:s.scrollContent,keyboardShouldPersistTaps:"handled",children:[i.loading&&i.rows.length===0?/* @__PURE__ */t.jsxs(n.View,{style:s.state,accessibilityLabel:gi.loading,accessibilityState:{busy:true},children:[
216
+ /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:yi.closeA11y,onPress:i.close,style:s.close,children:Of(o,"close",/* @__PURE__ */t.jsx(CloseGlyph,{size:22,color:p.text.primary,strokeWidth:2}))})]}),
217
+ /* @__PURE__ */t.jsxs(n.ScrollView,{style:s.scroll,contentContainerStyle:s.scrollContent,keyboardShouldPersistTaps:"handled",children:[i.loading&&i.rows.length===0?/* @__PURE__ */t.jsxs(n.View,{style:s.state,accessibilityLabel:yi.loading,accessibilityState:{busy:true},children:[
217
218
  /* @__PURE__ */t.jsx(n.ActivityIndicator,{color:p.brandInk}),
218
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:s.mono,children:gi.loading})]}):null,i.error!==null?/* @__PURE__ */t.jsxs(n.View,{style:s.state,children:[
219
- /* @__PURE__ */t.jsx(Text,{style:s.stateText,accessibilityRole:"alert",children:gi.loadFailed}),
220
- /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:gi.retry,onPress:()=>{i.load()},style:s.link,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:s.linkText,children:gi.retry})})]}):null,!i.loading&&i.error===null&&i.rows.length===0?/* @__PURE__ */t.jsx(Text,{style:[s.stateText,s.state],children:gi.empty}):null,c.map((l,a)=>/* @__PURE__ */t.jsxs(e.Fragment,{children:[l.day?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:[s.mono,s.day,a===0?s.dayFirst:null],children:l.day}):null,l.rows.map(e=>{let l=e.id===r.conversationId,a=e.unreadCount!==null&&e.unreadCount>0,u=uf(e.updatedAt);/* @__PURE__ */
221
- return t.jsxs(n.Pressable,{accessibilityRole:"button",accessibilityLabel:wi(e),accessibilityState:{selected:l},onPress:()=>{i.resume(e.id)},style:[s.row,l?s.rowCurrent:null],children:[
222
- /* @__PURE__ */t.jsx(n.View,{style:s.icon,children:zf(o,"chat",/* @__PURE__ */t.jsx(ChatBubbleGlyph,{size:19,color:p.linkInk,strokeWidth:1.75}))}),
219
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:s.mono,children:yi.loading})]}):null,i.error!==null?/* @__PURE__ */t.jsxs(n.View,{style:s.state,children:[
220
+ /* @__PURE__ */t.jsx(Text,{style:s.stateText,accessibilityRole:"alert",children:yi.loadFailed}),
221
+ /* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:yi.retry,onPress:()=>{i.load()},style:s.link,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:s.linkText,children:yi.retry})})]}):null,!i.loading&&i.error===null&&i.rows.length===0?/* @__PURE__ */t.jsx(Text,{style:[s.stateText,s.state],children:yi.empty}):null,c.map((l,a)=>/* @__PURE__ */t.jsxs(e.Fragment,{children:[l.day?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:[s.mono,s.day,a===0?s.dayFirst:null],children:l.day}):null,l.rows.map(e=>{let l=e.id===r.conversationId,a=e.unreadCount!==null&&e.unreadCount>0,u=mf(e.updatedAt);/* @__PURE__ */
222
+ return t.jsxs(n.Pressable,{accessibilityRole:"button",accessibilityLabel:Si(e),accessibilityState:{selected:l},onPress:()=>{i.resume(e.id)},style:[s.row,l?s.rowCurrent:null],children:[
223
+ /* @__PURE__ */t.jsx(n.View,{style:s.icon,children:Of(o,"chat",/* @__PURE__ */t.jsx(ChatBubbleGlyph,{size:19,color:p.linkInk,strokeWidth:1.75}))}),
223
224
  /* @__PURE__ */t.jsxs(n.View,{style:s.rowWords,children:[
224
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:s.rowTitle,numberOfLines:1,children:mi(e.title)}),e.preview!==void 0?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:s.preview,numberOfLines:1,children:e.preview}):null]}),
225
- /* @__PURE__ */t.jsxs(n.View,{style:s.rowEnd,children:[u!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:[s.mono,s.time,a?s.timeUnread:null],children:u}):null,a?/* @__PURE__ */t.jsx(n.View,{style:s.unreadDot,testID:`everfur-history-sheet-unread-${String(e.id)}`}):null]})]},String(e.id))})]},l.day)),i.cursor!==null&&!i.loadingMore?/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:gi.more,onPress:i.loadMore,style:s.link,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:s.linkText,children:gi.more})}):null]}),
226
- /* @__PURE__ */t.jsxs(n.Pressable,{accessibilityRole:"button",accessibilityLabel:gi.newChat,onPress:i.newConversation,style:s.newChat,children:[zf(o,"edit",/* @__PURE__ */t.jsx(EditGlyph,{size:18,color:a.slots.primaryButton?.textColor??p.onPrimary,strokeWidth:1.75})),
227
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:s.newChatText,children:gi.newChat})]})]})]})})}function If(e){let t=e.color,r=e.space,l={...face(e,"mono"),fontSize:gf,letterSpacing:gf*.06,textTransform:"uppercase",color:t.text.muted};return n.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{backgroundColor:df},sheet:{maxHeight:_f,backgroundColor:t.surface,borderTopLeftRadius:pf,borderTopRightRadius:pf,paddingTop:10,paddingHorizontal:20},grab:{width:ff,height:hf,borderRadius:3,backgroundColor:t.borderRingCream,alignSelf:"center",marginBottom:10},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},kicker:{...l,fontSize:bf,letterSpacing:bf*.08,flexShrink:1},close:{width:Ts,height:Ts,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:Ts/2},scroll:{flexGrow:0},scrollContent:{paddingBottom:r.xs},mono:l,day:{marginTop:r.lg,marginBottom:r.xs},dayFirst:{marginTop:Sf},state:{marginVertical:r.md,gap:r.sm,alignItems:"flex-start"},stateText:{...face(e,"regular"),fontSize:e.type.size.body,color:t.text.primary},link:{minHeight:Ts,justifyContent:"center"},linkText:{...face(e,"bold"),fontSize:e.type.size.body,color:t.brandInk},row:{flexDirection:"row",alignItems:"center",gap:r.md,paddingVertical:10,paddingHorizontal:r.sm,borderRadius:vf,minHeight:Ts},rowCurrent:{backgroundColor:t.surfaceSubtle},icon:{width:mf,height:mf,borderRadius:yf,backgroundColor:Ka(t.linkInk,jf)??t.surfaceSubtle,alignItems:"center",justifyContent:"center"},rowWords:{flex:1,minWidth:0},rowTitle:{...face(e,"bold"),fontSize:xf,lineHeight:xf*Cf,color:t.text.primary},preview:{...face(e,"regular"),fontSize:wf,color:t.text.muted,marginTop:2},rowEnd:{alignSelf:"flex-start",alignItems:"flex-end",gap:6},time:{marginTop:3,letterSpacing:gf*.04,textTransform:"none"},timeUnread:{...face(e,"monoBold"),color:t.text.primary},unreadDot:{width:Tf,height:Tf,borderRadius:Tf/2,backgroundColor:t.danger},newChat:{marginTop:r.lg,minHeight:kf,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.primary,...Ao(e.slots.primaryButton)},newChatText:{...face(e,"bold"),fontSize:Rf,color:t.onPrimary,...Oo(e.slots.primaryButton)}})}var Pf="Close",Ef=/* @__PURE__ */Object.freeze({action:e=>e.possessive===null?null:`See ${e.possessive} Health Plan`,ask:"What does it mean?",askPrompt:(e,t)=>e.risk?.lead?`${e.risk.lead} ${t}`:`${e.title}: ${t}`,close:e=>e.possessive===null?null:`Close ${e.possessive} focus`,resultsKicker:e=>e.possessive===null?null:`${Mf(e.possessive)} results`,resultsClose:e=>e.possessive===null?null:`Close ${e.possessive} results`,resultsTopRisk:"Top risk"});function Mf(e){return e.charAt(0).toUpperCase()+e.slice(1)}function healthPlanPossessive(e){let t=typeof e.sex=="string"?e.sex.trim().toLowerCase():null;if(t==="female")return"her";if(t==="male")return"his";let r=typeof e.name=="string"?e.name.trim():"";return r!==""?`${r}'s`:null}function healthPlanTopCard(e,t={}){let r=e?.page?.focus;if(e===null||r===void 0||r.title.trim()===""||r.kicker.trim()==="")return;let n={...Ef,...t.copy},l={pet:e.pet,possessive:healthPlanPossessive(e.pet)},i=r.sources?.find(e=>e.label.trim()!=="")?.label,o=t.onOpenPlan,a=o===void 0?null:n.action(l),s=n.close(l),u=n.ask.trim(),c=t.results!==void 0&&r.report!==void 0?t.results:void 0;if(c!==void 0){let e=n.resultsKicker(l)?.trim()||r.kicker,s=n.resultsClose(l),d=c.onTopRisk??o,p={key:"top-risk",label:n.resultsTopRisk,title:r.title,...r.risk?.lead?{line:r.risk.lead}:{},tone:"risk",...d===void 0?{}:{onPress:d}};return{kicker:e,...i===void 0?{}:{badge:i},title:r.title,results:[p,...c.rows??[]],...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?Pf:s,pill:e,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}return{kicker:r.kicker,...i===void 0?{}:{badge:i},title:r.title,...r.risk?.lead?{lead:r.risk.lead}:{},...r.risk?.body?{body:r.risk.body}:{},...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?Pf:s,pill:r.kicker,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}function Ff(e){let t=face(e,"medium");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"600"}}function Af(e){let t=face(e,"bold");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"800"}}var Lf=20,Of=14,Vf=16,Df=18,Bf=22,Hf=15,Wf=12,Nf=24,Uf=15,$f=14.5,qf=21,Gf=14.5,Kf=18,Yf=9,Qf=36,Zf=14,Jf=15,Xf=8,eh=40;function TopCard({card:r,open:l,onOpenChange:i,ask:o}){let a=useEverfurTheme(),s=Ap(),u=e.useMemo(()=>s!==null?rh(s):nh(a),[a,s]),c=e.useMemo(()=>Ao(a.slots.card),[a.slots.card]);if(!l)return null;let d=r.closeLabel===void 0?null:r.closeLabel.trim()!==""?r.closeLabel:je.close,p=r.action,f=r.ask,h=/* @__PURE__ */t.jsx(CloseGlyph,{size:s!==null?HOME_CLOSE_GLYPH(s):Kf,color:s!==null?String(s.text(".ask-focus__x").color):a.color.text.primary,strokeWidth:2});/* @__PURE__ */
225
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:s.rowTitle,numberOfLines:1,children:vi(e.title)}),e.preview!==void 0?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:s.preview,numberOfLines:1,children:e.preview}):null]}),
226
+ /* @__PURE__ */t.jsxs(n.View,{style:s.rowEnd,children:[u!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:[s.mono,s.time,a?s.timeUnread:null],children:u}):null,a?/* @__PURE__ */t.jsx(n.View,{style:s.unreadDot,testID:`everfur-history-sheet-unread-${String(e.id)}`}):null]})]},String(e.id))})]},l.day)),i.cursor!==null&&!i.loadingMore?/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:yi.more,onPress:i.loadMore,style:s.link,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:s.linkText,children:yi.more})}):null]}),
227
+ /* @__PURE__ */t.jsxs(n.Pressable,{accessibilityRole:"button",accessibilityLabel:yi.newChat,onPress:i.newConversation,style:s.newChat,children:[Of(o,"edit",/* @__PURE__ */t.jsx(EditGlyph,{size:18,color:a.slots.primaryButton?.textColor??p.onPrimary,strokeWidth:1.75})),
228
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:s.newChatText,children:yi.newChat})]})]})]})})}function Vf(e){let t=e.color,r=e.space,l={...face(e,"mono"),fontSize:Cf,letterSpacing:Cf*.06,textTransform:"uppercase",color:t.text.muted};return n.StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},scrim:{backgroundColor:vf},sheet:{maxHeight:Lf,backgroundColor:t.surface,borderTopLeftRadius:xf,borderTopRightRadius:xf,paddingTop:10,paddingHorizontal:20},grab:{width:wf,height:kf,borderRadius:3,backgroundColor:t.borderRingCream,alignSelf:"center",marginBottom:10},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},kicker:{...l,fontSize:Sf,letterSpacing:Sf*.08,flexShrink:1},close:{width:zs,height:zs,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:zs/2},scroll:{flexGrow:0},scrollContent:{paddingBottom:r.xs},mono:l,day:{marginTop:r.lg,marginBottom:r.xs},dayFirst:{marginTop:Pf},state:{marginVertical:r.md,gap:r.sm,alignItems:"flex-start"},stateText:{...face(e,"regular"),fontSize:e.type.size.body,color:t.text.primary},link:{minHeight:zs,justifyContent:"center"},linkText:{...face(e,"bold"),fontSize:e.type.size.body,color:t.brandInk},row:{flexDirection:"row",alignItems:"center",gap:r.md,paddingVertical:10,paddingHorizontal:r.sm,borderRadius:Tf,minHeight:zs},rowCurrent:{backgroundColor:t.surfaceSubtle},icon:{width:jf,height:jf,borderRadius:Rf,backgroundColor:Qa(t.linkInk,Mf)??t.surfaceSubtle,alignItems:"center",justifyContent:"center"},rowWords:{flex:1,minWidth:0},rowTitle:{...face(e,"bold"),fontSize:_f,lineHeight:_f*Ef,color:t.text.primary},preview:{...face(e,"regular"),fontSize:zf,color:t.text.muted,marginTop:2},rowEnd:{alignSelf:"flex-start",alignItems:"flex-end",gap:6},time:{marginTop:3,letterSpacing:Cf*.04,textTransform:"none"},timeUnread:{...face(e,"monoBold"),color:t.text.primary},unreadDot:{width:Ff,height:Ff,borderRadius:Ff/2,backgroundColor:t.danger},newChat:{marginTop:r.lg,minHeight:If,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:r.sm,borderRadius:e.radius.pill,backgroundColor:t.primary,...Oo(e.slots.primaryButton)},newChatText:{...face(e,"bold"),fontSize:Af,color:t.onPrimary,...Do(e.slots.primaryButton)}})}var Df="Close",Bf=/* @__PURE__ */Object.freeze({action:e=>e.possessive===null?null:`See ${e.possessive} Health Plan`,ask:"What does it mean?",askPrompt:(e,t)=>e.risk?.lead?`${e.risk.lead} ${t}`:`${e.title}: ${t}`,close:e=>e.possessive===null?null:`Close ${e.possessive} focus`,resultsKicker:e=>e.possessive===null?null:`${Hf(e.possessive)} results`,resultsClose:e=>e.possessive===null?null:`Close ${e.possessive} results`,resultsTopRisk:"Top risk"});function Hf(e){return e.charAt(0).toUpperCase()+e.slice(1)}function healthPlanPossessive(e){let t=typeof e.sex=="string"?e.sex.trim().toLowerCase():null;if(t==="female")return"her";if(t==="male")return"his";let r=typeof e.name=="string"?e.name.trim():"";return r!==""?`${r}'s`:null}function healthPlanTopCard(e,t={}){let r=e?.page?.focus;if(e===null||r===void 0||r.title.trim()===""||r.kicker.trim()==="")return;let n={...Bf,...t.copy},l={pet:e.pet,possessive:healthPlanPossessive(e.pet)},i=r.sources?.find(e=>e.label.trim()!=="")?.label,o=t.onOpenPlan,a=o===void 0?null:n.action(l),s=n.close(l),u=n.ask.trim(),c=t.results!==void 0&&r.report!==void 0?t.results:void 0;if(c!==void 0){let e=n.resultsKicker(l)?.trim()||r.kicker,s=n.resultsClose(l),d=c.onTopRisk??o,p={key:"top-risk",label:n.resultsTopRisk,title:r.title,...r.risk?.lead?{line:r.risk.lead}:{},tone:"risk",...d===void 0?{}:{onPress:d}};return{kicker:e,...i===void 0?{}:{badge:i},title:r.title,results:[p,...c.rows??[]],...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?Df:s,pill:e,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}return{kicker:r.kicker,...i===void 0?{}:{badge:i},title:r.title,...r.risk?.lead?{lead:r.risk.lead}:{},...r.risk?.body?{body:r.risk.body}:{},...a===null||a.trim()===""||o===void 0?{}:{action:{label:a,onPress:o}},...u===""?{}:{ask:{label:u,prompt:n.askPrompt(r,u)}},closeLabel:s===null||s.trim()===""?Df:s,pill:r.kicker,...t.renderIcon===void 0?{}:{renderIcon:t.renderIcon}}}function Wf(e){let t=face(e,"medium");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"600"}}function Nf(e){let t=face(e,"bold");return t.fontWeight===void 0?t:{fontFamily:t.fontFamily,fontWeight:"800"}}var Uf=20,$f=14,qf=16,Gf=18,Kf=22,Yf=15,Qf=12,Zf=24,Jf=15,Xf=14.5,eh=21,th=14.5,rh=18,nh=9,lh=36,ih=14,oh=15,ah=8,sh=40;function TopCard({card:r,open:l,onOpenChange:i,ask:o}){let a=useEverfurTheme(),s=Np(),u=e.useMemo(()=>s!==null?ch(s):dh(a),[a,s]),c=e.useMemo(()=>Oo(a.slots.card),[a.slots.card]);if(!l)return null;let d=r.closeLabel===void 0?null:r.closeLabel.trim()!==""?r.closeLabel:Te.close,p=r.action,f=r.ask,h=/* @__PURE__ */t.jsx(CloseGlyph,{size:s!==null?HOME_CLOSE_GLYPH(s):rh,color:s!==null?String(s.text(".ask-focus__x").color):a.color.text.primary,strokeWidth:2});/* @__PURE__ */
228
229
  return t.jsxs(n.View,{style:[u.card,c],testID:"everfur-top-card",children:[
229
230
  /* @__PURE__ */t.jsxs(n.View,{style:u.kickerRow,children:[
230
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:u.kicker,children:r.kicker}),r.badge!==void 0?/* @__PURE__ */t.jsx(n.View,{style:u.badge,children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:u.badgeText,numberOfLines:1,children:r.badge})}):null,d!==null?/* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>i(false),accessibilityRole:"button",accessibilityLabel:d,style:u.close,hitSlop:s!==null?th:void 0,testID:"everfur-top-card-close",children:r.renderIcon!==void 0?/* @__PURE__ */t.jsx(HostRender,{render:()=>r.renderIcon?.("close"),fallback:h}):h}):null]}),
231
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:u.kicker,children:r.kicker}),r.badge!==void 0?/* @__PURE__ */t.jsx(n.View,{style:u.badge,children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:u.badgeText,numberOfLines:1,children:r.badge})}):null,d!==null?/* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>i(false),accessibilityRole:"button",accessibilityLabel:d,style:u.close,hitSlop:s!==null?uh:void 0,testID:"everfur-top-card-close",children:r.renderIcon!==void 0?/* @__PURE__ */t.jsx(HostRender,{render:()=>r.renderIcon?.("close"),fallback:h}):h}):null]}),
231
232
  /* @__PURE__ */t.jsx(Text,{tier:"heading",style:u.title,accessibilityRole:"header",children:r.title}),r.lead!==void 0||r.body!==void 0?/* @__PURE__ */t.jsxs(n.View,{style:u.finding,children:[
232
233
  /* @__PURE__ */t.jsx(n.View,{style:u.dot}),
233
- /* @__PURE__ */t.jsxs(Text,{style:u.findingText,children:[r.lead!==void 0?/* @__PURE__ */t.jsx(Text,{style:u.lead,children:r.lead}):null,r.lead!==void 0&&r.body!==void 0?" ":null,r.body??null]})]}):null,p!==void 0||f!==void 0?/* @__PURE__ */t.jsxs(n.View,{style:u.actions,children:[p!==void 0?/* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>{Er(p.onPress)},accessibilityRole:"button",accessibilityLabel:p.label,style:u.action,hitSlop:s!==null?th:void 0,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:u.actionText,children:p.label})}):null,f!==void 0?/* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>o(f.prompt),accessibilityRole:"button",accessibilityLabel:f.label,style:u.ask,hitSlop:s!==null?th:void 0,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:u.askText,children:f.label})}):null]}):null]})}function TopCardPill({card:r,open:l,onOpenChange:i}){let o=useEverfurTheme(),a=Ap(),s=e.useMemo(()=>a!==null?rh(a):nh(o),[o,a]);if(l||r.closeLabel===void 0)return null;let u=r.pill??r.kicker;/* @__PURE__ */
234
- return t.jsxs(n.Pressable,{onPress:()=>i(true),accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{expanded:false},style:s.pill,hitSlop:a!==null?th:void 0,testID:"everfur-top-card-pill",children:[
234
+ /* @__PURE__ */t.jsxs(Text,{style:u.findingText,children:[r.lead!==void 0?/* @__PURE__ */t.jsx(Text,{style:u.lead,children:r.lead}):null,r.lead!==void 0&&r.body!==void 0?" ":null,r.body??null]})]}):null,p!==void 0||f!==void 0?/* @__PURE__ */t.jsxs(n.View,{style:u.actions,children:[p!==void 0?/* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>{Ar(p.onPress)},accessibilityRole:"button",accessibilityLabel:p.label,style:u.action,hitSlop:s!==null?uh:void 0,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:u.actionText,children:p.label})}):null,f!==void 0?/* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>o(f.prompt),accessibilityRole:"button",accessibilityLabel:f.label,style:u.ask,hitSlop:s!==null?uh:void 0,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:u.askText,children:f.label})}):null]}):null]})}function TopCardPill({card:r,open:l,onOpenChange:i}){let o=useEverfurTheme(),a=Np(),s=e.useMemo(()=>a!==null?ch(a):dh(o),[o,a]);if(l||r.closeLabel===void 0)return null;let u=r.pill??r.kicker;/* @__PURE__ */
235
+ return t.jsxs(n.Pressable,{onPress:()=>i(true),accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{expanded:false},style:s.pill,hitSlop:a!==null?uh:void 0,testID:"everfur-top-card-pill",children:[
235
236
  /* @__PURE__ */t.jsx(n.View,{style:s.pillDot}),
236
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:s.pillText,numberOfLines:1,children:u})]})}var th=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:Kf};function rh(e){let t=e.text(".hp-need__s",".ask-focus .hp-need__s"),r=typeof t.lineHeight=="number"?t.lineHeight:21,n=e.view(".dot",".dot--risk"),l=typeof n.height=="number"?n.height:Yf;return{card:e.view(".ask-focus"),kickerRow:e.view(".hp-need__k"),kicker:[e.text(".hp-need__k"),{flexShrink:1}],badge:[e.view(".hp-srcs"),e.view(".hp-src",".hp-src--dna"),{flexShrink:1}],badgeText:e.text(".hp-src",".hp-src--dna"),close:e.view(".ask-focus__x"),title:[e.view(".ask-focus h3"),e.text(".ask-focus h3")],finding:[e.view(".hp-need__s"),{alignItems:"flex-start"}],dot:[e.col(".hp-need__s",0),n,{marginTop:Math.round((r-l)/2)}],findingText:[e.col(".hp-need__s",1),t],lead:(({fontFamily:e,fontWeight:t,color:r})=>({fontFamily:e,fontWeight:t,color:r}))(e.strong(".hp-need__s b")),actions:e.view(".ask-focus__acts"),action:[e.view(".emb-btn",".emb-btn--sm"),{maxWidth:"100%"}],actionText:e.text(".emb-btn",".emb-btn--sm"),ask:[e.view(".ask-focus__q"),{justifyContent:"center",maxWidth:"100%"}],askText:e.text(".ask-focus__q"),pill:[e.view(".ask-focus-pill"),{maxWidth:"100%"}],pillDot:e.view(".ask-focus-pill i"),pillText:[e.text(".ask-focus-pill"),{flexShrink:1}]}}function nh(e){let t=e.color,r=e.space;return n.StyleSheet.create({card:{paddingTop:Of,paddingHorizontal:Vf,paddingBottom:Vf,borderRadius:Lf,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Ts-8},kicker:{...Af(e),fontSize:Hf,color:t.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:Nf,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:Wf,color:t.text.secondary},close:{width:Ts,height:Ts,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:Ts/2},title:{...Af(e),fontSize:Df,lineHeight:Bf,color:t.text.primary,marginTop:r.xs},finding:{flexDirection:"row",gap:r.sm,marginTop:r.xs+2},dot:{width:Yf,height:Yf,borderRadius:Yf/2,marginTop:7,backgroundColor:t.danger},findingText:{...face(e,"regular"),flex:1,fontSize:$f,lineHeight:qf,color:t.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.lg,marginTop:14},action:{minHeight:Math.max(eh,Ts),paddingHorizontal:r.lg,borderRadius:e.radius.pill,backgroundColor:t.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:Uf,color:t.onPrimary},ask:{minHeight:Ts,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:Gf,color:t.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Math.max(Qf,Ts),paddingHorizontal:Zf,borderRadius:e.radius.pill,backgroundColor:t.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:Xf,height:Xf,borderRadius:Xf/2,backgroundColor:t.danger},pillText:{...face(e,"bold"),fontSize:Jf,color:t.danger,flexShrink:1}})}var lh=/* @__PURE__ */Object.freeze({ink:"#262523",ink2:"#4A4845",ink3:"#6B6863",paper:"#F8F7F4",card:"#FFFFFF",line:"#E7E6E2",tile:"#F2F1EE",shadow:"rgba(38, 37, 35, .07)",riskBg:"#FFE3E1",riskInk:"#B0231B",riskDot:"#E5372B",clearBg:"#E6F4D3",clearInk:"#2F6A12",clearDot:"#5FA82B",watchDot:"#E5A000"}),ih=/* @__PURE__ */new WeakMap;function oh(e){let t=ih.get(e);if(t!==void 0)return t;let r=e.color,n=e.brightness==="dark",l=n?{dark:n,ink:r.text.primary,ink2:r.text.secondary,ink3:r.text.muted,paper:r.background,card:r.surface,line:r.borderRingCream,tile:r.surfaceSubtle,shadow:r.shadow,riskBg:r.badgeBgCritical,riskInk:r.danger,riskDot:r.danger,clearBg:r.badgeBgPositive,clearInk:r.success,clearDot:r.success,watchDot:r.warningStrong}:{dark:n,...lh},i=(e,t)=>Qa(e,t,Wa(t),ah),o=(e,t)=>contrastRatio(e,t)>=ah?e:Ha(t,ah),a=[l.card,l.paper].map(e=>Ga(r.brandSoft,e)??e),s={primary:r.primary,onPrimary:o(r.onPrimary,r.primary),accent:r.accent,onAccent:o(r.onAccent,r.accent),link:i(r.linkInk,[l.card,l.paper,l.tile]),badge:r.brandSoft,onBadge:i(r.brandInk,a)},u=/* @__PURE__ */Object.freeze({...l,...s});return ih.set(e,u),u}var ah=4.5;function sh(e,t){for(let r of t)if(contrastRatio(r,e)>=ah)return r;return Ha(e,ah)}function uh(e,t,r){let n=Ka(e,t);return(n===null?null:Ga(n,r))??r}function ch(e){let t=oh(e),r=e.color,n=t.card;return{ink:t.ink,ink2:t.ink2,ink3:t.ink3,paper:t.paper,tile:t.tile,line:t.line,card:n,onInk:t.dark?r.background:"#FFFFFF",primary:t.primary,onPrimary:t.onPrimary,accent:t.accent,onAccent:sh(t.accent,[t.ink,t.onAccent]),accent2:uh(t.accent,.75,n),accent4:uh(t.accent,.17,n),accentChip:uh(t.accent,.47,n),link:t.link,linkChip:uh(t.link,.2,n),riskDot:t.riskDot,riskChip:t.dark?r.badgeBgCritical:"#FFD8D6",clearBg:t.clearBg,clearInk:t.clearInk,clearChip:t.dark?r.badgeBgPositive:"#DDEFC4",byInk:r.brandInk}}var dh=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),ph=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),fh=["paddingTop","paddingRight","paddingBottom","paddingLeft"],hh=17,bh=1.5,gh=400,mh=700;function yh(e){return e<=450?"regular":e<=650?"medium":"bold"}function vh(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function xh(e,t,r){if(t==="$mono"){let t=r<=450?"mono":r<=650?"monoMedium":"monoBold",n=face(e,t);return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:vh(r)}}let n=t==="$serif"?headingFace(e,yh(r)):face(e,yh(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:vh(r)}}function wh(e,t,r={}){let n=ch(e),l=e.brightness==="dark",i=e.motion.reducedMotion,o=e=>{if(typeof e=="string"&&e.startsWith("$")){let t=e.slice(1);return t.startsWith("n_")?l?n.line??e:`#${t.slice(2)}`:t==="sans"||t==="serif"||t==="mono"?e:n[t]??e}return Array.isArray(e)?e.map(e=>o(e)):e},a=/* @__PURE__ */new Map,s=e=>{let n=e.filter(e=>typeof e=="string"&&e!==""),l=n.join("|"),s=a.get(l);if(s!==void 0)return s;let u={},c=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)c(t[e]),i&&c(r[e]);let d=/* @__PURE__ */Object.freeze(u);return a.set(l,d),d},u=/* @__PURE__ */new Map,c=(...e)=>{let t=e.filter(Boolean).join("|"),r=u.get(t);if(r!==void 0)return r;let n=s(e),l={};for(let[e,t]of Object.entries(n))dh.has(e)||ph.has(e)||e==="ring"||e==="edge"||e==="shadow"||e==="round"||e==="zIndex"&&typeof t=="number"&&t<0||t!==null&&(l[e]=t);if((typeof n.fontSize=="number"||n.flexDirection==="row")&&n.position!=="absolute"&&typeof n.height=="number"&&typeof n.width!="number"){let e=l.height;delete l.height,typeof l.minHeight!="number"&&(l.minHeight=e)}let i=n.ring;if(Array.isArray(i)){let[e,t]=i;l.borderWidth=e,l.borderColor=t;for(let t of fh){let r=l[t];typeof r=="number"&&(l[t]=Math.max(0,r-e))}}let o=n.edge;if(Array.isArray(o)){let[e,t]=o;l.borderBottomWidth=e,l.borderBottomColor=t}let a=n.shadow;if(Array.isArray(a)){let[e,t,r,n]=a;l.shadowColor=n,l.shadowOffset={width:e,height:t},l.shadowOpacity=1,l.shadowRadius=r/2}if(n.round===1){let e=typeof n.width=="number"?n.width:typeof n.height=="number"?n.height:999;l.borderRadius=e/2}let c=/* @__PURE__ */Object.freeze(l);return u.set(t,c),c},d=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=d.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:hh,u=typeof o.lh=="number"?o.lh:bh,c=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...xh(e,p,c),fontSize:a,lineHeight:Math.round(a*u*100)/100,color:typeof o.color=="string"?o.color:n.ink};typeof o.ls=="number"&&(f.letterSpacing=Math.round(o.ls*a*100)/100);for(let e of["fontStyle","textAlign","textTransform","textDecorationLine"])typeof o[e]=="string"&&(f[e]=o[e]);let h=/* @__PURE__ */Object.freeze(f);return d.set(l,h),h};return{reduced:i,colors:n,view:c,text:(...e)=>p(gh,e),strong:(...e)=>p(mh,e),icon:(...e)=>{let t=s(e),r={tintColor:typeof t.color=="string"?t.color:n.ink};for(let e of["width","height","opacity"])typeof t[e]=="number"&&(r[e]=t[e]);return r},col:(e,t)=>{let r=s([e]).cols;if(!Array.isArray(r))return{};let n=r[Math.min(t,r.length-1)];if(typeof n=="number")return{width:n,flexShrink:0};let l=typeof n=="string"?Number.parseFloat(n):1;return{flex:Number.isFinite(l)?l:1,minWidth:0}},motion:(...e)=>{let t=s(e),r=t.ease;return{dur:typeof t.dur=="number"?t.dur:0,delay:typeof t.delay=="number"?t.delay:0,stagger:typeof t.stagger=="number"?t.stagger:0,ease:Array.isArray(r)&&r.length===4?r:null}},raw:(e,...t)=>s(t)[e]}}var kh={".serif":{family:"$serif",fontWeight:"800",ls:-.01},".emb-btn":{flexDirection:"row",alignItems:"center",justifyContent:"center",minHeight:48,paddingTop:0,paddingRight:22,paddingBottom:0,paddingLeft:22,borderRadius:999,backgroundColor:"$primary",color:"$onPrimary",fontWeight:"700",fontSize:16,textDecorationLine:"none",dur:160,ease:[.23,1,.32,1],gap:8},".emb-btn--sm":{minHeight:40,paddingTop:0,paddingRight:16,paddingBottom:0,paddingLeft:16,fontSize:15},".dot":{width:9,height:9,round:1,flexGrow:0,flexShrink:0},".dot--risk":{backgroundColor:"$riskDot"},".ask-chips":{flexDirection:"column",alignItems:"center",marginTop:22,gap:10},".chip":{paddingTop:10,paddingRight:16,paddingBottom:10,paddingLeft:16,borderRadius:999,fontSize:15,fontWeight:"600",lh:1.3,textAlign:"center",dur:160,ease:[.23,1,.32,1]},".ask-empty":{minHeight:"100%",flexDirection:"column",alignItems:"center",paddingTop:14,paddingRight:16,paddingBottom:22,paddingLeft:16,textAlign:"center"},".ask-empty h2":{fontSize:23,lh:1.12},".ask-start":{width:"100%",marginTop:"auto",marginRight:0,marginBottom:"auto",marginLeft:0,paddingTop:18,paddingRight:0,paddingBottom:18,paddingLeft:0,flexDirection:"column",alignItems:"center"},".ask-empty .ask-chips":{marginTop:14,alignSelf:"center",alignItems:"stretch",width:"100%",maxWidth:340},".hp-need__k":{flexDirection:"row",alignItems:"center",fontSize:15,fontWeight:"800",gap:8},".hp-srcs":{marginLeft:"auto",flexDirection:"row",gap:4},".hp-src":{height:24,paddingTop:0,paddingRight:9,paddingBottom:0,paddingLeft:9,borderRadius:999,backgroundColor:"$tile",color:"$ink2",fontSize:12,fontWeight:"700",flexDirection:"row",alignItems:"center",nowrap:1},".hp-src--dna":{backgroundColor:"$n_E0FDFF",color:"$link"},".hp-need__s":{alignItems:"baseline",marginTop:6,fontSize:15,lh:1.45,color:"$ink2",flexDirection:"row",cols:[9,"1fr"],gap:9},".hp-need__s b":{color:"$ink",fontWeight:"800"},".ask-focus":{width:"100%",paddingTop:14,paddingRight:16,paddingBottom:16,paddingLeft:16,borderRadius:20,backgroundColor:"$card",textAlign:"left",shadow:[0,1,3,"rgba(38, 37, 35, .07)"]},".ask-focus h3":{marginTop:10,fontSize:18,fontWeight:"800",lh:1.22},".ask-focus__x":{width:36,height:36,marginTop:-8,marginRight:-10,marginBottom:-8,marginLeft:-2,alignItems:"center",justifyContent:"center",round:1,color:"$ink2"},".ask-focus__x svg":{width:18,height:18},".ask-focus-pill":{marginLeft:"auto",flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:14,paddingBottom:0,paddingLeft:14,borderRadius:999,backgroundColor:"$n_FFE3E1",color:"$n_B0231B",fontSize:15,fontWeight:"800",gap:7},".ask-focus-pill i":{width:8,height:8,round:1,backgroundColor:"$riskDot"},".ask-focus .hp-need__s":{fontSize:14.5},".ask-focus__acts":{flexDirection:"row",flexWrap:"wrap",alignItems:"center",marginTop:12,rowGap:4,columnGap:16},".ask-focus__q":{minHeight:36,fontSize:14.5,fontWeight:"700",color:"$link",textDecorationLine:"underline"},".ask-top":{alignSelf:"stretch",flexDirection:"row",marginTop:-8,marginRight:0,marginBottom:6,marginLeft:0},".thread__hist":{flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:4,paddingBottom:0,paddingLeft:4,fontSize:15,fontWeight:"700",color:"$link",gap:6},".thread__hist svg":{width:18,height:18},".thread__count":{minWidth:22,height:20,paddingTop:0,paddingRight:6,paddingBottom:0,paddingLeft:6,borderRadius:999,backgroundColor:"$card",color:"$ink2",fontSize:12,fontWeight:"800",alignItems:"center",justifyContent:"center",ring:[1,"$line"]}},Sh=16;var Ch=4e3,jh=.5;function Rh(e,t,r){let n=1,l=-1;for(let i of e)l<0?l=i:l+t+i<=r?l+=t+i:(n+=1,l=i);return n}function Th(e,t,r){if(e.length===0)return r;let n=Rh(e,t,r),l=[];for(let n=0;n<e.length;n+=1){let i=0;for(let o=n;o<e.length;o+=1)i+=(o>n?t:0)+e[o],i<=r&&l.push(i)}l.sort((e,t)=>e-t);let i=jh*e.length+1;for(let o of l)if(Rh(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:r,style:l,measureCh:i}){let o=e.useMemo(()=>r.split(/\s+/).filter(e=>e!==""),[r]),a=n.StyleSheet.flatten(l),s=[r,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=e.useRef({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:o.map(()=>null)});let[c,d]=e.useState(null),p=c!==null&&c.key===s?c.value:null,f=()=>{let e=u.current;if(e.ch===null||e.line===null||e.words.some(e=>e===null))return;let t=e.words,r=t.reduce((e,t)=>e+t,0),n=t.length>1?Math.max(0,(e.line-r)/(t.length-1)):0,l=Th(t,n,(e.ch+jh)*i);d(t=>t!==null&&t.key===e.key&&t.value===l?t:{key:e.key,value:l})},h=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),f())};/* @__PURE__ */
237
- return t.jsxs(n.View,{style:_h.wrap,children:[
237
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:s.pillText,numberOfLines:1,children:u})]})}var uh=4,HOME_CLOSE_GLYPH=e=>{let t=e.icon(".ask-focus__x svg").width;return typeof t=="number"?t:rh};function ch(e){let t=e.text(".hp-need__s",".ask-focus .hp-need__s"),r=typeof t.lineHeight=="number"?t.lineHeight:21,n=e.view(".dot",".dot--risk"),l=typeof n.height=="number"?n.height:nh;return{card:e.view(".ask-focus"),kickerRow:e.view(".hp-need__k"),kicker:[e.text(".hp-need__k"),{flexShrink:1}],badge:[e.view(".hp-srcs"),e.view(".hp-src",".hp-src--dna"),{flexShrink:1}],badgeText:e.text(".hp-src",".hp-src--dna"),close:e.view(".ask-focus__x"),title:[e.view(".ask-focus h3"),e.text(".ask-focus h3")],finding:[e.view(".hp-need__s"),{alignItems:"flex-start"}],dot:[e.col(".hp-need__s",0),n,{marginTop:Math.round((r-l)/2)}],findingText:[e.col(".hp-need__s",1),t],lead:(({fontFamily:e,fontWeight:t,color:r})=>({fontFamily:e,fontWeight:t,color:r}))(e.strong(".hp-need__s b")),actions:e.view(".ask-focus__acts"),action:[e.view(".emb-btn",".emb-btn--sm"),{maxWidth:"100%"}],actionText:e.text(".emb-btn",".emb-btn--sm"),ask:[e.view(".ask-focus__q"),{justifyContent:"center",maxWidth:"100%"}],askText:e.text(".ask-focus__q"),pill:[e.view(".ask-focus-pill"),{maxWidth:"100%"}],pillDot:e.view(".ask-focus-pill i"),pillText:[e.text(".ask-focus-pill"),{flexShrink:1}]}}function dh(e){let t=e.color,r=e.space;return n.StyleSheet.create({card:{paddingTop:$f,paddingHorizontal:qf,paddingBottom:qf,borderRadius:Uf,backgroundColor:t.surface,borderWidth:1,borderColor:t.borderRingCream,alignSelf:"stretch"},kickerRow:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:zs-8},kicker:{...Nf(e),fontSize:Yf,color:t.text.primary,flexShrink:1},badge:{marginLeft:"auto",minHeight:Zf,justifyContent:"center",paddingHorizontal:9,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,flexShrink:1},badgeText:{...face(e,"bold"),fontSize:Qf,color:t.text.secondary},close:{width:zs,height:zs,marginVertical:-4,marginRight:-10,alignItems:"center",justifyContent:"center",borderRadius:zs/2},title:{...Nf(e),fontSize:Gf,lineHeight:Kf,color:t.text.primary,marginTop:r.xs},finding:{flexDirection:"row",gap:r.sm,marginTop:r.xs+2},dot:{width:nh,height:nh,borderRadius:nh/2,marginTop:7,backgroundColor:t.danger},findingText:{...face(e,"regular"),flex:1,fontSize:Xf,lineHeight:eh,color:t.text.primary},lead:face(e,"bold"),actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.lg,marginTop:14},action:{minHeight:Math.max(sh,zs),paddingHorizontal:r.lg,borderRadius:e.radius.pill,backgroundColor:t.primary,alignItems:"center",justifyContent:"center",maxWidth:"100%"},actionText:{...face(e,"bold"),fontSize:Jf,color:t.onPrimary},ask:{minHeight:zs,justifyContent:"center",maxWidth:"100%"},askText:{...face(e,"bold"),fontSize:th,color:t.brandInk,textDecorationLine:"underline"},pill:{flexDirection:"row",alignItems:"center",gap:r.sm,minHeight:Math.max(lh,zs),paddingHorizontal:ih,borderRadius:e.radius.pill,backgroundColor:t.badgeBgCritical,alignSelf:"flex-start",maxWidth:"100%"},pillDot:{width:ah,height:ah,borderRadius:ah/2,backgroundColor:t.danger},pillText:{...face(e,"bold"),fontSize:oh,color:t.danger,flexShrink:1}})}var ph=/* @__PURE__ */Symbol.for("everfur.sdk.rn.chatShellTabsBar");function fh(){let t=globalThis,r=t[ph];if(r!==void 0)return r;let n=e.createContext(false);return t[ph]=n,n}var hh=fh();function bh(){return e.useContext(hh)}var gh=/* @__PURE__ */Object.freeze({ink:"#262523",ink2:"#4A4845",ink3:"#6B6863",paper:"#F8F7F4",card:"#FFFFFF",line:"#E7E6E2",tile:"#F2F1EE",shadow:"rgba(38, 37, 35, .07)",riskBg:"#FFE3E1",riskInk:"#B0231B",riskDot:"#E5372B",clearBg:"#E6F4D3",clearInk:"#2F6A12",clearDot:"#5FA82B",watchDot:"#E5A000"}),mh=/* @__PURE__ */new WeakMap;function yh(e){let t=mh.get(e);if(t!==void 0)return t;let r=e.color,n=e.brightness==="dark",l=n?{dark:n,ink:r.text.primary,ink2:r.text.secondary,ink3:r.text.muted,paper:r.background,card:r.surface,line:r.borderRingCream,tile:r.surfaceSubtle,shadow:r.shadow,riskBg:r.badgeBgCritical,riskInk:r.danger,riskDot:r.danger,clearBg:r.badgeBgPositive,clearInk:r.success,clearDot:r.success,watchDot:r.warningStrong}:{dark:n,...gh},i=(e,t)=>Ja(e,t,Ua(t),vh),o=(e,t)=>contrastRatio(e,t)>=vh?e:Na(t,vh),a=[l.card,l.paper].map(e=>Ya(r.brandSoft,e)??e),s={primary:r.primary,onPrimary:o(r.onPrimary,r.primary),accent:r.accent,onAccent:o(r.onAccent,r.accent),link:i(r.linkInk,[l.card,l.paper,l.tile]),badge:r.brandSoft,onBadge:i(r.brandInk,a)},u=/* @__PURE__ */Object.freeze({...l,...s});return mh.set(e,u),u}var vh=4.5;function xh(e,t){for(let r of t)if(contrastRatio(r,e)>=vh)return r;return Na(e,vh)}function wh(e,t,r){let n=Qa(e,t);return(n===null?null:Ya(n,r))??r}function kh(e){let t=yh(e),r=e.color,n=t.card;return{ink:t.ink,ink2:t.ink2,ink3:t.ink3,paper:t.paper,tile:t.tile,line:t.line,card:n,onInk:t.dark?r.background:"#FFFFFF",primary:t.primary,onPrimary:t.onPrimary,accent:t.accent,onAccent:xh(t.accent,[t.ink,t.onAccent]),accent2:wh(t.accent,.75,n),accent4:wh(t.accent,.17,n),accentChip:wh(t.accent,.47,n),link:t.link,linkChip:wh(t.link,.2,n),riskDot:t.riskDot,riskChip:t.dark?r.badgeBgCritical:"#FFD8D6",clearBg:t.clearBg,clearInk:t.clearInk,clearChip:t.dark?r.badgeBgPositive:"#DDEFC4",byInk:r.brandInk}}var Sh=/* @__PURE__ */new Set(["color","fontSize","fontWeight","fontStyle","lh","ls","family","textAlign","textTransform","textDecorationLine"]),Ch=/* @__PURE__ */new Set(["dur","delay","stagger","ease","tint","k","cols","nowrap"]),jh=["paddingTop","paddingRight","paddingBottom","paddingLeft"],Rh=17,Th=1.5,_h=400,zh=700;function Ih(e){return e<=450?"regular":e<=650?"medium":"bold"}function Ph(e){let t=Math.min(900,Math.max(100,Math.round(e/100)*100));return String(t)}function Eh(e,t,r){if(t==="$mono"){let t=r<=450?"mono":r<=650?"monoMedium":"monoBold",n=face(e,t);return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Ph(r)}}let n=t==="$serif"?headingFace(e,Ih(r)):face(e,Ih(r));return n.fontWeight===void 0?{fontFamily:n.fontFamily}:{fontFamily:n.fontFamily,fontWeight:Ph(r)}}function Mh(e,t,r={}){let n=kh(e),l=e.brightness==="dark",i=e.motion.reducedMotion,o=e=>{if(typeof e=="string"&&e.startsWith("$")){let t=e.slice(1);return t.startsWith("n_")?l?n.line??e:`#${t.slice(2)}`:t==="sans"||t==="serif"||t==="mono"?e:n[t]??e}return Array.isArray(e)?e.map(e=>o(e)):e},a=/* @__PURE__ */new Map,s=e=>{let n=e.filter(e=>typeof e=="string"&&e!==""),l=n.join("|"),s=a.get(l);if(s!==void 0)return s;let u={},c=e=>{if(e!==void 0)for(let[t,r]of Object.entries(e))u[t]=o(r)};for(let e of n)c(t[e]),i&&c(r[e]);let d=/* @__PURE__ */Object.freeze(u);return a.set(l,d),d},u=/* @__PURE__ */new Map,c=(...e)=>{let t=e.filter(Boolean).join("|"),r=u.get(t);if(r!==void 0)return r;let n=s(e),l={};for(let[e,t]of Object.entries(n))Sh.has(e)||Ch.has(e)||e==="ring"||e==="edge"||e==="shadow"||e==="round"||e==="zIndex"&&typeof t=="number"&&t<0||t!==null&&(l[e]=t);if((typeof n.fontSize=="number"||n.flexDirection==="row")&&n.position!=="absolute"&&typeof n.height=="number"&&typeof n.width!="number"){let e=l.height;delete l.height,typeof l.minHeight!="number"&&(l.minHeight=e)}let i=n.ring;if(Array.isArray(i)){let[e,t]=i;l.borderWidth=e,l.borderColor=t;for(let t of jh){let r=l[t];typeof r=="number"&&(l[t]=Math.max(0,r-e))}}let o=n.edge;if(Array.isArray(o)){let[e,t]=o;l.borderBottomWidth=e,l.borderBottomColor=t}let a=n.shadow;if(Array.isArray(a)){let[e,t,r,n]=a;l.shadowColor=n,l.shadowOffset={width:e,height:t},l.shadowOpacity=1,l.shadowRadius=r/2}if(n.round===1){let e=typeof n.width=="number"?n.width:typeof n.height=="number"?n.height:999;l.borderRadius=e/2}let c=/* @__PURE__ */Object.freeze(l);return u.set(t,c),c},d=/* @__PURE__ */new Map,p=(t,r)=>{let l=`${t}|${r.filter(Boolean).join("|")}`,i=d.get(l);if(i!==void 0)return i;let o=s(r),a=typeof o.fontSize=="number"?o.fontSize:Rh,u=typeof o.lh=="number"?o.lh:Th,c=typeof o.fontWeight=="string"?Number(o.fontWeight):t,p=typeof o.family=="string"?o.family:"$sans",f={...Eh(e,p,c),fontSize:a,lineHeight:Math.round(a*u*100)/100,color:typeof o.color=="string"?o.color:n.ink};typeof o.ls=="number"&&(f.letterSpacing=Math.round(o.ls*a*100)/100);for(let e of["fontStyle","textAlign","textTransform","textDecorationLine"])typeof o[e]=="string"&&(f[e]=o[e]);let h=/* @__PURE__ */Object.freeze(f);return d.set(l,h),h};return{reduced:i,colors:n,view:c,text:(...e)=>p(_h,e),strong:(...e)=>p(zh,e),icon:(...e)=>{let t=s(e),r={tintColor:typeof t.color=="string"?t.color:n.ink};for(let e of["width","height","opacity"])typeof t[e]=="number"&&(r[e]=t[e]);return r},col:(e,t)=>{let r=s([e]).cols;if(!Array.isArray(r))return{};let n=r[Math.min(t,r.length-1)];if(typeof n=="number")return{width:n,flexShrink:0};let l=typeof n=="string"?Number.parseFloat(n):1;return{flex:Number.isFinite(l)?l:1,minWidth:0}},motion:(...e)=>{let t=s(e),r=t.ease;return{dur:typeof t.dur=="number"?t.dur:0,delay:typeof t.delay=="number"?t.delay:0,stagger:typeof t.stagger=="number"?t.stagger:0,ease:Array.isArray(r)&&r.length===4?r:null}},raw:(e,...t)=>s(t)[e]}}var Ah={".serif":{family:"$serif",fontWeight:"800",ls:-.01},".emb-btn":{flexDirection:"row",alignItems:"center",justifyContent:"center",minHeight:48,paddingTop:0,paddingRight:22,paddingBottom:0,paddingLeft:22,borderRadius:999,backgroundColor:"$primary",color:"$onPrimary",fontWeight:"700",fontSize:16,textDecorationLine:"none",dur:160,ease:[.23,1,.32,1],gap:8},".emb-btn--sm":{minHeight:40,paddingTop:0,paddingRight:16,paddingBottom:0,paddingLeft:16,fontSize:15},".dot":{width:9,height:9,round:1,flexGrow:0,flexShrink:0},".dot--risk":{backgroundColor:"$riskDot"},".ask-chips":{flexDirection:"column",alignItems:"center",marginTop:22,gap:10},".chip":{paddingTop:10,paddingRight:16,paddingBottom:10,paddingLeft:16,borderRadius:999,fontSize:15,fontWeight:"600",lh:1.3,textAlign:"center",dur:160,ease:[.23,1,.32,1]},".ask-empty":{minHeight:"100%",flexDirection:"column",alignItems:"center",paddingTop:14,paddingRight:16,paddingBottom:22,paddingLeft:16,textAlign:"center"},".ask-empty h2":{fontSize:23,lh:1.12},".ask-start":{width:"100%",marginTop:"auto",marginRight:0,marginBottom:"auto",marginLeft:0,paddingTop:18,paddingRight:0,paddingBottom:18,paddingLeft:0,flexDirection:"column",alignItems:"center"},".ask-empty .ask-chips":{marginTop:14,alignSelf:"center",alignItems:"stretch",width:"100%",maxWidth:340},".hp-need__k":{flexDirection:"row",alignItems:"center",fontSize:15,fontWeight:"800",gap:8},".hp-srcs":{marginLeft:"auto",flexDirection:"row",gap:4},".hp-src":{height:24,paddingTop:0,paddingRight:9,paddingBottom:0,paddingLeft:9,borderRadius:999,backgroundColor:"$tile",color:"$ink2",fontSize:12,fontWeight:"700",flexDirection:"row",alignItems:"center",nowrap:1},".hp-src--dna":{backgroundColor:"$n_E0FDFF",color:"$link"},".hp-need__s":{alignItems:"baseline",marginTop:6,fontSize:15,lh:1.45,color:"$ink2",flexDirection:"row",cols:[9,"1fr"],gap:9},".hp-need__s b":{color:"$ink",fontWeight:"800"},".ask-focus":{width:"100%",paddingTop:14,paddingRight:16,paddingBottom:16,paddingLeft:16,borderRadius:20,backgroundColor:"$card",textAlign:"left",shadow:[0,1,3,"rgba(38, 37, 35, .07)"]},".ask-focus h3":{marginTop:10,fontSize:18,fontWeight:"800",lh:1.22},".ask-focus__x":{width:36,height:36,marginTop:-8,marginRight:-10,marginBottom:-8,marginLeft:-2,alignItems:"center",justifyContent:"center",round:1,color:"$ink2"},".ask-focus__x svg":{width:18,height:18},".ask-focus-pill":{marginLeft:"auto",flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:14,paddingBottom:0,paddingLeft:14,borderRadius:999,backgroundColor:"$n_FFE3E1",color:"$n_B0231B",fontSize:15,fontWeight:"800",gap:7},".ask-focus-pill i":{width:8,height:8,round:1,backgroundColor:"$riskDot"},".ask-focus .hp-need__s":{fontSize:14.5},".ask-focus__acts":{flexDirection:"row",flexWrap:"wrap",alignItems:"center",marginTop:12,rowGap:4,columnGap:16},".ask-focus__q":{minHeight:36,fontSize:14.5,fontWeight:"700",color:"$link",textDecorationLine:"underline"},".ask-top":{alignSelf:"stretch",flexDirection:"row",marginTop:-8,marginRight:0,marginBottom:6,marginLeft:0},".thread__hist":{flexDirection:"row",alignItems:"center",minHeight:36,paddingTop:0,paddingRight:4,paddingBottom:0,paddingLeft:4,fontSize:15,fontWeight:"700",color:"$link",gap:6},".thread__hist svg":{width:18,height:18},".thread__count":{minWidth:22,height:20,paddingTop:0,paddingRight:6,paddingBottom:0,paddingLeft:6,borderRadius:999,backgroundColor:"$card",color:"$ink2",fontSize:12,fontWeight:"800",alignItems:"center",justifyContent:"center",ring:[1,"$line"]}},Fh=16;var Lh=4e3,Oh=.5;function Vh(e,t,r){let n=1,l=-1;for(let i of e)l<0?l=i:l+t+i<=r?l+=t+i:(n+=1,l=i);return n}function Dh(e,t,r){if(e.length===0)return r;let n=Vh(e,t,r),l=[];for(let n=0;n<e.length;n+=1){let i=0;for(let o=n;o<e.length;o+=1)i+=(o>n?t:0)+e[o],i<=r&&l.push(i)}l.sort((e,t)=>e-t);let i=Oh*e.length+1;for(let o of l)if(Vh(e,t,o)<=n)return Math.min(r,o+i);return r}function BalancedTitle({text:r,style:l,measureCh:i}){let o=e.useMemo(()=>r.split(/\s+/).filter(e=>e!==""),[r]),a=n.StyleSheet.flatten(l),s=[r,a.fontFamily,a.fontSize,a.fontWeight,a.letterSpacing].join("|"),u=e.useRef({key:"",ch:null,line:null,words:[]});u.current.key!==s&&(u.current={key:s,ch:null,line:null,words:o.map(()=>null)});let[c,d]=e.useState(null),p=c!==null&&c.key===s?c.value:null,f=()=>{let e=u.current;if(e.ch===null||e.line===null||e.words.some(e=>e===null))return;let t=e.words,r=t.reduce((e,t)=>e+t,0),n=t.length>1?Math.max(0,(e.line-r)/(t.length-1)):0,l=Dh(t,n,(e.ch+Oh)*i);d(t=>t!==null&&t.key===e.key&&t.value===l?t:{key:e.key,value:l})},h=e=>t=>{u.current.key===s&&(e(u.current,t.nativeEvent.layout.width),f())};/* @__PURE__ */
238
+ return t.jsxs(n.View,{style:Bh.wrap,children:[
238
239
  /* @__PURE__ */t.jsx(Text,{tier:"heading",style:p===null?l:[l,{maxWidth:p}],accessibilityRole:"header",children:r}),
239
- /* @__PURE__ */t.jsx(n.View,{style:_h.probeClip,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */t.jsxs(n.View,{style:_h.probeRow,children:[
240
+ /* @__PURE__ */t.jsx(n.View,{style:Bh.probeClip,pointerEvents:"none",accessibilityElementsHidden:true,importantForAccessibility:"no-hide-descendants",children:/* @__PURE__ */t.jsxs(n.View,{style:Bh.probeRow,children:[
240
241
  /* @__PURE__ */t.jsx(Text,{tier:"heading",style:l,onLayout:h((e,t)=>{e.ch=t}),children:"0"}),
241
- /* @__PURE__ */t.jsx(Text,{tier:"heading",style:l,onLayout:h((e,t)=>{e.line=t}),children:o.join(" ")}),o.map((e,r)=>/* @__PURE__ */t.jsx(Text,{tier:"heading",style:l,onLayout:h((e,t)=>{e.words[r]=t}),children:e},`${r}:${e}`))]})})]})}var _h=n.StyleSheet.create({wrap:{alignSelf:"stretch",alignItems:"center"},probeClip:{position:"absolute",left:0,top:0,width:0,height:0,overflow:"hidden",opacity:0},probeRow:{width:Ch,flexDirection:"row",alignItems:"flex-start"}});function zh(e){return{kit:wh(e,kh),Title:BalancedTitle,titleCh:Sh}}var Ih=/* @__PURE__ */Symbol.for("everfur.sdk.rn.poweredBy");function Ph(){let e=globalThis,t=e[Ih];if(t!==void 0)return t;let r={count:0,listeners:/* @__PURE__ */new Set};return e[Ih]=r,r}var Eh=e=>{let t=Ph();return t.listeners.add(e),()=>t.listeners.delete(e)},Mh=()=>Ph().count>0;function useHostPoweredBy(){return e.useSyncExternalStore(Eh,Mh,Mh)}function EverfurPoweredBy({children:r,style:n}){let l=useEverfurTheme().meta.hidePoweredBy;return e.useEffect(()=>{if(l)return;let e=Ph();return e.count+=1,e.listeners.forEach(e=>e()),()=>{e.count-=1,e.listeners.forEach(e=>e())}},[l]),l?null:r??/* @__PURE__ */t.jsx(Text,{tier:"compact",style:n,accessibilityRole:"text",children:je.poweredBy})}var Fh=/* @__PURE__ */Object.freeze({}),Ah=100,Lh=20;function Oh(e,t,r,n){return![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}function Vh(t,r){let l=typeof t=="number"&&Number.isFinite(t),i=e.useRef(null),[o,a]=e.useState(null),s=e.useRef(null),u=e.useRef(null),c=e.useRef(true),d=e.useCallback(()=>{u.current!==null&&clearTimeout(u.current),u.current=null},[]);e.useEffect(()=>(c.current=true,()=>{c.current=false,d()}),[d]);let p=e.useCallback(function e(t){i.current?.measureInWindow((r,l)=>{let i=s.current;if(!c.current||i===null)return;let o=Oh(l,i.y,i.height,n.Dimensions.get("window").height);if(o!==null){a(e=>e!==null&&e.chatTop===o.chatTop&&e.parentTop===o.parentTop?e:o);return}t>=Lh||(u.current=setTimeout(()=>{u.current=null,e(t+1)},Ah))})},[]),f=e.useCallback(e=>{let{y:t,height:r}=e.nativeEvent.layout;s.current={y:t,height:r},d(),p(0)},[p,d]);return e.useMemo(()=>{if(!r)return{avoidingProps:l?{keyboardVerticalOffset:t}:Fh,probeRef:null,topInWindow:null};let e=o?.parentTop??0;return{avoidingProps:l?{keyboardVerticalOffset:t,onLayout:f}:e>0?{keyboardVerticalOffset:e,onLayout:f}:{onLayout:f},probeRef:i,topInWindow:o?.chatTop??null}},[r,l,t,o,f])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */t.jsx(n.View,{ref:e,collapsable:false,pointerEvents:"none",style:Dh})}var Dh=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function Bh(){let[t,r]=e.useState(false);return e.useEffect(()=>{let e=n.Keyboard;if(typeof e?.addListener!="function")return;let t=n.Platform.OS==="ios",l=e.addListener(t?"keyboardWillShow":"keyboardDidShow",()=>r(true)),i=e.addListener(t?"keyboardWillHide":"keyboardDidHide",()=>r(false));return()=>{l.remove(),i.remove()}},[]),t}var Hh=4.5;var Wh=3;function Nh(e,t,r){return Qa(e,t,Wa(t),r)}function Uh(e,t){if(e.level==="emergency")return e;let r=e.level==="schedule_soon",n=Td(t),l=r?n.warning:n.info,i=Rd(t)&&!l?e:$h(e,t,r);return qh(i,t.slots.banner)}function $h(e,t,r){let n=t.color,l=Ga(r?n.badgeBgCaution:n.badgeBgInfo,n.surface)??n.surface,i=r?n.cautionAccent:n.infoEdge,o=Nh(Ga(i,n.surface)??i,[n.surface,n.chatGround],Wh),a=Nh(r?n.warningStrong:n.info,[l,n.surface],Hh);/* @__PURE__ */
242
- return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:Nh(n.text.primary,[l],Hh),pillColor:n.surface})}function qh(e,t){if(t===void 0)return e;let r={...e};return t.backgroundColor!==void 0&&(r.backgroundColor=t.backgroundColor),t.borderColor!==void 0&&(r.borderColor=t.borderColor),t.textColor!==void 0&&(r.textColor=t.textColor,r.reasonColor=t.textColor),/* @__PURE__ */Object.freeze(r)}function Gh(petRef,e){let t={entry:"chat",petRef:petRef};return e?.returnTo!==void 0&&(t.returnTo=e.returnTo),e?.usState!==void 0&&(t.usState=e.usState),e?.prefer!==void 0&&(t.prefer=e.prefer),t}var Kh=.75,Yh=1.5,Qh=.4,Zh=4,Jh=1.5,Xh=22,eb=14,tb=8,rb=20,nb=10,lb=13,ib=12,ob=15,ab=44,sb=14,ub=1.25,cb=14,db=6,pb=2;function fb(e,t){let r=e.color;if(t.level==="emergency")return{card:{backgroundColor:r.badgeBgCritical,borderColor:Ka(r.danger,Qh)??r.danger,borderWidth:Yh},label:r.danger,reason:r.text.primary,close:r.danger,action:{fill:r.surface,edge:r.danger,ink:r.danger}};let n=e.slots.banner?.borderRadius;return{card:{backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:Kh,...n===void 0?{}:{borderRadius:n}},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}function UrgencyBanner({surface:r,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,compact:o=false}){let a=useEverfurTheme(),s=e.useMemo(()=>hb(a),[a]),u=oo(),c=r.tier===null?null:Uh(r.tier,a),d=r.source;/* @__PURE__ */
242
+ /* @__PURE__ */t.jsx(Text,{tier:"heading",style:l,onLayout:h((e,t)=>{e.line=t}),children:o.join(" ")}),o.map((e,r)=>/* @__PURE__ */t.jsx(Text,{tier:"heading",style:l,onLayout:h((e,t)=>{e.words[r]=t}),children:e},`${r}:${e}`))]})})]})}var Bh=n.StyleSheet.create({wrap:{alignSelf:"stretch",alignItems:"center"},probeClip:{position:"absolute",left:0,top:0,width:0,height:0,overflow:"hidden",opacity:0},probeRow:{width:Lh,flexDirection:"row",alignItems:"flex-start"}});function Hh(e){return{kit:Mh(e,Ah),Title:BalancedTitle,titleCh:Fh}}var Wh=/* @__PURE__ */Symbol.for("everfur.sdk.rn.poweredBy");function Nh(){let e=globalThis,t=e[Wh];if(t!==void 0)return t;let r={count:0,listeners:/* @__PURE__ */new Set};return e[Wh]=r,r}var Uh=e=>{let t=Nh();return t.listeners.add(e),()=>t.listeners.delete(e)},$h=()=>Nh().count>0;function useHostPoweredBy(){return e.useSyncExternalStore(Uh,$h,$h)}function EverfurPoweredBy({children:r,style:n}){let l=useEverfurTheme().meta.hidePoweredBy;return e.useEffect(()=>{if(l)return;let e=Nh();return e.count+=1,e.listeners.forEach(e=>e()),()=>{e.count-=1,e.listeners.forEach(e=>e())}},[l]),l?null:r??/* @__PURE__ */t.jsx(Text,{tier:"compact",style:n,accessibilityRole:"text",children:Te.poweredBy})}var qh=/* @__PURE__ */Object.freeze({}),Gh=100,Kh=20;function Yh(e,t,r,n){return![e,t,r,n].every(Number.isFinite)||e+r>n+1?null:{chatTop:Math.max(0,e),parentTop:Math.max(0,e-t)}}function Qh(t,r){let l=typeof t=="number"&&Number.isFinite(t),i=e.useRef(null),[o,a]=e.useState(null),s=e.useRef(null),u=e.useRef(null),c=e.useRef(true),d=e.useCallback(()=>{u.current!==null&&clearTimeout(u.current),u.current=null},[]);e.useEffect(()=>(c.current=true,()=>{c.current=false,d()}),[d]);let p=e.useCallback(function e(t){i.current?.measureInWindow((r,l)=>{let i=s.current;if(!c.current||i===null)return;let o=Yh(l,i.y,i.height,n.Dimensions.get("window").height);if(o!==null){a(e=>e!==null&&e.chatTop===o.chatTop&&e.parentTop===o.parentTop?e:o);return}t>=Kh||(u.current=setTimeout(()=>{u.current=null,e(t+1)},Gh))})},[]),f=e.useCallback(e=>{let{y:t,height:r}=e.nativeEvent.layout;s.current={y:t,height:r},d(),p(0)},[p,d]);return e.useMemo(()=>{if(!r)return{avoidingProps:l?{keyboardVerticalOffset:t}:qh,probeRef:null,topInWindow:null};let e=o?.parentTop??0;return{avoidingProps:l?{keyboardVerticalOffset:t,onLayout:f}:e>0?{keyboardVerticalOffset:e,onLayout:f}:{onLayout:f},probeRef:i,topInWindow:o?.chatTop??null}},[r,l,t,o,f])}function KeyboardOffsetProbe({probeRef:e}){return e===null?null:/* @__PURE__ */t.jsx(n.View,{ref:e,collapsable:false,pointerEvents:"none",style:Zh})}var Zh=/* @__PURE__ */Object.freeze({position:"absolute",top:0,left:0,width:0,height:0});function Jh(){let[t,r]=e.useState(false);return e.useEffect(()=>{let e=n.Keyboard;if(typeof e?.addListener!="function")return;let t=n.Platform.OS==="ios",l=e.addListener(t?"keyboardWillShow":"keyboardDidShow",()=>r(true)),i=e.addListener(t?"keyboardWillHide":"keyboardDidHide",()=>r(false));return()=>{l.remove(),i.remove()}},[]),t}var Xh=4.5;var eb=3;function tb(e,t,r){return Ja(e,t,Ua(t),r)}function rb(e,t){if(e.level==="emergency")return e;let r=e.level==="schedule_soon",n=Fd(t),l=r?n.warning:n.info,i=Ad(t)&&!l?e:nb(e,t,r);return lb(i,t.slots.banner)}function nb(e,t,r){let n=t.color,l=Ya(r?n.badgeBgCaution:n.badgeBgInfo,n.surface)??n.surface,i=r?n.cautionAccent:n.infoEdge,o=tb(Ya(i,n.surface)??i,[n.surface,n.chatGround],eb),a=tb(r?n.warningStrong:n.info,[l,n.surface],Xh);/* @__PURE__ */
243
+ return Object.freeze({...e,borderColor:o,backgroundColor:l,textColor:a,reasonColor:tb(n.text.primary,[l],Xh),pillColor:n.surface})}function lb(e,t){if(t===void 0)return e;let r={...e};return t.backgroundColor!==void 0&&(r.backgroundColor=t.backgroundColor),t.borderColor!==void 0&&(r.borderColor=t.borderColor),t.textColor!==void 0&&(r.textColor=t.textColor,r.reasonColor=t.textColor),/* @__PURE__ */Object.freeze(r)}function ib(petRef,e){let t={entry:"chat",petRef:petRef};return e?.returnTo!==void 0&&(t.returnTo=e.returnTo),e?.usState!==void 0&&(t.usState=e.usState),e?.prefer!==void 0&&(t.prefer=e.prefer),t}var ob=.75,ab=1.5,sb=.4,ub=4,cb=1.5,db=22,pb=14,fb=8,hb=20,bb=10,gb=13,mb=12,yb=15,vb=44,xb=14,wb=1.25,kb=14,Sb=6,Cb=2;function jb(e,t){let r=e.color;if(t.level==="emergency")return{card:{backgroundColor:r.badgeBgCritical,borderColor:Qa(r.danger,sb)??r.danger,borderWidth:ab},label:r.danger,reason:r.text.primary,close:r.danger,action:{fill:r.surface,edge:r.danger,ink:r.danger}};let n=e.slots.banner?.borderRadius;return{card:{backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:ob,...n===void 0?{}:{borderRadius:n}},label:t.textColor,reason:t.reasonColor,close:t.textColor,action:null}}function UrgencyBanner({surface:r,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,compact:o=false}){let a=useEverfurTheme(),s=e.useMemo(()=>Rb(a),[a]),u=so(),c=r.tier===null?null:rb(r.tier,a),d=r.source;/* @__PURE__ */
243
244
  return t.jsxs(t.Fragment,{children:[
244
245
  /* @__PURE__ */t.jsx(FadePresence,{visible:r.showBanner&&c!==null,inMs:u.bannerInMs,outMs:u.bannerOutMs,style:s.pinned,children:c!==null&&d!==null?/* @__PURE__ */t.jsx(BannerCard,{tier:c,reason:d.reason,surface:r,petRef:petRef,renderVetAction:n,onFindVet:l,vet:i,styles:s,compact:o}):null}),
245
- /* @__PURE__ */t.jsx(FadePresence,{visible:r.showCompactIcon,inMs:u.iconInMs,outMs:u.iconOutMs,style:s.indicatorRow,children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:je.showLatestVetAlert,hitSlop:nb,onPress:r.expand,children:/* @__PURE__ */t.jsx(InfoGlyph,{size:rb,color:a.color.text.muted,strokeWidth:2})})})]})}function BannerCard({tier:e,reason:r,surface:l,petRef:petRef,renderVetAction:i,onFindVet:o,vet:a,styles:s,compact:u}){let c=useEverfurTheme(),d=fb(c,e),p=/* @__PURE__ */t.jsx(VetAction,{tier:e,paint:d,petRef:petRef,onFindVet:o,vet:a,styles:s}),f=l.showVetAction?i!==void 0?/* @__PURE__ */t.jsx(HostRender,{render:()=>i(e.level),fallback:p,resetKey:e.level}):p:null,h=d.action!==null?/* @__PURE__ */t.jsx(PoisonControl,{paint:d.action,styles:s}):null,b=e.level==="emergency"&&o===void 0,g=e.level==="emergency"||e.level==="schedule_soon";/* @__PURE__ */
246
+ /* @__PURE__ */t.jsx(FadePresence,{visible:r.showCompactIcon,inMs:u.iconInMs,outMs:u.iconOutMs,style:s.indicatorRow,children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Te.showLatestVetAlert,hitSlop:bb,onPress:r.expand,children:/* @__PURE__ */t.jsx(InfoGlyph,{size:hb,color:a.color.text.muted,strokeWidth:2})})})]})}function BannerCard({tier:e,reason:r,surface:l,petRef:petRef,renderVetAction:i,onFindVet:o,vet:a,styles:s,compact:u}){let c=useEverfurTheme(),d=jb(c,e),p=/* @__PURE__ */t.jsx(VetAction,{tier:e,paint:d,petRef:petRef,onFindVet:o,vet:a,styles:s}),f=l.showVetAction?i!==void 0?/* @__PURE__ */t.jsx(HostRender,{render:()=>i(e.level),fallback:p,resetKey:e.level}):p:null,h=d.action!==null?/* @__PURE__ */t.jsx(PoisonControl,{paint:d.action,styles:s}):null,b=e.level==="emergency"&&o===void 0,g=e.level==="emergency"||e.level==="schedule_soon";/* @__PURE__ */
246
247
  return t.jsxs(n.View,{...g?{accessibilityRole:"alert"}:{accessibilityLiveRegion:"polite"},style:[s.card,d.card,u?s.cardCompact:null],testID:u?"chat-urgency-compact":void 0,children:[
247
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:[s.label,{color:d.label}],children:e.label}),r!==null?/* @__PURE__ */t.jsx(Text,{style:[s.reason,{color:d.reason}],numberOfLines:u?pb:void 0,accessibilityLabel:u?r:void 0,children:r}):null,b?/* @__PURE__ */t.jsx(Text,{style:[s.reason,s.erLine,{color:d.reason}],children:je.goToNearestEmergencyVet}):null,f!==null||h!==null?/* @__PURE__ */t.jsxs(n.View,{style:s.actions,children:[f,h]}):null,l.dismissLabel!==null?/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:l.dismissLabel,hitSlop:tb,containerStyle:s.closeSlot,style:s.closeButton,onPress:l.dismiss,children:/* @__PURE__ */t.jsx(CloseGlyph,{size:eb,color:d.close,strokeWidth:1.5})}):null]})}function PoisonControl({paint:e,styles:r}){let l=()=>{try{n.Linking.openURL(ze).catch(()=>{})}catch{}};/* @__PURE__ */
248
- return t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:je.poisonControlNative,hitSlop:0,style:[r.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:l,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:[r.actionLabel,{color:e.ink}],children:je.poisonControlNative})})}function VetAction({tier:e,paint:r,petRef:petRef,onFindVet:n,vet:l,styles:i}){let o=useEverfurTheme(),a=useVetVisit(Gh(petRef,l)),s=a.status==="opening",u=!a.available&&n!==void 0,c=a.available?()=>{a.open()}:n!==void 0?()=>{Er(n,e.level)}:null;if(c===null)return null;let d=r.action;if(d!==null){let e=u?je.nearestEmergencyVet:je.findVet,r=Lo(o.slots.vetVisitButton)?.textColor??d.ink;/* @__PURE__ */
249
- return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:u?je.nearestEmergencyVet:je.findVetA11y,accessibilityState:{busy:s},hitSlop:0,style:[i.action,{backgroundColor:d.fill,borderColor:d.edge},i.findVetSlotBox,s?i.findVetBusy:null],onPress:c,children:[
250
- /* @__PURE__ */t.jsx(MapPinGlyph,{size:lb,color:r,strokeWidth:1.5}),
251
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:[i.actionLabel,{color:r}],children:e})]})}let p=Lo(o.slots.vetVisitButton)?.textColor??e.textColor;/* @__PURE__ */
252
- return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:je.findVetA11y,accessibilityState:{busy:s},style:[i.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},i.findVetSlotBox,s?i.findVetBusy:null],onPress:c,children:[
253
- /* @__PURE__ */t.jsx(MapPinGlyph,{size:lb,color:p,strokeWidth:1.5}),
254
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:[i.findVetLabel,{color:p}],children:je.findVet})]})}function hb(e){let t=Lo(e.slots.vetVisitButton),r=e.space,l=e.type;return n.StyleSheet.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+Zh,paddingVertical:r.lg,gap:r.sm},cardCompact:{paddingVertical:r.md,gap:r.xs},label:{...face(e,"bold"),fontSize:l.size.body,paddingRight:Xh},reason:{...face(e,"regular"),fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*Jh),paddingRight:Xh},erLine:{...face(e,"bold")},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:db,minHeight:ab,paddingHorizontal:sb,borderRadius:e.radius.pill,borderWidth:ub},actionLabel:{...face(e,"bold"),fontSize:cb},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...Ao(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...face(e,"monoBold"),fontSize:ib,lineHeight:ob},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:Xh,height:Xh,borderRadius:Xh/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}function bb(t,userRef,petRef,r){let[n,l]=e.useState({pet:petRef,user:userRef}),i=n.pet!==petRef||n.user===null&&userRef!==null;i&&l({pet:petRef,user:userRef});let o=i?{user:userRef}:n,a=petRef!==null&&o.user!==null&&o.user!==userRef;return e.useEffect(()=>{if(!a||userRef===null||petRef===null)return;let e=true,r=createPetsRepository(t.registry.services.authFor(userRef)),n=async()=>{let t=await r.list();e&&t.ok&&t.value.some(e=>e.petRef===petRef)&&l({pet:petRef,user:userRef})};n();let i=Hc(t,()=>{n()});return()=>{e=false,i()}},[a,t,userRef,petRef,r]),a}var gb=/* @__PURE__ */Object.freeze({status:"idle",messages:/* @__PURE__ */Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:/* @__PURE__ */Object.freeze([]),unreadCount:null});function useEverfurChat(t){let{runtime:r,userRef:userRef,activePet:n,scopeEpoch:l}=Fe(),petRef=t?.petRef??n??null,conversationId=t?.conversationId??null,i=bb(r,userRef,petRef,l),o=e.useMemo(()=>({runtime:r,userRef:userRef,petRef:petRef,conversationId:conversationId,scopeEpoch:l,held:i}),[r,userRef,petRef,conversationId,l,i]),[a,s]=e.useState(null),u=i?null:a?.scope===o?a.controller:r.registry.peekChat({userRef:userRef,petRef:petRef,conversationId:conversationId}),c=e.useRef(null);e.useEffect(()=>{if(i)return;let e=r.registry.acquireChat({userRef:userRef,petRef:petRef,conversationId:conversationId});return c.current=e,s({scope:o,controller:e}),()=>{c.current=null,s(t=>t?.controller===e?null:t),r.registry.releaseChat(e)}},[r,userRef,petRef,conversationId,l,i,o]);let d=e.useCallback(e=>u?u.subscribe(e):NOOP_UNSUBSCRIBE,[u]),p=e.useCallback(()=>u?u.getSnapshot():gb,[u]),f=e.useSyncExternalStore(d,p,p),h=e.useCallback((e,t)=>u&&c.current===u&&!u.getSnapshot().isBootstrapping?yb(u,u.send(e,t?.imageS3Keys===void 0?{}:{imageS3Keys:t.imageS3Keys}),()=>c.current===u):Promise.resolve(xb()),[u]),b=e.useCallback(e=>u&&c.current===u&&!u.getSnapshot().isBootstrapping?yb(u,u.askEverfur(e),()=>c.current===u):Promise.resolve(xb()),[u]),g=e.useCallback(()=>u&&c.current===u?yb(u,u.retryLast(),()=>c.current===u):Promise.resolve(xb()),[u]),m=e.useCallback(()=>{u&&c.current===u&&u.stop()},[u]),y=e.useCallback(()=>{u&&c.current===u&&u.newConversation()},[u]),[v,x]=e.useState({controller:null,byMessage:{}}),w=v.controller===u?v.byMessage:mb,k=e.useCallback(async(e,t,r,n)=>{if(!u||c.current!==u)return err(makeEverfurError("accessDenied"));let l=String(e),i=v.controller===u?v.byMessage[l]:void 0;if(i===t&&r==null)return x(e=>{let t={...e.controller===u?e.byMessage:{}};return delete t[l],{controller:u,byMessage:t}}),ok(/* @__PURE__ */Object.freeze({feedbackId:""}));x(e=>({controller:u,byMessage:{...e.controller===u?e.byMessage:{},[l]:t}}));let o=await u.submitFeedback(e,vp(t,r??null),n??null);return c.current!==u?err(makeEverfurError("accessDenied")):(o.ok||x(e=>{let t={...e.controller===u?e.byMessage:{}};return i===void 0?delete t[l]:t[l]=i,{controller:u,byMessage:t}}),o)},[u,v]),S=e.useMemo(()=>{let e=async e=>{if(!u||c.current!==u)return err(makeEverfurError("accessDenied"));let t=await e(u);return c.current===u?t:err(makeEverfurError("accessDenied"))};return{listConversations:t=>e(e=>e.listConversations({...petRef?{petRef:petRef}:{},...t})),getMessages:(t,r)=>e(e=>e.getMessages(t,r)),resumeConversation:t=>e(e=>e.resumeConversation(t)),loadOlderMessages:()=>e(e=>e.loadOlderMessages()),markRead:()=>e(e=>e.markRead()),refreshActiveThread:t=>e(e=>e.refreshActiveThread(t)),answerCheckin:(t,r)=>e(e=>e.answerCheckin(t,r)),openCheckin:t=>e(e=>e.openCheckin(t))}},[u,petRef]);return e.useMemo(()=>({status:f.status,messages:f.messages,conversationId:f.conversationId,petRef:petRef,error:f.error,isStreaming:f.isStreaming,isBootstrapping:f.isBootstrapping,historyCursor:f.historyCursor??null,isLoadingHistory:f.isLoadingHistory??false,stopped:f.stopped??false,reconnecting:f.reconnecting??false,...S,suggestedPrompts:f.suggestedPrompts,unreadCount:f.unreadCount,hasUnreadThreads:f.hasUnreadThreads??false,pendingCheckin:f.pendingCheckin??null,newConversation:y,sentimentByMessage:w,feedback:k,send:h,askEverfur:b,retryLast:g,stop:m}),[f,petRef,h,b,g,m,S,y,w,k])}var NOOP_UNSUBSCRIBE=()=>{},mb=/* @__PURE__ */Object.freeze({});async function yb(e,t,r){for await(let e of t);if(!r())return err(makeEverfurError("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?err(n.error):ok(vb(n.messages))}function vb(e){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r&&r.role==="assistant"&&r.responseId!==void 0)return r.responseId}return null}function xb(){return Ml()}function wb(){let t=useEverfurPets(),{handle:r}=Fe(),n=e.useCallback(petRef=>r.setActivePet(petRef),[r]);return e.useMemo(()=>({...t,setActivePet:n}),[t,n])}function kb(){try{let e=n.AccessibilityInfo?.announceForAccessibility;typeof e=="function"&&e.call(n.AccessibilityInfo,je.answered)}catch{}}function Sb(t){let r=e.useRef(false),n=e.useRef({send:t.send,id:t.conversationId});e.useEffect(()=>{let e=n.current;if((e.send!==t.send||e.id!==null&&e.id!==t.conversationId)&&(r.current=false),n.current={send:t.send,id:t.conversationId},r.current&&!t.isStreaming){let e=t.messages[t.messages.length-1];e!==void 0&&e.role==="assistant"&&kb()}r.current=t.isStreaming},[t.isStreaming,t.messages,t.send,t.conversationId])}var Cb=/* @__PURE__ */Object.freeze({kind:"live"}),jb=/* @__PURE__ */Object.freeze({kind:"folded"});function Rb(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=li(e.proactiveOriginRef);return{caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}function Tb(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let t of e){let e=Rb(t);if(e===null)continue;let n=r.get(e.caseId);(n===void 0||e.dueDay>=n.dueDay)&&r.set(e.caseId,{messageId:t.id,dueDay:e.dueDay})}if(r.size===0)return t;let n=null;for(let l of e){let e=Rb(l);if(e===null){n=null;continue}if(r.get(e.caseId)?.messageId===l.id){t.set(l.id,Cb),n=null;continue}if(n!==null&&n.caseId===e.caseId){n.days.push(e.dueDay),t.set(l.id,jb);continue}let i=[e.dueDay];n={id:l.id,caseId:e.caseId,days:i},t.set(l.id,{kind:"past",runDueDays:i})}return t}function _b(e){let t=/* @__PURE__ */new Set;for(let[r,n]of e)n.kind==="live"&&t.add(r);return t}var zb=864e5,Ib=365;function Pb(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let l=Math.floor(n/zb)-Math.floor(r/zb);return l<1||l>Ib?null:l}function Eb(e){return Rb(e)?.dueDay||null}function Mb(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function AssistantSender({avatarUrl:e,named:r,styles:l}){let i=xd(e);return i.shown?/* @__PURE__ */t.jsxs(n.View,{style:l.assistantSender,testID:"everfur-assistant-sender",children:[
255
- /* @__PURE__ */t.jsx(BrandImage,{uri:e,decorative:true,style:l.assistantAvatar,resizeMode:"cover",onError:i.onError,testID:"everfur-assistant-avatar"}),r?/* @__PURE__ */t.jsx(Text,{tier:"control",style:[l.assistantName,l.assistantNameInRow],children:je.assistantName}):null]}):r?/* @__PURE__ */t.jsx(Text,{tier:"control",style:l.assistantName,children:je.assistantName}):null}var Fb=/* @__PURE__ */Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),Ab="#C8BEB4";function Lb(e){return e?Fb[e.toUpperCase()]??Ab:Ab}function Ob(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}function Vb(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}function Db(e){let t=Vb(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}function Bb(e,t){let r=Vb(e.source_name)??Vb(e.sourceName),n=Vb(e.section),l=Vb(e.authority_tier)??Vb(e.authorityTier),i=Ob(l),o=r??Vb(e.title)??`Source ${t+1}`,a=Vb(e.monograph_chunk_id)??Vb(e.chunkId),s=[n,i].filter(e=>e!==null).join(" · ");/* @__PURE__ */
256
- return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:Db(e.url),excerpt:Vb(e.excerpt),tierColor:Lb(l),key:`${o}-${a??"none"}-${t}`})}function Hb(e){return e===void 0||e.length===0?Wb:/* @__PURE__ */Object.freeze(e.map((e,t)=>Bb(e,t)))}var Wb=/* @__PURE__ */Object.freeze([]);function Nb(e){return e===1?`1 ${je.sourceSingular}`:`${e} ${je.sourcePlural}`}function Ub(e,t){return`${t?je.hideSources:je.showSources} ${Nb(e)}`}function $b(e){return[e.url!==null?`${je.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(e=>e!==null&&e.length>0).join(". ")}var qb="https:\\/\\/sdk(?:-[a-z]+)?\\.everfur\\.com";function Gb(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}typeof __EVERFUR_BRAND_CDN_ORIGIN__=="string"&&__EVERFUR_BRAND_CDN_ORIGIN__.length>0?Gb(__EVERFUR_BRAND_CDN_ORIGIN__):qb;function hardenHttpsUrl(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}function Kb(e){let t=e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:[e]}var Yb=/^\s*[-*]\s+(\S.*)$/,Qb=/^\s*(\d{1,3})[.)]\s+(\S.*)$/;function Zb(e){let t=[],r=[],n=null,l=()=>{r.length>0&&t.push({kind:"text",text:r.join(`\n`)}),r=[]},i=()=>{n!==null&&t.push(n.ordered?{kind:"list",ordered:true,start:n.start,items:n.items}:{kind:"list",ordered:false,items:n.items}),n=null};for(let t of e.split(`\n`)){let e=Yb.exec(t),o=e===null?Qb.exec(t):null,a=e?.[1]??o?.[2];if(a===void 0){i(),r.push(t);continue}let s=o!==null;l(),n!==null&&n.ordered!==s&&i(),n===null&&(n={ordered:s,start:o===null?1:Number(o[1]),items:[]}),n.items.push(a.trim())}return l(),i(),t}function Jb(e,t){let r=e.findIndex(e=>e.id===t);for(let t=r-1;t>=0;t-=1){let r=e[t];if(r!==void 0&&r.role==="user")return r.text}return null}function Xb(e,t){if(e===void 0)return[];try{let r=e(t);return Array.isArray(r)?r:[]}catch{return[]}}function eg(e){return hardenHttpsUrl(e.trim())}function tg(e,t){if(t?.followUpActions===void 0||e.isStreaming||e.status==="error")return[];let r=e.messages[e.messages.length-1];return r===void 0||r.role!=="assistant"||r.pending===true?[]:Xb(t.followUpActions,{answer:r.text,question:Jb(e.messages,r.id),messageId:r.id})}var rg=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g,ng=new RegExp(`\\[([^\\]\\n]{1,300})\\]\\((https:\\/\\/[^\\s()<>]{1,${Wi}})\\)|(https:\\/\\/[^\\s<>"'\`*\\[\\]]{1,${Wi}})`,"gi"),lg=/https:\/\//i,ig=`.,;:!?'"`;function og(e,t){return e.includes("*")||e.includes("`")||t!==void 0&&lg.test(e)}function ag(e,t){let r=[],n=e=>{t===void 0?r.push({kind:"text",text:e}):cg(r,e,t)},l=0;rg.lastIndex=0;for(let t=rg.exec(e);t!==null;t=rg.exec(e)){t.index>l&&n(e.slice(l,t.index));let i=t[1],o=t[2],a=t[3];i!==void 0?r.push({kind:"bold",text:i}):o!==void 0?r.push({kind:"italic",text:o}):a!==void 0&&r.push({kind:"code",text:a}),l=t.index+t[0].length}return l<e.length&&n(e.slice(l)),r}function sg(e){let t=e.length;for(;;){let r=e[t-1];if(r===void 0)break;if(ig.includes(r))t-=1;else if(r===")"&&ug(e,"(",t)<ug(e,")",t))t-=1;else break}return e.slice(0,t)}function ug(e,t,r){let n=0;for(let l=0;l<r;l+=1)e[l]===t&&(n+=1);return n}function cg(e,t,r){if(!lg.test(t)){e.push({kind:"text",text:t});return}let n=0;ng.lastIndex=0;for(let l=ng.exec(t);l!==null;l=ng.exec(t)){let i=l[1],o=l[2],a=l[3],s,u,c;if(i!==void 0&&o!==void 0)s=i.trim(),u=s.length>0?qi(o,r):null,c=l[0].length;else if(a!==void 0)s=sg(a),u=qi(s,r),c=s.length;else continue;u!==null&&(l.index>n&&e.push({kind:"text",text:t.slice(n,l.index)}),e.push({kind:"link",text:s,href:u}),n=l.index+c,ng.lastIndex=n)}n<t.length&&e.push({kind:"text",text:t.slice(n)})}var dg=/* @__PURE__ */Object.freeze({textDecorationLine:"underline"});function pg(e,t){return t===void 0||!og(e,t.hosts)?false:ag(e,t.hosts).some(e=>e.kind==="link")}function fg(e,r,n){let l=n?.hosts;return og(e,l)?ag(e,l).map((e,l)=>{switch(e.kind){case"bold":/* @__PURE__ */
248
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:[s.label,{color:d.label}],children:e.label}),r!==null?/* @__PURE__ */t.jsx(Text,{style:[s.reason,{color:d.reason}],numberOfLines:u?Cb:void 0,accessibilityLabel:u?r:void 0,children:r}):null,b?/* @__PURE__ */t.jsx(Text,{style:[s.reason,s.erLine,{color:d.reason}],children:Te.goToNearestEmergencyVet}):null,f!==null||h!==null?/* @__PURE__ */t.jsxs(n.View,{style:s.actions,children:[f,h]}):null,l.dismissLabel!==null?/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:l.dismissLabel,hitSlop:fb,containerStyle:s.closeSlot,style:s.closeButton,onPress:l.dismiss,children:/* @__PURE__ */t.jsx(CloseGlyph,{size:pb,color:d.close,strokeWidth:1.5})}):null]})}function PoisonControl({paint:e,styles:r}){let l=()=>{try{n.Linking.openURL(Pe).catch(()=>{})}catch{}};/* @__PURE__ */
249
+ return t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:Te.poisonControlNative,hitSlop:0,style:[r.action,{backgroundColor:e.fill,borderColor:e.edge}],onPress:l,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:[r.actionLabel,{color:e.ink}],children:Te.poisonControlNative})})}function VetAction({tier:e,paint:r,petRef:petRef,onFindVet:n,vet:l,styles:i}){let o=useEverfurTheme(),a=useVetVisit(ib(petRef,l)),s=a.status==="opening",u=!a.available&&n!==void 0,c=a.available?()=>{a.open()}:n!==void 0?()=>{Ar(n,e.level)}:null;if(c===null)return null;let d=r.action;if(d!==null){let e=u?Te.nearestEmergencyVet:Te.findVet,r=Vo(o.slots.vetVisitButton)?.textColor??d.ink;/* @__PURE__ */
250
+ return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:u?Te.nearestEmergencyVet:Te.findVetA11y,accessibilityState:{busy:s},hitSlop:0,style:[i.action,{backgroundColor:d.fill,borderColor:d.edge},i.findVetSlotBox,s?i.findVetBusy:null],onPress:c,children:[
251
+ /* @__PURE__ */t.jsx(MapPinGlyph,{size:gb,color:r,strokeWidth:1.5}),
252
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:[i.actionLabel,{color:r}],children:e})]})}let p=Vo(o.slots.vetVisitButton)?.textColor??e.textColor;/* @__PURE__ */
253
+ return t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:Te.findVetA11y,accessibilityState:{busy:s},style:[i.findVetButton,{borderColor:e.borderColor,backgroundColor:e.pillColor},i.findVetSlotBox,s?i.findVetBusy:null],onPress:c,children:[
254
+ /* @__PURE__ */t.jsx(MapPinGlyph,{size:gb,color:p,strokeWidth:1.5}),
255
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:[i.findVetLabel,{color:p}],children:Te.findVet})]})}function Rb(e){let t=Vo(e.slots.vetVisitButton),r=e.space,l=e.type;return n.StyleSheet.create({pinned:{marginTop:0,marginBottom:r.xs,paddingHorizontal:r.lg},card:{borderRadius:e.radius.lg,paddingHorizontal:r.lg+ub,paddingVertical:r.lg,gap:r.sm},cardCompact:{paddingVertical:r.md,gap:r.xs},label:{...face(e,"bold"),fontSize:l.size.body,paddingRight:db},reason:{...face(e,"regular"),fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*cb),paddingRight:db},erLine:{...face(e,"bold")},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.sm},action:{flexDirection:"row",alignItems:"center",gap:Sb,minHeight:vb,paddingHorizontal:xb,borderRadius:e.radius.pill,borderWidth:wb},actionLabel:{...face(e,"bold"),fontSize:kb},findVetButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:e.radius.pill,borderWidth:1},findVetSlotBox:{...Oo(t,1)},findVetBusy:{opacity:.6},findVetLabel:{...face(e,"monoBold"),fontSize:mb,lineHeight:yb},closeSlot:{position:"absolute",top:r.md,right:r.md},closeButton:{width:db,height:db,borderRadius:db/2,alignItems:"center",justifyContent:"center"},indicatorRow:{alignItems:"flex-end",paddingHorizontal:r.lg,paddingTop:2,paddingBottom:r.xs}})}var Tb=/* @__PURE__ */Symbol.for("everfur.sdk.tabsBar.v1");function _b(){return globalThis[Tb]??null}function zb(e){return e==="tabs_bar"&&_b()!==null}function SeverityCard(e){let r=_b()?.ask.SeverityCard;return r===void 0?null:/* @__PURE__ */t.jsx(r,{...e})}function AnswerRecordCards(e){let r=_b()?.ask.AnswerRecordCards;return r===void 0?null:/* @__PURE__ */t.jsx(r,{...e})}function PrivacyLine(e){let r=_b()?.ask.PrivacyLine;return r===void 0?null:/* @__PURE__ */t.jsx(r,{...e})}function AskBarDisclaimer(){let e=_b()?.ask.AskBarDisclaimer;return e===void 0?null:/* @__PURE__ */t.jsx(e,{})}function Ib(t,userRef,petRef,r){let[n,l]=e.useState({pet:petRef,user:userRef}),i=n.pet!==petRef||n.user===null&&userRef!==null;i&&l({pet:petRef,user:userRef});let o=i?{user:userRef}:n,a=petRef!==null&&o.user!==null&&o.user!==userRef;return e.useEffect(()=>{if(!a||userRef===null||petRef===null)return;let e=true,r=createPetsRepository(t.registry.services.authFor(userRef)),n=async()=>{let t=await r.list();e&&t.ok&&t.value.some(e=>e.petRef===petRef)&&l({pet:petRef,user:userRef})};n();let i=Yc(t,()=>{n()});return()=>{e=false,i()}},[a,t,userRef,petRef,r]),a}var Pb=/* @__PURE__ */Object.freeze({status:"idle",messages:/* @__PURE__ */Object.freeze([]),conversationId:null,error:null,isStreaming:false,isBootstrapping:true,suggestedPrompts:/* @__PURE__ */Object.freeze([]),unreadCount:null});function useEverfurChat(t){let{runtime:r,userRef:userRef,activePet:n,scopeEpoch:l}=Le(),petRef=t?.petRef??n??null,conversationId=t?.conversationId??null,i=Ib(r,userRef,petRef,l),o=e.useMemo(()=>({runtime:r,userRef:userRef,petRef:petRef,conversationId:conversationId,scopeEpoch:l,held:i}),[r,userRef,petRef,conversationId,l,i]),[a,s]=e.useState(null),u=i?null:a?.scope===o?a.controller:r.registry.peekChat({userRef:userRef,petRef:petRef,conversationId:conversationId}),c=e.useRef(null);e.useEffect(()=>{if(i)return;let e=r.registry.acquireChat({userRef:userRef,petRef:petRef,conversationId:conversationId});return c.current=e,s({scope:o,controller:e}),()=>{c.current=null,s(t=>t?.controller===e?null:t),r.registry.releaseChat(e)}},[r,userRef,petRef,conversationId,l,i,o]);let d=e.useCallback(e=>u?u.subscribe(e):NOOP_UNSUBSCRIBE,[u]),p=e.useCallback(()=>u?u.getSnapshot():Pb,[u]),f=e.useSyncExternalStore(d,p,p),h=e.useCallback((e,t)=>u&&c.current===u&&!u.getSnapshot().isBootstrapping?Mb(u,u.send(e,t?.imageS3Keys===void 0?{}:{imageS3Keys:t.imageS3Keys}),()=>c.current===u):Promise.resolve(Fb()),[u]),b=e.useCallback(e=>u&&c.current===u&&!u.getSnapshot().isBootstrapping?Mb(u,u.askEverfur(e),()=>c.current===u):Promise.resolve(Fb()),[u]),g=e.useCallback(()=>u&&c.current===u?Mb(u,u.retryLast(),()=>c.current===u):Promise.resolve(Fb()),[u]),m=e.useCallback(()=>{u&&c.current===u&&u.stop()},[u]),y=e.useCallback(()=>{u&&c.current===u&&u.newConversation()},[u]),[v,x]=e.useState({controller:null,byMessage:{}}),w=v.controller===u?v.byMessage:Eb,k=e.useCallback(async(e,t,r,n)=>{if(!u||c.current!==u)return err(makeEverfurError("accessDenied"));let l=String(e),i=v.controller===u?v.byMessage[l]:void 0;if(i===t&&r==null)return x(e=>{let t={...e.controller===u?e.byMessage:{}};return delete t[l],{controller:u,byMessage:t}}),ok(/* @__PURE__ */Object.freeze({feedbackId:""}));x(e=>({controller:u,byMessage:{...e.controller===u?e.byMessage:{},[l]:t}}));let o=await u.submitFeedback(e,Tp(t,r??null),n??null);return c.current!==u?err(makeEverfurError("accessDenied")):(o.ok||x(e=>{let t={...e.controller===u?e.byMessage:{}};return i===void 0?delete t[l]:t[l]=i,{controller:u,byMessage:t}}),o)},[u,v]),S=e.useMemo(()=>{let e=async e=>{if(!u||c.current!==u)return err(makeEverfurError("accessDenied"));let t=await e(u);return c.current===u?t:err(makeEverfurError("accessDenied"))};return{listConversations:t=>e(e=>e.listConversations({...petRef?{petRef:petRef}:{},...t})),getMessages:(t,r)=>e(e=>e.getMessages(t,r)),resumeConversation:t=>e(e=>e.resumeConversation(t)),loadOlderMessages:()=>e(e=>e.loadOlderMessages()),markRead:()=>e(e=>e.markRead()),refreshActiveThread:t=>e(e=>e.refreshActiveThread(t)),answerCheckin:(t,r)=>e(e=>e.answerCheckin(t,r)),openCheckin:t=>e(e=>e.openCheckin(t))}},[u,petRef]);return e.useMemo(()=>({status:f.status,messages:f.messages,conversationId:f.conversationId,petRef:petRef,error:f.error,isStreaming:f.isStreaming,isBootstrapping:f.isBootstrapping,historyCursor:f.historyCursor??null,isLoadingHistory:f.isLoadingHistory??false,stopped:f.stopped??false,reconnecting:f.reconnecting??false,...S,suggestedPrompts:f.suggestedPrompts,unreadCount:f.unreadCount,hasUnreadThreads:f.hasUnreadThreads??false,pendingCheckin:f.pendingCheckin??null,newConversation:y,sentimentByMessage:w,feedback:k,send:h,askEverfur:b,retryLast:g,stop:m}),[f,petRef,h,b,g,m,S,y,w,k])}var NOOP_UNSUBSCRIBE=()=>{},Eb=/* @__PURE__ */Object.freeze({});async function Mb(e,t,r){for await(let e of t);if(!r())return err(makeEverfurError("accessDenied"));let n=e.getSnapshot();return n.status==="error"&&n.error!==null?err(n.error):ok(Ab(n.messages))}function Ab(e){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(r&&r.role==="assistant"&&r.responseId!==void 0)return r.responseId}return null}function Fb(){return Fl()}function Lb(){let t=useEverfurPets(),{handle:r}=Le(),n=e.useCallback(petRef=>r.setActivePet(petRef),[r]);return e.useMemo(()=>({...t,setActivePet:n}),[t,n])}function Ob(){try{let e=n.AccessibilityInfo?.announceForAccessibility;typeof e=="function"&&e.call(n.AccessibilityInfo,Te.answered)}catch{}}function Vb(t){let r=e.useRef(false),n=e.useRef({send:t.send,id:t.conversationId});e.useEffect(()=>{let e=n.current;if((e.send!==t.send||e.id!==null&&e.id!==t.conversationId)&&(r.current=false),n.current={send:t.send,id:t.conversationId},r.current&&!t.isStreaming){let e=t.messages[t.messages.length-1];e!==void 0&&e.role==="assistant"&&Ob()}r.current=t.isStreaming},[t.isStreaming,t.messages,t.send,t.conversationId])}var Db=/* @__PURE__ */Object.freeze({kind:"live"}),Bb=/* @__PURE__ */Object.freeze({kind:"folded"});function Hb(e){if(e.role!=="assistant"||e.checkin===void 0)return null;let t=e.checkin.caseId,r=oi(e.proactiveOriginRef);return{caseId:t,dueDay:r!==null&&r.caseId===t?r.dueDay:""}}function Wb(e){let t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;for(let t of e){let e=Hb(t);if(e===null)continue;let n=r.get(e.caseId);(n===void 0||e.dueDay>=n.dueDay)&&r.set(e.caseId,{messageId:t.id,dueDay:e.dueDay})}if(r.size===0)return t;let n=null;for(let l of e){let e=Hb(l);if(e===null){n=null;continue}if(r.get(e.caseId)?.messageId===l.id){t.set(l.id,Db),n=null;continue}if(n!==null&&n.caseId===e.caseId){n.days.push(e.dueDay),t.set(l.id,Bb);continue}let i=[e.dueDay];n={id:l.id,caseId:e.caseId,days:i},t.set(l.id,{kind:"past",runDueDays:i})}return t}function Nb(e){let t=/* @__PURE__ */new Set;for(let[r,n]of e)n.kind==="live"&&t.add(r);return t}var Ub=864e5,$b=365;function qb(e,t){if(typeof e!="string"||typeof t!="string")return null;let r=Date.parse(e),n=Date.parse(t);if(Number.isNaN(r)||Number.isNaN(n))return null;let l=Math.floor(n/Ub)-Math.floor(r/Ub);return l<1||l>$b?null:l}function Gb(e){return Hb(e)?.dueDay||null}function Kb(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function AssistantSender({avatarUrl:e,named:r,styles:l}){let i=_d(e);return i.shown?/* @__PURE__ */t.jsxs(n.View,{style:l.assistantSender,testID:"everfur-assistant-sender",children:[
256
+ /* @__PURE__ */t.jsx(BrandImage,{uri:e,decorative:true,style:l.assistantAvatar,resizeMode:"cover",onError:i.onError,testID:"everfur-assistant-avatar"}),r?/* @__PURE__ */t.jsx(Text,{tier:"control",style:[l.assistantName,l.assistantNameInRow],children:Te.assistantName}):null]}):r?/* @__PURE__ */t.jsx(Text,{tier:"control",style:l.assistantName,children:Te.assistantName}):null}var Yb=/* @__PURE__ */Object.freeze({TIER_1:"#07C168",TIER_2:"#27A9FF",TIER_3:"#FBC558"}),Qb="#C8BEB4";function Zb(e){return e?Yb[e.toUpperCase()]??Qb:Qb}function Jb(e){if(!e)return null;let t=/^tier[_\s-]?(\d+)$/i.exec(e.trim());return t?`Tier ${t[1]}`:e}function Xb(e){if(typeof e!="string")return null;let t=e.trim();return t.length===0?null:t}function eg(e){let t=Xb(e);return t!==null&&/^https:\/\/\S+$/i.test(t)?t:null}function tg(e,t){let r=Xb(e.source_name)??Xb(e.sourceName),n=Xb(e.section),l=Xb(e.authority_tier)??Xb(e.authorityTier),i=Jb(l),o=r??Xb(e.title)??`Source ${t+1}`,a=Xb(e.monograph_chunk_id)??Xb(e.chunkId),s=[n,i].filter(e=>e!==null).join(" · ");/* @__PURE__ */
257
+ return Object.freeze({title:o,sourceName:r,section:n,authorityTier:l,tierLabel:i,meta:s.length===0?null:s,url:eg(e.url),excerpt:Xb(e.excerpt),tierColor:Zb(l),key:`${o}-${a??"none"}-${t}`})}function rg(e){return e===void 0||e.length===0?ng:/* @__PURE__ */Object.freeze(e.map((e,t)=>tg(e,t)))}var ng=/* @__PURE__ */Object.freeze([]);function lg(e){return e===1?`1 ${Te.sourceSingular}`:`${e} ${Te.sourcePlural}`}function ig(e,t){return`${t?Te.hideSources:Te.showSources} ${lg(e)}`}function og(e){return[e.url!==null?`${Te.openSource}: ${e.title}`:e.title,e.meta,e.excerpt].filter(e=>e!==null&&e.length>0).join(". ")}var ag="https:\\/\\/sdk(?:-[a-z]+)?\\.everfur\\.com";function sg(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}typeof __EVERFUR_BRAND_CDN_ORIGIN__=="string"&&__EVERFUR_BRAND_CDN_ORIGIN__.length>0?sg(__EVERFUR_BRAND_CDN_ORIGIN__):ag;function hardenHttpsUrl(e){if(e===null)return null;let t=e.trim();return t.length===0?null:/^https:\/\/\S+$/i.test(t)?t:null}function ug(e){let t=e.split(/\n\s*\n/).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:[e]}var cg=/^\s*[-*]\s+(\S.*)$/,dg=/^\s*(\d{1,3})[.)]\s+(\S.*)$/;function pg(e){let t=[],r=[],n=null,l=()=>{r.length>0&&t.push({kind:"text",text:r.join(`\n`)}),r=[]},i=()=>{n!==null&&t.push(n.ordered?{kind:"list",ordered:true,start:n.start,items:n.items}:{kind:"list",ordered:false,items:n.items}),n=null};for(let t of e.split(`\n`)){let e=cg.exec(t),o=e===null?dg.exec(t):null,a=e?.[1]??o?.[2];if(a===void 0){i(),r.push(t);continue}let s=o!==null;l(),n!==null&&n.ordered!==s&&i(),n===null&&(n={ordered:s,start:o===null?1:Number(o[1]),items:[]}),n.items.push(a.trim())}return l(),i(),t}function fg(e,t){let r=e.findIndex(e=>e.id===t);for(let t=r-1;t>=0;t-=1){let r=e[t];if(r!==void 0&&r.role==="user")return r.text}return null}function hg(e,t){if(e===void 0)return[];try{let r=e(t);return Array.isArray(r)?r:[]}catch{return[]}}function bg(e){return hardenHttpsUrl(e.trim())}function gg(e,t){if(t?.followUpActions===void 0||e.isStreaming||e.status==="error")return[];let r=e.messages[e.messages.length-1];return r===void 0||r.role!=="assistant"||r.pending===true?[]:hg(t.followUpActions,{answer:r.text,question:fg(e.messages,r.id),messageId:r.id})}var mg=/\*\*([^*]+?)\*\*|\*([^*]+?)\*|`([^`]+?)`/g,yg=new RegExp(`\\[([^\\]\\n]{1,300})\\]\\((https:\\/\\/[^\\s()<>]{1,${Ui}})\\)|(https:\\/\\/[^\\s<>"'\`*\\[\\]]{1,${Ui}})`,"gi"),vg=/https:\/\//i,xg=`.,;:!?'"`;function wg(e,t){return e.includes("*")||e.includes("`")||t!==void 0&&vg.test(e)}function kg(e,t){let r=[],n=e=>{t===void 0?r.push({kind:"text",text:e}):jg(r,e,t)},l=0;mg.lastIndex=0;for(let t=mg.exec(e);t!==null;t=mg.exec(e)){t.index>l&&n(e.slice(l,t.index));let i=t[1],o=t[2],a=t[3];i!==void 0?r.push({kind:"bold",text:i}):o!==void 0?r.push({kind:"italic",text:o}):a!==void 0&&r.push({kind:"code",text:a}),l=t.index+t[0].length}return l<e.length&&n(e.slice(l)),r}function Sg(e){let t=e.length;for(;;){let r=e[t-1];if(r===void 0)break;if(xg.includes(r))t-=1;else if(r===")"&&Cg(e,"(",t)<Cg(e,")",t))t-=1;else break}return e.slice(0,t)}function Cg(e,t,r){let n=0;for(let l=0;l<r;l+=1)e[l]===t&&(n+=1);return n}function jg(e,t,r){if(!vg.test(t)){e.push({kind:"text",text:t});return}let n=0;yg.lastIndex=0;for(let l=yg.exec(t);l!==null;l=yg.exec(t)){let i=l[1],o=l[2],a=l[3],s,u,c;if(i!==void 0&&o!==void 0)s=i.trim(),u=s.length>0?Ki(o,r):null,c=l[0].length;else if(a!==void 0)s=Sg(a),u=Ki(s,r),c=s.length;else continue;u!==null&&(l.index>n&&e.push({kind:"text",text:t.slice(n,l.index)}),e.push({kind:"link",text:s,href:u}),n=l.index+c,yg.lastIndex=n)}n<t.length&&e.push({kind:"text",text:t.slice(n)})}var Rg=/* @__PURE__ */Object.freeze({textDecorationLine:"underline"});function Tg(e,t){return t===void 0||!wg(e,t.hosts)?false:kg(e,t.hosts).some(e=>e.kind==="link")}function _g(e,r,n){let l=n?.hosts;return wg(e,l)?kg(e,l).map((e,l)=>{switch(e.kind){case"bold":/* @__PURE__ */
257
258
  return t.jsx(Text,{style:r.bold,children:e.text},l);case"italic":return r.italic?/* @__PURE__ */t.jsx(Text,{style:r.italic,children:e.text},l):e.text;case"code":return r.code?/* @__PURE__ */t.jsx(Text,{style:r.code,children:e.text},l):e.text;case"link":{if(n===void 0)return e.text;let{href:r}=e;/* @__PURE__ */
258
- return t.jsx(Text,{style:dg,accessibilityRole:"link",accessibilityLabel:e.text,onPress:()=>n.open(r),children:e.text},l)}default:return e.text}}):e}var hg=10.5,bg=16,gg=12,mg=38,yg=11,vg=15,xg=22,wg=32,kg=13.5,Sg=14,Cg=15,jg=16,Rg=13,Tg=13,_g=26,zg=21,Ig=42,Pg=1,Eg=.06,Mg=.07,Fg=.12,Ag="45%";function Lg(){let t=useEverfurTheme(),r=e.useMemo(()=>Og(t),[t]);return{theme:t,styles:r}}function Chevron({options:e,color:r}){let n=/* @__PURE__ */t.jsx(ChevronGlyph,{size:jg,color:r,strokeWidth:2,direction:"right"}),l=e?.renderIcon;return l===void 0?n:/* @__PURE__ */t.jsx(HostRender,{render:()=>l("chevron"),fallback:n})}function AnswerCard({card:e,options:r}){let{theme:l,styles:i}=Lg();if(e.render!==void 0){let l=e.render;/* @__PURE__ */
259
- return t.jsx(n.View,{style:[i.card,e.variant!==void 0?r?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */t.jsx(HostRender,{render:l,fallback:null})})}let o=e.value!==void 0,a=r?.styles,s=[i.card,o?a?.cardStat:null,e.variant!==void 0?a?.cardVariant?.[e.variant]:null],u=e.tile?.tone,c=e.pill?.tone,d=e.tile?.imageUrl!==void 0?eg(e.tile.imageUrl):null,p=/* @__PURE__ */t.jsxs(t.Fragment,{children:[o?null:/* @__PURE__ */t.jsx(n.View,{style:[i.tile,u!==void 0?a?.tileTone?.[u]:null],children:d!==null?/* @__PURE__ */t.jsx(n.Image,{source:{uri:d},style:i.tileImage,accessibilityIgnoresInvertColors:true}):e.tile?.icon??null}),
259
+ return t.jsx(Text,{style:Rg,accessibilityRole:"link",accessibilityLabel:e.text,onPress:()=>n.open(r),children:e.text},l)}default:return e.text}}):e}var zg=10.5,Ig=16,Pg=12,Eg=38,Mg=11,Ag=15,Fg=22,Lg=32,Og=13.5,Vg=14,Dg=15,Bg=16,Hg=13,Wg=13,Ng=26,Ug=21,$g=42,qg=1,Gg=.06,Kg=.07,Yg=.12,Qg="45%";function Zg(){let t=useEverfurTheme(),r=e.useMemo(()=>Jg(t),[t]);return{theme:t,styles:r}}function Chevron({options:e,color:r}){let n=/* @__PURE__ */t.jsx(ChevronGlyph,{size:Bg,color:r,strokeWidth:2,direction:"right"}),l=e?.renderIcon;return l===void 0?n:/* @__PURE__ */t.jsx(HostRender,{render:()=>l("chevron"),fallback:n})}function AnswerCard({card:e,options:r}){let{theme:l,styles:i}=Zg();if(e.render!==void 0){let l=e.render;/* @__PURE__ */
260
+ return t.jsx(n.View,{style:[i.card,e.variant!==void 0?r?.styles?.cardVariant?.[e.variant]:null],accessible:false,accessibilityLabel:e.title,testID:"everfur-answer-host-card",children:/* @__PURE__ */t.jsx(HostRender,{render:l,fallback:null})})}let o=e.value!==void 0,a=r?.styles,s=[i.card,o?a?.cardStat:null,e.variant!==void 0?a?.cardVariant?.[e.variant]:null],u=e.tile?.tone,c=e.pill?.tone,d=e.tile?.imageUrl!==void 0?bg(e.tile.imageUrl):null,p=/* @__PURE__ */t.jsxs(t.Fragment,{children:[o?null:/* @__PURE__ */t.jsx(n.View,{style:[i.tile,u!==void 0?a?.tileTone?.[u]:null],children:d!==null?/* @__PURE__ */t.jsx(n.Image,{source:{uri:d},style:i.tileImage,accessibilityIgnoresInvertColors:true}):e.tile?.icon??null}),
260
261
  /* @__PURE__ */t.jsxs(n.View,{style:i.cardWords,children:[
261
262
  /* @__PURE__ */t.jsx(Text,{tier:"control",style:i.cardTitle,children:e.title}),e.meta!==void 0?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:i.cardMeta,children:e.meta}):null]}),o?/* @__PURE__ */t.jsxs(Text,{tier:"control",style:i.stat,children:[e.value?.amount,e.value?.unit!==void 0?/* @__PURE__ */t.jsx(Text,{style:i.statUnit,children:e.value.unit}):null]}):/* @__PURE__ */t.jsxs(t.Fragment,{children:[e.pill!==void 0?/* @__PURE__ */t.jsx(n.View,{style:[i.pill,c!==void 0?a?.pillTone?.[c]:null],children:/* @__PURE__ */t.jsx(Text,{tier:"badge",style:[i.pillText,c!==void 0?a?.pillToneText?.[c]:null],numberOfLines:1,ellipsizeMode:"tail",children:e.pill.label})}):null,e.onPress!==void 0?/* @__PURE__ */t.jsx(Chevron,{options:r,color:l.color.text.muted}):null]})]});if(e.onPress!==void 0){let r=e.onPress;/* @__PURE__ */
262
- return t.jsx(n.Pressable,{onPress:()=>{Er(r)},accessibilityRole:"button",accessibilityLabel:e.title,style:s,children:p})}/* @__PURE__ */
263
- return t.jsx(n.View,{style:s,children:p})}function CardsAnswer({message:r,text:l,streaming:i,messages:o,options:a,sentiment:s,onSentiment:u,sender:c,footer:d,onOpenUrl:p}){let{styles:f}=Lg(),h=e.useMemo(()=>({answer:r.text,question:Jb(o,r.id),messageId:r.id}),[r.text,r.id,o]),b=!i&&r.pending!==true,g=b?Xb(a?.cards,h):[],m=e.useMemo(()=>b?Hb(r.citations):[],[b,r.citations]),y=a?.byline,v=a?.feedback!==void 0&&r.responseId!==void 0&&u!==void 0?a.feedback:null,x={bold:f.bold,italic:f.italic,code:f.code},w=Yi(),k=b?w:void 0;/* @__PURE__ */
263
+ return t.jsx(n.Pressable,{onPress:()=>{Ar(r)},accessibilityRole:"button",accessibilityLabel:e.title,style:s,children:p})}/* @__PURE__ */
264
+ return t.jsx(n.View,{style:s,children:p})}function CardsAnswer({message:r,text:l,streaming:i,messages:o,options:a,sentiment:s,onSentiment:u,sender:c,footer:d,onOpenUrl:p}){let{styles:f}=Zg(),h=e.useMemo(()=>({answer:r.text,question:fg(o,r.id),messageId:r.id}),[r.text,r.id,o]),b=!i&&r.pending!==true,g=b?hg(a?.cards,h):[],m=e.useMemo(()=>b?rg(r.citations):[],[b,r.citations]),y=a?.byline,v=a?.feedback!==void 0&&r.responseId!==void 0&&u!==void 0?a.feedback:null,x={bold:f.bold,italic:f.italic,code:f.code},w=Zi(),k=b?w:void 0;/* @__PURE__ */
264
265
  return t.jsxs(n.View,{style:f.answer,testID:"everfur-answer-cards",children:[y!==void 0?/* @__PURE__ */t.jsxs(n.View,{style:f.byline,children:[y.icon??null,
265
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:f.bylineText,children:y.label})]}):c,
266
- /* @__PURE__ */t.jsx(n.View,{style:f.body,children:Kb(l).flatMap((e,r)=>Zb(e).map((e,l)=>{let i=`${r}-${l}`;return e.kind==="text"?/* @__PURE__ */t.jsx(Text,{style:f.paragraph,children:fg(e.text,x,k)},i):/* @__PURE__ */t.jsx(n.View,{style:f.list,children:e.items.map((r,l)=>/* @__PURE__ */t.jsxs(n.View,{style:f.listItem,children:[
266
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:f.bylineText,children:y.label})]}):c,b?/* @__PURE__ */t.jsx(SeverityCard,{message:r}):null,
267
+ /* @__PURE__ */t.jsx(n.View,{style:f.body,children:ug(l).flatMap((e,r)=>pg(e).map((e,l)=>{let i=`${r}-${l}`;return e.kind==="text"?/* @__PURE__ */t.jsx(Text,{style:f.paragraph,children:_g(e.text,x,k)},i):/* @__PURE__ */t.jsx(n.View,{style:f.list,children:e.items.map((r,l)=>/* @__PURE__ */t.jsxs(n.View,{style:f.listItem,children:[
267
268
  /* @__PURE__ */t.jsx(Text,{style:f.paragraph,children:e.ordered?`${e.start+l}.`:"•"}),
268
- /* @__PURE__ */t.jsx(Text,{style:[f.paragraph,f.listText],children:fg(r,x,k)})]},l))},i)}))}),g.length>0?/* @__PURE__ */t.jsx(n.View,{style:f.cards,children:g.map(e=>/* @__PURE__ */t.jsx(AnswerCard,{card:e,options:a},e.key))}):null,b?/* @__PURE__ */t.jsx(ServerCardsSlot,{message:r}):null,m.length>0?/* @__PURE__ */t.jsxs(n.View,{style:f.cards,accessibilityLabel:Nb(m.length),children:[
269
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:f.label,children:je.sourcesHeading}),m.map(e=>{let r=e.url;/* @__PURE__ */
269
+ /* @__PURE__ */t.jsx(Text,{style:[f.paragraph,f.listText],children:_g(r,x,k)})]},l))},i)}))}),g.length>0?/* @__PURE__ */t.jsx(n.View,{style:f.cards,children:g.map(e=>/* @__PURE__ */t.jsx(AnswerCard,{card:e,options:a},e.key))}):null,b?/* @__PURE__ */t.jsx(AnswerRecordCards,{message:r}):null,b?/* @__PURE__ */t.jsx(ServerCardsSlot,{message:r}):null,m.length>0?/* @__PURE__ */t.jsxs(n.View,{style:f.cards,accessibilityLabel:lg(m.length),children:[
270
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:f.label,children:Te.sourcesHeading}),m.map(e=>{let r=e.url;/* @__PURE__ */
270
271
  return t.jsx(AnswerCard,{card:{key:e.key,title:e.title,...e.meta!==null?{meta:e.meta}:{},tile:{icon:/* @__PURE__ */t.jsx(SourceTileGlyph,{})},...p!==void 0&&r!==null?{onPress:()=>p(r)}:{}},options:a},e.key)})]}):null,b&&v!==null&&u!==void 0?/* @__PURE__ */t.jsxs(n.View,{style:[f.feedback,a?.styles?.feedback],children:[
271
272
  /* @__PURE__ */t.jsx(FeedbackChip,{label:v.helpful,on:s==="up",onPress:()=>u("up"),styles:f,host:a?.styles}),
272
273
  /* @__PURE__ */t.jsx(FeedbackChip,{label:v.notHelpful,on:s==="down",onPress:()=>u("down"),styles:f,host:a?.styles})]}):null,b?d(v===null):null]})}function SourceTileGlyph(){let e=useEverfurTheme();/* @__PURE__ */
273
- return t.jsx(BookGlyph,{size:zg,color:e.color.linkInk,strokeWidth:1.5})}function FeedbackChip({label:e,on:r,onPress:l,styles:i,host:o}){/* @__PURE__ */
274
- return t.jsx(n.Pressable,{onPress:l,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:r},style:[i.chip,o?.feedbackChip,r?i.chipOn:null],hitSlop:(Ts-wg)/2,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:[i.chipText,o?.feedbackChipText],children:e})})}function CardsFollowUps({prompts:e,onSelectPrompt:r,label:l,actions:i,options:o}){let{theme:a,styles:s}=Lg();if(e.length===0&&i.length===0)return null;let u=o?.styles,c=l??je.followUpsHeadingNative;/* @__PURE__ */
275
- return t.jsxs(n.View,{style:[s.followUps,u?.followUps],accessibilityLabel:c,testID:"everfur-cards-follow-ups",children:[
276
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:[s.label,u?.followUpsLabel],accessibilityRole:"header",children:c}),i.map(e=>/* @__PURE__ */t.jsxs(n.Pressable,{onPress:()=>{Er(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:Pg,style:[s.row,s.rowAction,u?.followUp,u?.followUpAction],children:[e.icon??null,
277
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:[s.rowText,s.rowTextAction,u?.followUpText,u?.followUpActionText],children:e.label}),
278
- /* @__PURE__ */t.jsx(Chevron,{options:o,color:a.color.text.primary})]},`action:${e.key}`)),e.map(e=>/* @__PURE__ */t.jsxs(n.Pressable,{onPress:()=>r(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:Pg,style:[s.row,u?.followUp],children:[
279
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:[s.rowText,u?.followUpText],children:e}),
280
- /* @__PURE__ */t.jsx(Chevron,{options:o,color:a.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:r}=Lg();/* @__PURE__ */
281
- return t.jsx(n.View,{style:r.byline,children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:r.bylineText,children:e})})}function Og(e){let t=e.color,r=e.space,l={...face(e,"mono"),fontSize:hg,textTransform:"uppercase",color:t.text.muted},i={borderWidth:1,borderColor:t.borderRingCream},o={borderWidth:1,borderColor:Ka(t.text.primary,Eg)??t.borderRingCream},a={shadowColor:t.text.primary,shadowOffset:{width:0,height:1},shadowOpacity:Mg,shadowRadius:2,elevation:1},s=textRole(e,"message"),chipInk=Oo(e.slots.chip);return n.StyleSheet.create({answer:{gap:r.md,alignSelf:"stretch"},byline:{flexDirection:"row",alignItems:"center",gap:10,minHeight:14},bylineText:{...l,letterSpacing:hg*.06,flexShrink:1},body:{gap:10},paragraph:{...face(e,"regular"),fontSize:s.fontSize,lineHeight:Math.round(s.lineHeight),color:t.text.primary},list:{gap:4},listItem:{flexDirection:"row",gap:r.sm,paddingLeft:r.xs},listText:{flex:1},bold:face(e,"bold"),italic:{fontStyle:"italic"},code:face(e,"mono"),cards:{gap:r.sm},card:{flexDirection:"row",alignItems:"center",gap:r.md,padding:gg,borderRadius:bg,backgroundColor:t.surface,...o,...a,minHeight:Ts,...Ao(e.slots.card)},tile:{width:mg,height:mg,borderRadius:yg,backgroundColor:Ka(t.linkInk,Fg)??t.surfaceSubtle,alignItems:"center",justifyContent:"center",overflow:"hidden"},tileImage:{width:mg,height:mg},cardWords:{flex:1,minWidth:0},cardTitle:{...face(e,"bold"),fontSize:vg,lineHeight:Math.round(vg*1.25),color:t.text.primary,...Oo(e.slots.card)},cardMeta:{...l,letterSpacing:hg*.04,marginTop:3},stat:{...face(e,"mono"),fontSize:xg,color:t.text.primary},statUnit:{...face(e,"mono"),fontSize:hg+2,color:t.text.muted},pill:{minHeight:_g,paddingHorizontal:10,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,justifyContent:"center",flexShrink:1,maxWidth:Ag},pillText:{...face(e,"bold"),fontSize:Tg,color:t.text.primary},feedback:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,alignItems:"center"},chip:{minHeight:wg,paddingHorizontal:12,borderRadius:e.radius.pill,...i,justifyContent:"center"},chipOn:{backgroundColor:t.surfaceSubtle},chipText:{...Ff(e),fontSize:kg,color:t.text.primary,...chipInk},followUps:{gap:r.sm,alignSelf:"stretch",marginTop:r.xs},label:{...face(e,"bold"),fontSize:Rg,lineHeight:Math.round(Rg*1.5),color:t.text.muted,marginTop:2},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:Ig,paddingTop:11,paddingBottom:11,paddingRight:12,paddingLeft:14,borderRadius:Sg,backgroundColor:t.surface,...o},rowAction:{},rowText:{...Ff(e),flex:1,fontSize:Cg,lineHeight:Math.round(Cg*1.3),color:t.linkInk},rowTextAction:{color:t.text.primary}})}var Vg=/* @__PURE__ */Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" · ",answers:/* @__PURE__ */Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),Dg=/* @__PURE__ */Object.freeze(Xl.map(e=>/* @__PURE__ */Object.freeze({answer:e,label:Vg.answers[e]})));function Bg(t,r){let[n,l]=e.useState(null),[i,o]=e.useState(null),[a,s]=e.useState(null),u=e.useCallback(e=>{r!==null&&(l(e),o(null),r(t.caseId,e).then(t=>{l(null),t.ok?s(e):o(t.error)}))},[r,t.caseId]),c=a??t.answer;return{answer:c,answerable:!isCheckinSettled(t),escalated:c==="worse",pending:n,error:i,choose:u}}var Hg=44,Wg=.6,Ng=/* @__PURE__ */Object.freeze({caseId:"",answer:null,resolutionText:null,status:null});function CheckinCard({message:r,checkin:l,onAnswer:i,petRef:petRef,onFindVet:o,vet:a,onLayout:s,onOpen:u}){let c=useEverfurTheme(),d=e.useMemo(()=>Ug(c),[c]),p=Bg(l??Ng,l===null?null:i),f=p.answer!==null||p.pending!==null,h=l!==null&&i!==null&&p.answerable,b=l===null?null:Pb(l.openedAt,Eb(r));/* @__PURE__ */
282
- return t.jsxs(n.View,{style:d.card,accessibilityLabel:Vg.eyebrow,onLayout:s,children:[
274
+ return t.jsx(BookGlyph,{size:Ug,color:e.color.linkInk,strokeWidth:1.5})}function FeedbackChip({label:e,on:r,onPress:l,styles:i,host:o}){/* @__PURE__ */
275
+ return t.jsx(n.Pressable,{onPress:l,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{selected:r},style:[i.chip,o?.feedbackChip,r?i.chipOn:null],hitSlop:(zs-Lg)/2,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:[i.chipText,o?.feedbackChipText],children:e})})}function CardsFollowUps({prompts:r,onSelectPrompt:l,label:i,actions:o,options:a}){let{theme:s,styles:u}=Zg(),c=yc(),d=e.useMemo(()=>c===null?null:_b()?.ask.followUpStyles(c.paint)??null,[c]);if(r.length===0&&o.length===0)return null;let p=a?.styles,f=i??Te.followUpsHeadingNative;/* @__PURE__ */
276
+ return t.jsxs(n.View,{style:[u.followUps,d?.followUps,p?.followUps],accessibilityLabel:f,testID:"everfur-cards-follow-ups",children:[
277
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:[u.label,d?.label,p?.followUpsLabel],accessibilityRole:"header",children:f}),o.map(e=>/* @__PURE__ */t.jsxs(n.Pressable,{onPress:()=>{Ar(e.onPress)},accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:qg,style:[u.row,u.rowAction,d?.row,p?.followUp,p?.followUpAction],children:[e.icon??null,
278
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:[u.rowText,u.rowTextAction,d?.rowText,p?.followUpText,p?.followUpActionText],children:e.label}),
279
+ /* @__PURE__ */t.jsx(Chevron,{options:a,color:c?.paint.accent??s.color.text.primary})]},`action:${e.key}`)),r.map(e=>/* @__PURE__ */t.jsxs(n.Pressable,{onPress:()=>l(e),accessibilityRole:"button",accessibilityLabel:e,hitSlop:qg,style:[u.row,d?.row,p?.followUp],children:[
280
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:[u.rowText,d?.rowText,p?.followUpText],children:e}),
281
+ /* @__PURE__ */t.jsx(Chevron,{options:a,color:c?.paint.accent??s.color.linkInk})]},e))]})}function CardsByline({label:e}){let{styles:r}=Zg();/* @__PURE__ */
282
+ return t.jsx(n.View,{style:r.byline,children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:r.bylineText,children:e})})}function Jg(e){let t=e.color,r=e.space,l={...face(e,"mono"),fontSize:zg,textTransform:"uppercase",color:t.text.muted},i={borderWidth:1,borderColor:t.borderRingCream},o={borderWidth:1,borderColor:Qa(t.text.primary,Gg)??t.borderRingCream},a={shadowColor:t.text.primary,shadowOffset:{width:0,height:1},shadowOpacity:Kg,shadowRadius:2,elevation:1},s=textRole(e,"message"),chipInk=Do(e.slots.chip);return n.StyleSheet.create({answer:{gap:r.md,alignSelf:"stretch"},byline:{flexDirection:"row",alignItems:"center",gap:10,minHeight:14},bylineText:{...l,letterSpacing:zg*.06,flexShrink:1},body:{gap:10},paragraph:{...face(e,"regular"),fontSize:s.fontSize,lineHeight:Math.round(s.lineHeight),color:t.text.primary},list:{gap:4},listItem:{flexDirection:"row",gap:r.sm,paddingLeft:r.xs},listText:{flex:1},bold:face(e,"bold"),italic:{fontStyle:"italic"},code:face(e,"mono"),cards:{gap:r.sm},card:{flexDirection:"row",alignItems:"center",gap:r.md,padding:Pg,borderRadius:Ig,backgroundColor:t.surface,...o,...a,minHeight:zs,...Oo(e.slots.card)},tile:{width:Eg,height:Eg,borderRadius:Mg,backgroundColor:Qa(t.linkInk,Yg)??t.surfaceSubtle,alignItems:"center",justifyContent:"center",overflow:"hidden"},tileImage:{width:Eg,height:Eg},cardWords:{flex:1,minWidth:0},cardTitle:{...face(e,"bold"),fontSize:Ag,lineHeight:Math.round(Ag*1.25),color:t.text.primary,...Do(e.slots.card)},cardMeta:{...l,letterSpacing:zg*.04,marginTop:3},stat:{...face(e,"mono"),fontSize:Fg,color:t.text.primary},statUnit:{...face(e,"mono"),fontSize:zg+2,color:t.text.muted},pill:{minHeight:Ng,paddingHorizontal:10,borderRadius:e.radius.pill,backgroundColor:t.surfaceSubtle,justifyContent:"center",flexShrink:1,maxWidth:Qg},pillText:{...face(e,"bold"),fontSize:Wg,color:t.text.primary},feedback:{flexDirection:"row",flexWrap:"wrap",gap:r.sm,alignItems:"center"},chip:{minHeight:Lg,paddingHorizontal:12,borderRadius:e.radius.pill,...i,justifyContent:"center"},chipOn:{backgroundColor:t.surfaceSubtle},chipText:{...Wf(e),fontSize:Og,color:t.text.primary,...chipInk},followUps:{gap:r.sm,alignSelf:"stretch",marginTop:r.xs},label:{...face(e,"bold"),fontSize:Hg,lineHeight:Math.round(Hg*1.5),color:t.text.muted,marginTop:2},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:$g,paddingTop:11,paddingBottom:11,paddingRight:12,paddingLeft:14,borderRadius:Vg,backgroundColor:t.surface,...o},rowAction:{},rowText:{...Wf(e),flex:1,fontSize:Dg,lineHeight:Math.round(Dg*1.3),color:t.linkInk},rowTextAction:{color:t.text.primary}})}var Xg=/* @__PURE__ */Object.freeze({eyebrow:"Checking in",logged:"Logged",findVet:"Find a vet now",day:"Day {day}",daySeparator:" · ",answers:/* @__PURE__ */Object.freeze({better:"Better",same:"Same",worse:"Worse"})}),em=/* @__PURE__ */Object.freeze(ti.map(e=>/* @__PURE__ */Object.freeze({answer:e,label:Xg.answers[e]})));function tm(t,r){let[n,l]=e.useState(null),[i,o]=e.useState(null),[a,s]=e.useState(null),u=e.useCallback(e=>{r!==null&&(l(e),o(null),r(t.caseId,e).then(t=>{l(null),t.ok?s(e):o(t.error)}))},[r,t.caseId]),c=a??t.answer;return{answer:c,answerable:!isCheckinSettled(t),escalated:c==="worse",pending:n,error:i,choose:u}}var rm=44,nm=.6,lm=/* @__PURE__ */Object.freeze({caseId:"",answer:null,resolutionText:null,status:null});function CheckinCard({message:r,checkin:l,onAnswer:i,petRef:petRef,onFindVet:o,vet:a,onLayout:s,onOpen:u}){let c=useEverfurTheme(),d=e.useMemo(()=>im(c),[c]),p=tm(l??lm,l===null?null:i),f=p.answer!==null||p.pending!==null,h=l!==null&&i!==null&&p.answerable,b=l===null?null:qb(l.openedAt,Gb(r));/* @__PURE__ */
283
+ return t.jsxs(n.View,{style:d.card,accessibilityLabel:Xg.eyebrow,onLayout:s,children:[
283
284
  /* @__PURE__ */t.jsxs(n.View,{style:d.head,children:[
284
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:d.eyebrow,children:Vg.eyebrow}),b!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:d.headDay,children:Re(Vg.day,{day:b})}):null]}),u?/* @__PURE__ */t.jsx(n.Pressable,{onPress:u,accessibilityRole:"button",accessibilityLabel:r.text,style:d.open,children:/* @__PURE__ */t.jsx(Text,{style:[d.question,d.openText],children:r.text})}):/* @__PURE__ */t.jsx(Text,{style:d.question,accessibilityRole:"text",children:r.text}),h?/* @__PURE__ */t.jsx(n.View,{style:[d.row,p.pending?d.rowPending:null],children:Dg.map(({answer:e,label:r})=>{let l=(p.pending??p.answer)===e;/* @__PURE__ */
285
- return t.jsx(n.Pressable,{onPress:()=>p.choose(e),disabled:f,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{selected:l,disabled:f,busy:p.pending===e},style:[d.pill,l?d.pillSelected:null],children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:[d.pillLabel,l?d.pillLabelSelected:null],children:r})},e)})}):null,p.answer!==null?/* @__PURE__ */t.jsx(Text,{style:d.logged,children:Vg.logged}):null,p.escalated?/* @__PURE__ */t.jsx(CheckinFindVet,{petRef:petRef??null,onFindVet:o,vet:a,styles:d}):null,l?.resolutionText?/* @__PURE__ */t.jsx(Text,{style:d.resolution,children:l.resolutionText}):null,p.error?/* @__PURE__ */t.jsx(Text,{style:d.error,accessibilityRole:"alert",children:p.error.displayMessage}):null]})}function CheckinFindVet({petRef:petRef,onFindVet:e,vet:r,styles:l}){return useVetVisit(Gh(petRef,r)).available&&petRef!==null?/* @__PURE__ */t.jsx(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:Vg.findVet,...r?.returnTo!==void 0?{returnTo:r.returnTo}:{},...r?.usState!==void 0?{usState:r.usState}:{},...r?.prefer!==void 0?{prefer:r.prefer}:{},style:l.findVet,labelStyle:l.findVetLabel}):e===void 0?null:/* @__PURE__ */t.jsx(n.Pressable,{onPress:e,accessibilityRole:"button",accessibilityLabel:Vg.findVet,style:l.findVet,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:l.findVetLabel,children:Vg.findVet})})}function Ug(e){let t=e.color,r=e.space,l=e.radius,i=e.type,o=Lo(e.slots.card),a=Oo(o);return n.StyleSheet.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:l.lg,backgroundColor:t.brandSoft,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.brandBorder,...Ao(o,n.StyleSheet.hairlineWidth)},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...face(e,"regular"),color:t.text.secondary,fontSize:i.size.caption,letterSpacing:i.letterSpacing.eyebrow,textTransform:"uppercase",...a},headDay:{...face(e,"bold"),color:t.text.primary,fontSize:i.size.caption,letterSpacing:i.letterSpacing.eyebrow,textTransform:"uppercase",...a},question:{...face(e,"regular"),color:t.text.primary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.normal,...a},open:{minHeight:Hg,justifyContent:"center"},openText:{textDecorationLine:"underline"},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:Wg},pill:{flex:1,minHeight:Hg,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:l.pill,borderWidth:1,borderColor:t.controlEdge,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brandInk},pillLabel:{...face(e,"regular"),color:t.text.primary,fontSize:i.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...face(e,"regular"),color:t.text.secondary,fontSize:i.size.caption,...a},resolution:{...face(e,"regular"),color:t.text.primary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.normal,...a},error:{...face(e,"regular"),color:t.danger,fontSize:i.size.caption},findVet:{alignSelf:"stretch",minHeight:Hg,alignItems:"center",justifyContent:"center",borderRadius:l.pill,borderWidth:1.5,borderColor:t.controlEdge,backgroundColor:t.surface},findVetLabel:{...face(e,"bold"),color:t.brandInk,fontSize:i.size.body}})}var $g=244,qg=8,Gg=13,Kg=14,Yg=.3,Qg=-.24,Zg=22,Jg=10,Xg=15;function CitationCards({citations:r,onOpenUrl:l}){let i=useEverfurTheme(),o=e.useMemo(()=>em(i),[i]),a=e.useMemo(()=>Hb(r),[r]),[s,u]=e.useState(false);if(a.length===0)return null;let c=a.length;/* @__PURE__ */
285
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:d.eyebrow,children:Xg.eyebrow}),b!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:d.headDay,children:_e(Xg.day,{day:b})}):null]}),u?/* @__PURE__ */t.jsx(n.Pressable,{onPress:u,accessibilityRole:"button",accessibilityLabel:r.text,style:d.open,children:/* @__PURE__ */t.jsx(Text,{style:[d.question,d.openText],children:r.text})}):/* @__PURE__ */t.jsx(Text,{style:d.question,accessibilityRole:"text",children:r.text}),h?/* @__PURE__ */t.jsx(n.View,{style:[d.row,p.pending?d.rowPending:null],children:em.map(({answer:e,label:r})=>{let l=(p.pending??p.answer)===e;/* @__PURE__ */
286
+ return t.jsx(n.Pressable,{onPress:()=>p.choose(e),disabled:f,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{selected:l,disabled:f,busy:p.pending===e},style:[d.pill,l?d.pillSelected:null],children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:[d.pillLabel,l?d.pillLabelSelected:null],children:r})},e)})}):null,p.answer!==null?/* @__PURE__ */t.jsx(Text,{style:d.logged,children:Xg.logged}):null,p.escalated?/* @__PURE__ */t.jsx(CheckinFindVet,{petRef:petRef??null,onFindVet:o,vet:a,styles:d}):null,l?.resolutionText?/* @__PURE__ */t.jsx(Text,{style:d.resolution,children:l.resolutionText}):null,p.error?/* @__PURE__ */t.jsx(Text,{style:d.error,accessibilityRole:"alert",children:p.error.displayMessage}):null]})}function CheckinFindVet({petRef:petRef,onFindVet:e,vet:r,styles:l}){return useVetVisit(ib(petRef,r)).available&&petRef!==null?/* @__PURE__ */t.jsx(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:Xg.findVet,...r?.returnTo!==void 0?{returnTo:r.returnTo}:{},...r?.usState!==void 0?{usState:r.usState}:{},...r?.prefer!==void 0?{prefer:r.prefer}:{},style:l.findVet,labelStyle:l.findVetLabel}):e===void 0?null:/* @__PURE__ */t.jsx(n.Pressable,{onPress:e,accessibilityRole:"button",accessibilityLabel:Xg.findVet,style:l.findVet,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:l.findVetLabel,children:Xg.findVet})})}function im(e){let t=e.color,r=e.space,l=e.radius,i=e.type,o=Vo(e.slots.card),a=Do(o);return n.StyleSheet.create({card:{maxWidth:"92%",padding:r.md,gap:r.sm,borderRadius:l.lg,backgroundColor:t.brandSoft,borderWidth:n.StyleSheet.hairlineWidth,borderColor:t.brandBorder,...Oo(o,n.StyleSheet.hairlineWidth)},head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:r.sm},eyebrow:{...face(e,"regular"),color:t.text.secondary,fontSize:i.size.caption,letterSpacing:i.letterSpacing.eyebrow,textTransform:"uppercase",...a},headDay:{...face(e,"bold"),color:t.text.primary,fontSize:i.size.caption,letterSpacing:i.letterSpacing.eyebrow,textTransform:"uppercase",...a},question:{...face(e,"regular"),color:t.text.primary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.normal,...a},open:{minHeight:rm,justifyContent:"center"},openText:{textDecorationLine:"underline"},row:{flexDirection:"row",gap:r.sm,marginTop:r.xs},rowPending:{opacity:nm},pill:{flex:1,minHeight:rm,alignItems:"center",justifyContent:"center",paddingHorizontal:r.md,borderRadius:l.pill,borderWidth:1,borderColor:t.controlEdge,backgroundColor:t.surface},pillSelected:{backgroundColor:t.brand,borderColor:t.brandInk},pillLabel:{...face(e,"regular"),color:t.text.primary,fontSize:i.size.body},pillLabelSelected:{color:t.onPrimary},logged:{...face(e,"regular"),color:t.text.secondary,fontSize:i.size.caption,...a},resolution:{...face(e,"regular"),color:t.text.primary,fontSize:i.size.body,lineHeight:i.size.body*i.lineHeight.normal,...a},error:{...face(e,"regular"),color:t.danger,fontSize:i.size.caption},findVet:{alignSelf:"stretch",minHeight:rm,alignItems:"center",justifyContent:"center",borderRadius:l.pill,borderWidth:1.5,borderColor:t.controlEdge,backgroundColor:t.surface},findVetLabel:{...face(e,"bold"),color:t.brandInk,fontSize:i.size.body}})}var om=244,am=8,sm=13,um=14,cm=.3,dm=-.24,pm=22,fm=10,hm=15;function CitationCards({citations:r,onOpenUrl:l}){let i=useEverfurTheme(),o=e.useMemo(()=>bm(i),[i]),a=e.useMemo(()=>rg(r),[r]),[s,u]=e.useState(false);if(a.length===0)return null;let c=a.length;/* @__PURE__ */
286
287
  return t.jsxs(n.View,{style:o.block,children:[
287
- /* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:Ub(c,s),accessibilityState:{expanded:s},containerStyle:o.toggleSlot,style:o.togglePill,onPress:()=>u(e=>!e),children:[
288
- /* @__PURE__ */t.jsx(BookGlyph,{size:Gg,color:i.color.brandInk,strokeWidth:1.5}),
289
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:o.toggleLabel,children:Nb(c)}),
290
- /* @__PURE__ */t.jsx(ChevronGlyph,{size:Gg,color:i.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?/* @__PURE__ */t.jsx(Deck,{cards:a,styles:o,open:l}):null]})}function Deck({cards:e,styles:r,open:l}){let i=oo(),o=go(i.citationsInMs,{risePx:i.citationsRisePx});/* @__PURE__ */
291
- return t.jsx(n.Animated.View,{style:o,children:/* @__PURE__ */t.jsx(n.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:r.row,children:e.map(e=>/* @__PURE__ */t.jsx(Card,{card:e,styles:r,open:l},e.key))})})}function Card({card:e,styles:r,open:l}){let i=useEverfurTheme(),o=e.url!==null&&l!==void 0,a=$b(o?e:{...e,url:null}),s=/* @__PURE__ */t.jsxs(t.Fragment,{children:[
288
+ /* @__PURE__ */t.jsxs(PressScale,{accessibilityRole:"button",accessibilityLabel:ig(c,s),accessibilityState:{expanded:s},containerStyle:o.toggleSlot,style:o.togglePill,onPress:()=>u(e=>!e),children:[
289
+ /* @__PURE__ */t.jsx(BookGlyph,{size:sm,color:i.color.brandInk,strokeWidth:1.5}),
290
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:o.toggleLabel,children:lg(c)}),
291
+ /* @__PURE__ */t.jsx(ChevronGlyph,{size:sm,color:i.color.brandInk,strokeWidth:1.5,direction:s?"up":"down"})]}),s?/* @__PURE__ */t.jsx(Deck,{cards:a,styles:o,open:l}):null]})}function Deck({cards:e,styles:r,open:l}){let i=so(),o=yo(i.citationsInMs,{risePx:i.citationsRisePx});/* @__PURE__ */
292
+ return t.jsx(n.Animated.View,{style:o,children:/* @__PURE__ */t.jsx(n.ScrollView,{horizontal:true,nestedScrollEnabled:true,showsHorizontalScrollIndicator:false,contentContainerStyle:r.row,children:e.map(e=>/* @__PURE__ */t.jsx(Card,{card:e,styles:r,open:l},e.key))})})}function Card({card:e,styles:r,open:l}){let i=useEverfurTheme(),o=e.url!==null&&l!==void 0,a=og(o?e:{...e,url:null}),s=/* @__PURE__ */t.jsxs(t.Fragment,{children:[
292
293
  /* @__PURE__ */t.jsxs(n.View,{style:r.cardHeader,children:[
293
294
  /* @__PURE__ */t.jsx(n.View,{style:[r.tierDot,{backgroundColor:e.tierColor}]}),
294
- /* @__PURE__ */t.jsx(Text,{style:[r.cardTitle,o?r.cardTitleLink:null],numberOfLines:2,children:e.title}),o?/* @__PURE__ */t.jsx(ArrowUpRightGlyph,{size:Kg,color:i.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:r.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?/* @__PURE__ */t.jsx(Text,{style:r.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&l!==void 0){let n=e.url;/* @__PURE__ */
295
+ /* @__PURE__ */t.jsx(Text,{style:[r.cardTitle,o?r.cardTitleLink:null],numberOfLines:2,children:e.title}),o?/* @__PURE__ */t.jsx(ArrowUpRightGlyph,{size:um,color:i.color.linkInk,strokeWidth:1.5}):null]}),e.meta!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:r.cardMeta,numberOfLines:1,children:e.meta}):null,e.excerpt!==null?/* @__PURE__ */t.jsx(Text,{style:r.cardExcerpt,numberOfLines:3,children:e.excerpt}):null]});if(e.url!==null&&l!==void 0){let n=e.url;/* @__PURE__ */
295
296
  return t.jsx(PressScale,{accessibilityRole:"link",accessibilityLabel:a,style:r.card,onPress:()=>l(n),children:s})}/* @__PURE__ */
296
- return t.jsx(n.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:a,style:r.card,children:s})}function em(e){let t=e.color,r=e.space,l=e.radius,i=e.type.size,o=Oo(e.slots.card);return n.StyleSheet.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:l.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:l.pill,backgroundColor:t.brandSoft},toggleLabel:{...face(e,"monoBold"),fontSize:i.micro,lineHeight:i.micro,letterSpacing:Yg,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:$g,borderRadius:l.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2,...Ao(e.slots.card,1)},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:qg,height:qg,borderRadius:l.pill},cardTitle:{...headingFace(e,"bold"),flex:1,fontSize:i.bodyTight,lineHeight:Zg,color:t.text.primary,letterSpacing:Qg,...o},cardTitleLink:{color:t.linkInk},cardMeta:{...face(e,"monoMedium"),fontSize:i.nano,lineHeight:Jg,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase",...o},cardExcerpt:{...face(e,"regular"),fontSize:i.tiny,lineHeight:Xg,color:t.text.muted,...o}})}var tm=15,rm=44,nm=16,lm=/* @__PURE__ */Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function MessageFooter({message:r,onCopy:l,sentiment:i=null,onSentiment:o,note:a=null}){let s=useEverfurTheme(),u=e.useMemo(()=>im(s),[s]),c=oo(),d=r.role==="user",p=e.useMemo(()=>Mb(r.createdAt),[r.createdAt]),f=l!==void 0&&r.role!=="vet"&&r.text.length>0,h=r.role==="assistant"&&o!==void 0&&r.responseId!==void 0,[b,g]=e.useState(false),m=e.useRef(null);e.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);let y=()=>{l!==void 0&&(Ar(l,r.text),g(true),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{g(false),m.current=null},c.copiedMs))};return p===null&&!f&&!h?null:/* @__PURE__ */t.jsxs(n.View,{style:u.wrap,children:[
297
- /* @__PURE__ */t.jsxs(n.View,{style:[u.row,d?u.rowUser:u.rowAssistant],children:[p!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:u.timestamp,children:p}):null,f?/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:b?je.copied:d?je.copyUserMessage:je.copyAssistantMessage,onPress:y,style:u.iconHit,children:b?/* @__PURE__ */t.jsx(CheckGlyph,{size:tm,color:s.color.success,strokeWidth:2}):/* @__PURE__ */t.jsx(CopyGlyph,{size:tm,color:s.color.text.timestamp,strokeWidth:1.5})}):null,h?mp.map(({sentiment:e,label:r})=>/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{selected:i===e},onPress:()=>o?.(e),style:u.iconHit,children:/* @__PURE__ */t.jsx(ThumbGlyph,{size:tm,color:i===e?s.color.sentiment[e]:s.color.text.timestamp,active:i===e,rotate:lm[e],strokeWidth:1.5})},e)):null]}),a==="thanks"?/* @__PURE__ */t.jsx(Text,{style:u.thanks,accessibilityLiveRegion:"polite",children:je.feedbackThanks}):null,a==="failed"?/* @__PURE__ */t.jsxs(t.Fragment,{children:[
298
- /* @__PURE__ */t.jsx(Text,{style:u.failed,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:je.feedbackFailed}),
299
- /* @__PURE__ */t.jsx(AnnounceLine,{line:je.feedbackFailed})]}):null]})}function im(e){let t=e.type;return n.StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:nm,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...face(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:rm,height:rm,marginVertical:-28/2,alignItems:"center",justifyContent:"center"},thanks:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary},failed:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.danger}})}var om=16,am=10,sm=12,um=10,cm=2,dm=.06,pm=34,fm=9,hm=10.5,bm=.06,gm=15,mm=19.5,ym=14,vm=19.6;function OpeningCard({card:r,onLayout:l}){let i=useEverfurTheme(),o=e.useMemo(()=>xm(i),[i]),a=r.styles;/* @__PURE__ */
297
+ return t.jsx(n.View,{accessible:true,accessibilityRole:"text",accessibilityLabel:a,style:r.card,children:s})}function bm(e){let t=e.color,r=e.space,l=e.radius,i=e.type.size,o=Do(e.slots.card);return n.StyleSheet.create({block:{gap:r.sm},toggleSlot:{alignSelf:"flex-start",borderRadius:l.pill},togglePill:{flexDirection:"row",alignItems:"center",gap:r.xs+2,paddingHorizontal:r.md,paddingVertical:r.xs+2,borderRadius:l.pill,backgroundColor:t.brandSoft},toggleLabel:{...face(e,"monoBold"),fontSize:i.micro,lineHeight:i.micro,letterSpacing:cm,color:t.brandInk,textTransform:"uppercase"},row:{gap:r.sm,paddingRight:r.xl,paddingTop:r.xs},card:{width:om,borderRadius:l.md,borderWidth:1,borderColor:t.brandBorder,backgroundColor:t.surface,padding:r.md,gap:r.xs+2,...Oo(e.slots.card,1)},cardHeader:{flexDirection:"row",alignItems:"center",gap:r.sm},tierDot:{width:am,height:am,borderRadius:l.pill},cardTitle:{...headingFace(e,"bold"),flex:1,fontSize:i.bodyTight,lineHeight:pm,color:t.text.primary,letterSpacing:dm,...o},cardTitleLink:{color:t.linkInk},cardMeta:{...face(e,"monoMedium"),fontSize:i.nano,lineHeight:fm,letterSpacing:e.type.letterSpacing.monoWide,color:t.text.metaCool,textTransform:"uppercase",...o},cardExcerpt:{...face(e,"regular"),fontSize:i.tiny,lineHeight:hm,color:t.text.muted,...o}})}var gm=15,mm=44,ym=16,vm=/* @__PURE__ */Object.freeze({up:"0deg",neutral:"270deg",down:"180deg"});function MessageFooter({message:r,onCopy:l,sentiment:i=null,onSentiment:o,note:a=null}){let s=useEverfurTheme(),u=e.useMemo(()=>xm(s),[s]),c=so(),d=r.role==="user",p=yc(),f=e.useMemo(()=>p?null:Kb(r.createdAt),[p,r.createdAt]),h=l!==void 0&&r.role!=="vet"&&r.text.length>0,b=r.role==="assistant"&&o!==void 0&&r.responseId!==void 0,[g,m]=e.useState(false),y=e.useRef(null);e.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);let v=()=>{l!==void 0&&(Or(l,r.text),m(true),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{m(false),y.current=null},c.copiedMs))};return f===null&&!h&&!b?null:/* @__PURE__ */t.jsxs(n.View,{style:u.wrap,children:[
298
+ /* @__PURE__ */t.jsxs(n.View,{style:[u.row,d?u.rowUser:u.rowAssistant],children:[f!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:u.timestamp,children:f}):null,h?/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:g?Te.copied:d?Te.copyUserMessage:Te.copyAssistantMessage,onPress:v,style:u.iconHit,children:g?/* @__PURE__ */t.jsx(CheckGlyph,{size:gm,color:s.color.success,strokeWidth:2}):/* @__PURE__ */t.jsx(CopyGlyph,{size:gm,color:s.color.text.timestamp,strokeWidth:1.5})}):null,b?jp.map(({sentiment:e,label:r})=>/* @__PURE__ */t.jsx(n.Pressable,{accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{selected:i===e},onPress:()=>o?.(e),style:u.iconHit,children:/* @__PURE__ */t.jsx(ThumbGlyph,{size:gm,color:i===e?s.color.sentiment[e]:s.color.text.timestamp,active:i===e,rotate:vm[e],strokeWidth:1.5})},e)):null]}),a==="thanks"?/* @__PURE__ */t.jsx(Text,{style:u.thanks,accessibilityLiveRegion:"polite",children:Te.feedbackThanks}):null,a==="failed"?/* @__PURE__ */t.jsxs(t.Fragment,{children:[
299
+ /* @__PURE__ */t.jsx(Text,{style:u.failed,accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:Te.feedbackFailed}),
300
+ /* @__PURE__ */t.jsx(AnnounceLine,{line:Te.feedbackFailed})]}):null]})}function xm(e){let t=e.type;return n.StyleSheet.create({wrap:{gap:4},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:ym,paddingTop:6},rowAssistant:{alignSelf:"flex-start"},rowUser:{alignSelf:"flex-end"},timestamp:{...face(e,"monoMedium"),fontSize:t.size.nano,lineHeight:t.size.nano+2,color:e.color.text.timestamp,textAlign:"center"},iconHit:{width:mm,height:mm,marginVertical:-28/2,alignItems:"center",justifyContent:"center"},thanks:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.text.secondary},failed:{...face(e,"regular"),fontSize:t.size.caption,lineHeight:t.size.caption*t.lineHeight.normal,color:e.color.danger}})}var wm=16,km=10,Sm=12,Cm=10,jm=2,Rm=.06,Tm=34,_m=9,zm=10.5,Im=.06,Pm=15,Em=19.5,Mm=14,Am=19.6;function OpeningCard({card:r,onLayout:l}){let i=useEverfurTheme(),o=e.useMemo(()=>Fm(i),[i]),a=r.styles;/* @__PURE__ */
300
301
  return t.jsxs(n.View,{testID:"everfur-opening-card",onLayout:l,accessible:true,accessibilityLabel:[r.kicker,r.title,r.body].filter(e=>e!==void 0).join(", "),style:[o.card,a?.card],children:[r.icon!==void 0?/* @__PURE__ */t.jsx(n.View,{style:[o.icon,a?.icon],children:r.icon}):null,
301
302
  /* @__PURE__ */t.jsxs(n.View,{style:o.words,children:[
302
303
  /* @__PURE__ */t.jsx(Text,{tier:"compact",style:[o.kicker,a?.kicker],children:r.kicker}),
303
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:[o.title,a?.title],children:r.title}),r.body!==void 0?/* @__PURE__ */t.jsx(Text,{style:[o.body,a?.body],children:r.body}):null]})]})}function xm(e){let t=e.color;return n.StyleSheet.create({card:{flexDirection:"row",alignItems:"flex-start",gap:um,paddingVertical:am,paddingHorizontal:sm,alignSelf:"stretch",borderRadius:om,backgroundColor:t.surface,borderWidth:1,borderColor:Ka(t.text.primary,dm)??t.borderRingCream},icon:{flexShrink:0,width:pm,height:pm,borderRadius:fm,backgroundColor:t.highlight,alignItems:"center",justifyContent:"center",overflow:"hidden"},words:{flex:1,minWidth:0,gap:cm},kicker:{...face(e,"mono"),fontSize:hm,letterSpacing:hm*bm,textTransform:"uppercase",color:t.text.muted},title:{...face(e,"bold"),fontSize:gm,lineHeight:mm,color:t.text.primary},body:{...face(e,"regular"),fontSize:ym,lineHeight:vm,color:t.text.secondary}})}var wm="#10462E",km="Book a video visit",Sm="#000000",Cm="#83E0B4",jm=/* @__PURE__ */Object.freeze([
304
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:[o.title,a?.title],children:r.title}),r.body!==void 0?/* @__PURE__ */t.jsx(Text,{style:[o.body,a?.body],children:r.body}):null]})]})}function Fm(e){let t=e.color;return n.StyleSheet.create({card:{flexDirection:"row",alignItems:"flex-start",gap:Cm,paddingVertical:km,paddingHorizontal:Sm,alignSelf:"stretch",borderRadius:wm,backgroundColor:t.surface,borderWidth:1,borderColor:Qa(t.text.primary,Rm)??t.borderRingCream},icon:{flexShrink:0,width:Tm,height:Tm,borderRadius:_m,backgroundColor:t.highlight,alignItems:"center",justifyContent:"center",overflow:"hidden"},words:{flex:1,minWidth:0,gap:jm},kicker:{...face(e,"mono"),fontSize:zm,letterSpacing:zm*Im,textTransform:"uppercase",color:t.text.muted},title:{...face(e,"bold"),fontSize:Pm,lineHeight:Em,color:t.text.primary},body:{...face(e,"regular"),fontSize:Mm,lineHeight:Am,color:t.text.secondary}})}var Lm="#10462E",Om="Book a video visit",Vm="#000000",Dm="#83E0B4",Bm=/* @__PURE__ */Object.freeze([
304
305
  /* @__PURE__ */Object.freeze({id:"breed-health-miss",intent:"send",label:"What {breed} health issue do owners miss most?",fallbackLabel:"What {species} health issue do owners miss most?",background:"#A0C4F6",borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
305
- /* @__PURE__ */Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:Cm,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
306
- /* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:wm,brandEdge:true,borderWidth:1}),
307
- /* @__PURE__ */Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}’s vet visit",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]);function Rm(e,t){return e?null:{fill:t.fill,ink:t.ink}}var Tm=8;function _m(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&t.length<=64&&!/[;{}<>]/u.test(t)?t:null}function zm(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(t.length>=Tm)break;if(r===null||typeof r!="object"||typeof r.label!="string")continue;let e=r.label.trim();if(e.length===0)continue;let n=typeof r.prompt=="string"&&r.prompt.trim().length>0?r.prompt.trim():e,l=_m(r.tint);t.push(/* @__PURE__ */Object.freeze({id:`starter-${t.length}`,label:e,prompt:n,tint:l,ink:l===null?null:_m(r.ink)}))}return t.length>0?/* @__PURE__ */Object.freeze(t):null}var Im=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function Pm(e){return e==null?e:e.replace(Im,"").trim()}var Em=/* @__PURE__ */new Set(["","?","-","--",".","n/a","na","none","null","nil","unknown","unspecified","unsure","not sure","not specified","not applicable","no idea","dunno","idk","tbd","other","i dont know","i don't know","dont know","don't know","do not know","i do not know","not known","no clue"]);function Mm(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return Em.has(t)}function Fm(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}function Am(e,t){let r=e?.trim();if(r===void 0||r==="")return Lm(t);let n=t?.name?.trim()||je.emptyTitlePetFallback,l=n.charAt(0).toUpperCase()+n.slice(1);return r.replace(/\{(pet|petName)\}/g,(e,t,r)=>r===0?l:n)}function Lm(e){let t=e?.name?.trim()||je.emptyTitlePetFallback;return Re(je.emptyTitle,{petName:t})}function Om(e){let t=e.toLowerCase();return t===Fm("dog").toLowerCase()||t===Fm("cat").toLowerCase()}function Vm(e){let t=Pm(e);if(Mm(t))return null;let r=String(t).replace(/\s+/gu," ").trim();return Om(r)?null:r}function Dm(e,t=wm,r){let n=canonicalPetSpecies(e?.species),l=e?.name?.trim()||null,i=Vm(e?.breed),o=zd(e?.ageYears),a=o===null?null:String(o),s=r?.vetPrepLabel?.trim()||null;/* @__PURE__ */
308
- return Object.freeze(jm.flatMap(e=>{let r=e.intent==="vet_report"&&s!==null?s:e.label,o=r.includes("{breed}"),u=r.includes("{ageYears}"),c=e.fallbackLabel!==void 0&&(o&&!i||u&&!a)&&e.fallbackLabel?e.fallbackLabel:r;if(c.includes("{breed}")&&i===null||c.includes("{ageYears}")&&a===null||n===null&&(c.includes("{species}")||c.includes("{petName}")&&l===null))return[];let d=Re(c,{petName:l??(n==="cat"?"my cat":"my dog"),breed:i??"",species:n??"",ageYears:a??""}),p=!l&&c.startsWith("{petName}")?d.charAt(0).toUpperCase()+d.slice(1):d;return[/* @__PURE__ */Object.freeze({id:e.id,intent:e.intent,label:p,background:e.background,borderColor:e.brandEdge===true?t:e.borderColor,borderWidth:e.borderWidth})]}))}var Bm=44,Hm=0,Wm={top:3,bottom:3},Nm=1,Um=.28,$m=2,qm=2,Gm=1.3,Km=-.015,Ym=/* @__PURE__ */Object.freeze([
306
+ /* @__PURE__ */Object.freeze({id:"attention-at-age",intent:"send",label:"What changes should I expect at {ageYears} years old?",fallbackLabel:"What changes should I expect as my {species} ages?",background:Dm,borderColor:"rgba(0,0,0,0.5)",borderWidth:1.25}),
307
+ /* @__PURE__ */Object.freeze({id:"early-pain-signs",intent:"send",label:"What are early signs of pain?",background:"#FBC558",borderColor:Lm,brandEdge:true,borderWidth:1}),
308
+ /* @__PURE__ */Object.freeze({id:"vet-prep",intent:"vet_report",label:"Help me prep for {petName}’s vet visit",background:"#FFBDBD",borderColor:"#6D1D14",borderWidth:1.25})]);function Hm(e,t){return e?null:{fill:t.fill,ink:t.ink}}var Wm=8;function Nm(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0&&t.length<=64&&!/[;{}<>]/u.test(t)?t:null}function Um(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(t.length>=Wm)break;if(r===null||typeof r!="object"||typeof r.label!="string")continue;let e=r.label.trim();if(e.length===0)continue;let n=typeof r.prompt=="string"&&r.prompt.trim().length>0?r.prompt.trim():e,l=Nm(r.tint);t.push(/* @__PURE__ */Object.freeze({id:`starter-${t.length}`,label:e,prompt:n,tint:l,ink:l===null?null:Nm(r.ink)}))}return t.length>0?/* @__PURE__ */Object.freeze(t):null}var $m=/\s*-\s*(?:small|medium|large|giant|toy)\s*$/i;function qm(e){return e==null?e:e.replace($m,"").trim()}var Gm=/* @__PURE__ */new Set(["","?","-","--",".","n/a","na","none","null","nil","unknown","unspecified","unsure","not sure","not specified","not applicable","no idea","dunno","idk","tbd","other","i dont know","i don't know","dont know","don't know","do not know","i do not know","not known","no clue"]);function Km(e){let t=String(e??"").replace(/\s+/gu," ").trim().toLowerCase().replace(/\u2019/g,"'");return Gm.has(t)}function Ym(e){return e==="cat"?"Domestic Short Hair Mix":"Mixed Breed"}function Qm(e,t){let r=e?.trim();if(r===void 0||r==="")return Zm(t);let n=t?.name?.trim()||Te.emptyTitlePetFallback,l=n.charAt(0).toUpperCase()+n.slice(1);return r.replace(/\{(pet|petName)\}/g,(e,t,r)=>r===0?l:n)}function Zm(e){let t=e?.name?.trim()||Te.emptyTitlePetFallback;return _e(Te.emptyTitle,{petName:t})}function Jm(e){let t=e.toLowerCase();return t===Ym("dog").toLowerCase()||t===Ym("cat").toLowerCase()}function Xm(e){let t=qm(e);if(Km(t))return null;let r=String(t).replace(/\s+/gu," ").trim();return Jm(r)?null:r}function ey(e,t=Lm,r){let n=canonicalPetSpecies(e?.species),l=e?.name?.trim()||null,i=Xm(e?.breed),o=Od(e?.ageYears),a=o===null?null:String(o),s=r?.vetPrepLabel?.trim()||null;/* @__PURE__ */
309
+ return Object.freeze(Bm.flatMap(e=>{let r=e.intent==="vet_report"&&s!==null?s:e.label,o=r.includes("{breed}"),u=r.includes("{ageYears}"),c=e.fallbackLabel!==void 0&&(o&&!i||u&&!a)&&e.fallbackLabel?e.fallbackLabel:r;if(c.includes("{breed}")&&i===null||c.includes("{ageYears}")&&a===null||n===null&&(c.includes("{species}")||c.includes("{petName}")&&l===null))return[];let d=_e(c,{petName:l??(n==="cat"?"my cat":"my dog"),breed:i??"",species:n??"",ageYears:a??""}),p=!l&&c.startsWith("{petName}")?d.charAt(0).toUpperCase()+d.slice(1):d;return[/* @__PURE__ */Object.freeze({id:e.id,intent:e.intent,label:p,background:e.background,borderColor:e.brandEdge===true?t:e.borderColor,borderWidth:e.borderWidth})]}))}var ty=44,ry=0,ny={top:3,bottom:3},ly=1,iy=.28,oy=2,ay=2,sy=1.3,uy=-.015,cy=/* @__PURE__ */Object.freeze([
309
310
  /* @__PURE__ */Object.freeze({tint:"#FFE7A1",ink:"#262523"}),
310
311
  /* @__PURE__ */Object.freeze({tint:"#C8F4F8",ink:"#262523"}),
311
312
  /* @__PURE__ */Object.freeze({tint:"#DDEFC4",ink:"#262523"}),
312
- /* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:r,petRef:petRef,onSend:l,onVetPrep:i,vet:o,starterPrompts:a,emptyState:s,centered:u=false}){let c=useEverfurTheme(),d=e.useMemo(()=>Qm(c),[c]),p=e.useMemo(()=>zm(a),[a]),f=e.useMemo(()=>p!==null?p.map(e=>({prompt:{id:e.id,intent:"send",label:e.label,background:e.tint??c.color.highlight,borderColor:"transparent",borderWidth:1},send:e.prompt,paint:e.tint===null?null:{fill:e.tint,ink:e.ink??c.color.text.primary}})):Dm(r,c.color.brandInk,{vetPrepLabel:km}).map(e=>({prompt:e,send:e.label,paint:null})),[p,r,c.color.brandInk,c.color.highlight,c.color.text.primary]),h=s?.chipTints!==void 0,b=e.useMemo(()=>(s?.chipTints??(c.brightness==="light"?Ym:[])).filter(e=>typeof e.tint=="string"&&e.tint.trim()!==""),[s?.chipTints,c.brightness]),g=e.useMemo(()=>b.length===0?f:f.map((e,t)=>{if(e.paint!==null)return e;let r=b[t%b.length];return{...e,paint:{fill:r.tint,ink:r.ink??c.color.text.primary},...h?{}:{cycleDefault:true}}}),[f,b,h,c.color.text.primary]),m=e.useMemo(()=>Rm(Rd(c),{fill:c.color.highlight,ink:c.color.onHighlight}),[c]),y=e.useMemo(()=>({fill:c.color.highlight,ink:c.color.onHighlight}),[c.color.highlight,c.color.onHighlight]),v=Am(s?.title,r),x=Ap(),w=Lp(),k=x!==null&&w!==null?/* @__PURE__ */t.jsx(w.Title,{text:v,style:[d.title,x.text(".serif",".ask-empty h2"),d.centerText],measureCh:w.titleCh}):/* @__PURE__ */t.jsx(Text,{tier:"heading",style:u?[d.title,d.centerText]:d.title,accessibilityRole:"header",children:v});/* @__PURE__ */
313
- return t.jsxs(n.View,{style:x!==null?d.homeBlock:d.block,children:[k,
314
- /* @__PURE__ */t.jsx(n.View,{style:x!==null?[d.list,d.listCentered,x.view(".ask-chips",".ask-empty .ask-chips")]:u?[d.list,d.listCentered]:d.list,accessibilityLabel:je.suggestions,children:g.map(({prompt:e,send:n,paint:a,cycleDefault:s},c)=>/* @__PURE__ */t.jsx(Chip,{prompt:e,send:n,themed:a??(p!==null?y:m),index:c,petRef:petRef,onSend:l,onVetPrep:i,vet:o,pet:r,styles:d,tinted:a!==null&&s!==true,soft:a!==null,centered:u},e.id))})]})}function Chip({prompt:e,send:r,themed:l,index:i,pet:o,petRef:petRef,onSend:a,onVetPrep:s,vet:u,styles:c,tinted:d,soft:p,centered:f}){let h=oo(),b=go(h.followUpInMs,{delayMs:lo(h,i),risePx:h.promptRisePx}),g=Ap(),m=g!==null?[c.chipHome,g.view(".chip")]:f&&p?c.chipNoEdge:c.chipEdge,y={backgroundColor:l?.fill??e.background},v=c.chipSlot===null?y:d?{...c.chipSlot,...y}:{...y,...c.chipSlot},x=g!==null?[c.chipLabel,g.text(".chip")]:f?[c.chipLabel,c.centerText]:[c.chipLabel],w=g!==null?Wm:Hm,k=l===null?c.chipSlotLabel===null?x:[...x,c.chipSlotLabel]:d?[...x,...c.chipSlotLabel===null?[]:[c.chipSlotLabel],{color:l.ink}]:[...x,{color:l.ink},...c.chipSlotLabel===null?[]:[c.chipSlotLabel]];return e.intent==="vet_report"?s!==void 0?/* @__PURE__ */t.jsx(n.Animated.View,{style:b,children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:w,style:[c.chip,m,v],onPress:()=>{Er(s,o)},children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:k,children:e.label})})}):petRef===null?null:/* @__PURE__ */t.jsx(n.Animated.View,{style:b,children:/* @__PURE__ */t.jsx(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:e.label,...u?.returnTo!==void 0?{returnTo:u.returnTo}:{},...u?.usState!==void 0?{usState:u.usState}:{},...u?.prefer!==void 0?{prefer:u.prefer}:{},style:[c.chip,m,v],labelStyle:k})}):/* @__PURE__ */t.jsx(n.Animated.View,{style:b,children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:w,style:[c.chip,m,v],onPress:()=>a(r),children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:k,children:e.label})})})}function Qm(e){let t=Lo(e.slots.chip),r=Oo(t);return{chipSlot:t===void 0?null:Ao(t,Nm),chipSlotLabel:r.color===void 0?null:r,...Zm(e)}}function Zm(e){let t=e.color,r=e.space,l=e.type;return n.StyleSheet.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},homeBlock:{alignItems:"stretch",width:"100%"},chipHome:{borderWidth:0,minHeight:0},title:{...headingFace(e,"medium"),fontSize:l.size.heading,lineHeight:Math.round(l.size.heading*l.lineHeight.snug),color:t.brandInk,letterSpacing:l.size.heading*Km,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+$m},listCentered:{flexDirection:"column",flexWrap:"nowrap",alignItems:"stretch"},centerText:{textAlign:"center"},chipNoEdge:{borderWidth:Nm,borderColor:"transparent"},chip:{borderRadius:e.radius.pill,paddingHorizontal:r.lg+qm,paddingVertical:r.sm,minHeight:Bm,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:Nm,borderColor:Ka(t.brandInk,Um)??t.borderRingCream},chipLabel:{...face(e,"bold"),fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*Gm),color:Sm,textAlign:"left"}})}var Jm=1e3,Xm=150,ey=.25,ty=.5,ry=3;function TypingIndicator({petName:r=null,inline:l=false}){let{theme:i,styles:o}=yu(),a=i.motion.reducedMotion,s=_e(je.reading,r),u=e.useRef(Array.from({length:ry},()=>new n.Animated.Value(0))).current;return e.useEffect(()=>{if(a)return;let e=u.map((e,t)=>n.Animated.loop(n.Animated.sequence([n.Animated.delay(t*Xm),n.Animated.timing(e,{toValue:1,duration:Jm*.4,useNativeDriver:true}),n.Animated.timing(e,{toValue:0,duration:Jm*.6,useNativeDriver:true}),n.Animated.delay((ry-t-1)*Xm)])));for(let t of e)t.start();return()=>{for(let t of e)t.stop()}},[a,u]),/* @__PURE__ */t.jsx(n.View,{style:l?o.readingInline:o.readingBox,accessible:true,accessibilityRole:"text",accessibilityLabel:s,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:u.map((e,r)=>/* @__PURE__ */t.jsx(n.Animated.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:[l?o.readingDotInline:o.readingDot,a?{opacity:ty}:{opacity:e.interpolate({inputRange:[0,1],outputRange:[ey,1]}),transform:[{translateY:e.interpolate({inputRange:[0,1],outputRange:[0,-3]})}]}]},r))})}function ny(e,t,r){let n=e-r,l=t!=null?Math.min(n,t):n;return Math.max(0,l)}function ly(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return{assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}function iy(e,t,r){let n=Math.max(0,r),l=e===null?n:Math.min(Math.max(0,e),n);return l>t+1?l:null}var oy=16;function ay(t,r,n=null){let l=e.useRef(null),i=e.useRef(true),o=e.useRef(r),a=e.useRef(0),s=e.useRef(0),u=e.useRef(0),c=e.useRef(/* @__PURE__ */new Map),d=e.useRef(null),p=e.useRef(false),f=t[0]?.id??null,h=e.useRef(f),b=e.useRef(null);e.useEffect(()=>{let e=h.current;if(h.current=f,e===null||e===f||(b.current=null,i.current||!t.some(t=>t.id===e)))return;let r=c.current.get(e);r!==void 0&&(b.current={id:e,top:r,offset:a.current})},[f,t]);let g=ly(t),m=g===null?null:t[g.assistantIndex]?.id??null,y=g===null||g.userIndex===null?null:t[g.userIndex]?.id??null,v=e.useCallback(()=>{let e=l.current;if(e===null||!i.current||s.current===0)return;let t=null;if(m!==null){let e=c.current.get(m);if(e===void 0)return;let r=y===null?null:c.current.get(y)??null;t=ny(e,r,96)}let r=iy(t,a.current,u.current-s.current);if(r!==null&&(a.current=r,e.scrollTo({y:r,animated:false})),!p.current||d.current===null)return;let n=iy(d.current+oy-s.current,a.current,u.current-s.current);n!==null&&(a.current=n,e.scrollTo({y:n,animated:false}))},[m,y]);e.useEffect(()=>{p.current=n!==null,n===null&&(d.current=null),v()},[n,v]),e.useEffect(()=>{r&&!o.current&&(i.current=true,p.current=false),o.current=r,v()},[t,r,v]);let x=e.useCallback(e=>{s.current=e.nativeEvent.layout.height,v()},[v]),w=e.useCallback((e,t)=>{u.current=t,s.current>0&&(a.current=Math.min(a.current,Math.max(0,t-s.current))),v()},[v]),k=e.useCallback(e=>{a.current=e.nativeEvent.contentOffset.y},[]),S=e.useCallback(()=>{i.current=false,p.current=false},[]),C=e.useCallback(e=>{let{contentOffset:t,contentSize:r,layoutMeasurement:n}=e.nativeEvent;a.current=t.y,i.current=r.height-t.y-n.height<=24},[]),j=e.useCallback(e=>t=>{let r=t.nativeEvent.layout.y;c.current.set(e,r);let n=b.current;if(n!==null&&n.id===e&&r!==n.top){b.current=null;let e=Math.max(0,n.offset+r-n.top);a.current=e,l.current?.scrollTo({y:e,animated:false})}(e===m||e===y)&&v()},[m,y,v]),R=e.useCallback(e=>{let{y:t,height:r}=e.nativeEvent.layout;d.current=t+r,v()},[v]);return{ref:l,onLayout:x,onContentSizeChange:w,onScroll:k,onScrollBeginDrag:S,onScrollEnd:C,rowLayout:j,asideLayout:R}}function sy(e,r,n){switch(e){case"loading":return n.renderPending?/* @__PURE__ */t.jsx(HostRender,{render:n.renderPending,fallback:/* @__PURE__ */t.jsx(LoadingState,{})}):/* @__PURE__ */t.jsx(LoadingState,{});case"empty":/* @__PURE__ */
313
+ /* @__PURE__ */Object.freeze({tint:"#FFD8D6",ink:"#262523"})]);function QuickPrompts({pet:r,petRef:petRef,onSend:l,onVetPrep:i,vet:o,starterPrompts:a,emptyState:s,centered:u=false}){let c=useEverfurTheme(),d=e.useMemo(()=>dy(c),[c]),p=e.useMemo(()=>Um(a),[a]),f=e.useMemo(()=>p!==null?p.map(e=>({prompt:{id:e.id,intent:"send",label:e.label,background:e.tint??c.color.highlight,borderColor:"transparent",borderWidth:1},send:e.prompt,paint:e.tint===null?null:{fill:e.tint,ink:e.ink??c.color.text.primary}})):ey(r,c.color.brandInk,{vetPrepLabel:Om}).map(e=>({prompt:e,send:e.label,paint:null})),[p,r,c.color.brandInk,c.color.highlight,c.color.text.primary]),h=yc(),b=s?.chipTints!==void 0,g=e.useMemo(()=>h===null?null:h.paint.pastels.map(e=>({tint:e,ink:h.paint.ink})),[h]),m=e.useMemo(()=>(s?.chipTints??g??(c.brightness==="light"?cy:[])).filter(e=>typeof e.tint=="string"&&e.tint.trim()!==""),[s?.chipTints,g,c.brightness]),y=e.useMemo(()=>m.length===0?f:f.map((e,t)=>{if(e.paint!==null)return e;let r=m[t%m.length];return{...e,paint:{fill:r.tint,ink:r.ink??c.color.text.primary},...b||g!==null?{}:{cycleDefault:true}}}),[f,m,b,g,c.color.text.primary]),v=e.useMemo(()=>Hm(Ad(c),{fill:c.color.highlight,ink:c.color.onHighlight}),[c]),x=e.useMemo(()=>({fill:c.color.highlight,ink:c.color.onHighlight}),[c.color.highlight,c.color.onHighlight]),w=Qm(s?.title,r),k=Np(),S=h!==null?null:k,C=Up(),j=h!==null?/* @__PURE__ */t.jsx(Text,{tier:"heading",style:[d.title,d.tabsTitle,{color:h.paint.ink}],accessibilityRole:"header",children:w}):S!==null&&C!==null?/* @__PURE__ */t.jsx(C.Title,{text:w,style:[d.title,S.text(".serif",".ask-empty h2"),d.centerText],measureCh:C.titleCh}):/* @__PURE__ */t.jsx(Text,{tier:"heading",style:u?[d.title,d.centerText]:d.title,accessibilityRole:"header",children:w});/* @__PURE__ */
314
+ return t.jsxs(n.View,{style:S!==null?d.homeBlock:d.block,children:[j,
315
+ /* @__PURE__ */t.jsx(n.View,{style:h!==null?[d.list,d.tabsList]:S!==null?[d.list,d.listCentered,S.view(".ask-chips",".ask-empty .ask-chips")]:u?[d.list,d.listCentered]:d.list,accessibilityLabel:Te.suggestions,children:y.map(({prompt:e,send:n,paint:a,cycleDefault:s},c)=>/* @__PURE__ */t.jsx(Chip,{prompt:e,send:n,themed:a??(p!==null?x:v),index:c,petRef:petRef,onSend:l,onVetPrep:i,vet:o,pet:r,styles:d,tinted:a!==null&&s!==true,soft:a!==null,centered:u,tabs:h!==null},e.id))})]})}function Chip({prompt:e,send:r,themed:l,index:i,pet:o,petRef:petRef,onSend:a,onVetPrep:s,vet:u,styles:c,tinted:d,soft:p,centered:f,tabs:h}){let b=so(),g=yo(b.followUpInMs,{delayMs:oo(b,i),risePx:b.promptRisePx}),m=Np(),y=h?null:m,v=h?[c.chipNoEdge,c.tabsChip]:y!==null?[c.chipHome,y.view(".chip")]:f&&p?c.chipNoEdge:c.chipEdge,x={backgroundColor:l?.fill??e.background},w=c.chipSlot===null?x:d?{...c.chipSlot,...x}:{...x,...c.chipSlot},k=h?[c.chipLabel,c.tabsChipLabel]:y!==null?[c.chipLabel,y.text(".chip")]:f?[c.chipLabel,c.centerText]:[c.chipLabel],S=y!==null?ny:ry,C=l===null?c.chipSlotLabel===null?k:[...k,c.chipSlotLabel]:d?[...k,...c.chipSlotLabel===null?[]:[c.chipSlotLabel],{color:l.ink}]:[...k,{color:l.ink},...c.chipSlotLabel===null?[]:[c.chipSlotLabel]];return e.intent==="vet_report"?s!==void 0?/* @__PURE__ */t.jsx(n.Animated.View,{style:g,children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:S,style:[c.chip,v,w],onPress:()=>{Ar(s,o)},children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:C,children:e.label})})}):petRef===null?null:/* @__PURE__ */t.jsx(n.Animated.View,{style:g,children:/* @__PURE__ */t.jsx(VetVisitButtonCore,{entry:"chat",petRef:petRef,label:e.label,...u?.returnTo!==void 0?{returnTo:u.returnTo}:{},...u?.usState!==void 0?{usState:u.usState}:{},...u?.prefer!==void 0?{prefer:u.prefer}:{},style:[c.chip,v,w],labelStyle:C})}):/* @__PURE__ */t.jsx(n.Animated.View,{style:g,children:/* @__PURE__ */t.jsx(PressScale,{accessibilityRole:"button",accessibilityLabel:e.label,hitSlop:S,style:[c.chip,v,w],onPress:()=>a(r),children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:C,children:e.label})})})}function dy(e){let t=Vo(e.slots.chip),r=Do(t);return{chipSlot:t===void 0?null:Oo(t,ly),chipSlotLabel:r.color===void 0?null:r,...py(e)}}function py(e){let t=e.color,r=e.space,l=e.type;return n.StyleSheet.create({block:{gap:r.lg,alignItems:"stretch",width:"100%"},homeBlock:{alignItems:"stretch",width:"100%"},chipHome:{borderWidth:0,minHeight:0},title:{...headingFace(e,"medium"),fontSize:l.size.heading,lineHeight:Math.round(l.size.heading*l.lineHeight.snug),color:t.brandInk,letterSpacing:l.size.heading*uy,textAlign:"left"},list:{width:"100%",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-start",gap:r.sm+oy},listCentered:{flexDirection:"column",flexWrap:"nowrap",alignItems:"stretch"},centerText:{textAlign:"center"},chipNoEdge:{borderWidth:ly,borderColor:"transparent"},tabsTitle:{...headingFace(e,"bold"),fontWeight:"800",fontSize:26,lineHeight:32,letterSpacing:0,textAlign:"center",maxWidth:260,alignSelf:"center"},tabsList:{justifyContent:"center",gap:10},tabsChip:{paddingHorizontal:16,paddingVertical:9,minHeight:0},tabsChipLabel:{fontSize:14,lineHeight:20,textAlign:"center"},chip:{borderRadius:e.radius.pill,paddingHorizontal:r.lg+ay,paddingVertical:r.sm,minHeight:ty,minWidth:0,alignItems:"center",justifyContent:"center",maxWidth:"100%"},chipEdge:{borderWidth:ly,borderColor:Qa(t.brandInk,iy)??t.borderRingCream},chipLabel:{...face(e,"bold"),fontSize:l.size.bodyTight,lineHeight:Math.round(l.size.bodyTight*sy),color:Vm,textAlign:"left"}})}var fy=1e3,hy=150,by=.25,gy=.5,my=3;function TypingIndicator({petName:r=null,inline:l=false}){let{theme:i,styles:o}=xu(),a=i.motion.reducedMotion,s=Ie(Te.reading,r),u=e.useRef(Array.from({length:my},()=>new n.Animated.Value(0))).current;return e.useEffect(()=>{if(a)return;let e=u.map((e,t)=>n.Animated.loop(n.Animated.sequence([n.Animated.delay(t*hy),n.Animated.timing(e,{toValue:1,duration:fy*.4,useNativeDriver:true}),n.Animated.timing(e,{toValue:0,duration:fy*.6,useNativeDriver:true}),n.Animated.delay((my-t-1)*hy)])));for(let t of e)t.start();return()=>{for(let t of e)t.stop()}},[a,u]),/* @__PURE__ */t.jsx(n.View,{style:l?o.readingInline:o.readingBox,accessible:true,accessibilityRole:"text",accessibilityLabel:s,accessibilityLiveRegion:"polite",accessibilityState:{busy:true},children:u.map((e,r)=>/* @__PURE__ */t.jsx(n.Animated.View,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:[l?o.readingDotInline:o.readingDot,a?{opacity:gy}:{opacity:e.interpolate({inputRange:[0,1],outputRange:[by,1]}),transform:[{translateY:e.interpolate({inputRange:[0,1],outputRange:[0,-3]})}]}]},r))})}function yy(e,t,r){let n=e-r,l=t!=null?Math.min(n,t):n;return Math.max(0,l)}function vy(e){let t=e.length-1,r=e[t];if(r===void 0||r.role!=="assistant")return null;let n=e[t-1];return{assistantIndex:t,userIndex:n!==void 0&&n.role==="user"?t-1:null}}function xy(e,t,r){let n=Math.max(0,r),l=e===null?n:Math.min(Math.max(0,e),n);return l>t+1?l:null}var wy=16;function ky(t,r,n=null){let l=e.useRef(null),i=e.useRef(true),o=e.useRef(r),a=e.useRef(0),s=e.useRef(0),u=e.useRef(0),c=e.useRef(/* @__PURE__ */new Map),d=e.useRef(null),p=e.useRef(false),f=t[0]?.id??null,h=e.useRef(f),b=e.useRef(null);e.useEffect(()=>{let e=h.current;if(h.current=f,e===null||e===f||(b.current=null,i.current||!t.some(t=>t.id===e)))return;let r=c.current.get(e);r!==void 0&&(b.current={id:e,top:r,offset:a.current})},[f,t]);let g=vy(t),m=g===null?null:t[g.assistantIndex]?.id??null,y=g===null||g.userIndex===null?null:t[g.userIndex]?.id??null,v=e.useCallback(()=>{let e=l.current;if(e===null||!i.current||s.current===0)return;let t=null;if(m!==null){let e=c.current.get(m);if(e===void 0)return;let r=y===null?null:c.current.get(y)??null;t=yy(e,r,96)}let r=xy(t,a.current,u.current-s.current);if(r!==null&&(a.current=r,e.scrollTo({y:r,animated:false})),!p.current||d.current===null)return;let n=xy(d.current+wy-s.current,a.current,u.current-s.current);n!==null&&(a.current=n,e.scrollTo({y:n,animated:false}))},[m,y]);e.useEffect(()=>{p.current=n!==null,n===null&&(d.current=null),v()},[n,v]),e.useEffect(()=>{r&&!o.current&&(i.current=true,p.current=false),o.current=r,v()},[t,r,v]);let x=e.useCallback(e=>{s.current=e.nativeEvent.layout.height,v()},[v]),w=e.useCallback((e,t)=>{u.current=t,s.current>0&&(a.current=Math.min(a.current,Math.max(0,t-s.current))),v()},[v]),k=e.useCallback(e=>{a.current=e.nativeEvent.contentOffset.y},[]),S=e.useCallback(()=>{i.current=false,p.current=false},[]),C=e.useCallback(e=>{let{contentOffset:t,contentSize:r,layoutMeasurement:n}=e.nativeEvent;a.current=t.y,i.current=r.height-t.y-n.height<=24},[]),j=e.useCallback(e=>t=>{let r=t.nativeEvent.layout.y;c.current.set(e,r);let n=b.current;if(n!==null&&n.id===e&&r!==n.top){b.current=null;let e=Math.max(0,n.offset+r-n.top);a.current=e,l.current?.scrollTo({y:e,animated:false})}(e===m||e===y)&&v()},[m,y,v]),R=e.useCallback(e=>{let{y:t,height:r}=e.nativeEvent.layout;d.current=t+r,v()},[v]);return{ref:l,onLayout:x,onContentSizeChange:w,onScroll:k,onScrollBeginDrag:S,onScrollEnd:C,rowLayout:j,asideLayout:R}}function Sy(e,r,n){switch(e){case"loading":return n.renderPending?/* @__PURE__ */t.jsx(HostRender,{render:n.renderPending,fallback:/* @__PURE__ */t.jsx(LoadingState,{})}):/* @__PURE__ */t.jsx(LoadingState,{});case"empty":/* @__PURE__ */
315
316
  return t.jsx(EmptyState,{pet:n.shownPet,petRef:r.petRef,onSelectPrompt:n.onSelectPrompt,onVetPrep:n.onVetPrep,vet:n.vet,top:n.threadTop,pendingCheckin:n.pendingCheckin??null,topCard:n.topCard,starterPrompts:n.starterPrompts,emptyState:n.emptyState,centered:n.emptyCentered===true,renderEmptyHeader:n.renderEmptyHeader});case"error":/* @__PURE__ */
316
317
  return t.jsx(ErrorState,{error:r.error,onRetry:r.retryLast,onAddPet:n.onAddPet});case"populated":/* @__PURE__ */
317
- return t.jsx(PopulatedState,{messages:r.messages,prompts:pn(r,n.followUpPolicy),actions:n.answerCards?tg(r,n.answerCards):cy,answerCards:n.answerCards??null,threadTop:n.threadTop,pendingCheckin:n.pendingCheckin??null,threadAside:n.threadAside,threadAsideKey:n.threadAsideKey??null,onSelectPrompt:n.onSelectPrompt,isStreaming:r.isStreaming,onAnswerCheckin:r.petRef?r.answerCheckin:null,onCopy:n.onCopy,sentimentByMessage:r.sentimentByMessage,onSentiment:n.onSentiment,feedbackNote:n.feedbackNote,imagesByMessage:n.imagesByMessage,onPreview:n.onPreview,notice:n.notice,reconnecting:r.reconnecting===true,onRetry:r.retryLast,onStartNew:r.newConversation,petRef:r.petRef,onFindVet:n.onCheckinFindVet,vet:n.vet,onOpenUrl:n.onOpenUrl,petName:n.shownPet?.name??null,followUpLabel:n.followUpPolicy?.label,openingCard:n.openingCard,earlier:r.historyCursor?{loading:r.isLoadingHistory,load:r.loadOlderMessages}:null});default:return assertNever(e)}}function LoadingState(){let{theme:r,styles:l}=yu(),[i,o]=e.useState(false);return e.useEffect(()=>{let e=setTimeout(()=>o(true),Cs);return()=>clearTimeout(e)},[]),/* @__PURE__ */t.jsx(n.View,{style:l.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:je.loading,children:i?/* @__PURE__ */t.jsx(n.ActivityIndicator,{color:r.color.brandInk}):null})}function EmptyState({pet:e,petRef:petRef,onSelectPrompt:r,onVetPrep:l,vet:i,top:o,topCard:a,pendingCheckin:s,starterPrompts:u,emptyState:c,centered:d,renderEmptyHeader:p}){let{styles:f}=yu(),h=Ap(),b=p===void 0?null:/* @__PURE__ */t.jsx(n.View,{testID:"everfur-empty-header",children:/* @__PURE__ */t.jsx(HostRender,{render:()=>p({ask:r}),fallback:null})});if(h!==null){let{minHeight:d,...p}=h.view(".ask-empty");/* @__PURE__ */
318
- return t.jsxs(n.ScrollView,{contentContainerStyle:[p,f.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:py,nestedScrollEnabled:true,accessibilityLabel:je.empty,children:[o!=null?/* @__PURE__ */t.jsx(n.View,{style:h.view(".ask-top"),children:o}):null,s,a??null,b,
318
+ return t.jsx(PopulatedState,{messages:r.messages,prompts:hn(r,n.followUpPolicy),actions:n.answerCards?gg(r,n.answerCards):jy,answerCards:n.answerCards??null,threadTop:n.threadTop,pendingCheckin:n.pendingCheckin??null,threadAside:n.threadAside,threadAsideKey:n.threadAsideKey??null,onSelectPrompt:n.onSelectPrompt,isStreaming:r.isStreaming,onAnswerCheckin:r.petRef?r.answerCheckin:null,onCopy:n.onCopy,sentimentByMessage:r.sentimentByMessage,onSentiment:n.onSentiment,feedbackNote:n.feedbackNote,imagesByMessage:n.imagesByMessage,onPreview:n.onPreview,notice:n.notice,reconnecting:r.reconnecting===true,onRetry:r.retryLast,onStartNew:r.newConversation,petRef:r.petRef,onFindVet:n.onCheckinFindVet,vet:n.vet,onOpenUrl:n.onOpenUrl,petName:n.shownPet?.name??null,followUpLabel:n.followUpPolicy?.label,openingCard:n.openingCard,earlier:r.historyCursor?{loading:r.isLoadingHistory,load:r.loadOlderMessages}:null});default:return assertNever(e)}}function LoadingState(){let{theme:r,styles:l}=xu(),[i,o]=e.useState(false);return e.useEffect(()=>{let e=setTimeout(()=>o(true),Rs);return()=>clearTimeout(e)},[]),/* @__PURE__ */t.jsx(n.View,{style:l.centered,accessible:true,accessibilityState:{busy:true},accessibilityLabel:Te.loading,children:i?/* @__PURE__ */t.jsx(n.ActivityIndicator,{color:r.color.brandInk}):null})}function EmptyState({pet:e,petRef:petRef,onSelectPrompt:r,onVetPrep:l,vet:i,top:o,topCard:a,pendingCheckin:s,starterPrompts:u,emptyState:c,centered:d,renderEmptyHeader:p}){let{styles:f}=xu(),h=Np(),b=p===void 0?null:/* @__PURE__ */t.jsx(n.View,{testID:"everfur-empty-header",children:/* @__PURE__ */t.jsx(HostRender,{render:()=>p({ask:r}),fallback:null})});if(h!==null){let{minHeight:d,...p}=h.view(".ask-empty");/* @__PURE__ */
319
+ return t.jsxs(n.ScrollView,{contentContainerStyle:[p,f.homeEmpty],keyboardShouldPersistTaps:"handled",keyboardDismissMode:Ty,nestedScrollEnabled:true,accessibilityLabel:Te.empty,children:[o!=null?/* @__PURE__ */t.jsx(n.View,{style:h.view(".ask-top"),children:o}):null,s,a??null,b,
319
320
  /* @__PURE__ */t.jsx(n.View,{style:h.view(".ask-start"),children:/* @__PURE__ */t.jsx(QuickPrompts,{pet:e,petRef:petRef,onSend:r,onVetPrep:l,vet:i,starterPrompts:u,emptyState:c,centered:true})})]})}
320
321
  /* @__PURE__ */
321
- return t.jsxs(n.ScrollView,{contentContainerStyle:f.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:py,nestedScrollEnabled:true,accessibilityLabel:je.empty,children:[o??null,s,a??null,b,
322
- /* @__PURE__ */t.jsx(QuickPrompts,{pet:e,petRef:petRef,onSend:r,onVetPrep:l,vet:i,starterPrompts:u,emptyState:c,centered:d})]})}function FollowUps({prompts:e,onSelectPrompt:r,label:l}){let{styles:i}=yu();return e.length===0?null:/* @__PURE__ */t.jsxs(n.View,{style:i.followUps,children:[
323
- /* @__PURE__ */t.jsx(Text,{tier:"compact",style:i.followUpsHeading,accessibilityRole:"header",children:l??je.followUpsHeadingNative}),e.map((e,n)=>/* @__PURE__ */t.jsx(FollowUpRow,{prompt:e,index:n,onSelectPrompt:r},e))]})}function FollowUpRow({prompt:e,index:r,onSelectPrompt:l}){let{theme:i,styles:o}=yu(),a=oo(),s=go(a.followUpInMs,{delayMs:lo(a,r)});/* @__PURE__ */
322
+ return t.jsxs(n.ScrollView,{contentContainerStyle:f.emptyContent,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Ty,nestedScrollEnabled:true,accessibilityLabel:Te.empty,children:[o??null,s,a??null,b,
323
+ /* @__PURE__ */t.jsx(QuickPrompts,{pet:e,petRef:petRef,onSend:r,onVetPrep:l,vet:i,starterPrompts:u,emptyState:c,centered:d})]})}function FollowUps({prompts:e,onSelectPrompt:r,label:l}){let{styles:i}=xu();return e.length===0?null:/* @__PURE__ */t.jsxs(n.View,{style:i.followUps,children:[
324
+ /* @__PURE__ */t.jsx(Text,{tier:"compact",style:i.followUpsHeading,accessibilityRole:"header",children:l??Te.followUpsHeadingNative}),e.map((e,n)=>/* @__PURE__ */t.jsx(FollowUpRow,{prompt:e,index:n,onSelectPrompt:r},e))]})}function FollowUpRow({prompt:e,index:r,onSelectPrompt:l}){let{theme:i,styles:o}=xu(),a=so(),s=yo(a.followUpInMs,{delayMs:oo(a,r)});/* @__PURE__ */
324
325
  return t.jsx(n.Animated.View,{style:s,children:/* @__PURE__ */t.jsxs(PressScale,{onPress:()=>l(e),accessibilityRole:"button",accessibilityLabel:e,containerStyle:[o.followUpSlot,r>0?o.followUpSlotRuled:null],style:o.followUpRow,children:[
325
326
  /* @__PURE__ */t.jsx(Text,{tier:"control",style:o.followUpText,children:e}),
326
- /* @__PURE__ */t.jsx(PlusGlyph,{size:fy,color:i.slots.chip?.textColor??i.color.text.muted,strokeWidth:1.75})]})})}function ErrorState({error:e,onRetry:r,onAddPet:l}){let{styles:i}=yu(),o=Tl(e)?Fr(l):void 0,a=rn(e);/* @__PURE__ */
327
+ /* @__PURE__ */t.jsx(PlusGlyph,{size:_y,color:i.slots.chip?.textColor??i.color.text.muted,strokeWidth:1.75})]})})}function ErrorState({error:e,onRetry:r,onAddPet:l}){let{styles:i}=xu(),o=zl(e)?Lr(l):void 0,a=ln(e);/* @__PURE__ */
327
328
  return t.jsxs(n.View,{style:i.centered,accessible:true,accessibilityRole:"alert",children:[a!==null?/* @__PURE__ */t.jsx(Text,{style:i.errorText,testID:"everfur-chat-cap-reached",children:a.reached}):null,
328
- /* @__PURE__ */t.jsx(Text,{style:i.errorText,children:e.displayMessage}),a!==null&&a.guidance!==null?/* @__PURE__ */t.jsx(Text,{style:i.errorText,testID:"everfur-chat-cap-guidance",children:a.guidance}):null,o!==void 0?/* @__PURE__ */t.jsx(n.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:je.addPet,style:i.retryButton,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:i.retryLabel,children:je.addPet})}):null,e.retryable?/* @__PURE__ */t.jsx(n.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:je.retry,style:i.retryButton,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:i.retryLabel,children:je.retry})}):null]})}function PopulatedState({messages:r,prompts:l,onSelectPrompt:i,isStreaming:o,onAnswerCheckin:a,onCopy:s,sentimentByMessage:u,onSentiment:c,feedbackNote:d,imagesByMessage:p,onPreview:f,notice:h,reconnecting:b,onRetry:g,onStartNew:m,petRef:petRef,onFindVet:y,vet:v,onOpenUrl:x,petName:w,actions:k,answerCards:S,threadTop:C,pendingCheckin:j,threadAside:R,threadAsideKey:T,followUpLabel:_,openingCard:z,earlier:I}){let{styles:P}=yu(),E=oo();Co(r.length,E);let M=e.useMemo(()=>_b(Tb(r)),[r]),F=on(r,o),A=r[r.length-1],L=R??null,O=ay(r,o,L===null?null:T??"shown"),V=vo(r),D=r[0],B=z!==void 0&&D!==void 0&&D.role==="user"&&D.text.trim()===z.prompt?D.id:null;/* @__PURE__ */
329
- return t.jsxs(n.ScrollView,{ref:O.ref,style:P.list,contentContainerStyle:S!==null?P.listContentCards:P.listContent,accessibilityLabel:je.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:py,nestedScrollEnabled:true,onLayout:O.onLayout,onContentSizeChange:O.onContentSizeChange,onScroll:O.onScroll,scrollEventThrottle:dy,onScrollBeginDrag:O.onScrollBeginDrag,onScrollEndDrag:O.onScrollEnd,onMomentumScrollEnd:O.onScrollEnd,children:[C??null,j,I!==null?/* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>{I.load()},disabled:I.loading,accessibilityRole:"button",accessibilityLabel:I.loading?gi.loadingEarlier:gi.earlier,accessibilityState:{disabled:I.loading,busy:I.loading},hitSlop:Us,style:P.earlierButton,children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:P.earlierLabel,children:I.loading?gi.loadingEarlier:gi.earlier})}):null,r.map(e=>e.id===B&&z!==void 0?/* @__PURE__ */t.jsx(OpeningCard,{card:z.card,onLayout:O.rowLayout(e.id)},e.id):e.checkin&&M.has(e.id)?/* @__PURE__ */t.jsx(CheckinCard,{message:e,checkin:e.checkin,onAnswer:a,petRef:petRef,onFindVet:y,vet:v,onLayout:O.rowLayout(e.id)},e.id):/* @__PURE__ */t.jsx(MessageRow,{onLayout:O.rowLayout(e.id),message:e,revealing:o&&e===A&&e.role==="assistant",onCopy:s,sentiment:e.responseId===void 0?null:u[String(e.responseId)]??null,onSentiment:c,note:e.responseId!==void 0&&d?.responseId===String(e.responseId)?d.kind:null,images:p[e.id]??uy,onPreview:f,onOpenUrl:x,entering:V(e.id),answerCards:S,messages:r},e.id)),b?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:P.reconnectingCaption,accessibilityRole:"text",children:je.reconnecting}):null,F?/* @__PURE__ */t.jsx(TypingIndicator,{petName:w,inline:S!==null}):null,h!==null?/* @__PURE__ */t.jsx(TurnNoticeCard,{notice:h,onRetry:g,onStartNew:m}):null,S!==null?/* @__PURE__ */t.jsx(CardsFollowUps,{prompts:l,onSelectPrompt:i,label:_,actions:k,options:S}):/* @__PURE__ */t.jsx(FollowUps,{prompts:l,onSelectPrompt:i,label:_}),L!==null?/* @__PURE__ */t.jsx(n.View,{onLayout:O.asideLayout,children:L}):null]})}function TurnNoticeCard({notice:e,onRetry:r,onStartNew:l}){let{styles:i}=yu(),o=e.tone==="error";/* @__PURE__ */
329
+ /* @__PURE__ */t.jsx(Text,{style:i.errorText,children:e.displayMessage}),a!==null&&a.guidance!==null?/* @__PURE__ */t.jsx(Text,{style:i.errorText,testID:"everfur-chat-cap-guidance",children:a.guidance}):null,o!==void 0?/* @__PURE__ */t.jsx(n.Pressable,{onPress:o,accessibilityRole:"button",accessibilityLabel:Te.addPet,style:i.retryButton,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:i.retryLabel,children:Te.addPet})}):null,e.retryable?/* @__PURE__ */t.jsx(n.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:Te.retry,style:i.retryButton,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:i.retryLabel,children:Te.retry})}):null]})}function PopulatedState({messages:r,prompts:l,onSelectPrompt:i,isStreaming:o,onAnswerCheckin:a,onCopy:s,sentimentByMessage:u,onSentiment:c,feedbackNote:d,imagesByMessage:p,onPreview:f,notice:h,reconnecting:b,onRetry:g,onStartNew:m,petRef:petRef,onFindVet:y,vet:v,onOpenUrl:x,petName:w,actions:k,answerCards:S,threadTop:C,pendingCheckin:j,threadAside:R,threadAsideKey:T,followUpLabel:_,openingCard:z,earlier:I}){let P=yc(),{styles:E}=xu(),M=so();Ro(r.length,M);let A=e.useMemo(()=>Nb(Wb(r)),[r]),F=sn(r,o),L=r[r.length-1],O=R??null,V=ky(r,o,O===null?null:T??"shown"),D=wo(r),B=r[0],H=z!==void 0&&B!==void 0&&B.role==="user"&&B.text.trim()===z.prompt?B.id:null;/* @__PURE__ */
330
+ return t.jsxs(n.ScrollView,{ref:V.ref,style:E.list,contentContainerStyle:S!==null?E.listContentCards:E.listContent,accessibilityLabel:Te.transcript,keyboardShouldPersistTaps:"handled",keyboardDismissMode:Ty,nestedScrollEnabled:true,onLayout:V.onLayout,onContentSizeChange:V.onContentSizeChange,onScroll:V.onScroll,scrollEventThrottle:Ry,onScrollBeginDrag:V.onScrollBeginDrag,onScrollEndDrag:V.onScrollEnd,onMomentumScrollEnd:V.onScrollEnd,children:[C??null,j,I!==null?/* @__PURE__ */t.jsx(n.Pressable,{onPress:()=>{I.load()},disabled:I.loading,accessibilityRole:"button",accessibilityLabel:I.loading?yi.loadingEarlier:yi.earlier,accessibilityState:{disabled:I.loading,busy:I.loading},hitSlop:qs,style:E.earlierButton,children:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:E.earlierLabel,children:I.loading?yi.loadingEarlier:yi.earlier})}):null,r.map(e=>e.id===H&&z!==void 0?/* @__PURE__ */t.jsx(OpeningCard,{card:z.card,onLayout:V.rowLayout(e.id)},e.id):e.checkin&&A.has(e.id)?/* @__PURE__ */t.jsx(CheckinCard,{message:e,checkin:e.checkin,onAnswer:a,petRef:petRef,onFindVet:y,vet:v,onLayout:V.rowLayout(e.id)},e.id):/* @__PURE__ */t.jsx(MessageRow,{onLayout:V.rowLayout(e.id),message:e,revealing:o&&e===L&&e.role==="assistant",onCopy:s,sentiment:e.responseId===void 0?null:u[String(e.responseId)]??null,onSentiment:c,note:e.responseId!==void 0&&d?.responseId===String(e.responseId)?d.kind:null,images:p[e.id]??Cy,onPreview:f,onOpenUrl:x,entering:D(e.id),answerCards:S,messages:r},e.id)),b?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:E.reconnectingCaption,accessibilityRole:"text",children:Te.reconnecting}):null,F?/* @__PURE__ */t.jsx(TypingIndicator,{petName:w,inline:S!==null}):null,h!==null?/* @__PURE__ */t.jsx(TurnNoticeCard,{notice:h,onRetry:g,onStartNew:m}):null,S!==null||P!==null?/* @__PURE__ */t.jsx(CardsFollowUps,{prompts:l,onSelectPrompt:i,label:_,actions:k,options:S??void 0}):/* @__PURE__ */t.jsx(FollowUps,{prompts:l,onSelectPrompt:i,label:_}),O!==null?/* @__PURE__ */t.jsx(n.View,{onLayout:V.asideLayout,children:O}):null]})}function TurnNoticeCard({notice:e,onRetry:r,onStartNew:l}){let{styles:i}=xu(),o=e.tone==="error";/* @__PURE__ */
330
331
  return t.jsxs(n.View,{style:[i.turnNotice,o?i.turnNoticeError:null],accessible:true,accessibilityRole:"alert",children:[
331
332
  /* @__PURE__ */t.jsx(Text,{tier:"control",style:[i.turnNoticeTitle,o?i.turnNoticeTitleError:null],children:e.title}),
332
333
  /* @__PURE__ */t.jsx(Text,{tier:"compact",style:i.turnNoticeBody,children:e.body}),e.guidance!==void 0?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:i.turnNoticeBody,testID:"everfur-chat-cap-guidance",children:e.guidance}):null,
333
- /* @__PURE__ */t.jsx(n.Pressable,{onPress:e.action==="startNew"?l:r,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:Us,style:i.turnNoticeAction,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:i.turnNoticeActionLabel,children:e.actionLabel})})]})}var uy=/* @__PURE__ */Object.freeze([]),cy=/* @__PURE__ */Object.freeze([]),dy=16,py=n.Platform.OS==="ios"?"interactive":"on-drag",fy=18;function MessageRow({message:r,revealing:l,onCopy:i,sentiment:o,onSentiment:a,note:s,images:u,onPreview:c,onOpenUrl:d,onLayout:p,entering:f,answerCards:h,messages:b}){let{theme:g,styles:m}=yu(),y=oo(),v=yo(f,y),x=wo(r.text,l,y),w=r.role==="user",k=r.role==="vet",S=r.role==="assistant",C=Yi(),j=S&&!l?C:void 0,R=j!==void 0&&pg(r.text,j),T=S&&!g.meta.hidePoweredBy,_=w?je.senderUser:k?fn(r):T?je.assistantName:je.senderAssistant,z=k?Mb(r.createdAt):null,I=e.useCallback(e=>a(r,e),[a,r]),P=r.pending!==true,E=S&&g.meta.assistantAvatarUrl!==null?/* @__PURE__ */t.jsx(AssistantSender,{avatarUrl:g.meta.assistantAvatarUrl,named:T,styles:m}):T?h!==null?/* @__PURE__ */t.jsx(CardsByline,{label:je.assistantName}):/* @__PURE__ */t.jsx(Text,{tier:"control",style:m.assistantName,children:je.assistantName}):null,M=h!==null;return S&&h!==null?/* @__PURE__ */t.jsx(n.Animated.View,{style:[m.rowBlock,v],onLayout:p,accessibilityLabel:`${_}: ${r.text}`,children:/* @__PURE__ */t.jsx(CardsAnswer,{message:r,text:x,streaming:l,messages:b,options:h,sentiment:o,onSentiment:r.responseId===void 0?void 0:I,sender:E,onOpenUrl:d,footer:e=>/* @__PURE__ */t.jsx(MessageFooter,{message:r,onCopy:i,sentiment:o,onSentiment:e&&r.responseId!==void 0?I:void 0,note:s})})}):/* @__PURE__ */t.jsxs(n.View,{style:[m.rowBlock,w?m.rowBlockUser:m.rowBlockAssistant],onLayout:p,children:[
334
- /* @__PURE__ */t.jsx(n.View,{style:[m.row,w?m.rowUser:m.rowAssistant],accessible:!R,accessibilityRole:R?void 0:"text",accessibilityLabel:R?void 0:`${_}: ${r.text}`,accessibilityState:r.pending===true?{busy:true}:void 0,children:/* @__PURE__ */t.jsxs(n.Animated.View,{style:[m.bubble,M?m.bubbleCards:null,w?m.bubbleSideUser:null,v],children:[E,k?/* @__PURE__ */t.jsxs(n.View,{style:m.vetHeader,children:[
335
- /* @__PURE__ */t.jsx(Text,{tier:"control",style:m.vetSender,children:_}),z!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:m.vetTime,children:z}):null]}):null,
336
- /* @__PURE__ */t.jsxs(n.View,{style:[w?m.bubbleUser:k?m.bubbleVet:m.bubbleAssistant,w&&M?m.bubbleUserCards:null,r.pending?m.bubblePending:null],children:[w&&u.length>0?/* @__PURE__ */t.jsx(SentImages,{images:u,onPreview:e=>c({uri:e.uri,label:e.filename})}):null,
337
- /* @__PURE__ */t.jsx(Text,{style:w?M?[m.bubbleTextUser,m.bubbleTextUserCards]:m.bubbleTextUser:k?m.bubbleTextVet:m.bubbleTextAssistant,children:S?fg(x,{bold:m.bubbleBold,italic:m.bubbleItalic,code:m.bubbleCode},j):r.text})]})]})}),S&&!l?/* @__PURE__ */t.jsx(ServerCardsSlot,{message:r}):null,S&&!l?/* @__PURE__ */t.jsx(CitationCards,{citations:r.citations,onOpenUrl:d}):null,P&&!(w&&h!==null)?/* @__PURE__ */t.jsx(MessageFooter,{message:r,onCopy:i,sentiment:o,onSentiment:r.responseId===void 0?void 0:I,note:s}):null]})}var hy=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(e){if(e.isBootstrapping===true||e.isLoadingHistory===true||e.isStreaming===true||e.status==="error"||e.stopped===true)return false;let t=e.messages[e.messages.length-1];return t===void 0||t.role!=="assistant"||t.pending===true||t.checkin!==void 0||t.text.trim().length===0?false:!(typeof t.urgencyLevel=="string"&&hy.has(t.urgencyLevel))}var NO_SNAPSHOT2=()=>null;function by(){let{runtime:t}=Fe(),r=t.entitlements??null,n=e.useCallback(e=>r===null?()=>{}:r.subscribe(e),[r]),l=r===null?NO_SNAPSHOT2:r.getSnapshot,i=e.useSyncExternalStore(n,l,l);return e.useMemo(()=>i!==null&&decideCapability("texting",i.decisions,{isPending:i.isPending}).enabled,[i])}var gy=/* @__PURE__ */Object.freeze({runner:null,line:null,entry:null,stage:null,headerEntry:null});function my(r,n,l=false){let[i,o]=e.useState(null);if(!r)return gy;let a=/* @__PURE__ */t.jsx(AskRunner,{ready:textingAskThreadReady(n),onAsk:o,entry:l}),s=l&&i!==null&&i.canOpen?{label:u.textingAskLines(i).accept,onOpen:i.open}:null;if(i===null||i.stage==="hidden"||i.stage==="dismissed")return{runner:a,line:null,entry:null,stage:null,headerEntry:s};let c=u.textingAskLines(i),d=/* @__PURE__ */t.jsx(AskLine,{stage:i.stage,text:i.stage==="verified"?c.verified:c.line,accept:c.accept,dismiss:c.dismiss,onAccept:i.accept,onDismiss:i.dismiss}),p=i.stage==="enrolling"?/* @__PURE__ */t.jsx(u.ChatTextingAskComposer,{ask:i}):null;return{runner:a,line:d,entry:p,stage:i.stage,headerEntry:s}}function AskRunner({ready:r,onAsk:n,entry:l}){let{userRef:userRef}=Fe(),i=by(),o=userRef!==null&&i;return e.useEffect(()=>{o||n(null)},[o,n]),o?/* @__PURE__ */t.jsx(u.ChatTextingAskController,{enabled:true,ready:r,onAsk:n,entry:l}):null}function AskLine({stage:e,text:r,accept:l,dismiss:i,onAccept:o,onDismiss:a}){let{theme:s,styles:u}=yu(),c=!s.meta.hidePoweredBy,d=c?je.assistantName:je.senderAssistant,p=s.meta.assistantAvatarUrl!==null?/* @__PURE__ */t.jsx(AssistantSender,{avatarUrl:s.meta.assistantAvatarUrl,named:c,styles:u}):c?/* @__PURE__ */t.jsx(Text,{tier:"control",style:u.assistantName,children:je.assistantName}):null;/* @__PURE__ */
334
+ /* @__PURE__ */t.jsx(n.Pressable,{onPress:e.action==="startNew"?l:r,accessibilityRole:"button",accessibilityLabel:e.actionLabel,hitSlop:qs,style:i.turnNoticeAction,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:i.turnNoticeActionLabel,children:e.actionLabel})})]})}var Cy=/* @__PURE__ */Object.freeze([]),jy=/* @__PURE__ */Object.freeze([]),Ry=16,Ty=n.Platform.OS==="ios"?"interactive":"on-drag",_y=18;function MessageRow({message:r,revealing:l,onCopy:i,sentiment:o,onSentiment:a,note:s,images:u,onPreview:c,onOpenUrl:d,onLayout:p,entering:f,answerCards:h,messages:b}){let{theme:g,styles:m}=xu(),y=yc()?.paint,v=so(),x=xo(f,v),w=So(r.text,l,v),k=r.role==="user",S=r.role==="vet",C=r.role==="assistant",j=Zi(),R=C&&!l?j:void 0,T=R!==void 0&&Tg(r.text,R),_=C&&!g.meta.hidePoweredBy,z=k?Te.senderUser:S?bn(r):_?Te.assistantName:Te.senderAssistant,I=S?Kb(r.createdAt):null,P=e.useCallback(e=>a(r,e),[a,r]),E=r.pending!==true,M=_&&y!==void 0?/* @__PURE__ */t.jsx(y.Byline,{}):C&&g.meta.assistantAvatarUrl!==null?/* @__PURE__ */t.jsx(AssistantSender,{avatarUrl:g.meta.assistantAvatarUrl,named:_,styles:m}):_?h!==null?/* @__PURE__ */t.jsx(CardsByline,{label:Te.assistantName}):/* @__PURE__ */t.jsx(Text,{tier:"control",style:m.assistantName,children:Te.assistantName}):null,A=h!==null;return C&&h!==null?/* @__PURE__ */t.jsx(n.Animated.View,{style:[m.rowBlock,x],onLayout:p,accessibilityLabel:`${z}: ${r.text}`,children:/* @__PURE__ */t.jsx(CardsAnswer,{message:r,text:w,streaming:l,messages:b,options:h,sentiment:o,onSentiment:r.responseId===void 0?void 0:P,sender:M,onOpenUrl:d,footer:e=>/* @__PURE__ */t.jsx(MessageFooter,{message:r,onCopy:i,sentiment:o,onSentiment:e&&r.responseId!==void 0?P:void 0,note:s})})}):/* @__PURE__ */t.jsxs(n.View,{style:[m.rowBlock,k?m.rowBlockUser:m.rowBlockAssistant],onLayout:p,children:[
335
+ /* @__PURE__ */t.jsx(n.View,{style:[m.row,k?m.rowUser:m.rowAssistant],accessible:!T,accessibilityRole:T?void 0:"text",accessibilityLabel:T?void 0:`${z}: ${r.text}`,accessibilityState:r.pending===true?{busy:true}:void 0,children:/* @__PURE__ */t.jsxs(n.Animated.View,{style:[m.bubble,A?m.bubbleCards:null,k?m.bubbleSideUser:null,x],children:[M,C&&E&&!l?/* @__PURE__ */t.jsx(SeverityCard,{message:r,spaced:true}):null,S?/* @__PURE__ */t.jsxs(n.View,{style:m.vetHeader,children:[
336
+ /* @__PURE__ */t.jsx(Text,{tier:"control",style:m.vetSender,children:z}),I!==null?/* @__PURE__ */t.jsx(Text,{tier:"compact",style:m.vetTime,children:I}):null]}):null,
337
+ /* @__PURE__ */t.jsxs(n.View,{style:[k?[m.bubbleUser,y?.userBubble]:S?m.bubbleVet:m.bubbleAssistant,k&&A?m.bubbleUserCards:null,r.pending?m.bubblePending:null],children:[k&&u.length>0?/* @__PURE__ */t.jsx(SentImages,{images:u,onPreview:e=>c({uri:e.uri,label:e.filename})}):null,
338
+ /* @__PURE__ */t.jsx(Text,{style:k?[m.bubbleTextUser,A?m.bubbleTextUserCards:null,y?.userText]:S?m.bubbleTextVet:m.bubbleTextAssistant,children:C?_g(w,{bold:m.bubbleBold,italic:m.bubbleItalic,code:m.bubbleCode},R):r.text})]})]})}),C&&!l?/* @__PURE__ */t.jsx(ServerCardsSlot,{message:r}):null,C&&!l?/* @__PURE__ */t.jsx(CitationCards,{citations:r.citations,onOpenUrl:d}):null,C&&!l?/* @__PURE__ */t.jsx(AnswerRecordCards,{message:r,spaced:true}):null,E&&!(k&&h!==null)?/* @__PURE__ */t.jsx(MessageFooter,{message:r,onCopy:i,sentiment:o,onSentiment:r.responseId===void 0?void 0:P,note:s}):null]})}var zy=/* @__PURE__ */new Set(["emergency","schedule_soon"]);function textingAskThreadReady(e){if(e.isBootstrapping===true||e.isLoadingHistory===true||e.isStreaming===true||e.status==="error"||e.stopped===true)return false;let t=e.messages[e.messages.length-1];return t===void 0||t.role!=="assistant"||t.pending===true||t.checkin!==void 0||t.text.trim().length===0?false:!(typeof t.urgencyLevel=="string"&&zy.has(t.urgencyLevel))}var NO_SNAPSHOT2=()=>null;function Iy(){let{runtime:t}=Le(),r=t.entitlements??null,n=e.useCallback(e=>r===null?()=>{}:r.subscribe(e),[r]),l=r===null?NO_SNAPSHOT2:r.getSnapshot,i=e.useSyncExternalStore(n,l,l);return e.useMemo(()=>i!==null&&decideCapability("texting",i.decisions,{isPending:i.isPending}).enabled,[i])}var Py=/* @__PURE__ */Object.freeze({runner:null,line:null,entry:null,stage:null,headerEntry:null});function Ey(r,n,l=false){let[i,o]=e.useState(null);if(!r)return Py;let a=/* @__PURE__ */t.jsx(AskRunner,{ready:textingAskThreadReady(n),onAsk:o,entry:l}),s=l&&i!==null&&i.canOpen?{label:u.textingAskLines(i).accept,onOpen:i.open}:null;if(i===null||i.stage==="hidden"||i.stage==="dismissed")return{runner:a,line:null,entry:null,stage:null,headerEntry:s};let c=u.textingAskLines(i),d=/* @__PURE__ */t.jsx(AskLine,{stage:i.stage,text:i.stage==="verified"?c.verified:c.line,accept:c.accept,dismiss:c.dismiss,onAccept:i.accept,onDismiss:i.dismiss}),p=i.stage==="enrolling"?/* @__PURE__ */t.jsx(u.ChatTextingAskComposer,{ask:i}):null;return{runner:a,line:d,entry:p,stage:i.stage,headerEntry:s}}function AskRunner({ready:r,onAsk:n,entry:l}){let{userRef:userRef}=Le(),i=Iy(),o=userRef!==null&&i;return e.useEffect(()=>{o||n(null)},[o,n]),o?/* @__PURE__ */t.jsx(u.ChatTextingAskController,{enabled:true,ready:r,onAsk:n,entry:l}):null}function AskLine({stage:e,text:r,accept:l,dismiss:i,onAccept:o,onDismiss:a}){let{theme:s,styles:u}=xu(),c=!s.meta.hidePoweredBy,d=c?Te.assistantName:Te.senderAssistant,p=s.meta.assistantAvatarUrl!==null?/* @__PURE__ */t.jsx(AssistantSender,{avatarUrl:s.meta.assistantAvatarUrl,named:c,styles:u}):c?/* @__PURE__ */t.jsx(Text,{tier:"control",style:u.assistantName,children:Te.assistantName}):null;/* @__PURE__ */
338
339
  return t.jsxs(n.View,{style:[u.rowBlock,u.rowBlockAssistant],testID:`everfur-texting-ask-${e}`,children:[
339
340
  /* @__PURE__ */t.jsx(n.View,{style:[u.row,u.rowAssistant],accessible:true,accessibilityRole:"text",accessibilityLabel:`${d}: ${r}`,children:/* @__PURE__ */t.jsxs(n.View,{style:u.bubble,children:[p,
340
- /* @__PURE__ */t.jsx(n.View,{style:u.bubbleAssistant,children:/* @__PURE__ */t.jsx(Text,{style:u.bubbleTextAssistant,children:r})})]})}),e==="offered"?/* @__PURE__ */t.jsx(n.View,{style:u.askChips,children:[{label:l,onPress:o,testID:"everfur-texting-ask-accept"},{label:i,onPress:a,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */t.jsx(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:u.askChip,testID:e.testID,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:u.askChipText,children:e.label})},e.testID))}):null]})}function yy(){let t=/* @__PURE__ */Symbol.for("@everfur/sdk#SdkSurfaceHooks@v1"),r=globalThis;return r[t]??(r[t]=e.createContext(null))}var vy=/* @__PURE__ */yy();function xy(e){return typeof e=="object"&&e!==null&&e.ok===true}function wy(e){if(typeof e!="object"||e===null)return null;let t=e;return t.ok!==false||typeof t.error!="object"||t.error===null?null:pt(t.error)}function ky(t){let r=e.useContext(vy),n=r?.onMessageSent,l=r?.onFreeCapReached,i=e.useCallback((...e)=>{let r=t(...e);return Promise.resolve(r).then(e=>{try{if(xy(e)){n?.();return}let t=l===void 0?null:wy(e);t!==null&&l?.(t)}catch{}},()=>{}),r},[t,n,l]);return n===void 0&&l===void 0?t:i}function EverfurChatCore(e){let{style:r,renderPending:n}=e;/* @__PURE__ */
341
- return t.jsx(CapabilityGate,{capability:"chat",style:r,...n?{renderPending:n}:{},children:/* @__PURE__ */t.jsx(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */t.jsx(ChatBody,{...e})})})}function Sy(){try{return Fe()}catch{return null}}function Cy(e){return en({...e.presentation,chatComposerMic:e.presentation?.chatComposerMic??(e.dictation===void 0?void 0:e.dictation!==false),chatComposerUpload:e.presentation?.chatComposerUpload??(e.attachments===void 0?void 0:true)})}function ChatBody(e){let r=Sy();return r===null?/* @__PURE__ */t.jsx(ChatBodyAlone,{...e}):/* @__PURE__ */t.jsx(ChatBodyInProvider,{...e,activePet:r.activePet,telemetry:r.runtime.registry?.services?.telemetry??null})}function ChatBodyAlone(r){let n=Cy(r),l=JSON.stringify(n),i=r.petRef??null,o=e.useMemo(()=>({presentation:resolvePresentation({server:null,locked:null,client:n}),isLocked:()=>false,planPage:null,planPetRef:i,inProvider:false,telemetry:null}),[l,i]);/* @__PURE__ */
342
- return t.jsx(ChatSurface,{...r,settings:o})}function ChatBodyInProvider({activePet:r,telemetry:n,...l}){let{presentation:i,isLocked:isLocked}=Xr(Cy(l)),o=qr("healthPlan"),a=i.chatTopCard==="focus"&&l.topCard===void 0&&o,s=l.petRef??r??null,u=useHealthPlanPage({petRef:s,enabled:a}),c=a&&u.phase==="ready"?u.page:null,d=e.useMemo(()=>({presentation:i,isLocked:isLocked,planPage:c,planPetRef:s,inProvider:true,telemetry:n}),[i,isLocked,c,s,n]);/* @__PURE__ */
343
- return t.jsx(ChatSurface,{...l,settings:d})}function ChatSurface({settings:r,petRef:petRef,conversationId:conversationId,style:i,renderPending:o,onCopy:a,onPetChange:s,onVetPrep:u,onFindVet:c,renderVetAction:d,attachments:p,pet:f,onAddPet:h,checkinTarget:b,handoffToken:g,initialAsk:m,initialAskKey:y,composerSeed:v,lifecycle:x,refreshIntervalMs:w,refreshesBlankThread:k,openUnreadOnRefresh:S,draftStore:C,vetReturnTo:j,vetUsState:R,vetPrefer:T,onOpenUrl:_,keyboardVerticalOffset:z,topCard:I,onOpenHealthPlan:P,answerCards:E,historySheet:M,historyBar:F,starterPrompts:A,emptyState:L,header:O=true,textingEntry:V=true,renderEmptyHeader:D,followUpPolicy:B,initialAskCard:H}){let{presentation:W,isLocked:isLocked,planPage:N,planPetRef:U}=r,{theme:$,styles:q}=yu(),G=Fp()??(W.chatAnswerStyle==="cards"?zh:null),K=e.useMemo(()=>G===null?null:G($),[G,$]),Y=useHostPoweredBy(),Q=oo(),Z=e.useMemo(()=>hn(petRef,conversationId),[petRef,conversationId]),J=useEverfurChat(Z),X=ky(J.send),ee=e.useMemo(()=>X===J.send?J:{...J,send:X},[J,X]),te=tn(ee),re=wb(),ne=ji(ee),le=l.useSafeAreaInsets(),ie=ln(ee,"web"),oe=e.useMemo(()=>c===void 0?void 0:()=>{Er(c,"emergency")},[c]),ae=e.useMemo(()=>j===void 0&&R===void 0&&T===void 0?void 0:{returnTo:j,usState:R,prefer:T},[j,R,T]),se=hp(re.pets,ee.petRef),[ue,ce]=e.useState(null),de=e.useMemo(()=>{let e=Pi(ee.messages,se?.name??null);return e?.level==="schedule_soon"&&e.messageId===ue?null:e},[ee.messages,se?.name,ue]),pe=Mi(de);Sb(ee),Co(pe.showBanner,Q);let fe=Sy(),he=fi(g,fe);bi(ee.openCheckin,b??he,{petRef:ee.petRef,pinned:petRef!==void 0,ready:!ee.isBootstrapping,selectPet:e=>{re.setActivePet(e),Er(s,e)}}),Ol(ee.askEverfur,ee.isBootstrapping,m,y);let be=e.useMemo(()=>Ll(v),[v]),ge=e.useMemo(()=>Ll(m),[m]),me=e.useMemo(()=>H!==void 0&&ge!==null?{card:H,prompt:ge}:void 0,[H,ge]),ye=e.useMemo(()=>x===void 0?createAppStateLifecycle():x??void 0,[x]);Yl(ye,{conversationId:ee.conversationId===null?null:String(ee.conversationId),isTurnInFlight:ee.isStreaming,refreshesBlankThread:k===true||S===true,refresh:ee.refreshActiveThread===void 0?void 0:()=>ee.refreshActiveThread?.(Wl(S===true,Nl(ye,Fo)))??Promise.resolve()},{intervalMs:w===void 0?3e4:w,isVisibleFallback:Fo}),Ul({isStreaming:ee.isStreaming,status:ee.status,conversationId:ee.conversationId===null?null:String(ee.conversationId),unreadCount:ee.unreadCount,markRead:ee.markRead},()=>Nl(ye,Fo));let ve=ee.pendingCheckin??null,xe=ve===null?null:/* @__PURE__ */t.jsx(n.View,{testID:"everfur-pending-checkin",accessibilityLiveRegion:"polite",children:/* @__PURE__ */t.jsx(CheckinCard,{message:ve.message,checkin:ve.checkin,onAnswer:ee.petRef?ee.answerCheckin:null,petRef:ee.petRef,onFindVet:oe,vet:ae,onOpen:()=>{ee.resumeConversation(ve.conversationId)}})}),we=(ee.hasUnreadThreads??false)||ne.rows.some(e=>e.unreadCount!==null&&e.unreadCount>0)||(ee.unreadCount??0)>0,ke=Pl(ee.messages),[Se,Ce]=e.useState(null),Re=e.useCallback(()=>Ce(null),[]),[Te,_e]=e.useState(null),[ze,Ie]=e.useState(null),Pe=e.useRef(null);e.useEffect(()=>()=>{Pe.current&&clearTimeout(Pe.current)},[]);let Ee=e.useCallback((e,t)=>{Ie({responseId:String(e),kind:t}),Pe.current&&clearTimeout(Pe.current),Pe.current=t==="thanks"?setTimeout(()=>{Ie(null),Pe.current=null},js):null},[]),Me=e.useCallback((e,t)=>{let r=e.responseId;if(r===void 0)return;let n=ee.sentimentByMessage[String(r)];Ie(e=>e?.responseId===String(r)?null:e),ee.feedback(r,t).then(e=>{e.ok||Ee(r,"failed")}),t==="down"&&n!=="down"&&_e(r)},[ee,Ee]),Fe=e.useCallback(async(e,t)=>Te===null||!(e==null&&t===null?{ok:true}:await ee.feedback(Te,"down",e??"other",t)).ok?false:(_e(null),Ee(Te,"thanks"),true),[ee,Te,Ee]),Ae=e.useCallback(()=>_e(null),[]),Le=e.useCallback(e=>{ee.send(e)},[ee.send]),Oe=e.useMemo(()=>_===void 0?void 0:e=>{Er(_,e,"citation")},[_]),Ve=n.Platform.OS==="ios"?"padding":void 0,De=Vh(z,Ve!==void 0),Be=De.topInWindow===null?le.top:Math.max(0,le.top-De.topInWindow),He=Bh(),We=e.useMemo(()=>P===void 0?void 0:()=>{Er(P,U)},[P,U]),Ne=e.useMemo(()=>({petRef:ee.petRef,vet:ae,cover:ce}),[ee.petRef,ae]),Ue=e.useMemo(()=>I===void 0?healthPlanTopCard(N,{onOpenPlan:We}):void 0,[I,N,We]),$e=W.chatTopCard==="focus"?I??Ue:void 0,[qe,Ge]=e.useState(true),Ke=e.useCallback(e=>{ee.send(e)},[ee.send]),Ye=e.useMemo(()=>mn(B,W,isLocked("chatFollowUpCount")),[B,W,isLocked]),Qe=W.chatAnswerStyle==="cards",Ze=e.useMemo(()=>Qe&&ee.messages.length===0?Ty(ee.suggestedPrompts):void 0,[Qe,ee.messages.length,ee.suggestedPrompts]),Je=W.chatHistoryStyle==="sheet",Xe=ee.messages.length===0,et=$e!==void 0?/* @__PURE__ */t.jsx(TopCardPill,{card:$e,open:qe,onOpenChange:Ge}):null,tt=F??(O?void 0:_y),rt=tt!==void 0?/* @__PURE__ */t.jsx(HistoryBar,{bar:tt,history:ne,empty:Xe,unread:we,extra:et}):null,nt=W.chatHistoryBar==="scroll"&&(te==="empty"||te==="populated"),lt=$e===void 0?null:/* @__PURE__ */t.jsxs(t.Fragment,{children:[
344
- /* @__PURE__ */t.jsx(TopCard,{card:$e,open:qe,onOpenChange:Ge,ask:Ke}),tt===void 0?et:null]}),it=tt!==void 0,ot=ne.load,at=ne.open;e.useEffect(()=>{it&&!at&&ot()},[it,at,ee.conversationId,ot]);let st={send:ee.send,stop:ee.stop,isStreaming:ee.isStreaming,conversationId:ee.conversationId,seed:be,draftStore:C,onStage:ke.stage,onPreview:Ce,petName:se?.name??null,petBreed:se?.breed??null,compact:W.chatComposerStyle==="compact",petPlaceholder:W.chatComposerPlaceholder==="pet_name",dimEmptySend:W.chatSendButton==="dim_when_empty",mood:zy(te,pe.source?.level??null),dictation:W.chatComposerMic,telemetry:r.telemetry},ut=my(W.chatTextingAsk&&r.inProvider,ee,V),ct=p!==void 0&&W.chatComposerUpload,dt=!W.chatGeneralBanner&&pe.source?.level==="general";
341
+ /* @__PURE__ */t.jsx(n.View,{style:u.bubbleAssistant,children:/* @__PURE__ */t.jsx(Text,{style:u.bubbleTextAssistant,children:r})})]})}),e==="offered"?/* @__PURE__ */t.jsx(n.View,{style:u.askChips,children:[{label:l,onPress:o,testID:"everfur-texting-ask-accept"},{label:i,onPress:a,testID:"everfur-texting-ask-dismiss"}].map(e=>/* @__PURE__ */t.jsx(PressScale,{onPress:e.onPress,accessibilityRole:"button",accessibilityLabel:e.label,style:u.askChip,testID:e.testID,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:u.askChipText,children:e.label})},e.testID))}):null]})}function My(){let t=/* @__PURE__ */Symbol.for("@everfur/sdk#SdkSurfaceHooks@v1"),r=globalThis;return r[t]??(r[t]=e.createContext(null))}var Ay=/* @__PURE__ */My();function Fy(e){return typeof e=="object"&&e!==null&&e.ok===true}function Ly(e){if(typeof e!="object"||e===null)return null;let t=e;return t.ok!==false||typeof t.error!="object"||t.error===null?null:ht(t.error)}function Oy(t){let r=e.useContext(Ay),n=r?.onMessageSent,l=r?.onFreeCapReached,i=e.useCallback((...e)=>{let r=t(...e);return Promise.resolve(r).then(e=>{try{if(Fy(e)){n?.();return}let t=l===void 0?null:Ly(e);t!==null&&l?.(t)}catch{}},()=>{}),r},[t,n,l]);return n===void 0&&l===void 0?t:i}function EverfurChatCore(e){let{style:r,renderPending:n}=e;/* @__PURE__ */
342
+ return t.jsx(CapabilityGate,{capability:"chat",style:r,...n?{renderPending:n}:{},children:/* @__PURE__ */t.jsx(MessageLinksScope,{linkHosts:e.linkHosts,onOpenUrl:e.onOpenUrl,children:/* @__PURE__ */t.jsx(ChatBody,{...e})})})}function Vy(){try{return Le()}catch{return null}}function Dy(e){return rn({...e.presentation,chatComposerMic:e.presentation?.chatComposerMic??(e.dictation===void 0?void 0:e.dictation!==false),chatComposerUpload:e.presentation?.chatComposerUpload??(e.attachments===void 0?void 0:true)})}function By(e,t){let r=zb(t?"tabs_bar":e.shellHeader);return r===(e.shellHeader==="tabs_bar")?e:/* @__PURE__ */Object.freeze({...e,shellHeader:r?"tabs_bar":"classic"})}function ChatBody(e){let r=Vy();return r===null?/* @__PURE__ */t.jsx(ChatBodyAlone,{...e}):/* @__PURE__ */t.jsx(ChatBodyInProvider,{...e,activePet:r.activePet,telemetry:r.runtime.registry?.services?.telemetry??null})}function ChatBodyAlone(r){let n=Dy(r),l=JSON.stringify(n),i=r.petRef??null,o=e.useMemo(()=>({presentation:By(resolvePresentation({server:null,locked:null,client:n}),false),isLocked:()=>false,planPage:null,planPetRef:i,inProvider:false,telemetry:null}),[l,i]);/* @__PURE__ */
343
+ return t.jsx(ChatSurface,{...r,settings:o})}function ChatBodyInProvider({activePet:r,telemetry:n,...l}){let{presentation:i,isLocked:isLocked}=tn(Dy(l)),o=bh(),a=e.useMemo(()=>By(i,o),[o,i]),s=Kr("healthPlan"),u=a.chatTopCard==="focus"&&a.shellHeader!=="tabs_bar"&&l.topCard===void 0&&s,c=l.petRef??r??null,d=useHealthPlanPage({petRef:c,enabled:u}),p=u&&d.phase==="ready"?d.page:null,f=e.useMemo(()=>({presentation:a,isLocked:isLocked,planPage:p,planPetRef:c,inProvider:true,telemetry:n}),[a,isLocked,p,c,n]);/* @__PURE__ */
344
+ return t.jsx(ChatSurface,{...l,settings:f})}function ChatSurface({settings:r,petRef:petRef,conversationId:conversationId,style:i,renderPending:o,onCopy:a,onPetChange:s,onVetPrep:u,onFindVet:c,renderVetAction:d,attachments:p,pet:f,onAddPet:h,checkinTarget:b,handoffToken:g,initialAsk:m,initialAskKey:y,composerSeed:v,lifecycle:x,refreshIntervalMs:w,refreshesBlankThread:k,openUnreadOnRefresh:S,draftStore:C,vetReturnTo:j,vetUsState:R,vetPrefer:T,onOpenUrl:_,keyboardVerticalOffset:z,topCard:I,onOpenHealthPlan:P,onOpenRecord:E,answerCards:M,historySheet:A,historyBar:F,starterPrompts:L,emptyState:O,header:V=true,textingEntry:D=true,renderEmptyHeader:B,followUpPolicy:H,initialAskCard:W}){let{presentation:N,isLocked:isLocked,planPage:U,planPetRef:$}=r,{theme:q,styles:G}=xu(),K=Wp()??(N.chatAnswerStyle==="cards"?Hh:null),Y=e.useMemo(()=>K===null?null:K(q),[K,q]),Q=useHostPoweredBy(),Z=so(),J=e.useMemo(()=>gn(petRef,conversationId),[petRef,conversationId]),X=useEverfurChat(J),ee=Oy(X.send),te=e.useMemo(()=>ee===X.send?X:{...X,send:ee},[X,ee]),re=nn(te),ne=Lb(),le=Ti(te),ie=l.useSafeAreaInsets(),oe=an(te,"web"),ae=e.useMemo(()=>c===void 0?void 0:()=>{Ar(c,"emergency")},[c]),se=e.useMemo(()=>j===void 0&&R===void 0&&T===void 0?void 0:{returnTo:j,usState:R,prefer:T},[j,R,T]),ue=kp(ne.pets,te.petRef),[ce,de]=e.useState(null),pe=e.useMemo(()=>{let e=Mi(te.messages,ue?.name??null);return e?.level==="schedule_soon"&&e.messageId===ce?null:e},[te.messages,ue?.name,ce]),fe=Fi(pe);Vb(te),Ro(fe.showBanner,Z);let he=Vy(),be=bi(g,he);mi(te.openCheckin,b??be,{petRef:te.petRef,pinned:petRef!==void 0,ready:!te.isBootstrapping,selectPet:e=>{ne.setActivePet(e),Ar(s,e)}}),Dl(te.askEverfur,te.isBootstrapping,m,y);let ge=e.useMemo(()=>Vl(v),[v]),me=e.useMemo(()=>Vl(m),[m]),ye=e.useMemo(()=>W!==void 0&&me!==null?{card:W,prompt:me}:void 0,[W,me]),ve=e.useMemo(()=>x===void 0?createAppStateLifecycle():x??void 0,[x]);Zl(ve,{conversationId:te.conversationId===null?null:String(te.conversationId),isTurnInFlight:te.isStreaming,refreshesBlankThread:k===true||S===true,refresh:te.refreshActiveThread===void 0?void 0:()=>te.refreshActiveThread?.(Ul(S===true,$l(ve,Lo)))??Promise.resolve()},{intervalMs:w===void 0?3e4:w,isVisibleFallback:Lo}),ql({isStreaming:te.isStreaming,status:te.status,conversationId:te.conversationId===null?null:String(te.conversationId),unreadCount:te.unreadCount,markRead:te.markRead},()=>$l(ve,Lo));let xe=te.pendingCheckin??null,we=xe===null?null:/* @__PURE__ */t.jsx(n.View,{testID:"everfur-pending-checkin",accessibilityLiveRegion:"polite",children:/* @__PURE__ */t.jsx(CheckinCard,{message:xe.message,checkin:xe.checkin,onAnswer:te.petRef?te.answerCheckin:null,petRef:te.petRef,onFindVet:ae,vet:se,onOpen:()=>{te.resumeConversation(xe.conversationId)}})}),ke=(te.hasUnreadThreads??false)||le.rows.some(e=>e.unreadCount!==null&&e.unreadCount>0)||(te.unreadCount??0)>0,Se=Ml(te.messages),[Ce,je]=e.useState(null),Re=e.useCallback(()=>je(null),[]),[_e,ze]=e.useState(null),[Ie,Pe]=e.useState(null),Ee=e.useRef(null);e.useEffect(()=>()=>{Ee.current&&clearTimeout(Ee.current)},[]);let Me=e.useCallback((e,t)=>{Pe({responseId:String(e),kind:t}),Ee.current&&clearTimeout(Ee.current),Ee.current=t==="thanks"?setTimeout(()=>{Pe(null),Ee.current=null},Ts):null},[]),Ae=e.useCallback((e,t)=>{let r=e.responseId;if(r===void 0)return;let n=te.sentimentByMessage[String(r)];Pe(e=>e?.responseId===String(r)?null:e),te.feedback(r,t).then(e=>{e.ok||Me(r,"failed")}),t==="down"&&n!=="down"&&ze(r)},[te,Me]),Fe=e.useCallback(async(e,t)=>_e===null||!(e==null&&t===null?{ok:true}:await te.feedback(_e,"down",e??"other",t)).ok?false:(ze(null),Me(_e,"thanks"),true),[te,_e,Me]),Le=e.useCallback(()=>ze(null),[]),Oe=e.useCallback(e=>{te.send(e)},[te.send]),Ve=e.useMemo(()=>_===void 0?void 0:e=>{Ar(_,e,"citation")},[_]),De=n.Platform.OS==="ios"?"padding":void 0,Be=Qh(z,De!==void 0),He=Be.topInWindow===null?ie.top:Math.max(0,ie.top-Be.topInWindow),We=Jh(),Ne=e.useMemo(()=>P===void 0?void 0:()=>{Ar(P,$)},[P,$]),Ue=e.useMemo(()=>({petRef:te.petRef,vet:se,cover:de}),[te.petRef,se]),$e=e.useMemo(()=>I===void 0?healthPlanTopCard(U,{onOpenPlan:Ne}):void 0,[I,U,Ne]),qe=N.chatTopCard==="focus"?I??(N.shellHeader==="tabs_bar"?void 0:$e):void 0,[Ge,Ke]=e.useState(true),Ye=e.useCallback(e=>{te.send(e)},[te.send]),Qe=e.useMemo(()=>vn(H,N,isLocked("chatFollowUpCount")),[H,N,isLocked]),Ze=N.chatAnswerStyle==="cards",Je=N.shellHeader==="tabs_bar",Xe=e.useMemo(()=>Ze&&te.messages.length===0?Wy(te.suggestedPrompts,Je?4:3):void 0,[Ze,te.messages.length,te.suggestedPrompts,Je]),et=N.chatHistoryStyle==="sheet",tt=te.messages.length===0,rt=qe!==void 0?/* @__PURE__ */t.jsx(TopCardPill,{card:qe,open:Ge,onOpenChange:Ke}):null,nt=F??(V?void 0:Ny),lt=nt!==void 0?/* @__PURE__ */t.jsx(HistoryBar,{bar:nt,history:le,empty:tt,unread:ke,extra:rt}):null,it=N.chatHistoryBar==="scroll"&&!Je&&(re==="empty"||re==="populated"),ot=qe===void 0?null:/* @__PURE__ */t.jsxs(t.Fragment,{children:[
345
+ /* @__PURE__ */t.jsx(TopCard,{card:qe,open:Ge,onOpenChange:Ke,ask:Ye}),nt===void 0?rt:null]}),at=nt!==void 0,st=le.load,ut=le.open;e.useEffect(()=>{at&&!ut&&st()},[at,ut,te.conversationId,st]);let ct={send:te.send,stop:te.stop,isStreaming:te.isStreaming,conversationId:te.conversationId,seed:ge,draftStore:C,onStage:Se.stage,onPreview:je,petName:ue?.name??null,petBreed:ue?.breed??null,compact:N.chatComposerStyle==="compact",petPlaceholder:N.chatComposerPlaceholder==="pet_name",dimEmptySend:N.chatSendButton==="dim_when_empty",mood:Uy(re,fe.source?.level??null),dictation:N.chatComposerMic,telemetry:r.telemetry},dt=Ey(N.chatTextingAsk&&r.inProvider,te,D),pt=p!==void 0&&N.chatComposerUpload,ft=!N.chatGeneralBanner&&fe.source?.level==="general",ht=Je?_b()?.ask??null:null,bt=e.useMemo(()=>ht!==null?{paint:ht.paint(q),petRef:te.petRef??null,vet:se,onFindVet:c,renderVetAction:d,onOpenRecord:E}:null,[ht,q,te.petRef,se,c,d,E]),gt=bt!==null&&bt.paint.partner!==null,mt=gt&&re!=="empty"?/* @__PURE__ */t.jsx(PrivacyLine,{}):null,yt=gt&&re==="empty"?/* @__PURE__ */t.jsx(PrivacyLine,{empty:true}):null,vt=it?mt===null?lt:/* @__PURE__ */t.jsxs(t.Fragment,{children:[lt,mt]}):null;
345
346
  /* @__PURE__ */
346
- return t.jsx(Mp.Provider,{value:K,children:/* @__PURE__ */t.jsxs(n.KeyboardAvoidingView,{style:[q.container,{paddingTop:Be},i],behavior:Ve,...De.avoidingProps,children:[
347
- /* @__PURE__ */t.jsx(KeyboardOffsetProbe,{probeRef:De.probeRef}),
348
- /* @__PURE__ */t.jsxs(SdkTabletColumn,{children:[O?/* @__PURE__ */t.jsx(ChatHeader,{pets:re,petRef:ee.petRef,historyUnread:we,onOpenHistory:ne.show,onNewChat:ne.newConversation,onPetChange:s,onAddPet:h,vet:ae,textingEntry:ut.headerEntry}):null,f!==void 0?/* @__PURE__ */t.jsx(PetSetupNotice,{petRef:petRef??null,pet:f,onRegistered:re.refresh}):null,!O&&ut.headerEntry!==null?/* @__PURE__ */t.jsx(TextingEntryRow,{entry:ut.headerEntry,place:"thread"}):null,nt?null:rt,dt?null:/* @__PURE__ */t.jsx(UrgencyBanner,{surface:pe,petRef:ee.petRef,renderVetAction:d,onFindVet:c,vet:ae,compact:He}),
349
- /* @__PURE__ */t.jsx(n.View,{style:q.body,children:/* @__PURE__ */t.jsx(Li.Provider,{value:Ne,children:sy(te,ee,{notice:ie,vet:ae,onCheckinFindVet:oe,onSelectPrompt:Le,renderPending:o,shownPet:se,onVetPrep:u,onCopy:a,onSentiment:Me,feedbackNote:ze,imagesByMessage:ke.byMessage,onPreview:Ce,onAddPet:h,onOpenUrl:Oe,threadTop:nt?rt:null,pendingCheckin:xe,topCard:lt,starterPrompts:A??Ze,emptyState:L,emptyCentered:W.chatAnswerStyle==="cards",followUpPolicy:Ye,answerCards:W.chatAnswerStyle==="cards"?E??jy:null,threadAside:ut.line,threadAsideKey:ut.stage,renderEmptyHeader:D,openingCard:me})})}),ut.runner,ut.entry!==null?/* @__PURE__ */t.jsx(n.View,{style:q.composerOuter,children:/* @__PURE__ */t.jsx(n.View,{style:q.askEntry,children:ut.entry})}):ct&&p!==void 0?/* @__PURE__ */t.jsx(ComposerWithAttachments,{...st,attachments:p}):/* @__PURE__ */t.jsx(Composer,{...st,attachments:null}),$.meta.hidePoweredBy||Y?null:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:q.poweredBy,accessibilityRole:"text",accessibilityLabel:je.poweredBy,children:je.poweredBy})]}),Je?/* @__PURE__ */t.jsx(HistorySheet,{chat:ee,history:ne,sheet:M}):/* @__PURE__ */t.jsx(HistoryDrawer,{chat:ee,history:ne}),
350
- /* @__PURE__ */t.jsx(FeedbackReasons,{visible:Te!==null,onSubmit:Fe,onSkip:Ae}),
351
- /* @__PURE__ */t.jsx(AttachmentImageLightbox,{uri:Se?.uri??null,label:Se?.label??"",onClose:Re}),
352
- /* @__PURE__ */t.jsx(TelevetHostOutlet,{})]})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:r}){let{styles:l}=yu(),i=zl(petRef,e,r);return i.status!=="failed"||i.error===null?null:/* @__PURE__ */t.jsxs(n.View,{style:l.setupNotice,accessible:true,accessibilityRole:"alert",children:[
347
+ return t.jsx(Hp.Provider,{value:Y,children:/* @__PURE__ */t.jsx(mc.Provider,{value:bt,children:/* @__PURE__ */t.jsxs(n.KeyboardAvoidingView,{style:[G.container,{paddingTop:He},i],behavior:De,...Be.avoidingProps,children:[
348
+ /* @__PURE__ */t.jsx(KeyboardOffsetProbe,{probeRef:Be.probeRef}),
349
+ /* @__PURE__ */t.jsxs(SdkTabletColumn,{children:[V?/* @__PURE__ */t.jsx(ChatHeader,{pets:ne,petRef:te.petRef,historyUnread:ke,onOpenHistory:le.show,onNewChat:le.newConversation,onPetChange:s,onAddPet:h,vet:se,textingEntry:dt.headerEntry}):null,f!==void 0?/* @__PURE__ */t.jsx(PetSetupNotice,{petRef:petRef??null,pet:f,onRegistered:ne.refresh}):null,!V&&dt.headerEntry!==null?/* @__PURE__ */t.jsx(TextingEntryRow,{entry:dt.headerEntry,place:"thread"}):null,it?null:lt,it?null:mt,ft||bt!==null?null:/* @__PURE__ */t.jsx(UrgencyBanner,{surface:fe,petRef:te.petRef,renderVetAction:d,onFindVet:c,vet:se,compact:We}),
350
+ /* @__PURE__ */t.jsx(n.View,{style:G.body,children:/* @__PURE__ */t.jsx(Vi.Provider,{value:Ue,children:Sy(re,te,{notice:oe,vet:se,onCheckinFindVet:ae,onSelectPrompt:Oe,renderPending:o,shownPet:ue,onVetPrep:u,onCopy:a,onSentiment:Ae,feedbackNote:Ie,imagesByMessage:Se.byMessage,onPreview:je,onAddPet:h,onOpenUrl:Ve,threadTop:vt,pendingCheckin:we,topCard:ot,starterPrompts:L??Xe,emptyState:O,emptyCentered:N.chatAnswerStyle==="cards",followUpPolicy:Qe,answerCards:N.chatAnswerStyle==="cards"?M??Hy:null,threadAside:dt.line,threadAsideKey:dt.stage,renderEmptyHeader:B,openingCard:ye})})}),dt.runner,yt,dt.entry!==null?/* @__PURE__ */t.jsx(n.View,{style:G.composerOuter,children:/* @__PURE__ */t.jsx(n.View,{style:G.askEntry,children:dt.entry})}):pt&&p!==void 0?/* @__PURE__ */t.jsx(ComposerWithAttachments,{...ct,attachments:p}):/* @__PURE__ */t.jsx(Composer,{...ct,attachments:null}),bt!==null?/* @__PURE__ */t.jsx(AskBarDisclaimer,{}):q.meta.hidePoweredBy||Q?null:/* @__PURE__ */t.jsx(Text,{tier:"compact",style:G.poweredBy,accessibilityRole:"text",accessibilityLabel:Te.poweredBy,children:Te.poweredBy})]}),et?/* @__PURE__ */t.jsx(HistorySheet,{chat:te,history:le,sheet:A}):/* @__PURE__ */t.jsx(HistoryDrawer,{chat:te,history:le}),
351
+ /* @__PURE__ */t.jsx(FeedbackReasons,{visible:_e!==null,onSubmit:Fe,onSkip:Le}),
352
+ /* @__PURE__ */t.jsx(AttachmentImageLightbox,{uri:Ce?.uri??null,label:Ce?.label??"",onClose:Re}),
353
+ /* @__PURE__ */t.jsx(TelevetHostOutlet,{})]})})})}function PetSetupNotice({petRef:petRef,pet:e,onRegistered:r}){let{styles:l}=xu(),i=Pl(petRef,e,r);return i.status!=="failed"||i.error===null?null:/* @__PURE__ */t.jsxs(n.View,{style:l.setupNotice,accessible:true,accessibilityRole:"alert",children:[
353
354
  /* @__PURE__ */t.jsx(Text,{tier:"compact",style:l.setupNoticeText,children:i.error.displayMessage}),
354
- /* @__PURE__ */t.jsx(n.Pressable,{onPress:i.retry,accessibilityRole:"button",accessibilityLabel:je.retry,hitSlop:Us,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:l.setupNoticeAction,children:je.retry})})]})}var jy=/* @__PURE__ */Object.freeze({}),Ry=3;function Ty(e){let t=[];for(let r of e){let e=r.trim();if(e.length>0&&!t.some(t=>t.label===e)&&t.push(/* @__PURE__ */Object.freeze({label:e})),t.length===Ry)break}return t.length>0?/* @__PURE__ */Object.freeze(t):void 0}var _y=/* @__PURE__ */Object.freeze({chats:gi.heading,newChat:gi.newChat});function zy(e,t){return t==="emergency"?"urgent":e==="populated"?"followUp":"ask"}function EverfurChat(e){/* @__PURE__ */
355
- return t.jsx(c.Provider,{value:EverfurTelevetHost,children:/* @__PURE__ */t.jsx(EverfurChatCore,{...e})})}var Iy=/* @__PURE__ */Object.freeze({hasUnread:null,unreadCount:null,conversationId:null,petRef:null}),NO_SUBSCRIPTION=()=>()=>{};function Py(t,r){let{runtime:n,userRef:userRef,activePet:l,scopeEpoch:i}=Fe(),o=n.unread??null,petRef=t===void 0?l:t,a=e.useCallback(e=>o===null?NO_SUBSCRIPTION():o.subscribe(e),[o]),s=e.useCallback(()=>o===null||userRef===null?Iy:o.get(petRef),[o,userRef,petRef]),u=e.useSyncExternalStore(a,s,s),c=e.useCallback(()=>o===null||userRef===null?Promise.resolve():o.refresh(petRef),[o,userRef,petRef]);return e.useEffect(()=>{c()},[c,i]),Yl(r,{conversationId:null,isTurnInFlight:false,refreshesBlankThread:true,refresh:c}),e.useMemo(()=>({...u,refresh:c}),[u,c])}function useEverfurUnread(t={}){let{lifecycle:r}=t,n=e.useMemo(()=>r===void 0?createAppStateLifecycle():r??void 0,[r]);return Py(t.petRef,n)}exports.EverfurChat=EverfurChat;exports.EverfurPoweredBy=EverfurPoweredBy;exports.chatHandoffTokenFromUrl=chatHandoffTokenFromUrl;exports.createAppStateLifecycle=createAppStateLifecycle;exports.createRnChatAttachmentTransport=createRnChatAttachmentTransport;exports.registerEverfurChatCards=registerEverfurChatCards;exports.registerEverfurDictation=registerEverfurDictation;exports.useChatAttachments=useChatAttachments;exports.useEverfurChat=useEverfurChat;exports.useEverfurPets=useEverfurPets;exports.useEverfurUnread=useEverfurUnread;exports.useHostPoweredBy=useHostPoweredBy;
355
+ /* @__PURE__ */t.jsx(n.Pressable,{onPress:i.retry,accessibilityRole:"button",accessibilityLabel:Te.retry,hitSlop:qs,children:/* @__PURE__ */t.jsx(Text,{tier:"control",style:l.setupNoticeAction,children:Te.retry})})]})}var Hy=/* @__PURE__ */Object.freeze({});function Wy(e,t){let r=[];for(let n of e){let e=n.trim();if(e.length>0&&!r.some(t=>t.label===e)&&r.push(/* @__PURE__ */Object.freeze({label:e})),r.length===t)break}return r.length>0?/* @__PURE__ */Object.freeze(r):void 0}var Ny=/* @__PURE__ */Object.freeze({chats:yi.heading,newChat:yi.newChat});function Uy(e,t){return t==="emergency"?"urgent":e==="populated"?"followUp":"ask"}function EverfurChat(e){/* @__PURE__ */
356
+ return t.jsx(c.Provider,{value:EverfurTelevetHost,children:/* @__PURE__ */t.jsx(EverfurChatCore,{...e})})}var $y=/* @__PURE__ */Object.freeze({hasUnread:null,unreadCount:null,conversationId:null,petRef:null}),NO_SUBSCRIPTION=()=>()=>{};function qy(t,r){let{runtime:n,userRef:userRef,activePet:l,scopeEpoch:i}=Le(),o=n.unread??null,petRef=t===void 0?l:t,a=e.useCallback(e=>o===null?NO_SUBSCRIPTION():o.subscribe(e),[o]),s=e.useCallback(()=>o===null||userRef===null?$y:o.get(petRef),[o,userRef,petRef]),u=e.useSyncExternalStore(a,s,s),c=e.useCallback(()=>o===null||userRef===null?Promise.resolve():o.refresh(petRef),[o,userRef,petRef]);return e.useEffect(()=>{c()},[c,i]),Zl(r,{conversationId:null,isTurnInFlight:false,refreshesBlankThread:true,refresh:c}),e.useMemo(()=>({...u,refresh:c}),[u,c])}function useEverfurUnread(t={}){let{lifecycle:r}=t,n=e.useMemo(()=>r===void 0?createAppStateLifecycle():r??void 0,[r]);return qy(t.petRef,n)}exports.EverfurChat=EverfurChat;exports.EverfurPoweredBy=EverfurPoweredBy;exports.chatHandoffTokenFromUrl=chatHandoffTokenFromUrl;exports.createAppStateLifecycle=createAppStateLifecycle;exports.createRnChatAttachmentTransport=createRnChatAttachmentTransport;exports.registerEverfurChatCards=registerEverfurChatCards;exports.registerEverfurDictation=registerEverfurDictation;exports.useChatAttachments=useChatAttachments;exports.useEverfurChat=useEverfurChat;exports.useEverfurPets=useEverfurPets;exports.useEverfurUnread=useEverfurUnread;exports.useHostPoweredBy=useHostPoweredBy;